MDL-51142 mod/assign: Fix erroneous submission status display
This prevents display of submission time/date when the assignment submission record is in a new state. It also keeps the display of overdue assignments identical for those students who have viewed the assignment yet not submitted, for those students who have not viewed the assignment, and for those students who have not viewed the assignment yet the instructor has accessed the grading page.
This commit is contained in:
committed by
Damyon Wiese
parent
29f88b5783
commit
968b596138
@@ -905,7 +905,7 @@ class assign_grading_table extends table_sql implements renderable {
|
||||
$this->get_group_and_submission($row->id, $group, $submission, -1);
|
||||
if ($submission && $submission->timemodified && $submission->status != ASSIGN_SUBMISSION_STATUS_NEW) {
|
||||
$o = userdate($submission->timemodified);
|
||||
} else if ($row->timesubmitted) {
|
||||
} else if ($row->timesubmitted && $row->status != ASSIGN_SUBMISSION_STATUS_NEW) {
|
||||
$o = userdate($row->timesubmitted);
|
||||
}
|
||||
|
||||
@@ -944,11 +944,16 @@ class assign_grading_table extends table_sql implements renderable {
|
||||
$status = $row->status;
|
||||
}
|
||||
|
||||
$displaystatus = $status;
|
||||
if ($displaystatus == 'new') {
|
||||
$displaystatus = '';
|
||||
}
|
||||
|
||||
if ($this->assignment->is_any_submission_plugin_enabled()) {
|
||||
|
||||
$o .= $this->output->container(get_string('submissionstatus_' . $status, 'assign'),
|
||||
array('class'=>'submissionstatus' .$status));
|
||||
if ($due && $timesubmitted > $due) {
|
||||
$o .= $this->output->container(get_string('submissionstatus_' . $displaystatus, 'assign'),
|
||||
array('class'=>'submissionstatus' .$displaystatus));
|
||||
if ($due && $timesubmitted > $due && $row->status != ASSIGN_SUBMISSION_STATUS_NEW) {
|
||||
$usertime = format_time($timesubmitted - $due);
|
||||
$latemessage = get_string('submittedlateshort',
|
||||
'assign',
|
||||
@@ -964,7 +969,7 @@ class assign_grading_table extends table_sql implements renderable {
|
||||
if (!$instance->markingworkflow) {
|
||||
if ($row->grade !== null && $row->grade >= 0) {
|
||||
$o .= $this->output->container(get_string('graded', 'assign'), 'submissiongraded');
|
||||
} else if (!$timesubmitted) {
|
||||
} else if (!$timesubmitted || $row->status == ASSIGN_SUBMISSION_STATUS_NEW) {
|
||||
$now = time();
|
||||
if ($due && ($now > $due)) {
|
||||
$overduestr = get_string('overdue', 'assign', format_time($now - $due));
|
||||
|
||||
@@ -680,7 +680,13 @@ class mod_assign_renderer extends plugin_renderer_base {
|
||||
if ($submission) {
|
||||
$row = new html_table_row();
|
||||
$cell1 = new html_table_cell(get_string('timemodified', 'assign'));
|
||||
$cell2 = new html_table_cell(userdate($submission->timemodified));
|
||||
|
||||
if ($submission->status != ASSIGN_SUBMISSION_STATUS_NEW) {
|
||||
$cell2 = new html_table_cell(userdate($submission->timemodified));
|
||||
} else {
|
||||
$cell2 = new html_table_cell('-');
|
||||
}
|
||||
|
||||
$row->cells = array($cell1, $cell2);
|
||||
$t->data[] = $row;
|
||||
|
||||
|
||||
@@ -229,6 +229,49 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
|
||||
$this->assertContains(get_string('submittedlateshort', 'assign', format_time(2*24*60*60 + $difftime)), $output);
|
||||
}
|
||||
|
||||
public function test_gradingtable_status_rendering() {
|
||||
global $PAGE;
|
||||
|
||||
// Setup the assignment.
|
||||
$this->create_extra_users();
|
||||
$this->setUser($this->editingteachers[0]);
|
||||
$time = time();
|
||||
$assign = $this->create_instance(array(
|
||||
'assignsubmission_onlinetext_enabled' => 1,
|
||||
'duedate' => $time - 4 * 24 * 60 * 60,
|
||||
));
|
||||
$PAGE->set_url(new moodle_url('/mod/assign/view.php', array(
|
||||
'id' => $assign->get_course_module()->id,
|
||||
'action' => 'grading',
|
||||
)));
|
||||
|
||||
// Check that the assignment is late.
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$this->assertContains(get_string('submissionstatus_', 'assign'), $output);
|
||||
$difftime = time() - $time;
|
||||
$this->assertContains(get_string('overdue', 'assign', format_time(4 * 24 * 60 * 60 + $difftime)), $output);
|
||||
|
||||
// Simulate a student viewing the assignment without submitting.
|
||||
$this->setUser($this->students[0]);
|
||||
$submission = $assign->get_user_submission($this->students[0]->id, true);
|
||||
$submission->status = ASSIGN_SUBMISSION_STATUS_NEW;
|
||||
$assign->testable_update_submission($submission, $this->students[0]->id, true, false);
|
||||
$submittedtime = time();
|
||||
|
||||
// Verify output.
|
||||
$this->setUser($this->editingteachers[0]);
|
||||
$gradingtable = new assign_grading_table($assign, 1, '', 0, true);
|
||||
$output = $assign->get_renderer()->render($gradingtable);
|
||||
$difftime = $submittedtime - $time;
|
||||
$this->assertContains(get_string('overdue', 'assign', format_time(4 * 24 * 60 * 60 + $difftime)), $output);
|
||||
|
||||
$document = new DOMDocument();
|
||||
$document->loadHTML($output);
|
||||
$xpath = new DOMXPath($document);
|
||||
$this->assertEquals('', $xpath->evaluate('string(//td[@id="mod_assign_grading_r0_c8"])'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that group submission information is rendered correctly in the
|
||||
* grading table.
|
||||
|
||||
Reference in New Issue
Block a user