MDL-48861 assign: Fix unit tests and behat tests

The tests were not working with the change to the needs grading filter.
This commit is contained in:
Damyon Wiese 2015-10-13 12:57:10 +08:00
parent ee58df52da
commit fb6bae3eae
2 changed files with 9 additions and 1 deletions

View File

@ -6703,6 +6703,7 @@ class assign {
global $USER, $CFG, $DB;
$grade = $this->get_user_grade($userid, true, $attemptnumber);
$originalgrade = $grade->grade;
$gradingdisabled = $this->grading_disabled($userid);
$gradinginstance = $this->get_grading_instance($userid, $grade, $gradingdisabled);
if (!$gradingdisabled) {
@ -6747,7 +6748,12 @@ class assign {
}
}
}
// We do not want to update the timemodified if no grade was added.
if (!empty($formdata->addattempt) ||
($originalgrade !== null && $originalgrade != -1) ||
($grade->grade !== null && $grade->grade != -1)) {
$this->update_grade($grade, !empty($formdata->addattempt));
}
// Note the default if not provided for this option is true (e.g. webservices).
// This is for backwards compatibility.
if (!isset($formdata->sendstudentnotifications) || $formdata->sendstudentnotifications) {

View File

@ -778,6 +778,8 @@ class mod_assign_locallib_testcase extends mod_assign_base_testcase {
$plugin = $assign1->get_submission_plugin_by_type('onlinetext');
$plugin->save($submission, $data);
// Wait 1 second so the submission and grade do not have the same timemodified.
sleep(1);
// Simulate adding a grade.
$this->setUser($this->teachers[0]);
$data = new stdClass();