diff --git a/mod/assign/lang/en/assign.php b/mod/assign/lang/en/assign.php index c0af1844902..6652b1839fc 100644 --- a/mod/assign/lang/en/assign.php +++ b/mod/assign/lang/en/assign.php @@ -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'; diff --git a/mod/assign/lib.php b/mod/assign/lib.php index fe082dc360d..d79fbce00f4 100644 --- a/mod/assign/lib.php +++ b/mod/assign/lib.php @@ -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)) { diff --git a/mod/assign/tests/lib_test.php b/mod/assign/tests/lib_test.php index 64b9a36c5c3..92773ac5a99 100644 --- a/mod/assign/tests/lib_test.php +++ b/mod/assign/tests/lib_test.php @@ -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;