Skip to content
Permalink
Browse files

Merge branch 'MDL-51142-30' of git://github.com/damyon/moodle into MO…

…ODLE_30_STABLE
  • Loading branch information...
dmonllao committed May 3, 2016
2 parents bc22230 + a1be990 commit 0a274ff84e48bb147d01f7e25a3b23837d7d7a2d
Showing with 60 additions and 6 deletions.
  1. +10 −5 mod/assign/gradingtable.php
  2. +7 −1 mod/assign/renderer.php
  3. +43 −0 mod/assign/tests/locallib_test.php
@@ -905,7 +905,7 @@ public function col_timesubmitted(stdClass $row) {
$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 @@ public function col_status(stdClass $row) {
$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 && $status != ASSIGN_SUBMISSION_STATUS_NEW) {
$usertime = format_time($timesubmitted - $due);
$latemessage = get_string('submittedlateshort',
'assign',
@@ -964,7 +969,7 @@ public function col_status(stdClass $row) {
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 || $status == ASSIGN_SUBMISSION_STATUS_NEW) {
$now = time();
if ($due && ($now > $due)) {
$overduestr = get_string('overdue', 'assign', format_time($now - $due));
@@ -680,7 +680,13 @@ public function render_assign_submission_status(assign_submission_status $status
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 @@ public function test_gradingtable_extension_date_calculation_for_lateness() {
$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.

0 comments on commit 0a274ff

Please sign in to comment.
You can’t perform that action at this time.