| Línea 38... |
Línea 38... |
| 38 |
*
|
38 |
*
|
| 39 |
* @package mod_quiz
|
39 |
* @package mod_quiz
|
| 40 |
* @copyright 2021 The Open University
|
40 |
* @copyright 2021 The Open University
|
| 41 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
41 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 42 |
*/
|
42 |
*/
|
| 43 |
class quiz_notify_attempt_manual_grading_completed_test extends advanced_testcase {
|
43 |
final class quiz_notify_attempt_manual_grading_completed_test extends advanced_testcase {
|
| 44 |
/** @var stdClass $course Test course to contain quiz. */
|
44 |
/** @var stdClass $course Test course to contain quiz. */
|
| 45 |
protected stdClass $course;
|
45 |
protected stdClass $course;
|
| Línea 46... |
Línea 46... |
| 46 |
|
46 |
|
| 47 |
/** @var stdClass $quiz A test quiz. */
|
47 |
/** @var stdClass $quiz A test quiz. */
|
| Línea 73... |
Línea 73... |
| 73 |
*
|
73 |
*
|
| 74 |
* Also create some bits of a quiz attempt to be used later.
|
74 |
* Also create some bits of a quiz attempt to be used later.
|
| 75 |
*/
|
75 |
*/
|
| 76 |
public function setUp(): void {
|
76 |
public function setUp(): void {
|
| 77 |
global $DB;
|
77 |
global $DB;
|
| - |
|
78 |
parent::setUp();
|
| Línea 78... |
Línea 79... |
| 78 |
|
79 |
|
| 79 |
$this->resetAfterTest();
|
80 |
$this->resetAfterTest();
|
| Línea 80... |
Línea 81... |
| 80 |
$this->setAdminUser();
|
81 |
$this->setAdminUser();
|
| Línea 125... |
Línea 126... |
| 125 |
|
126 |
|
| 126 |
// Process some responses from the student (30 mins ago) and submit (20 mins ago).
|
127 |
// Process some responses from the student (30 mins ago) and submit (20 mins ago).
|
| 127 |
$attemptobj1 = quiz_attempt::create($attempt1->id);
|
128 |
$attemptobj1 = quiz_attempt::create($attempt1->id);
|
| 128 |
$tosubmit = [2 => ['answer' => 'Student 1 answer', 'answerformat' => FORMAT_HTML]];
|
129 |
$tosubmit = [2 => ['answer' => 'Student 1 answer', 'answerformat' => FORMAT_HTML]];
|
| 129 |
$attemptobj1->process_submitted_actions($timenow - 30 * MINSECS, false, $tosubmit);
|
130 |
$attemptobj1->process_submitted_actions($timenow - 30 * MINSECS, false, $tosubmit);
|
| - |
|
131 |
$attemptobj1->process_submit($timenow - 20 * MINSECS, false);
|
| Línea 130... |
Línea 132... |
| 130 |
$attemptobj1->process_finish($timenow - 20 * MINSECS, false);
|
132 |
$attemptobj1->process_grade_submission($timenow - 10 * MINSECS);
|
| 131 |
|
133 |
|
| 132 |
// Finish the attempt of student (now).
|
134 |
// Finish the attempt of student (now).
|
| Línea 168... |
Línea 170... |
| 168 |
|
170 |
|
| 169 |
// Process some responses from the student (30 mins ago) and submit (now).
|
171 |
// Process some responses from the student (30 mins ago) and submit (now).
|
| 170 |
$attemptobj2 = quiz_attempt::create($attempt2->id);
|
172 |
$attemptobj2 = quiz_attempt::create($attempt2->id);
|
| 171 |
$tosubmit = [2 => ['answer' => 'Answer of student 2.', 'answerformat' => FORMAT_HTML]];
|
173 |
$tosubmit = [2 => ['answer' => 'Answer of student 2.', 'answerformat' => FORMAT_HTML]];
|
| 172 |
$attemptobj2->process_submitted_actions($timenow - 30 * MINSECS, false, $tosubmit);
|
174 |
$attemptobj2->process_submitted_actions($timenow - 30 * MINSECS, false, $tosubmit);
|
| - |
|
175 |
$attemptobj2->process_submit($timenow, false);
|
| Línea 173... |
Línea 176... |
| 173 |
$attemptobj2->process_finish($timenow, false);
|
176 |
$attemptobj2->process_grade_submission($timenow);
|
| 174 |
|
177 |
|
| 175 |
// After time to notify, except attempt not graded, so it won't appear.
|
178 |
// After time to notify, except attempt not graded, so it won't appear.
|
| 176 |
$task = new quiz_notify_attempt_manual_grading_completed();
|
179 |
$task = new quiz_notify_attempt_manual_grading_completed();
|
| Línea 186... |
Línea 189... |
| 186 |
public function test_notify_manual_grading_completed_task_without_capability(): void {
|
189 |
public function test_notify_manual_grading_completed_task_without_capability(): void {
|
| 187 |
global $DB;
|
190 |
global $DB;
|
| Línea 188... |
Línea 191... |
| 188 |
|
191 |
|
| 189 |
// Create an attempt for a user without the capability.
|
192 |
// Create an attempt for a user without the capability.
|
| - |
|
193 |
$timenow = time();
|
| - |
|
194 |
$timestart = $timenow - HOURSECS;
|
| - |
|
195 |
$timefinish = $timenow - 20 * MINSECS;
|
| 190 |
$timenow = time();
|
196 |
$gradetime = $timenow - 10 * MINSECS;
|
| 191 |
$attempt = quiz_create_attempt($this->quizobj, 3, false, $timenow, false, $this->student->id);
|
197 |
$attempt = quiz_create_attempt($this->quizobj, 3, false, $timenow, false, $this->student->id);
|
| 192 |
quiz_start_new_attempt($this->quizobj, $this->quba, $attempt, 3, $timenow - HOURSECS);
|
198 |
quiz_start_new_attempt($this->quizobj, $this->quba, $attempt, 3, $timestart);
|
| Línea 193... |
Línea 199... |
| 193 |
quiz_attempt_save_started($this->quizobj, $this->quba, $attempt);
|
199 |
quiz_attempt_save_started($this->quizobj, $this->quba, $attempt, $timestart);
|
| 194 |
|
200 |
|
| 195 |
// Process some responses and submit.
|
201 |
// Process some responses and submit.
|
| 196 |
$attemptobj = quiz_attempt::create($attempt->id);
|
202 |
$attemptobj = quiz_attempt::create($attempt->id);
|
| 197 |
$tosubmit = [2 => ['answer' => 'Essay answer.', 'answerformat' => FORMAT_HTML]];
|
203 |
$tosubmit = [2 => ['answer' => 'Essay answer.', 'answerformat' => FORMAT_HTML]];
|
| - |
|
204 |
$attemptobj->process_submitted_actions($timenow - 30 * MINSECS, false, $tosubmit);
|
| Línea 198... |
Línea 205... |
| 198 |
$attemptobj->process_submitted_actions($timenow - 30 * MINSECS, false, $tosubmit);
|
205 |
$attemptobj->process_submit($timefinish, false);
|
| 199 |
$attemptobj->process_finish($timenow - 20 * MINSECS, false);
|
206 |
$attemptobj->process_grade_submission($gradetime);
|
| 200 |
|
207 |
|
| Línea 216... |
Línea 223... |
| 216 |
$task = new quiz_notify_attempt_manual_grading_completed();
|
223 |
$task = new quiz_notify_attempt_manual_grading_completed();
|
| 217 |
$task->set_time_for_testing($timenow + 5 * HOURSECS + 1);
|
224 |
$task->set_time_for_testing($timenow + 5 * HOURSECS + 1);
|
| 218 |
$task->execute();
|
225 |
$task->execute();
|
| Línea 219... |
Línea 226... |
| 219 |
|
226 |
|
| 220 |
$attemptobj = quiz_attempt::create($attempt->id);
|
227 |
$attemptobj = quiz_attempt::create($attempt->id);
|
| 221 |
$this->assertEquals($attemptobj->get_attempt()->timefinish, $attemptobj->get_attempt()->gradednotificationsenttime);
|
228 |
$this->assertEquals($timefinish, $attemptobj->get_attempt()->gradednotificationsenttime);
|
| Línea 222... |
Línea 229... |
| 222 |
}
|
229 |
}
|
| 223 |
|
230 |
|
| 224 |
/**
|
231 |
/**
|
| Línea 238... |
Línea 245... |
| 238 |
|
245 |
|
| 239 |
// Process some responses from the student.
|
246 |
// Process some responses from the student.
|
| 240 |
$attemptobj = quiz_attempt::create($attempt->id);
|
247 |
$attemptobj = quiz_attempt::create($attempt->id);
|
| 241 |
$tosubmit = [2 => ['answer' => 'Answer of student.', 'answerformat' => FORMAT_HTML]];
|
248 |
$tosubmit = [2 => ['answer' => 'Answer of student.', 'answerformat' => FORMAT_HTML]];
|
| 242 |
$attemptobj->process_submitted_actions($timenow - 30 * MINSECS, false, $tosubmit);
|
249 |
$attemptobj->process_submitted_actions($timenow - 30 * MINSECS, false, $tosubmit);
|
| - |
|
250 |
$attemptobj->process_submit($timenow - 20 * MINSECS, false);
|
| Línea 243... |
Línea 251... |
| 243 |
$attemptobj->process_finish($timenow - 20 * MINSECS, false);
|
251 |
$attemptobj->process_grade_submission($timenow - 10 * MINSECS);
|
| 244 |
|
252 |
|
| 245 |
// Finish the attempt of student.
|
253 |
// Finish the attempt of student.
|