Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-30159: fixed bug: When evaluating by advanced grading extra entri…

…es are inserted in grading_instances
  • Loading branch information...
commit 13926e735d2ee40bbb1b6091a0b3a2c38dbec8b5 1 parent ffbf437
@marinaglancy marinaglancy authored
Showing with 23 additions and 1 deletion.
  1. +19 −0 grade/grading/form/lib.php
  2. +4 −1 mod/assignment/lib.php
View
19 grade/grading/form/lib.php
@@ -449,6 +449,25 @@ public function create_instance($raterid, $itemid = null) {
}
/**
+ * If instanceid is specified and grading instance exists and it is created by this rater for
+ * this item, this instance is returned.
+ * Otherwise new instance is created for the specified rater and itemid
+ *
+ * @param int $instanceid
+ * @param int $raterid
+ * @param int $itemid
+ * @return gradingform_instance
+ */
+ public function get_or_create_instance($instanceid, $raterid, $itemid) {
+ global $DB;
+ if ($instanceid &&
+ $instance = $DB->get_record('grading_instances', array('id' => $instanceid, 'raterid' => $raterid, 'itemid' => $itemid), '*', IGNORE_MISSING)) {
+ return $this->get_instance($instance);
+ }
+ return $this->create_instance($raterid, $itemid);
+ }
+
+ /**
* Returns the HTML code displaying the preview of the grading form
*
* Plugins are forced to override this. Ideally they should delegate
View
5 mod/assignment/lib.php
@@ -615,6 +615,7 @@ function submissions($mode) {
//make user global so we can use the id
global $USER, $OUTPUT, $DB, $PAGE;
+
$mailinfo = optional_param('mailinfo', null, PARAM_BOOL);
if (optional_param('next', null, PARAM_BOOL)) {
@@ -1077,7 +1078,8 @@ function display_submission($offset=-1,$userid =-1, $display=true) {
if (!empty($submission->id)) {
$itemid = $submission->id;
}
- $mformdata->advancedgradinginstance = $controller->create_instance($USER->id, $itemid);
+ $instanceid = optional_param('advancedgradinginstanceid', 0, PARAM_INT);
+ $mformdata->advancedgradinginstance = $controller->get_or_create_instance($instanceid, $USER->id, $itemid);
} else {
$advancedgradingwarning = $controller->form_unavailable_notification();
}
@@ -2389,6 +2391,7 @@ function add_grades_section() {
$grademenu = make_grades_menu($this->_customdata->assignment->grade);
if ($gradinginstance = $this->use_advanced_grading()) {
+ $mform->addElement('hidden', 'advancedgradinginstanceid', $gradinginstance->get_id());
$gradinginstance->get_controller()->set_grade_range($grademenu);
$mform->addElement('grading', 'advancedgrading', get_string('grade').':', array('gradinginstance' => $gradinginstance));
} else {
Please sign in to comment.
Something went wrong with that request. Please try again.