Merge branch 'MDL-83195-releaseanongradev2' of https://github.com/leonstr/moodle

This commit is contained in:
Huong Nguyen 2025-04-16 09:39:03 +07:00
commit ff60e9e7b6
3 changed files with 44 additions and 12 deletions

View File

@ -147,7 +147,8 @@ $string['batchsetallocatedmarker'] = 'Set allocated marker for {$a} selected use
$string['batchsetmarkingworkflowstateforusers'] = 'Set marking workflow state for {$a} selected user(s).';
$string['beginassignment'] = 'Begin assignment';
$string['blindmarking'] = 'Anonymous submissions';
$string['blindmarkingenabledwarning'] = 'Anonymous submissions are enabled for this activity. Grades will not be added to the gradebook until student identities are revealed via the "Actions" menu.';
$string['blindmarkingenabledwarning'] = 'Anonymous submissions are enabled for this activity.';
$string['blindmarkingnogradewarning'] = 'Anonymous submissions are enabled for this activity. Grades will not be added to the gradebook until student identities are revealed via the "Actions" menu.';
$string['blindmarking_help'] = 'Anonymous submissions hide the identity of students from markers. Anonymous submission settings will be locked once a submission or grade has been made in relation to this assignment.';
$string['cachedef_overrides'] = 'User and group override information';
$string['calendardue'] = '{$a} is due';

View File

@ -4533,7 +4533,11 @@ class assign {
$o .= $actionformtext;
if ($this->is_blind_marking() && has_capability('mod/assign:viewblinddetails', $this->get_context())) {
$o .= $this->get_renderer()->notification(get_string('blindmarkingenabledwarning', 'assign'), 'notifymessage');
if ($this->is_marking_anonymous()) {
$o .= $this->get_renderer()->notification(get_string('blindmarkingenabledwarning', 'assign'), 'notifymessage');
} else {
$o .= $this->get_renderer()->notification(get_string('blindmarkingnogradewarning', 'assign'), 'notifymessage');
}
}
// Print the table of submissions.
@ -6032,7 +6036,7 @@ class assign {
require_once($CFG->dirroot.'/mod/assign/lib.php');
// Do not push grade to gradebook if blind marking is active as
// the gradebook would reveal the students.
if ($this->is_blind_marking()) {
if ($this->is_blind_marking() && !$this->is_marking_anonymous()) {
return false;
}
@ -8403,15 +8407,6 @@ class assign {
$grade->feedbackfiles = $plugin->files_for_gradebook($grade);
}
$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();
// If markinganonymous is enabled then allow to release grades anonymously.
if (isset($assign->markinganonymous) && $assign->markinganonymous == 1) {
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();
}
@ -9733,6 +9728,15 @@ class assign {
return !empty($submission) && $submission->status !== ASSIGN_SUBMISSION_STATUS_SUBMITTED && $timedattemptstarted;
}
/**
* Is "Allow partial release of grades while marking anonymously" enabled?
*
* @return bool
*/
public function is_marking_anonymous(): bool {
return isset($this->get_instance()->markinganonymous) && $this->get_instance()->markinganonymous;
}
}
/**

View File

@ -4801,4 +4801,31 @@ Anchor link 2:<a title=\"bananas\" href=\"../logo-240x60.gif\">Link text</a>
$this->assertIsArray($result);
$this->assertNotEmpty($result);
}
/**
* Test that assignment grades are pushed to the gradebook when anonymous
* submissions and marking workflow are enabled (MDL-83195).
* @covers \assign::gradebook_item_update
*/
public function test_release_grade_anon(): void {
$this->resetAfterTest();
$course = $this->getDataGenerator()->create_course();
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
$assign = $this->create_instance($course, [
'blindmarking' => 1,
'markingworkflow' => 1,
'markinganonymous' => 1,
]);
// Add a grade and change the workflow status to "Released".
$this->mark_submission($teacher, $assign, $student, 50.0, [
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_RELEASED,
]);
// Make sure the grade has been pushed to the gradebook.
$gradinginfo = grade_get_grades($course->id, 'mod', 'assign', $assign->get_instance()->id, $student->id);
$this->assertEquals(50, (int)$gradinginfo->items[0]->grades[$student->id]->grade);
}
}