Moodle SQL Notes

Voici un petit code SQL qui permet tout simplement d’extraire les notes finales des cours pour tous les étudiants

SELECT c.shortname AS shortname, CONCAT(mu.firstname, ' ', mu.lastname) AS fullname, gg.finalgrade AS finalgrade
FROM mdl_grade_items AS gi
INNER JOIN mdl_course c ON c.id = gi.courseid
LEFT JOIN mdl_grade_grades AS gg ON gg.itemid = gi.id
INNER JOIN mdl_user AS mu ON gg.userid = mu.id
WHERE gi.itemtype = 'course'
ORDER BY c.id asc

Trouvé sur le forum de moodle https://moodle.org/mod/forum/discuss.php?d=226410#p990670 dans la discussion https://moodle.org/mod/forum/discuss.php?d=226410

Ce code peut être modifié pour inclure le numéro d’une catégorie, et ainsi limiter les résultats:

SELECT c.shortname AS shortname, CONCAT(mu.firstname, ' ', mu.lastname) AS fullname, gg.finalgrade AS finalgrade
FROM mdl_grade_items AS gi
INNER JOIN mdl_course c ON c.id = gi.courseid
LEFT JOIN mdl_grade_grades AS gg ON gg.itemid = gi.id
INNER JOIN mdl_user AS mu ON gg.userid = mu.id
WHERE gi.itemtype = 'course' AND c.category = 2
ORDER BY c.id asc
Partagez: