MDL-47655 assign: Treat 'new' status as never submitted.

This fixes the recent activity callbacks to ignore submissions with a 'new' status.

The unit tests for recent activity were modified, because they were relying on the old behaviour of 'submitted' being the default status.

AMOS BEGIN
     CPY [submissionstatus_,mod_assign],[submissionstatus_new,mod_assign]
AMOS END
This commit is contained in:
Damyon Wiese 2014-10-16 10:33:39 +08:00
parent ec72585d64
commit 9e035dae1b
3 changed files with 33 additions and 10 deletions

View File

@ -403,7 +403,7 @@ $string['submissionstatementacceptedlog'] = 'Submission statement accepted by us
$string['submissionstatus_draft'] = 'Draft (not submitted)';
$string['submissionstatusheading'] = 'Submission status';
$string['submissionstatus_marked'] = 'Graded';
$string['submissionstatus_new'] = 'New submission';
$string['submissionstatus_new'] = 'No submission';
$string['submissionstatus_reopened'] = 'Reopened';
$string['submissionstatus_'] = 'No submission';
$string['submissionstatus'] = 'Submission status';

View File

@ -465,10 +465,13 @@ function assign_print_overview($courses, &$htmlarray) {
if (isset($mysubmissions[$assignment->id])) {
$submission = $mysubmissions[$assignment->id];
}
if (!$submission || !$submission->status || $submission->status == 'draft') {
$str .= $strnotsubmittedyet;
} else if ($submission->nosubmissions) {
if ($submission && $submission->nosubmissions) {
$str .= get_string('offline', 'assign');
} else if (!$submission ||
!$submission->status ||
$submission->status == 'draft' ||
$submission->status == 'new') {
$str .= $strnotsubmittedyet;
} else {
$str .= get_string('submissionstatus_' . $submission->status, 'assign');
}
@ -499,10 +502,11 @@ function assign_print_overview($courses, &$htmlarray) {
*/
function assign_print_recent_activity($course, $viewfullnames, $timestart) {
global $CFG, $USER, $DB, $OUTPUT;
require_once($CFG->dirroot . '/mod/assign/locallib.php');
// Do not use log table if possible, it may be huge.
$dbparams = array($timestart, $course->id, 'assign');
$dbparams = array($timestart, $course->id, 'assign', ASSIGN_SUBMISSION_STATUS_SUBMITTED);
$namefields = user_picture::fields('u', null, 'userid');
if (!$submissions = $DB->get_records_sql("SELECT asb.id, asb.timemodified, cm.id AS cmid,
$namefields
@ -514,7 +518,8 @@ function assign_print_recent_activity($course, $viewfullnames, $timestart) {
WHERE asb.timemodified > ? AND
asb.latest = 1 AND
a.course = ? AND
md.name = ?
md.name = ? AND
asb.status = ?
ORDER BY asb.timemodified ASC", $dbparams)) {
return false;
}
@ -616,6 +621,8 @@ function assign_get_recent_mod_activity(&$activities,
$groupid=0) {
global $CFG, $COURSE, $USER, $DB;
require_once($CFG->dirroot . '/mod/assign/locallib.php');
if ($COURSE->id == $courseid) {
$course = $COURSE;
} else {
@ -644,6 +651,7 @@ function assign_get_recent_mod_activity(&$activities,
$params['cminstance'] = $cm->instance;
$params['timestart'] = $timestart;
$params['submitted'] = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
$userfields = user_picture::fields('u', null, 'userid');
@ -654,6 +662,7 @@ function assign_get_recent_mod_activity(&$activities,
JOIN {user} u ON u.id = asb.userid ' .
$groupjoin .
' WHERE asb.timemodified > :timestart AND
asb.status = :submitted AND
a.id = :cminstance
' . $userselect . ' ' . $groupselect .
' ORDER BY asb.timemodified ASC', $params)) {

View File

@ -126,9 +126,13 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase {
public function test_print_recent_activity() {
$this->setUser($this->editingteachers[0]);
$assign = $this->create_instance();
$data = new stdClass();
$data->userid = $this->students[0]->id;
$notices = array();
$this->setUser($this->students[0]);
$assign->submit_for_grading($data, $notices);
$submission = $assign->get_user_submission($this->students[0]->id, true);
$this->setUser($this->editingteachers[0]);
$this->expectOutputRegex('/submitted:/');
assign_print_recent_activity($this->course, true, time() - 3600);
}
@ -138,8 +142,13 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase {
$this->setUser($this->editingteachers[0]);
$assign = $this->create_instance();
$assign->get_user_submission($this->students[0]->id, true);
$data = new stdClass();
$data->userid = $this->students[0]->id;
$notices = array();
$this->setUser($this->students[0]);
$assign->submit_for_grading($data, $notices);
$this->setUser($this->editingteachers[0]);
$this->expectOutputRegex('/submitted:/');
set_config('fullnamedisplay', 'firstname, lastnamephonetic');
assign_print_recent_activity($this->course, false, time() - 3600);
@ -149,8 +158,13 @@ class mod_assign_lib_testcase extends mod_assign_base_testcase {
$this->setUser($this->editingteachers[0]);
$assign = $this->create_instance();
$submission = $assign->get_user_submission($this->students[0]->id, true);
$data = new stdClass();
$data->userid = $this->students[0]->id;
$notices = array();
$this->setUser($this->students[0]);
$assign->submit_for_grading($data, $notices);
$this->setUser($this->editingteachers[0]);
$activities = array();
$index = 0;