MDL-64336 assign: Submissions should be visible while frozen
Before this change if a student visited an assignment that is frozen they would only see the title and description even if they had made a submission to it. After the change they will be able to see the status of their submission and any feedback and grades they have recived. It will also make the Moodle app recognise that submission should not happen because the assignment is frozen. Tests based on ones created by Andrew Nicols
This commit is contained in:
committed by
Sara Arjona
parent
b62526d0ad
commit
dbcfda9641
@@ -2375,7 +2375,8 @@ class mod_assign_external extends external_api {
|
||||
}
|
||||
|
||||
// Retrieve the rest of the renderable objects.
|
||||
if (has_capability('mod/assign:submit', $assign->get_context(), $user)) {
|
||||
$cansubmit = has_capability('mod/assign:submit', $context, $user, false);
|
||||
if ($cansubmit || $assign->get_user_submission($user->id, false) !== false) {
|
||||
$lastattempt = $assign->get_assign_submission_status_renderable($user, true);
|
||||
}
|
||||
|
||||
@@ -2431,7 +2432,7 @@ class mod_assign_external extends external_api {
|
||||
}
|
||||
|
||||
// Can edit its own submission?
|
||||
$lastattempt->caneditowner = $assign->submissions_open($user->id) && $assign->is_any_submission_plugin_enabled();
|
||||
$lastattempt->caneditowner = $cansubmit && $assign->submissions_open($user->id) && $assign->is_any_submission_plugin_enabled();
|
||||
|
||||
$result['lastattempt'] = $lastattempt;
|
||||
}
|
||||
|
||||
@@ -4867,7 +4867,7 @@ class assign {
|
||||
if (has_any_capability(array('mod/assign:viewgrades', 'mod/assign:grade'), $this->context)) {
|
||||
return true;
|
||||
}
|
||||
if ($userid == $USER->id && has_capability('mod/assign:submit', $this->context)) {
|
||||
if ($userid == $USER->id) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -5438,8 +5438,9 @@ class assign {
|
||||
$o = '';
|
||||
|
||||
if ($this->can_view_submission($user->id)) {
|
||||
|
||||
if (has_capability('mod/assign:submit', $this->get_context(), $user, false)) {
|
||||
$cansubmit = has_capability('mod/assign:submit', $this->get_context(), $user, false);
|
||||
if ($cansubmit || $this->get_user_submission($user->id, false) !== false) {
|
||||
// The user can submit, or has a submission.
|
||||
$submissionstatus = $this->get_assign_submission_status_renderable($user, $showlinks);
|
||||
$o .= $this->get_renderer()->render($submissionstatus);
|
||||
}
|
||||
@@ -5468,6 +5469,10 @@ class assign {
|
||||
* @return bool
|
||||
*/
|
||||
protected function show_submit_button($submission = null, $teamsubmission = null, $userid = null) {
|
||||
if (!has_capability('mod/assign:submit', $this->get_context(), $userid, false)) {
|
||||
// The user does not have the capability to submit.
|
||||
return false;
|
||||
}
|
||||
if ($teamsubmission) {
|
||||
if ($teamsubmission->status === ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
|
||||
// The assignment submission has been completed.
|
||||
|
||||
@@ -2329,6 +2329,25 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
$this->setUser($student);
|
||||
$output = $assign->view_student_summary($student, true);
|
||||
$this->assertNotRegexp('/Feedback/', $output, 'Do not show feedback if the grade is hidden in the gradebook');
|
||||
|
||||
// Freeze the context.
|
||||
$this->setAdminUser();
|
||||
$context = $assign->get_context();
|
||||
$CFG->contextlocking = true;
|
||||
$context->set_locked(true);
|
||||
|
||||
// No feedback should be available because the grade is hidden.
|
||||
$this->setUser($student);
|
||||
$output = $assign->view_student_summary($student, true);
|
||||
$this->assertNotRegexp('/Feedback/', $output, 'Do not show feedback if the grade is hidden in the gradebook');
|
||||
|
||||
// Show the feedback again - it should still be visible even in a frozen context.
|
||||
$this->setUser($teacher);
|
||||
$gradeitem->set_hidden(0, false);
|
||||
|
||||
$this->setUser($student);
|
||||
$output = $assign->view_student_summary($student, true);
|
||||
$this->assertRegexp('/Feedback/', $output, 'Show feedback if there is a grade');
|
||||
}
|
||||
|
||||
public function test_show_student_summary_with_feedback() {
|
||||
|
||||
Reference in New Issue
Block a user