mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-29481: when student is being regraded we try to pick up the latest saved but not submitted version of grading
There are no visible changes yet because at the moment rubric is only saved when it is submitted but this is a base for AJAX saving
This commit is contained in:
parent
13926e735d
commit
188e840b99
@ -693,13 +693,26 @@ abstract class gradingform_instance {
|
||||
return $this->controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the specified element from object $this->data
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_data($key) {
|
||||
if (isset($this->data->$key)) {
|
||||
return $this->data->$key;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns instance id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function get_id() {
|
||||
return $this->data->id;
|
||||
return $this->get_data('id');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -708,7 +721,7 @@ abstract class gradingform_instance {
|
||||
* @return int
|
||||
*/
|
||||
public function get_status() {
|
||||
return $this->data->status;
|
||||
return $this->get_data('status');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,5 +82,6 @@ $string['regradeoption1'] = 'Mark for regrade';
|
||||
|
||||
$string['needregrademessage'] = 'Rubric definition was changed after this student had been graded. You must update the grade otherwise it will not be shown to student.';
|
||||
$string['rubricnotcompleted'] = 'Please choose something for each criterion';
|
||||
$string['restoredfromdraft'] = 'Please note: You did not submit the last attempt to grade this person. The grading is restored from draft. To cancel the changes press "Cancel" button below';
|
||||
|
||||
$string['backtoediting'] = 'Back to editing';
|
@ -483,6 +483,36 @@ class gradingform_rubric_controller extends gradingform_controller {
|
||||
$DB->delete_records_list('gradingform_rubric_criteria', 'id', $criteria);
|
||||
}
|
||||
|
||||
/**
|
||||
* If instanceid is specified and grading instance exists and it is created by this rater for
|
||||
* this item, this instance is returned.
|
||||
* If there exists a draft for this raterid+itemid, take this draft (this is the change from parent)
|
||||
* 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);
|
||||
}
|
||||
if ($itemid && $raterid) {
|
||||
if ($rs = $DB->get_records('grading_instances', array('raterid' => $raterid, 'itemid' => $itemid), 'timemodified DESC', '*', 0, 1)) {
|
||||
$record = reset($rs);
|
||||
$currentinstance = $this->get_current_instance($raterid, $itemid);
|
||||
if ($record->status == gradingform_rubric_instance::INSTANCE_STATUS_INCOMPLETE && $record->timemodified > $currentinstance->get_data('timemodified')) {
|
||||
$record->isrestored = true;
|
||||
return $this->get_instance($record);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->create_instance($raterid, $itemid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns html code to be included in student's feedback.
|
||||
*
|
||||
@ -725,6 +755,23 @@ class gradingform_rubric_instance extends gradingform_instance {
|
||||
if ($currentinstance && $currentinstance->get_status() == gradingform_instance::INSTANCE_STATUS_NEEDUPDATE) {
|
||||
$html .= html_writer::tag('div', get_string('needregrademessage', 'gradingform_rubric'), array('class' => 'gradingform_rubric-regrade'));
|
||||
}
|
||||
$haschanges = false;
|
||||
if ($currentinstance) {
|
||||
$curfilling = $currentinstance->get_rubric_filling();
|
||||
foreach ($curfilling['criteria'] as $criterionid => $curvalues) {
|
||||
$value['criteria'][$criterionid]['savedlevelid'] = $curvalues['levelid'];
|
||||
$newremark = null;
|
||||
$newlevelid = null;
|
||||
if (isset($value['criteria'][$criterionid]['remark'])) $newremark = $value['criteria'][$criterionid]['remark'];
|
||||
if (isset($value['criteria'][$criterionid]['levelid'])) $newlevelid = $value['criteria'][$criterionid]['levelid'];
|
||||
if ($newlevelid != $curvalues['levelid'] || $newremark != $curvalues['remark']) {
|
||||
$haschanges = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->get_data('isrestored') && $haschanges) {
|
||||
$html .= html_writer::tag('div', get_string('restoredfromdraft', 'gradingform_rubric'), array('class' => 'gradingform_rubric-restored'));
|
||||
}
|
||||
$html .= $this->get_controller()->get_renderer($page)->display_rubric($criteria, $options, $mode, $gradingformelement->getName(), $value);
|
||||
return $html;
|
||||
}
|
||||
|
@ -355,6 +355,9 @@ class gradingform_rubric_renderer extends plugin_renderer_base {
|
||||
$level['class'] .= ' checked';
|
||||
//in mode DISPLAY_EVAL the class 'checked' will be added by JS if it is enabled. If JS is not enabled, the 'checked' class will only confuse
|
||||
}
|
||||
if (isset($criterionvalue['savedlevelid']) && ((int)$criterionvalue['savedlevelid'] === $levelid)) {
|
||||
$level['class'] .= ' currentchecked';
|
||||
}
|
||||
$level['tdwidth'] = 100/count($criterion['levels']);
|
||||
$levels_str .= $this->level_template($mode, $options, $elementname, $id, $level);
|
||||
}
|
||||
|
@ -82,6 +82,7 @@
|
||||
.gradingform_rubric.editor .criterion.last .controls .movedown input {display:none;}
|
||||
|
||||
/* evaluation */
|
||||
.gradingform_rubric .criterion .levels .level.currentchecked {background:#fff0f0;}
|
||||
.gradingform_rubric .criterion .levels .level.checked {background:#d0ffd0;border:1px solid #555;}
|
||||
.gradingform_rubric.evaluate .criterion .levels .level:hover {background:#30ff30;}
|
||||
|
||||
@ -114,4 +115,5 @@
|
||||
*/
|
||||
|
||||
.gradingform_rubric-regrade {padding:10px;background:#FFDDDD;border:1px solid #F00;margin-bottom:10px;}
|
||||
.gradingform_rubric-restored {padding:10px;background:#FFFFDD;border:1px solid #FF0;margin-bottom:10px;}
|
||||
.gradingform_rubric-error {color:red;font-weight:bold;}
|
||||
|
Loading…
x
Reference in New Issue
Block a user