ソースを参照

fix: Correctly names gradebook entry as gradeimporter instance name

Bernardo 2 年 前
コミット
aa8eaac7b1
2 ファイル変更10 行追加3 行削除
  1. 6 1
      forms/submission/delete.php
  2. 4 2
      lib.php

+ 6 - 1
forms/submission/delete.php

@@ -64,6 +64,11 @@ foreach ($feedbacks as $feedback) {
 // Delete submission
 $DB->delete_records('gradeimporter_submission', array('id' => $submission->id));
 
+// If there are no more submission that go to the gradebook, reset it for this gradeimporter instance
+if (!$DB->get_records('gradeimporter_submission', array('gradebook' => 1))) {
+  gradeimporter_grade_item_update($submission, 'reset');
+}
+
 // Print page and redirects to submission page after 5 seconds
 $PAGE->set_title($submission->name);
 $PAGE->set_heading($course->fullname);
@@ -75,6 +80,6 @@ echo $OUTPUT->header("refresh:5;url=$viewlink");
 
 echo "<p>".get_string('deletesubmissiondata', 'gradeimporter', $submission->name)."</p>";
 echo "<p>".get_string('deletefeedbacksdata', 'gradeimporter', count($feedbacks))."</p>";
-echo "<p>".get_string('redirect5s', 'gradeimporter')."<a href=\"$viewlink\">".get_string('here', 'gradeimporter')."</p>";
+echo "<p>".get_string('redirect5s', 'gradeimporter')."<a href=\"$viewlink\"> ".get_string('here', 'gradeimporter')."</p>";
 
 echo $OUTPUT->footer();

+ 4 - 2
lib.php

@@ -167,11 +167,13 @@ function mod_gradeimporter_pluginfile($course, $cm, $context, $filearea, $args,
 }
 
 function gradeimporter_grade_item_update ($submission, $grades = null) {
-  global $CFG, $COURSE;
+  global $CFG, $COURSE, $DB;
 
   require_once("{$CFG->libdir}/gradelib.php");
 
-  $params = array('itemname' => $submission->name, 'idnumber' => $submission->cmid);
+  $gradeimporter = $DB->get_record('gradeimporter', array('id' => $submission->gradeimporterid));
+
+  $params = array('itemname' => $gradeimporter->name, 'idnumber' => $submission->gradeimporterid, 'reset' => false);
 
   if ($submission->gradebook == 0) {
     $params['gradetype'] = GRADE_TYPE_NONE;