Skip to content

Commit

Permalink
MDL-66137 mod_assign: fixed marking workflow incorrect grade display
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Tom Dickman committed Sep 4, 2019
1 parent 310d690 commit 028c5ed
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 26 deletions.
16 changes: 8 additions & 8 deletions mod/assign/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -8121,14 +8121,14 @@ protected function process_set_batch_marking_workflow_state() {

// 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();
Expand Down
46 changes: 28 additions & 18 deletions mod/assign/tests/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,24 +433,34 @@ public function test_workflow_state_updated() {
$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.
Expand Down

0 comments on commit 028c5ed

Please sign in to comment.