MDL-66137 mod_assign: fixed marking workflow incorrect grade display

Aligned logic between quick grading changes and set marking workflow state changes to accurately
finalise or remove final grade from the gradebook, depending on the marking workflow state if
being used.
This commit is contained in:
Tom Dickman
2019-09-04 15:08:49 +10:00
parent 2baf9a81d8
commit b51509778b
2 changed files with 36 additions and 26 deletions
+8 -8
View File
@@ -7834,14 +7834,14 @@ class assign {
// Will not apply update if user does not have permission to assign this workflow state.
if (!$gradingdisabled && $this->update_user_flags($flags)) {
if ($state == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
// Update Gradebook.
$assign = clone $this->get_instance();
$assign->cmidnumber = $this->get_course_module()->idnumber;
// Set assign gradebook feedback plugin status.
$assign->gradefeedbackenabled = $this->is_gradebook_feedback_enabled();
assign_update_grades($assign, $userid);
}
// Update Gradebook.
$grade = $this->get_user_grade($userid, true);
$this->update_grade($grade);
$assign = clone $this->get_instance();
$assign->cmidnumber = $this->get_course_module()->idnumber;
// Set assign gradebook feedback plugin status.
$assign->gradefeedbackenabled = $this->is_gradebook_feedback_enabled();
assign_update_grades($assign, $userid);
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
\mod_assign\event\workflow_state_updated::create_from_user($this, $user, $state)->trigger();
+28 -18
View File
@@ -426,24 +426,34 @@ class assign_events_testcase extends advanced_testcase {
$assign->testable_process_set_batch_marking_workflow_state($student->id, ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW);
$events = $sink->get_events();
$this->assertCount(1, $events);
$event = reset($events);
$this->assertInstanceOf('\mod_assign\event\workflow_state_updated', $event);
$this->assertEquals($assign->get_context(), $event->get_context());
$this->assertEquals($assign->get_instance()->id, $event->objectid);
$this->assertEquals($student->id, $event->relateduserid);
$this->assertEquals($teacher->id, $event->userid);
$this->assertEquals(ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW, $event->other['newstate']);
$expected = array(
$assign->get_course()->id,
'assign',
'set marking workflow state',
'view.php?id=' . $assign->get_course_module()->id,
get_string('setmarkingworkflowstateforlog', 'assign', array('id' => $student->id,
'fullname' => fullname($student), 'state' => ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW)),
$assign->get_course_module()->id
);
$this->assertEventLegacyLogData($expected, $event);
$eventcount = 0;
foreach ($events as $event) {
if ($event instanceof \mod_assign\event\submission_graded) {
$eventcount++;
$this->assertInstanceOf('\mod_assign\event\submission_graded', $event);
$this->assertEquals($assign->get_context(), $event->get_context());
}
if ($event instanceof \mod_assign\event\workflow_state_updated) {
$eventcount++;
$this->assertInstanceOf('\mod_assign\event\workflow_state_updated', $event);
$this->assertEquals($assign->get_context(), $event->get_context());
$this->assertEquals($assign->get_instance()->id, $event->objectid);
$this->assertEquals($student->id, $event->relateduserid);
$this->assertEquals($teacher->id, $event->userid);
$this->assertEquals(ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW, $event->other['newstate']);
$expected = array(
$assign->get_course()->id,
'assign',
'set marking workflow state',
'view.php?id=' . $assign->get_course_module()->id,
get_string('setmarkingworkflowstateforlog', 'assign', array('id' => $student->id,
'fullname' => fullname($student), 'state' => ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW)),
$assign->get_course_module()->id
);
$this->assertEventLegacyLogData($expected, $event);
}
}
$this->assertEquals(2, $eventcount);
$sink->close();
// Test setting workflow state in apply_grade_to_user.