mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 14:03:52 +01:00
MDL-58337 mod_assign: Do not show submitted assignments in dashboard
Part of MDL-55611 epic.
This commit is contained in:
parent
1d23b50c56
commit
d846cb244d
@ -1756,6 +1756,14 @@ function mod_assign_core_calendar_provide_event_action(\core_calendar\event $eve
|
||||
$itemcount = $assign->count_submissions_need_grading();
|
||||
$actionable = $assign->can_grade() && (time() >= $assign->get_instance()->allowsubmissionsfromdate);
|
||||
} else {
|
||||
$usersubmission = $assign->get_user_submission($USER->id, false);
|
||||
if ($usersubmission && $usersubmission->status === ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
|
||||
// The user has already submitted.
|
||||
// We do not want to change the text to edit the submission, we want to remove the event from the Dashboard entirely.
|
||||
return null;
|
||||
}
|
||||
|
||||
// The user has not yet submitted anything. Show the addsubmission link.
|
||||
$name = get_string('addsubmission', 'assign');
|
||||
$url = new \moodle_url('/mod/assign/view.php', [
|
||||
'id' => $cm->id,
|
||||
|
@ -548,6 +548,46 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase {
|
||||
$this->assertFalse($actionevent->is_actionable());
|
||||
}
|
||||
|
||||
public function test_assign_core_calendar_provide_event_action_duedate_as_student_submitted() {
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create an assignment.
|
||||
$assign = $this->create_instance(array('assignsubmission_onlinetext_enabled' => 1));
|
||||
|
||||
// Create a calendar event.
|
||||
$event = $this->create_action_event($assign->get_instance()->id, ASSIGN_EVENT_TYPE_DUE);
|
||||
|
||||
// Create an action factory.
|
||||
$factory = new \core_calendar\action_factory();
|
||||
|
||||
// Set the user to a student.
|
||||
$this->setUser($this->students[0]);
|
||||
|
||||
// Submit the assignment.
|
||||
$submission = $assign->get_user_submission($this->students[0]->id, true);
|
||||
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
||||
$assign->testable_update_submission($submission, $this->students[0]->id, true, false);
|
||||
$data = (object) [
|
||||
'userid' => $this->students[0]->id,
|
||||
'onlinetext_editor' => [
|
||||
'itemid' => file_get_unused_draft_itemid(),
|
||||
'text' => 'Submission text',
|
||||
'format' => FORMAT_MOODLE,
|
||||
],
|
||||
];
|
||||
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
||||
$plugin->save($submission, $data);
|
||||
|
||||
// Create an action factory.
|
||||
$factory = new \core_calendar\action_factory();
|
||||
|
||||
// Decorate action event.
|
||||
$actionevent = mod_assign_core_calendar_provide_event_action($event, $factory);
|
||||
|
||||
// Confirm there was no event to action.
|
||||
$this->assertNull($actionevent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an action event.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user