Просмотр исходного кода

Added lib function gradeimporter_reset_gradebook
- When gradebook is reset all submissions grades are also reset

Bernardo 2 лет назад
Родитель
Сommit
8c2d529a42
1 измененных файлов с 10 добавлено и 0 удалено
  1. 10 0
      lib.php

+ 10 - 0
lib.php

@@ -220,7 +220,17 @@ function gradeimporter_update_grades ($submission, $userid = 0, $nullifnone = tr
 
 function gradeimporter_reset_gradebook ($courseid, $type = '') {
   global $CFG, $DB;
+  $tp = $CFG->prefix;
   // Select all grades on gradebook and reset them
+  $sql = "SELECT gs.*
+          FROM {$tp}gradeimporter_submission as gs
+          JOIN {$tp}gradeimporter as g ON g.id = gs.gradeimporterid
+          WHERE g.course = $courseid";
+
+  $submissions = $DB->get_records_sql($sql);
+  foreach ($submissions as $submission) {
+    gradeimporter_grade_item_update($submission, 'reset');
+  }
 }
 
 function gradeimporter_get_user_grades($submission, $userid) {