Línea 16... |
Línea 16... |
16 |
|
16 |
|
17 |
/**
|
17 |
/**
|
18 |
* Unit tests for (some of) mod/assign/locallib.php.
|
18 |
* Unit tests for (some of) mod/assign/locallib.php.
|
19 |
*
|
19 |
*
|
20 |
* @package mod_assign
|
20 |
* @package mod_assign
|
21 |
* @category phpunit
|
21 |
* @category test
|
22 |
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
22 |
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
23 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
23 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
24 |
*/
|
24 |
*/
|
Línea 38... |
Línea 38... |
38 |
* Unit tests for (some of) mod/assign/locallib.php.
|
38 |
* Unit tests for (some of) mod/assign/locallib.php.
|
39 |
*
|
39 |
*
|
40 |
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
40 |
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
|
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 locallib_test extends \advanced_testcase {
|
43 |
final class locallib_test extends \advanced_testcase {
|
44 |
|
- |
|
45 |
// Use the generator helper.
|
44 |
// Use the generator helper.
|
46 |
use mod_assign_test_generator;
|
45 |
use mod_assign_test_generator;
|
Línea 47... |
Línea 46... |
47 |
|
46 |
|
48 |
/** @var array */
|
47 |
/** @var array */
|
Línea 146... |
Línea 145... |
146 |
}
|
145 |
}
|
Línea 147... |
Línea 146... |
147 |
|
146 |
|
148 |
/**
|
147 |
/**
|
149 |
* Data provider for test_get_assign_perpage
|
148 |
* Data provider for test_get_assign_perpage
|
150 |
*
|
149 |
*
|
151 |
* @return array Provider data
|
150 |
* @return array[] Provider data
|
152 |
*/
|
151 |
*/
|
153 |
public function get_assign_perpage_provider() {
|
152 |
public static function get_assign_perpage_provider(): array {
|
154 |
return array(
|
153 |
return [
|
155 |
array(
|
154 |
[
|
156 |
'maxperpage' => -1,
|
155 |
'maxperpage' => -1,
|
157 |
'userprefs' => array(
|
156 |
'userprefs' => [
|
158 |
-1 => -1,
|
157 |
-1 => -1,
|
159 |
10 => 10,
|
158 |
10 => 10,
|
160 |
20 => 20,
|
159 |
20 => 20,
|
161 |
50 => 50,
|
160 |
50 => 50,
|
162 |
),
|
161 |
],
|
163 |
),
|
162 |
],
|
164 |
array(
|
163 |
[
|
165 |
'maxperpage' => 15,
|
164 |
'maxperpage' => 15,
|
166 |
'userprefs' => array(
|
165 |
'userprefs' => [
|
167 |
-1 => 15,
|
166 |
-1 => 15,
|
168 |
10 => 10,
|
167 |
10 => 10,
|
169 |
20 => 15,
|
168 |
20 => 15,
|
170 |
50 => 15,
|
169 |
50 => 15,
|
171 |
),
|
170 |
],
|
172 |
),
|
171 |
],
|
173 |
);
|
172 |
];
|
Línea 174... |
Línea 173... |
174 |
}
|
173 |
}
|
175 |
|
174 |
|
176 |
/**
|
175 |
/**
|
Línea 213... |
Línea 212... |
213 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
212 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
214 |
$this->setUser($teacher);
|
213 |
$this->setUser($teacher);
|
215 |
$assign = $this->create_instance($course, [
|
214 |
$assign = $this->create_instance($course, [
|
216 |
'assignsubmission_onlinetext_enabled' => 1,
|
215 |
'assignsubmission_onlinetext_enabled' => 1,
|
217 |
'assignfeedback_comments_enabled' => 0,
|
216 |
'assignfeedback_comments_enabled' => 0,
|
218 |
'grade' => GRADE_TYPE_NONE
|
217 |
'grade' => GRADE_TYPE_NONE,
|
219 |
]);
|
218 |
]);
|
Línea 220... |
Línea 219... |
220 |
|
219 |
|
221 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', array(
|
220 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', [
|
222 |
'id' => $assign->get_course_module()->id,
|
221 |
'id' => $assign->get_course_module()->id,
|
223 |
'action' => 'grading',
|
222 |
'action' => 'grading',
|
Línea 224... |
Línea 223... |
224 |
)));
|
223 |
]));
|
225 |
|
224 |
|
226 |
// Render the table with the requires grading filter.
|
225 |
// Render the table with the requires grading filter.
|
Línea 248... |
Línea 247... |
248 |
$time = time();
|
247 |
$time = time();
|
249 |
$assign = $this->create_instance($course, [
|
248 |
$assign = $this->create_instance($course, [
|
250 |
'assignsubmission_onlinetext_enabled' => 1,
|
249 |
'assignsubmission_onlinetext_enabled' => 1,
|
251 |
'duedate' => time() - (4 * DAYSECS),
|
250 |
'duedate' => time() - (4 * DAYSECS),
|
252 |
]);
|
251 |
]);
|
253 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', array(
|
252 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', [
|
254 |
'id' => $assign->get_course_module()->id,
|
253 |
'id' => $assign->get_course_module()->id,
|
255 |
'action' => 'grading',
|
254 |
'action' => 'grading',
|
256 |
)));
|
255 |
]));
|
Línea 257... |
Línea 256... |
257 |
|
256 |
|
258 |
// Check that the assignment is late.
|
257 |
// Check that the assignment is late.
|
259 |
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
258 |
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
260 |
$output = $assign->get_renderer()->render($gradingtable);
|
259 |
$output = $assign->get_renderer()->render($gradingtable);
|
Línea 307... |
Línea 306... |
307 |
$time = time();
|
306 |
$time = time();
|
308 |
$assign = $this->create_instance($course, [
|
307 |
$assign = $this->create_instance($course, [
|
309 |
'assignsubmission_onlinetext_enabled' => 1,
|
308 |
'assignsubmission_onlinetext_enabled' => 1,
|
310 |
'duedate' => time() - (4 * DAYSECS),
|
309 |
'duedate' => time() - (4 * DAYSECS),
|
311 |
]);
|
310 |
]);
|
312 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', array(
|
311 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', [
|
313 |
'id' => $assign->get_course_module()->id,
|
312 |
'id' => $assign->get_course_module()->id,
|
314 |
'action' => 'grading',
|
313 |
'action' => 'grading',
|
315 |
)));
|
314 |
]));
|
Línea 316... |
Línea 315... |
316 |
|
315 |
|
317 |
// Check that the assignment is late.
|
316 |
// Check that the assignment is late.
|
318 |
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
317 |
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
319 |
$output = $assign->get_renderer()->render($gradingtable);
|
318 |
$output = $assign->get_renderer()->render($gradingtable);
|
Línea 351... |
Línea 350... |
351 |
$output = $assign->get_renderer()->render($gradingtable);
|
350 |
$output = $assign->get_renderer()->render($gradingtable);
|
352 |
$this->assertStringContainsString(get_string('submissionstatus_submitted', 'assign'), $output);
|
351 |
$this->assertStringContainsString(get_string('submissionstatus_submitted', 'assign'), $output);
|
353 |
$this->assertStringContainsString(get_string('userextensiondate', 'assign', userdate($time - (2 * DAYSECS))), $output);
|
352 |
$this->assertStringContainsString(get_string('userextensiondate', 'assign', userdate($time - (2 * DAYSECS))), $output);
|
Línea 354... |
Línea 353... |
354 |
|
353 |
|
- |
|
354 |
$difftime = $submittedtime - $time;
|
355 |
$difftime = $submittedtime - $time;
|
355 |
$this->assertStringContainsString(
|
356 |
$this->assertStringContainsString(get_string('submittedlateshort', 'assign', format_time((2 * DAYSECS) + $difftime)),
|
356 |
get_string('submittedlateshort', 'assign', format_time((2 * DAYSECS) + $difftime)),
|
- |
|
357 |
$output
|
357 |
$output);
|
358 |
);
|
Línea 358... |
Línea 359... |
358 |
}
|
359 |
}
|
359 |
|
360 |
|
Línea 370... |
Línea 371... |
370 |
$time = time();
|
371 |
$time = time();
|
371 |
$assign = $this->create_instance($course, [
|
372 |
$assign = $this->create_instance($course, [
|
372 |
'assignsubmission_onlinetext_enabled' => 1,
|
373 |
'assignsubmission_onlinetext_enabled' => 1,
|
373 |
'duedate' => $time - (4 * DAYSECS),
|
374 |
'duedate' => $time - (4 * DAYSECS),
|
374 |
]);
|
375 |
]);
|
375 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', array(
|
376 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', [
|
376 |
'id' => $assign->get_course_module()->id,
|
377 |
'id' => $assign->get_course_module()->id,
|
377 |
'action' => 'grading',
|
378 |
'action' => 'grading',
|
378 |
)));
|
379 |
]));
|
Línea 379... |
Línea 380... |
379 |
|
380 |
|
380 |
// Check that the assignment is late.
|
381 |
// Check that the assignment is late.
|
381 |
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
382 |
$gradingtable = new \assign_grading_table($assign, 1, '', 0, true);
|
382 |
$output = $assign->get_renderer()->render($gradingtable);
|
383 |
$output = $assign->get_renderer()->render($gradingtable);
|
Línea 399... |
Línea 400... |
399 |
$this->assertStringContainsString(get_string('overdue', 'assign', format_time((4 * DAYSECS) + $difftime)), $output);
|
400 |
$this->assertStringContainsString(get_string('overdue', 'assign', format_time((4 * DAYSECS) + $difftime)), $output);
|
Línea 400... |
Línea 401... |
400 |
|
401 |
|
401 |
$document = new \DOMDocument();
|
402 |
$document = new \DOMDocument();
|
402 |
@$document->loadHTML($output);
|
403 |
@$document->loadHTML($output);
|
403 |
$xpath = new \DOMXPath($document);
|
404 |
$xpath = new \DOMXPath($document);
|
404 |
$this->assertEmpty($xpath->evaluate('string(//td[@id="mod_assign_grading-' . $assign->get_context()->id. '_r0_c8"])'));
|
405 |
$this->assertEmpty($xpath->evaluate('string(//td[@id="mod_assign_grading-' . $assign->get_context()->id . '_r0_c6"])'));
|
Línea 405... |
Línea 406... |
405 |
}
|
406 |
}
|
406 |
|
407 |
|
407 |
/**
|
408 |
/**
|
Línea 442... |
Línea 443... |
442 |
'teamsubmission' => 1,
|
443 |
'teamsubmission' => 1,
|
443 |
'assignsubmission_onlinetext_enabled' => 1,
|
444 |
'assignsubmission_onlinetext_enabled' => 1,
|
444 |
'submissiondrafts' => 1,
|
445 |
'submissiondrafts' => 1,
|
445 |
'requireallteammemberssubmit' => 0,
|
446 |
'requireallteammemberssubmit' => 0,
|
446 |
]);
|
447 |
]);
|
447 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', array(
|
448 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', [
|
448 |
'id' => $assign->get_course_module()->id,
|
449 |
'id' => $assign->get_course_module()->id,
|
449 |
'action' => 'grading',
|
450 |
'action' => 'grading',
|
450 |
)));
|
451 |
]));
|
Línea 451... |
Línea 452... |
451 |
|
452 |
|
452 |
// Add a submission.
|
453 |
// Add a submission.
|
453 |
$this->setUser($student);
|
454 |
$this->setUser($student);
|
454 |
$data = new \stdClass();
|
455 |
$data = new \stdClass();
|
455 |
$data->onlinetext_editor = [
|
456 |
$data->onlinetext_editor = [
|
456 |
'itemid' => file_get_unused_draft_itemid(),
|
457 |
'itemid' => file_get_unused_draft_itemid(),
|
457 |
'text' => 'Submission text',
|
458 |
'text' => 'Submission text',
|
458 |
'format' => FORMAT_MOODLE,
|
459 |
'format' => FORMAT_MOODLE,
|
459 |
];
|
460 |
];
|
460 |
$notices = array();
|
461 |
$notices = [];
|
Línea 461... |
Línea 462... |
461 |
$assign->save_submission($data, $notices);
|
462 |
$assign->save_submission($data, $notices);
|
462 |
|
463 |
|
463 |
$submission = $assign->get_group_submission($student->id, 0, true);
|
464 |
$submission = $assign->get_group_submission($student->id, 0, true);
|
Línea 474... |
Línea 475... |
474 |
|
475 |
|
475 |
// The XPath expression is based on the unique ID of the table.
|
476 |
// The XPath expression is based on the unique ID of the table.
|
Línea 476... |
Línea 477... |
476 |
$xpathuniqueidroot = 'mod_assign_grading-' . $assign->get_context()->id;
|
477 |
$xpathuniqueidroot = 'mod_assign_grading-' . $assign->get_context()->id;
|
- |
|
478 |
|
477 |
|
479 |
// Check status.
|
478 |
// Check status.
|
480 |
$this->assertSame(
|
- |
|
481 |
get_string('submissionstatus_submitted', 'assign'),
|
- |
|
482 |
$xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r0_c3"]//div[@class="submissionstatussubmitted"])')
|
479 |
$this->assertSame(get_string('submissionstatus_submitted', 'assign'),
|
483 |
);
|
480 |
$xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r0_c4"]/div[@class="submissionstatussubmitted"])'));
|
484 |
$this->assertSame(
|
- |
|
485 |
get_string('submissionstatus_submitted', 'assign'),
|
Línea 481... |
Línea 486... |
481 |
$this->assertSame(get_string('submissionstatus_submitted', 'assign'),
|
486 |
$xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r3_c3"]//div[@class="submissionstatussubmitted"])')
|
482 |
$xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r3_c4"]/div[@class="submissionstatussubmitted"])'));
|
487 |
);
|
483 |
|
488 |
|
Línea 484... |
Línea 489... |
484 |
// Check submission last modified date.
|
489 |
// Check submission last modified date.
|
485 |
$this->assertGreaterThan(0, strtotime($xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r0_c8"])')));
|
490 |
$this->assertGreaterThan(0, strtotime($xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r0_c6"])')));
|
486 |
$this->assertGreaterThan(0, strtotime($xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r3_c8"])')));
|
491 |
$this->assertGreaterThan(0, strtotime($xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r3_c6"])')));
|
Línea 487... |
Línea 492... |
487 |
|
492 |
|
488 |
// Check group.
|
493 |
// Check group.
|
489 |
$this->assertSame($group->name, $xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r0_c5"])'));
|
494 |
$this->assertSame($group->name, $xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r0_c4"])'));
|
Línea 490... |
Línea 495... |
490 |
$this->assertSame($group->name, $xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r3_c5"])'));
|
495 |
$this->assertSame($group->name, $xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r3_c4"])'));
|
491 |
|
496 |
|
492 |
// Check submission text.
|
497 |
// Check submission text.
|
493 |
$this->assertSame('Submission text', $xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r0_c9"]/div/div)'));
|
498 |
$this->assertSame('Submission text', $xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r0_c7"]/div/div)'));
|
Línea 494... |
Línea 499... |
494 |
$this->assertSame('Submission text', $xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r3_c9"]/div/div)'));
|
499 |
$this->assertSame('Submission text', $xpath->evaluate('string(//td[@id="' . $xpathuniqueidroot . '_r3_c7"]/div/div)'));
|
495 |
|
500 |
|
496 |
// Check comments can be made.
|
501 |
// Check comments can be made.
|
Línea 546... |
Línea 551... |
546 |
|
551 |
|
547 |
// Submit the submission.
|
552 |
// Submit the submission.
|
548 |
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
553 |
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
549 |
$assign->testable_update_submission($submission, $student->id, true, false);
|
554 |
$assign->testable_update_submission($submission, $student->id, true, false);
|
550 |
$data = new \stdClass();
|
555 |
$data = new \stdClass();
|
551 |
$data->onlinetext_editor = array(
|
556 |
$data->onlinetext_editor = [
|
552 |
'itemid' => file_get_unused_draft_itemid(),
|
557 |
'itemid' => file_get_unused_draft_itemid(),
|
553 |
'text' => 'Submission text',
|
558 |
'text' => 'Submission text',
|
554 |
'format' => FORMAT_MOODLE);
|
559 |
'format' => FORMAT_MOODLE];
|
555 |
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
560 |
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
Línea 556... |
Línea 561... |
556 |
$plugin->save($submission, $data);
|
561 |
$plugin->save($submission, $data);
|
557 |
|
562 |
|
Línea 606... |
Línea 611... |
606 |
// Now try and delete.
|
611 |
// Now try and delete.
|
607 |
$this->setUser($teacher);
|
612 |
$this->setUser($teacher);
|
608 |
$this->assertEquals(true, $assign->delete_instance());
|
613 |
$this->assertEquals(true, $assign->delete_instance());
|
609 |
}
|
614 |
}
|
Línea -... |
Línea 615... |
- |
|
615 |
|
- |
|
616 |
/**
|
- |
|
617 |
* @covers ::assign_reset_userdata
|
610 |
|
618 |
*/
|
611 |
public function test_reset_userdata(): void {
|
619 |
public function test_reset_userdata(): void {
|
Línea 612... |
Línea 620... |
612 |
global $DB;
|
620 |
global $DB;
|
613 |
|
621 |
|
Línea 617... |
Línea 625... |
617 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
625 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
Línea 618... |
Línea 626... |
618 |
|
626 |
|
619 |
$now = time();
|
627 |
$now = time();
|
620 |
$this->setUser($teacher);
|
628 |
$this->setUser($teacher);
|
621 |
$assign = $this->create_instance($course, [
|
629 |
$assign = $this->create_instance($course, [
|
- |
|
630 |
'assignsubmission_onlinetext_enabled' => 1,
|
622 |
'assignsubmission_onlinetext_enabled' => 1,
|
631 |
'allowsubmissionsfromdate' => $now - HOURSECS,
|
- |
|
632 |
'duedate' => $now,
|
- |
|
633 |
'cutoffdate' => $now + HOURSECS,
|
623 |
'duedate' => $now,
|
634 |
'gradingduedate' => $now + DAYSECS,
|
Línea 624... |
Línea 635... |
624 |
]);
|
635 |
]);
|
625 |
|
636 |
|
626 |
// Simulate adding a grade.
|
637 |
// Simulate adding a grade.
|
627 |
$this->add_submission($student, $assign);
|
638 |
$this->add_submission($student, $assign);
|
Línea 628... |
Línea 639... |
628 |
$this->submit_for_grading($student, $assign);
|
639 |
$this->submit_for_grading($student, $assign);
|
629 |
$this->mark_submission($teacher, $assign, $student, 50.0);
|
640 |
$this->mark_submission($teacher, $assign, $student, 50.0);
|
630 |
|
641 |
|
631 |
// Simulate a submission.
|
642 |
// Simulate a submission.
|
632 |
$this->setUser($student);
|
643 |
$this->setUser($student);
|
633 |
$submission = $assign->get_user_submission($student->id, true);
|
644 |
$submission = $assign->get_user_submission($student->id, true);
|
634 |
$data = new \stdClass();
|
645 |
$data = new \stdClass();
|
635 |
$data->onlinetext_editor = array(
|
646 |
$data->onlinetext_editor = [
|
636 |
'itemid' => file_get_unused_draft_itemid(),
|
647 |
'itemid' => file_get_unused_draft_itemid(),
|
637 |
'text' => 'Submission text',
|
648 |
'text' => 'Submission text',
|
Línea 638... |
Línea 649... |
638 |
'format' => FORMAT_MOODLE);
|
649 |
'format' => FORMAT_MOODLE];
|
639 |
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
650 |
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
Línea 651... |
Línea 662... |
651 |
$this->setUser($teacher);
|
662 |
$this->setUser($teacher);
|
652 |
$assign->reset_userdata($data);
|
663 |
$assign->reset_userdata($data);
|
653 |
$this->assertEquals(false, $assign->has_submissions_or_grades());
|
664 |
$this->assertEquals(false, $assign->has_submissions_or_grades());
|
Línea 654... |
Línea 665... |
654 |
|
665 |
|
655 |
// Reload the instance data.
|
666 |
// Reload the instance data.
|
- |
|
667 |
$instance = $DB->get_record('assign', ['id' => $assign->get_instance()->id]);
|
656 |
$instance = $DB->get_record('assign', array('id' => $assign->get_instance()->id));
|
668 |
$this->assertEquals($now - HOURSECS + DAYSECS, $instance->allowsubmissionsfromdate);
|
- |
|
669 |
$this->assertEquals($now + DAYSECS, $instance->duedate);
|
- |
|
670 |
$this->assertEquals($now + HOURSECS + DAYSECS, $instance->cutoffdate);
|
Línea 657... |
Línea 671... |
657 |
$this->assertEquals($now + DAYSECS, $instance->duedate);
|
671 |
$this->assertEquals($now + DAYSECS + DAYSECS, $instance->gradingduedate);
|
658 |
|
672 |
|
659 |
// Test reset using assign_reset_userdata().
|
673 |
// Test reset using assign_reset_userdata().
|
660 |
$assignduedate = $instance->duedate; // Keep old updated value for comparison.
|
674 |
$assignduedate = $instance->duedate; // Keep old updated value for comparison.
|
661 |
$data->timeshift = (2 * DAYSECS);
|
675 |
$data->timeshift = (2 * DAYSECS);
|
662 |
assign_reset_userdata($data);
|
676 |
assign_reset_userdata($data);
|
Línea 663... |
Línea 677... |
663 |
$instance = $DB->get_record('assign', array('id' => $assign->get_instance()->id));
|
677 |
$instance = $DB->get_record('assign', ['id' => $assign->get_instance()->id]);
|
664 |
$this->assertEquals($assignduedate + (2 * DAYSECS), $instance->duedate);
|
678 |
$this->assertEquals($assignduedate + (2 * DAYSECS), $instance->duedate);
|
665 |
|
679 |
|
666 |
// Create one more assignment and reset, make sure time shifted for previous assignment is not changed.
|
680 |
// Create one more assignment and reset, make sure time shifted for previous assignment is not changed.
|
667 |
$assign2 = $this->create_instance($course, [
|
681 |
$assign2 = $this->create_instance($course, [
|
668 |
'assignsubmission_onlinetext_enabled' => 1,
|
682 |
'assignsubmission_onlinetext_enabled' => 1,
|
669 |
'duedate' => $now,
|
683 |
'duedate' => $now,
|
670 |
]);
|
684 |
]);
|
671 |
$assignduedate = $instance->duedate;
|
685 |
$assignduedate = $instance->duedate;
|
672 |
$data->timeshift = 3 * DAYSECS;
|
686 |
$data->timeshift = 3 * DAYSECS;
|
673 |
$assign2->reset_userdata($data);
|
687 |
$assign2->reset_userdata($data);
|
674 |
$instance = $DB->get_record('assign', array('id' => $assign->get_instance()->id));
|
688 |
$instance = $DB->get_record('assign', ['id' => $assign->get_instance()->id]);
|
Línea 675... |
Línea 689... |
675 |
$this->assertEquals($assignduedate, $instance->duedate);
|
689 |
$this->assertEquals($assignduedate, $instance->duedate);
|
676 |
$instance2 = $DB->get_record('assign', array('id' => $assign2->get_instance()->id));
|
690 |
$instance2 = $DB->get_record('assign', ['id' => $assign2->get_instance()->id]);
|
677 |
$this->assertEquals($now + 3 * DAYSECS, $instance2->duedate);
|
691 |
$this->assertEquals($now + 3 * DAYSECS, $instance2->duedate);
|
678 |
|
692 |
|
679 |
// Reset both assignments using assign_reset_userdata() and make sure both assignments have same date.
|
693 |
// Reset both assignments using assign_reset_userdata() and make sure both assignments have same date.
|
680 |
$assignduedate = $instance->duedate;
|
694 |
$assignduedate = $instance->duedate;
|
681 |
$assign2duedate = $instance2->duedate;
|
695 |
$assign2duedate = $instance2->duedate;
|
682 |
$data->timeshift = (4 * DAYSECS);
|
696 |
$data->timeshift = (4 * DAYSECS);
|
683 |
assign_reset_userdata($data);
|
697 |
assign_reset_userdata($data);
|
684 |
$instance = $DB->get_record('assign', array('id' => $assign->get_instance()->id));
|
698 |
$instance = $DB->get_record('assign', ['id' => $assign->get_instance()->id]);
|
Línea 685... |
Línea 699... |
685 |
$this->assertEquals($assignduedate + (4 * DAYSECS), $instance->duedate);
|
699 |
$this->assertEquals($assignduedate + (4 * DAYSECS), $instance->duedate);
|
686 |
$instance2 = $DB->get_record('assign', array('id' => $assign2->get_instance()->id));
|
700 |
$instance2 = $DB->get_record('assign', ['id' => $assign2->get_instance()->id]);
|
Línea 723... |
Línea 737... |
723 |
$_REQUEST['introeditor'] = $draftid;
|
737 |
$_REQUEST['introeditor'] = $draftid;
|
724 |
$_POST['introeditor'] = $draftid;
|
738 |
$_POST['introeditor'] = $draftid;
|
725 |
$_POST['sesskey'] = sesskey();
|
739 |
$_POST['sesskey'] = sesskey();
|
Línea 726... |
Línea 740... |
726 |
|
740 |
|
- |
|
741 |
// Write links to a draft area.
|
727 |
// Write links to a draft area.
|
742 |
$fakearealink1 = file_rewrite_pluginfile_urls(
|
728 |
$fakearealink1 = file_rewrite_pluginfile_urls('<a href="@@PLUGINFILE@@/pic.gif">link</a>', 'draftfile.php', $userctx,
|
743 |
'<a href="@@PLUGINFILE@@/pic.gif">link</a>',
|
- |
|
744 |
'draftfile.php',
|
- |
|
745 |
$userctx,
|
- |
|
746 |
'user',
|
- |
|
747 |
'draft',
|
- |
|
748 |
$draftid
|
729 |
'user', 'draft', $draftid);
|
749 |
);
|
- |
|
750 |
$fakearealink2 = file_rewrite_pluginfile_urls(
|
730 |
$fakearealink2 = file_rewrite_pluginfile_urls('<a href="@@PLUGINFILE@@/pic.gif">new</a>', 'draftfile.php', $userctx,
|
751 |
'<a href="@@PLUGINFILE@@/pic.gif">new</a>',
|
- |
|
752 |
'draftfile.php',
|
- |
|
753 |
$userctx,
|
- |
|
754 |
'user',
|
- |
|
755 |
'draft',
|
- |
|
756 |
$draftid
|
Línea 731... |
Línea 757... |
731 |
'user', 'draft', $draftid);
|
757 |
);
|
732 |
|
758 |
|
733 |
// Create a new \assignment with links to a draft area.
|
759 |
// Create a new \assignment with links to a draft area.
|
734 |
$now = time();
|
760 |
$now = time();
|
735 |
$assign = $this->create_instance($course, [
|
761 |
$assign = $this->create_instance($course, [
|
736 |
'duedate' => $now,
|
762 |
'duedate' => $now,
|
737 |
'intro' => $fakearealink1,
|
763 |
'intro' => $fakearealink1,
|
Línea 738... |
Línea 764... |
738 |
'introformat' => FORMAT_HTML
|
764 |
'introformat' => FORMAT_HTML,
|
739 |
]);
|
765 |
]);
|
740 |
|
766 |
|
741 |
// See if there is an event in the calendar.
|
767 |
// See if there is an event in the calendar.
|
742 |
$params = array('modulename' => 'assign', 'instance' => $assign->get_instance()->id);
|
768 |
$params = ['modulename' => 'assign', 'instance' => $assign->get_instance()->id];
|
Línea 743... |
Línea 769... |
743 |
$event = $DB->get_record('event', $params);
|
769 |
$event = $DB->get_record('event', $params);
|
744 |
$this->assertNotEmpty($event);
|
770 |
$this->assertNotEmpty($event);
|
745 |
$this->assertSame('link', $event->description); // The pluginfile links are removed.
|
771 |
$this->assertSame('link', $event->description); // The pluginfile links are removed.
|
746 |
|
772 |
|
747 |
// Make sure the same works when updating the assignment.
|
773 |
// Make sure the same works when updating the assignment.
|
748 |
$instance = $assign->get_instance();
|
774 |
$instance = $assign->get_instance();
|
749 |
$instance->instance = $instance->id;
|
775 |
$instance->instance = $instance->id;
|
750 |
$instance->intro = $fakearealink2;
|
776 |
$instance->intro = $fakearealink2;
|
751 |
$instance->introformat = FORMAT_HTML;
|
777 |
$instance->introformat = FORMAT_HTML;
|
752 |
$assign->update_instance($instance);
|
778 |
$assign->update_instance($instance);
|
Línea 753... |
Línea 779... |
753 |
$params = array('modulename' => 'assign', 'instance' => $assign->get_instance()->id);
|
779 |
$params = ['modulename' => 'assign', 'instance' => $assign->get_instance()->id];
|
Línea 762... |
Línea 788... |
762 |
'allowsubmissionsfromdate' => $now + 60,
|
788 |
'allowsubmissionsfromdate' => $now + 60,
|
763 |
'intro' => 'Some text',
|
789 |
'intro' => 'Some text',
|
764 |
]);
|
790 |
]);
|
Línea 765... |
Línea 791... |
765 |
|
791 |
|
766 |
// Get the event from the calendar.
|
792 |
// Get the event from the calendar.
|
767 |
$params = array('modulename' => 'assign', 'instance' => $assign->get_instance()->id);
|
793 |
$params = ['modulename' => 'assign', 'instance' => $assign->get_instance()->id];
|
768 |
$event = $DB->get_record('event', [
|
794 |
$event = $DB->get_record('event', [
|
769 |
'modulename' => 'assign',
|
795 |
'modulename' => 'assign',
|
770 |
'instance' => $assign->get_instance()->id,
|
796 |
'instance' => $assign->get_instance()->id,
|
Línea 771... |
Línea 797... |
771 |
]);
|
797 |
]);
|
Línea 772... |
Línea 798... |
772 |
|
798 |
|
773 |
$this->assertEmpty($event->description);
|
799 |
$this->assertEmpty($event->description);
|
774 |
|
800 |
|
775 |
// Change the allowsubmissionfromdate to the past - do this directly in the DB
|
801 |
// Change the allowsubmissionfromdate to the past - do this directly in the DB
|
776 |
// because if we call the assignment update method - it will update the calendar
|
802 |
// because if we call the assignment update method - it will update the calendar
|
777 |
// and we want to test that this works from cron.
|
803 |
// and we want to test that this works from cron.
|
778 |
$DB->set_field('assign', 'allowsubmissionsfromdate', $now - 60, array('id' => $assign->get_instance()->id));
|
804 |
$DB->set_field('assign', 'allowsubmissionsfromdate', $now - 60, ['id' => $assign->get_instance()->id]);
|
Línea 779... |
Línea 805... |
779 |
// Run cron to update the event in the calendar.
|
805 |
// Run cron to update the event in the calendar.
|
780 |
\assign::cron();
|
- |
|
781 |
$event = $DB->get_record('event', $params);
|
806 |
\assign::cron();
|
Línea 782... |
Línea 807... |
782 |
|
807 |
$event = $DB->get_record('event', $params);
|
783 |
$this->assertStringContainsString('Some text', $event->description);
|
808 |
|
Línea 820... |
Línea 845... |
820 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
845 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
Línea 821... |
Línea 846... |
821 |
|
846 |
|
822 |
// Test you cannot see the submit button for an offline assignment regardless.
|
847 |
// Test you cannot see the submit button for an offline assignment regardless.
|
823 |
$this->setUser($student);
|
848 |
$this->setUser($student);
|
- |
|
849 |
$output = $assign->view_student_summary($student, true);
|
824 |
$output = $assign->view_student_summary($student, true);
|
850 |
$this->assertStringNotContainsString(
|
- |
|
851 |
get_string('submitassignment', 'assign'),
|
825 |
$this->assertStringNotContainsString(get_string('submitassignment', 'assign'),
|
852 |
$output,
|
- |
|
853 |
'Can submit empty offline assignment'
|
826 |
$output, 'Can submit empty offline assignment');
|
854 |
);
|
Línea 827... |
Línea 855... |
827 |
}
|
855 |
}
|
828 |
|
856 |
|
Línea 842... |
Línea 870... |
842 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
870 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
Línea 843... |
Línea 871... |
843 |
|
871 |
|
844 |
// Test you cannot see the submit button for an online text assignment with no submission.
|
872 |
// Test you cannot see the submit button for an online text assignment with no submission.
|
845 |
$this->setUser($student);
|
873 |
$this->setUser($student);
|
- |
|
874 |
$output = $assign->view_student_summary($student, true);
|
846 |
$output = $assign->view_student_summary($student, true);
|
875 |
$this->assertStringNotContainsString(
|
- |
|
876 |
get_string('submitassignment', 'assign'),
|
847 |
$this->assertStringNotContainsString(get_string('submitassignment', 'assign'),
|
877 |
$output,
|
- |
|
878 |
'Cannot submit empty onlinetext assignment'
|
848 |
$output, 'Cannot submit empty onlinetext assignment');
|
879 |
);
|
Línea 849... |
Línea 880... |
849 |
}
|
880 |
}
|
850 |
|
881 |
|
Línea 867... |
Línea 898... |
867 |
$this->add_submission($student, $assign);
|
898 |
$this->add_submission($student, $assign);
|
Línea 868... |
Línea 899... |
868 |
|
899 |
|
869 |
// Test you can see the submit button for an online text assignment with a submission.
|
900 |
// Test you can see the submit button for an online text assignment with a submission.
|
870 |
$this->setUser($student);
|
901 |
$this->setUser($student);
|
- |
|
902 |
$output = $assign->view_submission_action_bar($assign->get_instance(), $student);
|
871 |
$output = $assign->view_submission_action_bar($assign->get_instance(), $student);
|
903 |
$this->assertStringContainsString(
|
- |
|
904 |
get_string('submitassignment', 'assign'),
|
872 |
$this->assertStringContainsString(get_string('submitassignment', 'assign'),
|
905 |
$output,
|
- |
|
906 |
'Can submit non empty onlinetext assignment'
|
873 |
$output, 'Can submit non empty onlinetext assignment');
|
907 |
);
|
Línea 874... |
Línea 908... |
874 |
}
|
908 |
}
|
875 |
|
909 |
|
876 |
/**
|
910 |
/**
|
Línea 915... |
Línea 949... |
915 |
}
|
949 |
}
|
Línea 916... |
Línea 950... |
916 |
|
950 |
|
917 |
/**
|
951 |
/**
|
918 |
* Dataprovider for the test_new_submission_empty testcase
|
952 |
* Dataprovider for the test_new_submission_empty testcase
|
919 |
*
|
953 |
*
|
920 |
* @return array of testcases
|
954 |
* @return array[] An array of testcases
|
921 |
*/
|
955 |
*/
|
922 |
public function new_submission_empty_testcases() {
|
956 |
public static function new_submission_empty_testcases(): array {
|
923 |
return [
|
957 |
return [
|
924 |
'With file and onlinetext' => [
|
958 |
'With file and onlinetext' => [
|
925 |
[
|
959 |
[
|
926 |
'file' => [
|
960 |
'file' => [
|
927 |
'component' => 'user',
|
961 |
'component' => 'user',
|
928 |
'filearea' => 'draft',
|
962 |
'filearea' => 'draft',
|
929 |
'filepath' => '/',
|
963 |
'filepath' => '/',
|
930 |
'filename' => 'not_a_virus.exe'
|
964 |
'filename' => 'not_a_virus.exe',
|
931 |
],
|
965 |
],
|
932 |
'onlinetext' => 'Balin Fundinul Uzbadkhazaddumu'
|
966 |
'onlinetext' => 'Balin Fundinul Uzbadkhazaddumu',
|
933 |
],
|
967 |
],
|
934 |
false
|
968 |
false,
|
935 |
]
|
969 |
],
|
936 |
];
|
970 |
];
|
Línea 937... |
Línea 971... |
937 |
}
|
971 |
}
|
938 |
|
972 |
|
Línea 1158... |
Línea 1192... |
1158 |
$course = $this->getDataGenerator()->create_course();
|
1192 |
$course = $this->getDataGenerator()->create_course();
|
1159 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
1193 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
1160 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1194 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1161 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1195 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
Línea 1162... |
Línea 1196... |
1162 |
|
1196 |
|
1163 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
1197 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
1164 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
1198 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
1165 |
$group2 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
1199 |
$group2 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
1166 |
groups_add_member($group1, $student1);
|
1200 |
groups_add_member($group1, $student1);
|
Línea 1182... |
Línea 1216... |
1182 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
1216 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
1183 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1217 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1184 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1218 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1185 |
$student3 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1219 |
$student3 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
Línea 1186... |
Línea 1220... |
1186 |
|
1220 |
|
1187 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
1221 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
Línea 1188... |
Línea 1222... |
1188 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
1222 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
1189 |
|
1223 |
|
1190 |
$this->getDataGenerator()->create_grouping_group(array('groupid' => $group1->id, 'groupingid' => $grouping->id));
|
1224 |
$this->getDataGenerator()->create_grouping_group(['groupid' => $group1->id, 'groupingid' => $grouping->id]);
|
Línea 1191... |
Línea 1225... |
1191 |
$group2 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
1225 |
$group2 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
1192 |
$this->getDataGenerator()->create_grouping_group(array('groupid' => $group2->id, 'groupingid' => $grouping->id));
|
1226 |
$this->getDataGenerator()->create_grouping_group(['groupid' => $group2->id, 'groupingid' => $grouping->id]);
|
Línea 1193... |
Línea 1227... |
1193 |
|
1227 |
|
Línea 1218... |
Línea 1252... |
1218 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
1252 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
1219 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1253 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1220 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1254 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1221 |
$student3 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1255 |
$student3 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
Línea 1222... |
Línea 1256... |
1222 |
|
1256 |
|
1223 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
1257 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
Línea 1224... |
Línea 1258... |
1224 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
1258 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
1225 |
|
1259 |
|
1226 |
$this->getDataGenerator()->create_grouping_group(array('groupid' => $group1->id, 'groupingid' => $grouping->id));
|
1260 |
$this->getDataGenerator()->create_grouping_group(['groupid' => $group1->id, 'groupingid' => $grouping->id]);
|
Línea 1227... |
Línea 1261... |
1227 |
$group2 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
1261 |
$group2 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
1228 |
$this->getDataGenerator()->create_grouping_group(array('groupid' => $group2->id, 'groupingid' => $grouping->id));
|
1262 |
$this->getDataGenerator()->create_grouping_group(['groupid' => $group2->id, 'groupingid' => $grouping->id]);
|
Línea 1229... |
Línea 1263... |
1229 |
|
1263 |
|
Línea 1248... |
Línea 1282... |
1248 |
*/
|
1282 |
*/
|
1249 |
public function test_count_teams_groups_only(): void {
|
1283 |
public function test_count_teams_groups_only(): void {
|
1250 |
$this->resetAfterTest();
|
1284 |
$this->resetAfterTest();
|
Línea 1251... |
Línea 1285... |
1251 |
|
1285 |
|
1252 |
$course = $this->getDataGenerator()->create_course();
|
1286 |
$course = $this->getDataGenerator()->create_course();
|
Línea 1253... |
Línea 1287... |
1253 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
1287 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
1254 |
|
1288 |
|
1255 |
$assign = $this->create_instance($course, [
|
1289 |
$assign = $this->create_instance($course, [
|
1256 |
'teamsubmission' => 1,
|
1290 |
'teamsubmission' => 1,
|
Línea 1265... |
Línea 1299... |
1265 |
|
1299 |
|
1266 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1300 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1267 |
$group2 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
1301 |
$group2 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
Línea 1268... |
Línea 1302... |
1268 |
groups_add_member($group2, $student2);
|
1302 |
groups_add_member($group2, $student2);
|
1269 |
|
1303 |
|
Línea 1270... |
Línea 1304... |
1270 |
$this->getDataGenerator()->create_grouping_group(array('groupid' => $group1->id, 'groupingid' => $grouping->id));
|
1304 |
$this->getDataGenerator()->create_grouping_group(['groupid' => $group1->id, 'groupingid' => $grouping->id]);
|
Línea 1271... |
Línea 1305... |
1271 |
$this->getDataGenerator()->create_grouping_group(array('groupid' => $group2->id, 'groupingid' => $grouping->id));
|
1305 |
$this->getDataGenerator()->create_grouping_group(['groupid' => $group2->id, 'groupingid' => $grouping->id]);
|
1272 |
|
1306 |
|
Línea 1478... |
Línea 1512... |
1478 |
$this->setUser($this->extrastudents[1]);
|
1512 |
$this->setUser($this->extrastudents[1]);
|
1479 |
$submission = $assign->get_group_submission($this->extrastudents[1]->id, $groupid, true);
|
1513 |
$submission = $assign->get_group_submission($this->extrastudents[1]->id, $groupid, true);
|
1480 |
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
1514 |
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
1481 |
$assign->testable_update_submission($submission, $this->extrastudents[1]->id, true, false);
|
1515 |
$assign->testable_update_submission($submission, $this->extrastudents[1]->id, true, false);
|
1482 |
$data = new \stdClass();
|
1516 |
$data = new \stdClass();
|
1483 |
$data->onlinetext_editor = array(
|
1517 |
$data->onlinetext_editor = [
|
1484 |
'itemid' => file_get_unused_draft_itemid(),
|
1518 |
'itemid' => file_get_unused_draft_itemid(),
|
1485 |
'text' => 'Submission text',
|
1519 |
'text' => 'Submission text',
|
1486 |
'format' => FORMAT_MOODLE);
|
1520 |
'format' => FORMAT_MOODLE];
|
1487 |
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
1521 |
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
1488 |
$plugin->save($submission, $data);
|
1522 |
$plugin->save($submission, $data);
|
Línea 1489... |
Línea 1523... |
1489 |
|
1523 |
|
1490 |
// Simulate a submission.
|
1524 |
// Simulate a submission.
|
1491 |
$this->setUser($this->extrastudents[2]);
|
1525 |
$this->setUser($this->extrastudents[2]);
|
1492 |
$submission = $assign->get_group_submission($this->extrastudents[2]->id, $groupid, true);
|
1526 |
$submission = $assign->get_group_submission($this->extrastudents[2]->id, $groupid, true);
|
1493 |
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
1527 |
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
1494 |
$assign->testable_update_submission($submission, $this->extrastudents[2]->id, true, false);
|
1528 |
$assign->testable_update_submission($submission, $this->extrastudents[2]->id, true, false);
|
1495 |
$data = new \stdClass();
|
1529 |
$data = new \stdClass();
|
1496 |
$data->onlinetext_editor = array(
|
1530 |
$data->onlinetext_editor = [
|
1497 |
'itemid' => file_get_unused_draft_itemid(),
|
1531 |
'itemid' => file_get_unused_draft_itemid(),
|
1498 |
'text' => 'Submission text',
|
1532 |
'text' => 'Submission text',
|
1499 |
'format' => FORMAT_MOODLE);
|
1533 |
'format' => FORMAT_MOODLE];
|
1500 |
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
1534 |
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
Línea 1501... |
Línea 1535... |
1501 |
$plugin->save($submission, $data);
|
1535 |
$plugin->save($submission, $data);
|
1502 |
|
1536 |
|
1503 |
// Simulate a submission.
|
1537 |
// Simulate a submission.
|
1504 |
$this->setUser($this->extrastudents[3]);
|
1538 |
$this->setUser($this->extrastudents[3]);
|
1505 |
$submission = $assign->get_group_submission($this->extrastudents[3]->id, $groupid, true);
|
1539 |
$submission = $assign->get_group_submission($this->extrastudents[3]->id, $groupid, true);
|
1506 |
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
1540 |
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
1507 |
$assign->testable_update_submission($submission, $this->extrastudents[3]->id, true, false);
|
1541 |
$assign->testable_update_submission($submission, $this->extrastudents[3]->id, true, false);
|
1508 |
$data = new \stdClass();
|
1542 |
$data = new \stdClass();
|
1509 |
$data->onlinetext_editor = array(
|
1543 |
$data->onlinetext_editor = [
|
1510 |
'itemid' => file_get_unused_draft_itemid(),
|
1544 |
'itemid' => file_get_unused_draft_itemid(),
|
1511 |
'text' => 'Submission text',
|
1545 |
'text' => 'Submission text',
|
1512 |
'format' => FORMAT_MOODLE);
|
1546 |
'format' => FORMAT_MOODLE];
|
Línea 1513... |
Línea 1547... |
1513 |
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
1547 |
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
1514 |
$plugin->save($submission, $data);
|
1548 |
$plugin->save($submission, $data);
|
Línea 1536... |
Línea 1570... |
1536 |
|
1570 |
|
1537 |
$course = $this->getDataGenerator()->create_course();
|
1571 |
$course = $this->getDataGenerator()->create_course();
|
1538 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
1572 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
1539 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1573 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
- |
|
1574 |
$suspendedstudent = $this->getDataGenerator()->create_and_enrol(
|
- |
|
1575 |
$course,
|
- |
|
1576 |
'student',
|
- |
|
1577 |
null,
|
- |
|
1578 |
'manual',
|
- |
|
1579 |
0,
|
1540 |
$suspendedstudent = $this->getDataGenerator()->create_and_enrol(
|
1580 |
0,
|
- |
|
1581 |
ENROL_USER_SUSPENDED
|
Línea 1541... |
Línea 1582... |
1541 |
$course, 'student', null, 'manual', 0, 0, ENROL_USER_SUSPENDED);
|
1582 |
);
|
Línea 1542... |
Línea 1583... |
1542 |
|
1583 |
|
1543 |
$this->setUser($teacher);
|
1584 |
$this->setUser($teacher);
|
Línea 1551... |
Línea 1592... |
1551 |
|
1592 |
|
1552 |
$course = $this->getDataGenerator()->create_course();
|
1593 |
$course = $this->getDataGenerator()->create_course();
|
1553 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
1594 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
1554 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1595 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
- |
|
1596 |
$suspendedstudent = $this->getDataGenerator()->create_and_enrol(
|
- |
|
1597 |
$course,
|
- |
|
1598 |
'student',
|
- |
|
1599 |
null,
|
- |
|
1600 |
'manual',
|
- |
|
1601 |
0,
|
1555 |
$suspendedstudent = $this->getDataGenerator()->create_and_enrol(
|
1602 |
0,
|
- |
|
1603 |
ENROL_USER_SUSPENDED
|
Línea 1556... |
Línea 1604... |
1556 |
$course, 'student', null, 'manual', 0, 0, ENROL_USER_SUSPENDED);
|
1604 |
);
|
1557 |
|
1605 |
|
Línea 1558... |
Línea 1606... |
1558 |
$this->setUser($teacher);
|
1606 |
$this->setUser($teacher);
|
Línea 1683... |
Línea 1731... |
1683 |
|
1731 |
|
1684 |
// First run cron so there are no messages waiting to be sent (from other tests).
|
1732 |
// First run cron so there are no messages waiting to be sent (from other tests).
|
1685 |
\core\cron::setup_user();
|
1733 |
\core\cron::setup_user();
|
Línea 1686... |
Línea 1734... |
1686 |
\assign::cron();
|
1734 |
\assign::cron();
|
1687 |
|
1735 |
|
1688 |
$course = $this->getDataGenerator()->create_course();
|
1736 |
$course = $this->getDataGenerator()->create_course(['shortname' => 'E&U']);
|
Línea 1689... |
Línea 1737... |
1689 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
1737 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
1690 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1738 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1691 |
|
1739 |
|
- |
|
1740 |
// Now create an assignment and add some feedback.
|
1692 |
// Now create an assignment and add some feedback.
|
1741 |
$this->setUser($teacher);
|
1693 |
$this->setUser($teacher);
|
1742 |
$assign = $this->create_instance($course, [
|
1694 |
$assign = $this->create_instance($course, [
|
1743 |
'name' => 'Escaping & Unescaping',
|
Línea 1695... |
Línea 1744... |
1695 |
'sendstudentnotifications' => 1,
|
1744 |
'sendstudentnotifications' => 1,
|
Línea 1724... |
Línea 1773... |
1724 |
$this->expectOutputRegex('/Done processing 1 assignment submissions/');
|
1773 |
$this->expectOutputRegex('/Done processing 1 assignment submissions/');
|
1725 |
\assign::cron();
|
1774 |
\assign::cron();
|
1726 |
$messages = $sink->get_messages();
|
1775 |
$messages = $sink->get_messages();
|
Línea 1727... |
Línea 1776... |
1727 |
|
1776 |
|
- |
|
1777 |
$this->assertEquals(1, count($messages));
|
- |
|
1778 |
|
- |
|
1779 |
// Get some bits we will need to verify the content of the message.
|
- |
|
1780 |
$assignname = $assign->get_instance()->name;
|
- |
|
1781 |
$assignurl = (new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]))->out();
|
- |
|
1782 |
$teachername = fullname($teacher);
|
- |
|
1783 |
$assignsurl = (new \moodle_url('/mod/assign/index.php', ['id' => $course->id]))->out();
|
- |
|
1784 |
$courseurl = (new \moodle_url('/course/view.php', ['id' => $course->id]))->out();
|
- |
|
1785 |
|
1728 |
$this->assertEquals(1, count($messages));
|
1786 |
$message = $messages[0];
|
1729 |
$this->assertEquals(1, $messages[0]->notification);
|
1787 |
$this->assertEquals(1, $message->notification);
|
- |
|
1788 |
$this->assertEquals(format_string($assign->get_instance()->name), $message->contexturlname);
|
- |
|
1789 |
$this->assertEquals("$teachername has given feedback for assignment $assignname", $message->subject, );
|
- |
|
1790 |
$this->assertEquals("E&U -> Assignment -> Escaping & Unescaping
|
- |
|
1791 |
---------------------------------------------------------------------
|
- |
|
1792 |
$teachername has posted some feedback on your
|
- |
|
1793 |
assignment submission for 'Escaping & Unescaping'
|
- |
|
1794 |
|
- |
|
1795 |
You can see it appended to your assignment submission:
|
- |
|
1796 |
|
- |
|
1797 |
$assignurl
|
- |
|
1798 |
|
- |
|
1799 |
---------------------------------------------------------------------
|
- |
|
1800 |
",
|
- |
|
1801 |
$message->fullmessage,
|
- |
|
1802 |
);
|
- |
|
1803 |
$this->assertEquals(
|
- |
|
1804 |
'<p><font face="sans-serif">
|
- |
|
1805 |
<a href="' . $courseurl . '">E&U</a> ->
|
- |
|
1806 |
<a href="' . $assignsurl . '">Assignment</a> ->
|
- |
|
1807 |
<a href="' . $assignurl . '">Escaping & Unescaping</a>
|
- |
|
1808 |
</font></p>
|
- |
|
1809 |
<hr>
|
- |
|
1810 |
<font face="sans-serif"><p>' . $teachername . ' has posted some feedback on your ' .
|
- |
|
1811 |
'assignment submission for \'Escaping & Unescaping\'.
|
- |
|
1812 |
You can see it appended to your <a href="' . $assignurl .
|
- |
|
1813 |
'">assignment submission</a>.</p></font>
|
- |
|
1814 |
<hr>',
|
- |
|
1815 |
$message->fullmessagehtml
|
1730 |
$this->assertEquals($assign->get_instance()->name, $messages[0]->contexturlname);
|
1816 |
);
|
Línea 1731... |
Línea 1817... |
1731 |
}
|
1817 |
}
|
1732 |
|
1818 |
|
Línea 1810... |
Línea 1896... |
1810 |
$this->assertFalse($assign->can_grade($student->id));
|
1896 |
$this->assertFalse($assign->can_grade($student->id));
|
Línea 1811... |
Línea 1897... |
1811 |
|
1897 |
|
1812 |
// Test the viewgrades capability - without mod/assign:grade.
|
1898 |
// Test the viewgrades capability - without mod/assign:grade.
|
Línea 1813... |
Línea 1899... |
1813 |
$this->setUser($student);
|
1899 |
$this->setUser($student);
|
1814 |
|
1900 |
|
1815 |
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
1901 |
$studentrole = $DB->get_record('role', ['shortname' => 'student']);
|
1816 |
assign_capability('mod/assign:viewgrades', CAP_ALLOW, $studentrole->id, $assign->get_context()->id);
|
1902 |
assign_capability('mod/assign:viewgrades', CAP_ALLOW, $studentrole->id, $assign->get_context()->id);
|
Línea 1817... |
Línea 1903... |
1817 |
$this->assertEquals(false, $assign->can_grade());
|
1903 |
$this->assertEquals(false, $assign->can_grade());
|
Línea 1826... |
Línea 1912... |
1826 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
1912 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
1827 |
$editingteacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
1913 |
$editingteacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
1828 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1914 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1829 |
$otherstudent = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1915 |
$otherstudent = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
1830 |
$suspendedstudent = $this->getDataGenerator()->create_and_enrol(
|
1916 |
$suspendedstudent = $this->getDataGenerator()->create_and_enrol(
|
- |
|
1917 |
$course,
|
- |
|
1918 |
'student',
|
- |
|
1919 |
null,
|
- |
|
1920 |
'manual',
|
- |
|
1921 |
0,
|
- |
|
1922 |
0,
|
1831 |
$course, 'student', null, 'manual', 0, 0, ENROL_USER_SUSPENDED);
|
1923 |
ENROL_USER_SUSPENDED
|
- |
|
1924 |
);
|
Línea 1832... |
Línea 1925... |
1832 |
|
1925 |
|
Línea 1833... |
Línea 1926... |
1833 |
$assign = $this->create_instance($course);
|
1926 |
$assign = $this->create_instance($course);
|
1834 |
|
1927 |
|
Línea 1849... |
Línea 1942... |
1849 |
$this->assertEquals(true, $assign->can_view_submission($teacher->id));
|
1942 |
$this->assertEquals(true, $assign->can_view_submission($teacher->id));
|
1850 |
$this->assertEquals(true, $assign->can_view_submission($suspendedstudent->id));
|
1943 |
$this->assertEquals(true, $assign->can_view_submission($suspendedstudent->id));
|
Línea 1851... |
Línea 1944... |
1851 |
|
1944 |
|
1852 |
// Test the viewgrades capability - without mod/assign:grade.
|
1945 |
// Test the viewgrades capability - without mod/assign:grade.
|
1853 |
$this->setUser($student);
|
1946 |
$this->setUser($student);
|
1854 |
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
1947 |
$studentrole = $DB->get_record('role', ['shortname' => 'student']);
|
1855 |
assign_capability('mod/assign:viewgrades', CAP_ALLOW, $studentrole->id, $assign->get_context()->id);
|
1948 |
assign_capability('mod/assign:viewgrades', CAP_ALLOW, $studentrole->id, $assign->get_context()->id);
|
1856 |
$this->assertEquals(true, $assign->can_view_submission($student->id));
|
1949 |
$this->assertEquals(true, $assign->can_view_submission($student->id));
|
1857 |
$this->assertEquals(true, $assign->can_view_submission($otherstudent->id));
|
1950 |
$this->assertEquals(true, $assign->can_view_submission($otherstudent->id));
|
1858 |
$this->assertEquals(true, $assign->can_view_submission($teacher->id));
|
1951 |
$this->assertEquals(true, $assign->can_view_submission($teacher->id));
|
Línea 2095... |
Línea 2188... |
2095 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
2188 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
2096 |
$editingteacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
2189 |
$editingteacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
2097 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
2190 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
2098 |
$otherstudent = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
2191 |
$otherstudent = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
2099 |
$suspendedstudent = $this->getDataGenerator()->create_and_enrol(
|
2192 |
$suspendedstudent = $this->getDataGenerator()->create_and_enrol(
|
- |
|
2193 |
$course,
|
- |
|
2194 |
'student',
|
- |
|
2195 |
null,
|
- |
|
2196 |
'manual',
|
- |
|
2197 |
0,
|
- |
|
2198 |
0,
|
2100 |
$course, 'student', null, 'manual', 0, 0, ENROL_USER_SUSPENDED);
|
2199 |
ENROL_USER_SUSPENDED
|
- |
|
2200 |
);
|
Línea 2101... |
Línea 2201... |
2101 |
|
2201 |
|
Línea 2102... |
Línea 2202... |
2102 |
$this->setAdminUser();
|
2202 |
$this->setAdminUser();
|
2103 |
|
2203 |
|
Línea 2164... |
Línea 2264... |
2164 |
$this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
2264 |
$this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
2165 |
$editingteacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
2265 |
$editingteacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
2166 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
2266 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
2167 |
$otherstudent = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
2267 |
$otherstudent = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
Línea 2168... |
Línea 2268... |
2168 |
|
2268 |
|
2169 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
2269 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
2170 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
2270 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
Línea 2171... |
Línea 2271... |
2171 |
groups_add_member($group1, $student);
|
2271 |
groups_add_member($group1, $student);
|
Línea 2172... |
Línea 2272... |
2172 |
|
2272 |
|
2173 |
$this->setAdminUser();
|
2273 |
$this->setAdminUser();
|
2174 |
|
2274 |
|
Línea 2175... |
Línea 2275... |
2175 |
// Force create an assignment with SEPARATEGROUPS.
|
2275 |
// Force create an assignment with SEPARATEGROUPS.
|
2176 |
$group = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
2276 |
$group = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
2177 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
2277 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
2178 |
|
2278 |
|
Línea 2192... |
Línea 2292... |
2192 |
global $CFG, $DB;
|
2292 |
global $CFG, $DB;
|
Línea 2193... |
Línea 2293... |
2193 |
|
2293 |
|
Línea 2194... |
Línea 2294... |
2194 |
$this->resetAfterTest();
|
2294 |
$this->resetAfterTest();
|
2195 |
|
2295 |
|
2196 |
$course = $this->getDataGenerator()->create_course();
|
2296 |
$course = $this->getDataGenerator()->create_course();
|
2197 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
2297 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
Línea 2198... |
Línea 2298... |
2198 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
2298 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
2199 |
$this->getDataGenerator()->create_grouping_group(array('groupid' => $group1->id, 'groupingid' => $grouping->id));
|
2299 |
$this->getDataGenerator()->create_grouping_group(['groupid' => $group1->id, 'groupingid' => $grouping->id]);
|
Línea 2200... |
Línea 2300... |
2200 |
|
2300 |
|
Línea 2210... |
Línea 2310... |
2210 |
$otherstudent = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
2310 |
$otherstudent = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
2211 |
$this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
2311 |
$this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
Línea 2212... |
Línea 2312... |
2212 |
|
2312 |
|
2213 |
$capability = 'mod/assign:receivegradernotifications';
|
2313 |
$capability = 'mod/assign:receivegradernotifications';
|
2214 |
$coursecontext = \context_course::instance($course->id);
|
2314 |
$coursecontext = \context_course::instance($course->id);
|
Línea 2215... |
Línea 2315... |
2215 |
$role = $DB->get_record('role', array('shortname' => 'teacher'));
|
2315 |
$role = $DB->get_record('role', ['shortname' => 'teacher']);
|
Línea 2216... |
Línea 2316... |
2216 |
|
2316 |
|
2217 |
$this->setUser($teacher);
|
2317 |
$this->setUser($teacher);
|
Línea 2236... |
Línea 2336... |
2236 |
global $CFG, $DB;
|
2336 |
global $CFG, $DB;
|
Línea 2237... |
Línea 2337... |
2237 |
|
2337 |
|
Línea 2238... |
Línea 2338... |
2238 |
$this->resetAfterTest();
|
2338 |
$this->resetAfterTest();
|
2239 |
|
2339 |
|
2240 |
$course = $this->getDataGenerator()->create_course();
|
2340 |
$course = $this->getDataGenerator()->create_course();
|
2241 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
2341 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
Línea 2242... |
Línea 2342... |
2242 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
2342 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
2243 |
$this->getDataGenerator()->create_grouping_group(array('groupid' => $group1->id, 'groupingid' => $grouping->id));
|
2343 |
$this->getDataGenerator()->create_grouping_group(['groupid' => $group1->id, 'groupingid' => $grouping->id]);
|
Línea 2244... |
Línea 2344... |
2244 |
|
2344 |
|
Línea 2287... |
Línea 2387... |
2287 |
global $CFG;
|
2387 |
global $CFG;
|
Línea 2288... |
Línea 2388... |
2288 |
|
2388 |
|
Línea 2289... |
Línea 2389... |
2289 |
$this->resetAfterTest();
|
2389 |
$this->resetAfterTest();
|
2290 |
|
2390 |
|
2291 |
$course = $this->getDataGenerator()->create_course();
|
2391 |
$course = $this->getDataGenerator()->create_course();
|
2292 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
2392 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
2293 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
2393 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
2294 |
$this->getDataGenerator()->create_grouping_group([
|
2394 |
$this->getDataGenerator()->create_grouping_group([
|
2295 |
'groupid' => $group1->id,
|
2395 |
'groupid' => $group1->id,
|
Línea 2390... |
Línea 2490... |
2390 |
$output = $assign->view_student_summary($student, true);
|
2490 |
$output = $assign->view_student_summary($student, true);
|
2391 |
$this->assertMatchesRegularExpression('/Feedback/', $output, 'Show feedback if there is a grade');
|
2491 |
$this->assertMatchesRegularExpression('/Feedback/', $output, 'Show feedback if there is a grade');
|
Línea 2392... |
Línea 2492... |
2392 |
|
2492 |
|
2393 |
// Now hide the grade in gradebook.
|
2493 |
// Now hide the grade in gradebook.
|
2394 |
$this->setUser($teacher);
|
2494 |
$this->setUser($teacher);
|
2395 |
require_once($CFG->libdir.'/gradelib.php');
|
2495 |
require_once($CFG->libdir . '/gradelib.php');
|
2396 |
$gradeitem = new \grade_item(array(
|
2496 |
$gradeitem = new \grade_item([
|
2397 |
'itemtype' => 'mod',
|
2497 |
'itemtype' => 'mod',
|
2398 |
'itemmodule' => 'assign',
|
2498 |
'itemmodule' => 'assign',
|
2399 |
'iteminstance' => $assign->get_instance()->id,
|
2499 |
'iteminstance' => $assign->get_instance()->id,
|
Línea 2400... |
Línea 2500... |
2400 |
'courseid' => $course->id));
|
2500 |
'courseid' => $course->id]);
|
Línea 2401... |
Línea 2501... |
2401 |
|
2501 |
|
2402 |
$gradeitem->set_hidden(1, false);
|
2502 |
$gradeitem->set_hidden(1, false);
|
2403 |
|
2503 |
|
2404 |
// No feedback should be available because the grade is hidden.
|
2504 |
// No feedback should be available because the grade is hidden.
|
- |
|
2505 |
$this->setUser($student);
|
- |
|
2506 |
$output = $assign->view_student_summary($student, true);
|
2405 |
$this->setUser($student);
|
2507 |
$this->assertDoesNotMatchRegularExpression(
|
- |
|
2508 |
'/Feedback/',
|
Línea 2406... |
Línea 2509... |
2406 |
$output = $assign->view_student_summary($student, true);
|
2509 |
$output,
|
2407 |
$this->assertDoesNotMatchRegularExpression('/Feedback/', $output,
|
2510 |
'Do not show feedback if the grade is hidden in the gradebook'
|
2408 |
'Do not show feedback if the grade is hidden in the gradebook');
|
2511 |
);
|
2409 |
|
2512 |
|
2410 |
// Freeze the context.
|
2513 |
// Freeze the context.
|
Línea 2411... |
Línea 2514... |
2411 |
$this->setAdminUser();
|
2514 |
$this->setAdminUser();
|
2412 |
$context = $assign->get_context();
|
2515 |
$context = $assign->get_context();
|
2413 |
$CFG->contextlocking = true;
|
2516 |
$CFG->contextlocking = true;
|
- |
|
2517 |
$context->set_locked(true);
|
- |
|
2518 |
|
- |
|
2519 |
// No feedback should be available because the grade is hidden.
|
2414 |
$context->set_locked(true);
|
2520 |
$this->setUser($student);
|
- |
|
2521 |
$output = $assign->view_student_summary($student, true);
|
Línea 2415... |
Línea 2522... |
2415 |
|
2522 |
$this->assertDoesNotMatchRegularExpression(
|
2416 |
// No feedback should be available because the grade is hidden.
|
2523 |
'/Feedback/',
|
2417 |
$this->setUser($student);
|
2524 |
$output,
|
Línea 2435... |
Línea 2542... |
2435 |
$course = $this->getDataGenerator()->create_course();
|
2542 |
$course = $this->getDataGenerator()->create_course();
|
2436 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
2543 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
2437 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
2544 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
2438 |
$this->setUser($teacher);
|
2545 |
$this->setUser($teacher);
|
2439 |
$assign = $this->create_instance($course, [
|
2546 |
$assign = $this->create_instance($course, [
|
2440 |
'assignfeedback_comments_enabled' => 1
|
2547 |
'assignfeedback_comments_enabled' => 1,
|
2441 |
]);
|
2548 |
]);
|
2442 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
2549 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
Línea 2443... |
Línea 2550... |
2443 |
|
2550 |
|
2444 |
// No feedback should be available because this student has not been graded.
|
2551 |
// No feedback should be available because this student has not been graded.
|
Línea 2480... |
Línea 2587... |
2480 |
$this->assertMatchesRegularExpression('/Grade/', $output);
|
2587 |
$this->assertMatchesRegularExpression('/Grade/', $output);
|
2481 |
$this->assertMatchesRegularExpression('/Graded on/', $output);
|
2588 |
$this->assertMatchesRegularExpression('/Graded on/', $output);
|
Línea 2482... |
Línea 2589... |
2482 |
|
2589 |
|
2483 |
// Now hide the grade in gradebook.
|
2590 |
// Now hide the grade in gradebook.
|
2484 |
$this->setUser($teacher);
|
2591 |
$this->setUser($teacher);
|
2485 |
$gradeitem = new \grade_item(array(
|
2592 |
$gradeitem = new \grade_item([
|
2486 |
'itemtype' => 'mod',
|
2593 |
'itemtype' => 'mod',
|
2487 |
'itemmodule' => 'assign',
|
2594 |
'itemmodule' => 'assign',
|
2488 |
'iteminstance' => $assign->get_instance()->id,
|
2595 |
'iteminstance' => $assign->get_instance()->id,
|
Línea 2489... |
Línea 2596... |
2489 |
'courseid' => $course->id));
|
2596 |
'courseid' => $course->id]);
|
Línea 2490... |
Línea 2597... |
2490 |
|
2597 |
|
2491 |
$gradeitem->set_hidden(1, false);
|
2598 |
$gradeitem->set_hidden(1, false);
|
2492 |
|
2599 |
|
2493 |
// No feedback should be available because the grade is hidden.
|
2600 |
// No feedback should be available because the grade is hidden.
|
- |
|
2601 |
$this->setUser($student);
|
- |
|
2602 |
$output = $assign->view_student_summary($student, true);
|
2494 |
$this->setUser($student);
|
2603 |
$this->assertDoesNotMatchRegularExpression(
|
- |
|
2604 |
'/Feedback/',
|
2495 |
$output = $assign->view_student_summary($student, true);
|
2605 |
$output,
|
Línea 2496... |
Línea 2606... |
2496 |
$this->assertDoesNotMatchRegularExpression('/Feedback/', $output,
|
2606 |
'Do not show feedback if the grade is hidden in the gradebook'
|
2497 |
'Do not show feedback if the grade is hidden in the gradebook');
|
2607 |
);
|
2498 |
}
|
2608 |
}
|
Línea 2652... |
Línea 2762... |
2652 |
|
2762 |
|
2653 |
// Add a second submission.
|
2763 |
// Add a second submission.
|
2654 |
$this->add_submission($student, $assign);
|
2764 |
$this->add_submission($student, $assign);
|
Línea 2655... |
Línea 2765... |
2655 |
$this->submit_for_grading($student, $assign);
|
2765 |
$this->submit_for_grading($student, $assign);
|
2656 |
|
2766 |
|
Línea 2657... |
Línea 2767... |
2657 |
// Mark the submission as passing.
|
2767 |
// Mark the second submission as passing.
|
2658 |
$this->mark_submission($teacher, $assign, $student, 80.0);
|
2768 |
$this->mark_submission($teacher, $assign, $student, 80.0, [], 1);
|
2659 |
|
2769 |
|
2660 |
// Check that the student does not have a button for Add a new attempt.
|
2770 |
// Check that the student does not have a button for Add a new attempt.
|
Línea 2661... |
Línea 2771... |
2661 |
$this->setUser($student);
|
2771 |
$this->setUser($student);
|
2662 |
$output = $assign->view_student_summary($student, true);
|
2772 |
$output = $assign->view_student_summary($student, true);
|
Línea 2663... |
Línea 2773... |
2663 |
$this->assertEquals(false, strpos($output, get_string('addnewattempt', 'assign')));
|
2773 |
$this->assertEquals(false, strpos($output, get_string('addnewattempt', 'assign')));
|
2664 |
|
2774 |
|
2665 |
// Re-mark the submission as not passing.
|
2775 |
// Re-mark the second submission as not passing.
|
Línea 2757... |
Línea 2867... |
2757 |
$output = $assign->view_student_summary($student, true);
|
2867 |
$output = $assign->view_student_summary($student, true);
|
2758 |
$this->assertEquals(false, strpos($output, get_string('addnewattempt', 'assign')));
|
2868 |
$this->assertEquals(false, strpos($output, get_string('addnewattempt', 'assign')));
|
2759 |
}
|
2869 |
}
|
Línea 2760... |
Línea 2870... |
2760 |
|
2870 |
|
- |
|
2871 |
/**
|
- |
|
2872 |
* Test reopen behavior when in "Automatic" mode.
|
- |
|
2873 |
*
|
- |
|
2874 |
* @coversNothing
|
- |
|
2875 |
*/
|
- |
|
2876 |
public function test_attempt_reopen_method_automatic(): void {
|
- |
|
2877 |
global $PAGE;
|
- |
|
2878 |
|
- |
|
2879 |
$this->resetAfterTest();
|
- |
|
2880 |
$course = $this->getDataGenerator()->create_course();
|
- |
|
2881 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
- |
|
2882 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
- |
|
2883 |
|
- |
|
2884 |
$assign = $this->create_instance($course, [
|
- |
|
2885 |
'attemptreopenmethod' => ASSIGN_ATTEMPT_REOPEN_METHOD_AUTOMATIC,
|
- |
|
2886 |
'maxattempts' => 3,
|
- |
|
2887 |
'submissiondrafts' => 1,
|
- |
|
2888 |
'assignsubmission_onlinetext_enabled' => 1,
|
- |
|
2889 |
]);
|
- |
|
2890 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
- |
|
2891 |
|
- |
|
2892 |
// Set grade to pass to 80.
|
- |
|
2893 |
$gradeitem = $assign->get_grade_item();
|
- |
|
2894 |
$gradeitem->gradepass = '80.0';
|
- |
|
2895 |
$gradeitem->update();
|
- |
|
2896 |
|
- |
|
2897 |
// Student should be able to see an add submission button.
|
- |
|
2898 |
$this->setUser($student);
|
- |
|
2899 |
$output = $assign->view_submission_action_bar($assign->get_instance(), $student);
|
- |
|
2900 |
$this->assertNotEquals(false, strpos($output, get_string('addsubmission', 'assign')));
|
- |
|
2901 |
|
- |
|
2902 |
// Add a submission as a student.
|
- |
|
2903 |
$this->add_submission($student, $assign);
|
- |
|
2904 |
$this->submit_for_grading($student, $assign);
|
- |
|
2905 |
|
- |
|
2906 |
// Verify the student cannot make a new attempt.
|
- |
|
2907 |
$output = $assign->view_student_summary($student, true);
|
- |
|
2908 |
$this->assertEquals(false, strpos($output, get_string('addnewattempt', 'assign')));
|
- |
|
2909 |
|
- |
|
2910 |
// Mark the submission as non-passing.
|
- |
|
2911 |
$this->mark_submission($teacher, $assign, $student, 50.0);
|
- |
|
2912 |
|
- |
|
2913 |
// Check the student now has a button for Add a new attempt.
|
- |
|
2914 |
$this->setUser($student);
|
- |
|
2915 |
$output = $assign->view_submission_action_bar($assign->get_instance(), $student);
|
- |
|
2916 |
$this->assertNotEquals(false, strpos($output, get_string('addnewattempt', 'assign')));
|
- |
|
2917 |
|
- |
|
2918 |
// Add a second submission.
|
- |
|
2919 |
$this->add_submission($student, $assign);
|
- |
|
2920 |
$this->submit_for_grading($student, $assign);
|
- |
|
2921 |
|
- |
|
2922 |
// Mark the submission as passing.
|
- |
|
2923 |
$this->mark_submission($teacher, $assign, $student, 80.0, [], 1);
|
- |
|
2924 |
|
- |
|
2925 |
// Check the student now has a button for Add a new attempt.
|
- |
|
2926 |
$this->setUser($student);
|
- |
|
2927 |
$output = $assign->view_submission_action_bar($assign->get_instance(), $student);
|
- |
|
2928 |
$this->assertNotEquals(false, strpos($output, get_string('addnewattempt', 'assign')));
|
- |
|
2929 |
}
|
- |
|
2930 |
|
2761 |
/**
|
2931 |
/**
|
2762 |
* Test student visibility for each stage of the marking workflow.
|
2932 |
* Test student visibility for each stage of the marking workflow.
|
2763 |
*/
|
2933 |
*/
|
2764 |
public function test_markingworkflow(): void {
|
2934 |
public function test_markingworkflow(): void {
|
Línea 2774... |
Línea 2944... |
2774 |
]);
|
2944 |
]);
|
Línea 2775... |
Línea 2945... |
2775 |
|
2945 |
|
Línea 2776... |
Línea 2946... |
2776 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
2946 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', ['id' => $assign->get_course_module()->id]));
|
2777 |
|
2947 |
|
2778 |
// Mark the submission and set to notmarked.
|
2948 |
// Mark the submission and set to notmarked.
|
2779 |
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
2949 |
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
Línea 2780... |
Línea 2950... |
2780 |
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED,
|
2950 |
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED,
|
2781 |
]);
|
2951 |
]);
|
Línea 2788... |
Línea 2958... |
2788 |
// Make sure the grade isn't pushed to the gradebook.
|
2958 |
// Make sure the grade isn't pushed to the gradebook.
|
2789 |
$grades = $assign->get_user_grades_for_gradebook($student->id);
|
2959 |
$grades = $assign->get_user_grades_for_gradebook($student->id);
|
2790 |
$this->assertEmpty($grades);
|
2960 |
$this->assertEmpty($grades);
|
Línea 2791... |
Línea 2961... |
2791 |
|
2961 |
|
2792 |
// Mark the submission and set to inmarking.
|
2962 |
// Mark the submission and set to inmarking.
|
2793 |
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
2963 |
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
2794 |
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_INMARKING,
|
2964 |
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_INMARKING,
|
Línea 2795... |
Línea 2965... |
2795 |
]);
|
2965 |
]);
|
2796 |
|
2966 |
|
Línea 2802... |
Línea 2972... |
2802 |
// Make sure the grade isn't pushed to the gradebook.
|
2972 |
// Make sure the grade isn't pushed to the gradebook.
|
2803 |
$grades = $assign->get_user_grades_for_gradebook($student->id);
|
2973 |
$grades = $assign->get_user_grades_for_gradebook($student->id);
|
2804 |
$this->assertEmpty($grades);
|
2974 |
$this->assertEmpty($grades);
|
Línea 2805... |
Línea 2975... |
2805 |
|
2975 |
|
2806 |
// Mark the submission and set to readyforreview.
|
2976 |
// Mark the submission and set to readyforreview.
|
2807 |
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
2977 |
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
2808 |
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW,
|
2978 |
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW,
|
Línea 2809... |
Línea 2979... |
2809 |
]);
|
2979 |
]);
|
2810 |
|
2980 |
|
Línea 2816... |
Línea 2986... |
2816 |
// Make sure the grade isn't pushed to the gradebook.
|
2986 |
// Make sure the grade isn't pushed to the gradebook.
|
2817 |
$grades = $assign->get_user_grades_for_gradebook($student->id);
|
2987 |
$grades = $assign->get_user_grades_for_gradebook($student->id);
|
2818 |
$this->assertEmpty($grades);
|
2988 |
$this->assertEmpty($grades);
|
Línea 2819... |
Línea 2989... |
2819 |
|
2989 |
|
2820 |
// Mark the submission and set to inreview.
|
2990 |
// Mark the submission and set to inreview.
|
2821 |
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
2991 |
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
2822 |
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW,
|
2992 |
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW,
|
Línea 2823... |
Línea 2993... |
2823 |
]);
|
2993 |
]);
|
2824 |
|
2994 |
|
Línea 2830... |
Línea 3000... |
2830 |
// Make sure the grade isn't pushed to the gradebook.
|
3000 |
// Make sure the grade isn't pushed to the gradebook.
|
2831 |
$grades = $assign->get_user_grades_for_gradebook($student->id);
|
3001 |
$grades = $assign->get_user_grades_for_gradebook($student->id);
|
2832 |
$this->assertEmpty($grades);
|
3002 |
$this->assertEmpty($grades);
|
Línea 2833... |
Línea 3003... |
2833 |
|
3003 |
|
2834 |
// Mark the submission and set to readyforrelease.
|
3004 |
// Mark the submission and set to readyforrelease.
|
2835 |
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
3005 |
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
2836 |
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE,
|
3006 |
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE,
|
Línea 2837... |
Línea 3007... |
2837 |
]);
|
3007 |
]);
|
2838 |
|
3008 |
|
Línea 2844... |
Línea 3014... |
2844 |
// Make sure the grade isn't pushed to the gradebook.
|
3014 |
// Make sure the grade isn't pushed to the gradebook.
|
2845 |
$grades = $assign->get_user_grades_for_gradebook($student->id);
|
3015 |
$grades = $assign->get_user_grades_for_gradebook($student->id);
|
2846 |
$this->assertEmpty($grades);
|
3016 |
$this->assertEmpty($grades);
|
Línea 2847... |
Línea 3017... |
2847 |
|
3017 |
|
2848 |
// Mark the submission and set to released.
|
3018 |
// Mark the submission and set to released.
|
2849 |
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
3019 |
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
2850 |
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_RELEASED,
|
3020 |
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_RELEASED,
|
Línea 2851... |
Línea 3021... |
2851 |
]);
|
3021 |
]);
|
2852 |
|
3022 |
|
Línea 2872... |
Línea 3042... |
2872 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
3042 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
2873 |
$otherteacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
3043 |
$otherteacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
Línea 2874... |
Línea 3044... |
2874 |
|
3044 |
|
2875 |
$assign = $this->create_instance($course, [
|
3045 |
$assign = $this->create_instance($course, [
|
2876 |
'markingworkflow' => 1,
|
3046 |
'markingworkflow' => 1,
|
2877 |
'markingallocation' => 1
|
3047 |
'markingallocation' => 1,
|
Línea 2878... |
Línea 3048... |
2878 |
]);
|
3048 |
]);
|
Línea 2879... |
Línea 3049... |
2879 |
|
3049 |
|
Línea 3039... |
Línea 3209... |
3039 |
'assignsubmission_onlinetext_enabled' => 1,
|
3209 |
'assignsubmission_onlinetext_enabled' => 1,
|
3040 |
]);
|
3210 |
]);
|
Línea 3041... |
Línea 3211... |
3041 |
|
3211 |
|
3042 |
$this->setUser($student);
|
3212 |
$this->setUser($student);
|
- |
|
3213 |
$output = $assign->view_student_summary($student, true);
|
- |
|
3214 |
$this->assertStringNotContainsString(
|
3043 |
$output = $assign->view_student_summary($student, true);
|
3215 |
$output,
|
3044 |
$this->assertStringNotContainsString($output, get_string('editsubmission', 'assign'),
|
3216 |
get_string('editsubmission', 'assign'),
|
- |
|
3217 |
'Should not be able to edit after cutoff date.'
|
- |
|
3218 |
);
|
- |
|
3219 |
$this->assertStringNotContainsString(
|
3045 |
'Should not be able to edit after cutoff date.');
|
3220 |
$output,
|
3046 |
$this->assertStringNotContainsString($output, get_string('submitassignment', 'assign'),
|
3221 |
get_string('submitassignment', 'assign'),
|
- |
|
3222 |
'Should not be able to submit after cutoff date.'
|
3047 |
'Should not be able to submit after cutoff date.');
|
3223 |
);
|
Línea 3048... |
Línea 3224... |
3048 |
}
|
3224 |
}
|
3049 |
|
3225 |
|
3050 |
/**
|
3226 |
/**
|
Línea 3065... |
Línea 3241... |
3065 |
$assign = $this->create_instance($course, $instanceconfig);
|
3241 |
$assign = $this->create_instance($course, $instanceconfig);
|
3066 |
$plugin = $assign->get_submission_plugin_by_type('comments');
|
3242 |
$plugin = $assign->get_submission_plugin_by_type('comments');
|
3067 |
$this->assertEquals($isenabled, (bool) $plugin->is_enabled('enabled'));
|
3243 |
$this->assertEquals($isenabled, (bool) $plugin->is_enabled('enabled'));
|
3068 |
}
|
3244 |
}
|
Línea -... |
Línea 3245... |
- |
|
3245 |
|
- |
|
3246 |
/**
|
- |
|
3247 |
* Data provider for test_submission_comment_plugin_settings.
|
- |
|
3248 |
*
|
- |
|
3249 |
* @return array[]
|
3069 |
|
3250 |
*/
|
3070 |
public function submission_plugin_settings_provider() {
|
3251 |
public static function submission_plugin_settings_provider(): array {
|
3071 |
return [
|
3252 |
return [
|
3072 |
'CFG->usecomments true, empty config => Enabled by default' => [
|
3253 |
'CFG->usecomments true, empty config => Enabled by default' => [
|
3073 |
true,
|
3254 |
true,
|
3074 |
[],
|
3255 |
[],
|
Línea 3157... |
Línea 3338... |
3157 |
'rownum' => 0,
|
3338 |
'rownum' => 0,
|
3158 |
'last' => true,
|
3339 |
'last' => true,
|
3159 |
'useridlistid' => $assign->get_useridlist_key_id(),
|
3340 |
'useridlistid' => $assign->get_useridlist_key_id(),
|
3160 |
'attemptnumber' => 0,
|
3341 |
'attemptnumber' => 0,
|
3161 |
];
|
3342 |
];
|
3162 |
$formparams = array($assign, $data, $pagination);
|
3343 |
$formparams = [$assign, $data, $pagination];
|
3163 |
$mform = new mod_assign_grade_form(null, [$assign, $data, $pagination]);
|
3344 |
$mform = new mod_assign_grade_form(null, [$assign, $data, $pagination]);
|
Línea 3164... |
Línea 3345... |
3164 |
|
3345 |
|
3165 |
// We need to get the URL these will be transformed to.
|
3346 |
// We need to get the URL these will be transformed to.
|
3166 |
$context = \context_user::instance($USER->id);
|
3347 |
$context = \context_user::instance($USER->id);
|
Línea 3200... |
Línea 3381... |
3200 |
$assign = $this->create_instance($course, $instanceconfig);
|
3381 |
$assign = $this->create_instance($course, $instanceconfig);
|
3201 |
$plugin = $assign->get_feedback_plugin_by_type('comments');
|
3382 |
$plugin = $assign->get_feedback_plugin_by_type('comments');
|
3202 |
$this->assertEquals($isenabled, (bool) $plugin->is_enabled('enabled'));
|
3383 |
$this->assertEquals($isenabled, (bool) $plugin->is_enabled('enabled'));
|
3203 |
}
|
3384 |
}
|
Línea -... |
Línea 3385... |
- |
|
3385 |
|
- |
|
3386 |
/**
|
- |
|
3387 |
* Data provider for test_feedback_plugin_settings.
|
- |
|
3388 |
*
|
- |
|
3389 |
* @return array[]
|
3204 |
|
3390 |
*/
|
3205 |
public function feedback_plugin_settings_provider() {
|
3391 |
public static function feedback_plugin_settings_provider(): array {
|
3206 |
return [
|
3392 |
return [
|
3207 |
'No configuration => disabled' => [
|
3393 |
'No configuration => disabled' => [
|
3208 |
[],
|
3394 |
[],
|
3209 |
false,
|
3395 |
false,
|
Línea 3338... |
Línea 3524... |
3338 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3524 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3339 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3525 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3340 |
$student3 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3526 |
$student3 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3341 |
$student4 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3527 |
$student4 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
Línea 3342... |
Línea 3528... |
3342 |
|
3528 |
|
3343 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
3529 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
3344 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
3530 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
3345 |
groups_assign_grouping($grouping->id, $group1->id);
|
3531 |
groups_assign_grouping($grouping->id, $group1->id);
|
3346 |
groups_add_member($group1, $student1);
|
3532 |
groups_add_member($group1, $student1);
|
Línea 3375... |
Línea 3561... |
3375 |
|
3561 |
|
3376 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3562 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3377 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3563 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3378 |
$student3 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3564 |
$student3 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
- |
|
3565 |
$student4 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
Línea 3379... |
Línea 3566... |
3379 |
$student4 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3566 |
$student5 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3380 |
|
3567 |
|
3381 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
3568 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
3382 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
3569 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
3383 |
groups_assign_grouping($grouping->id, $group1->id);
|
3570 |
groups_assign_grouping($grouping->id, $group1->id);
|
Línea 3392... |
Línea 3579... |
3392 |
$assign = $this->create_instance($course, [
|
3579 |
$assign = $this->create_instance($course, [
|
3393 |
'assignsubmission_onlinetext_enabled' => 1,
|
3580 |
'assignsubmission_onlinetext_enabled' => 1,
|
3394 |
'submissiondrafts' => 1,
|
3581 |
'submissiondrafts' => 1,
|
3395 |
'groupingid' => $grouping->id,
|
3582 |
'groupingid' => $grouping->id,
|
3396 |
'groupmode' => SEPARATEGROUPS,
|
3583 |
'groupmode' => SEPARATEGROUPS,
|
- |
|
3584 |
'preventsubmissionnotingroup' => 0,
|
3397 |
]);
|
3585 |
]);
|
Línea 3398... |
Línea 3586... |
3398 |
|
3586 |
|
3399 |
// Add the capability to the new \assignment for student 1.
|
3587 |
// Add the capability to the new \assignment for student 1.
|
3400 |
$roleid = create_role('Dummy role', 'dummyrole', 'dummy role description');
|
3588 |
$roleid = create_role('Dummy role', 'dummyrole', 'dummy role description');
|
Línea 3405... |
Línea 3593... |
3405 |
// Verify student1 has the ability to edit submissions for other users in their group, but not other groups.
|
3593 |
// Verify student1 has the ability to edit submissions for other users in their group, but not other groups.
|
3406 |
$this->assertTrue($assign->can_edit_submission($student1->id, $student1->id));
|
3594 |
$this->assertTrue($assign->can_edit_submission($student1->id, $student1->id));
|
3407 |
$this->assertTrue($assign->can_edit_submission($student2->id, $student1->id));
|
3595 |
$this->assertTrue($assign->can_edit_submission($student2->id, $student1->id));
|
3408 |
$this->assertFalse($assign->can_edit_submission($student3->id, $student1->id));
|
3596 |
$this->assertFalse($assign->can_edit_submission($student3->id, $student1->id));
|
3409 |
$this->assertFalse($assign->can_edit_submission($student4->id, $student1->id));
|
3597 |
$this->assertFalse($assign->can_edit_submission($student4->id, $student1->id));
|
- |
|
3598 |
$this->assertFalse($assign->can_edit_submission($student5->id, $student1->id));
|
Línea 3410... |
Línea 3599... |
3410 |
|
3599 |
|
3411 |
// Verify other students do not have the ability to edit submissions for other users.
|
3600 |
// Verify other students do not have the ability to edit submissions for other users.
|
3412 |
$this->assertTrue($assign->can_edit_submission($student2->id, $student2->id));
|
3601 |
$this->assertTrue($assign->can_edit_submission($student2->id, $student2->id));
|
3413 |
$this->assertFalse($assign->can_edit_submission($student1->id, $student2->id));
|
3602 |
$this->assertFalse($assign->can_edit_submission($student1->id, $student2->id));
|
3414 |
$this->assertFalse($assign->can_edit_submission($student3->id, $student2->id));
|
3603 |
$this->assertFalse($assign->can_edit_submission($student3->id, $student2->id));
|
- |
|
3604 |
$this->assertFalse($assign->can_edit_submission($student4->id, $student2->id));
|
- |
|
3605 |
$this->assertFalse($assign->can_edit_submission($student5->id, $student2->id));
|
- |
|
3606 |
|
- |
|
3607 |
// Add the required capability to edit other submissions and to view all groups to the teacher.
|
- |
|
3608 |
$roleid = create_role('Dummy role 2', 'dummyrole2', 'dummy role description');
|
- |
|
3609 |
assign_capability('mod/assign:editothersubmission', CAP_ALLOW, $roleid, $assign->get_context()->id);
|
- |
|
3610 |
assign_capability('moodle/site:accessallgroups', CAP_ALLOW, $roleid, $assign->get_context()->id);
|
- |
|
3611 |
role_assign($roleid, $teacher->id, $assign->get_context()->id);
|
- |
|
3612 |
|
- |
|
3613 |
// Verify the teacher has the ability to edit submissions for other users including users not in a group.
|
- |
|
3614 |
$this->assertTrue($assign->can_edit_submission($student1->id, $teacher->id));
|
- |
|
3615 |
$this->assertTrue($assign->can_edit_submission($student2->id, $teacher->id));
|
- |
|
3616 |
$this->assertTrue($assign->can_edit_submission($student3->id, $teacher->id));
|
- |
|
3617 |
$this->assertTrue($assign->can_edit_submission($student4->id, $teacher->id));
|
3415 |
$this->assertFalse($assign->can_edit_submission($student4->id, $student2->id));
|
3618 |
$this->assertTrue($assign->can_edit_submission($student5->id, $teacher->id));
|
Línea 3416... |
Línea 3619... |
3416 |
}
|
3619 |
}
|
3417 |
|
3620 |
|
3418 |
/**
|
3621 |
/**
|
Línea 3459... |
Línea 3662... |
3459 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3662 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3460 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3663 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3461 |
$student3 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3664 |
$student3 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3462 |
$student4 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3665 |
$student4 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
Línea 3463... |
Línea 3666... |
3463 |
|
3666 |
|
3464 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
3667 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
3465 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
3668 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
3466 |
groups_assign_grouping($grouping->id, $group1->id);
|
3669 |
groups_assign_grouping($grouping->id, $group1->id);
|
3467 |
groups_add_member($group1, $student1);
|
3670 |
groups_add_member($group1, $student1);
|
Línea 3512... |
Línea 3715... |
3512 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3715 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3513 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3716 |
$student2 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3514 |
$student3 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3717 |
$student3 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3515 |
$student4 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3718 |
$student4 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
Línea 3516... |
Línea 3719... |
3516 |
|
3719 |
|
3517 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
3720 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
3518 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
3721 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
3519 |
groups_assign_grouping($grouping->id, $group1->id);
|
3722 |
groups_assign_grouping($grouping->id, $group1->id);
|
3520 |
groups_add_member($group1, $student1);
|
3723 |
groups_add_member($group1, $student1);
|
Línea 3583... |
Línea 3786... |
3583 |
continue;
|
3786 |
continue;
|
3584 |
}
|
3787 |
}
|
3585 |
$fileareas = $plugin->get_file_areas();
|
3788 |
$fileareas = $plugin->get_file_areas();
|
Línea 3586... |
Línea 3789... |
3586 |
|
3789 |
|
3587 |
if ($type == 'onlinetext') {
|
3790 |
if ($type == 'onlinetext') {
|
3588 |
$this->assertEquals(array('submissions_onlinetext' => 'Online text'), $fileareas);
|
3791 |
$this->assertEquals(['submissions_onlinetext' => 'Online text'], $fileareas);
|
3589 |
$usingfilearea++;
|
3792 |
$usingfilearea++;
|
3590 |
} else if ($type == 'file') {
|
3793 |
} else if ($type == 'file') {
|
3591 |
$this->assertEquals(array('submission_files' => 'File submissions'), $fileareas);
|
3794 |
$this->assertEquals(['submission_files' => 'File submissions'], $fileareas);
|
3592 |
$usingfilearea++;
|
3795 |
$usingfilearea++;
|
3593 |
} else {
|
3796 |
} else {
|
3594 |
$this->assertEmpty($fileareas);
|
3797 |
$this->assertEmpty($fileareas);
|
3595 |
}
|
3798 |
}
|
Línea 3613... |
Línea 3816... |
3613 |
'importhtml' => 'Annotate PDF',
|
3816 |
'importhtml' => 'Annotate PDF',
|
3614 |
'pages' => 'Annotate PDF',
|
3817 |
'pages' => 'Annotate PDF',
|
3615 |
'readonlypages' => 'Annotate PDF',
|
3818 |
'readonlypages' => 'Annotate PDF',
|
3616 |
'stamps' => 'Annotate PDF',
|
3819 |
'stamps' => 'Annotate PDF',
|
3617 |
'tmp_jpg_to_pdf' => 'Annotate PDF',
|
3820 |
'tmp_jpg_to_pdf' => 'Annotate PDF',
|
3618 |
'tmp_rotated_jpg' => 'Annotate PDF'
|
3821 |
'tmp_rotated_jpg' => 'Annotate PDF',
|
3619 |
];
|
3822 |
];
|
3620 |
$this->assertEquals($checkareas, $fileareas);
|
3823 |
$this->assertEquals($checkareas, $fileareas);
|
3621 |
$usingfilearea++;
|
3824 |
$usingfilearea++;
|
3622 |
} else if ($type == 'file') {
|
3825 |
} else if ($type == 'file') {
|
3623 |
$this->assertEquals(array('feedback_files' => 'Feedback files'), $fileareas);
|
3826 |
$this->assertEquals(['feedback_files' => 'Feedback files'], $fileareas);
|
3624 |
$usingfilearea++;
|
3827 |
$usingfilearea++;
|
3625 |
} else if ($type == 'comments') {
|
3828 |
} else if ($type == 'comments') {
|
3626 |
$this->assertEquals(array('feedback' => 'Feedback comments'), $fileareas);
|
3829 |
$this->assertEquals(['feedback' => 'Feedback comments'], $fileareas);
|
3627 |
$usingfilearea++;
|
3830 |
$usingfilearea++;
|
3628 |
} else {
|
3831 |
} else {
|
3629 |
$this->assertEmpty($fileareas);
|
3832 |
$this->assertEmpty($fileareas);
|
3630 |
}
|
3833 |
}
|
3631 |
}
|
3834 |
}
|
Línea 3643... |
Línea 3846... |
3643 |
|
3846 |
|
3644 |
$this->resetAfterTest();
|
3847 |
$this->resetAfterTest();
|
3645 |
$course = $this->getDataGenerator()->create_course();
|
3848 |
$course = $this->getDataGenerator()->create_course();
|
Línea 3646... |
Línea 3849... |
3646 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
3849 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
3647 |
|
3850 |
|
3648 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
3851 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
Línea 3649... |
Línea 3852... |
3649 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
3852 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
3650 |
$group2 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
3853 |
$group2 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
Línea 3683... |
Línea 3886... |
3683 |
'userid' => null,
|
3886 |
'userid' => null,
|
3684 |
'sortorder' => 1,
|
3887 |
'sortorder' => 1,
|
3685 |
'allowsubmissionsfromdate' => 1,
|
3888 |
'allowsubmissionsfromdate' => 1,
|
3686 |
'duedate' => 2,
|
3889 |
'duedate' => 2,
|
3687 |
'cutoffdate' => 3,
|
3890 |
'cutoffdate' => 3,
|
3688 |
'timelimit' => null
|
3891 |
'timelimit' => null,
|
3689 |
],
|
3892 |
],
|
3690 |
(object) [
|
3893 |
(object) [
|
3691 |
// Override for group 2, lower priority (numerically higher sortorder).
|
3894 |
// Override for group 2, lower priority (numerically higher sortorder).
|
3692 |
'assignid' => $instance->id,
|
3895 |
'assignid' => $instance->id,
|
3693 |
'groupid' => $group2->id,
|
3896 |
'groupid' => $group2->id,
|
3694 |
'userid' => null,
|
3897 |
'userid' => null,
|
3695 |
'sortorder' => 2,
|
3898 |
'sortorder' => 2,
|
3696 |
'allowsubmissionsfromdate' => 5,
|
3899 |
'allowsubmissionsfromdate' => 5,
|
3697 |
'duedate' => 6,
|
3900 |
'duedate' => 6,
|
3698 |
'cutoffdate' => 6,
|
3901 |
'cutoffdate' => 6,
|
3699 |
'timelimit' => null
|
3902 |
'timelimit' => null,
|
3700 |
],
|
3903 |
],
|
3701 |
(object) [
|
3904 |
(object) [
|
3702 |
// User override.
|
3905 |
// User override.
|
3703 |
'assignid' => $instance->id,
|
3906 |
'assignid' => $instance->id,
|
3704 |
'groupid' => null,
|
3907 |
'groupid' => null,
|
3705 |
'userid' => $student3->id,
|
3908 |
'userid' => $student3->id,
|
3706 |
'sortorder' => null,
|
3909 |
'sortorder' => null,
|
3707 |
'allowsubmissionsfromdate' => 7,
|
3910 |
'allowsubmissionsfromdate' => 7,
|
3708 |
'duedate' => 8,
|
3911 |
'duedate' => 8,
|
3709 |
'cutoffdate' => 9,
|
3912 |
'cutoffdate' => 9,
|
3710 |
'timelimit' => null
|
3913 |
'timelimit' => null,
|
3711 |
],
|
3914 |
],
|
3712 |
];
|
3915 |
];
|
Línea 3713... |
Línea 3916... |
3713 |
|
3916 |
|
3714 |
foreach ($overrides as &$override) {
|
3917 |
foreach ($overrides as &$override) {
|
Línea 3744... |
Línea 3947... |
3744 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3947 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
Línea 3745... |
Línea 3948... |
3745 |
|
3948 |
|
3746 |
$teacher->ignoresesskey = true;
|
3949 |
$teacher->ignoresesskey = true;
|
3747 |
$this->setUser($teacher);
|
3950 |
$this->setUser($teacher);
|
- |
|
3951 |
$assign = $this->create_instance($course, [
|
3748 |
$assign = $this->create_instance($course, [
|
3952 |
'maxattempts' => ASSIGN_UNLIMITED_ATTEMPTS,
|
3749 |
'attemptreopenmethod' => ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL,
|
3953 |
'attemptreopenmethod' => ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL,
|
Línea 3750... |
Línea 3954... |
3750 |
]);
|
3954 |
]);
|
3751 |
|
3955 |
|
Línea 3765... |
Línea 3969... |
3765 |
$grade = $assign->get_user_grade($student->id, false);
|
3969 |
$grade = $assign->get_user_grade($student->id, false);
|
3766 |
$this->assertEquals(60.0, $grade->grade);
|
3970 |
$this->assertEquals(60.0, $grade->grade);
|
Línea 3767... |
Línea 3971... |
3767 |
|
3971 |
|
3768 |
// Attempt to grade with a past attempts grade info.
|
3972 |
// Attempt to grade with a past attempts grade info.
|
3769 |
$assign->testable_process_add_attempt($student->id);
|
3973 |
$assign->testable_process_add_attempt($student->id);
|
3770 |
$data = array(
|
3974 |
$data = [
|
3771 |
'grademodified_' . $student->id => $grade->timemodified,
|
3975 |
'grademodified_' . $student->id => $grade->timemodified,
|
3772 |
'gradeattempt_' . $student->id => $grade->attemptnumber,
|
3976 |
'gradeattempt_' . $student->id => $grade->attemptnumber,
|
3773 |
'quickgrade_' . $student->id => '50.0'
|
3977 |
'quickgrade_' . $student->id => '50.0',
|
3774 |
);
|
3978 |
];
|
3775 |
$result = $assign->testable_process_save_quick_grades($data);
|
3979 |
$result = $assign->testable_process_save_quick_grades($data);
|
3776 |
$this->assertStringContainsString(get_string('errorrecordmodified', 'assign'), $result);
|
3980 |
$this->assertStringContainsString(get_string('errorrecordmodified', 'assign'), $result);
|
3777 |
$grade = $assign->get_user_grade($student->id, false);
|
3981 |
$grade = $assign->get_user_grade($student->id, false);
|
Línea 3778... |
Línea 3982... |
3778 |
$this->assertFalse($grade);
|
3982 |
$this->assertFalse($grade);
|
3779 |
|
3983 |
|
3780 |
// Attempt to grade a the attempt.
|
3984 |
// Attempt to grade a the attempt.
|
3781 |
$submission = $assign->get_user_submission($student->id, false);
|
3985 |
$submission = $assign->get_user_submission($student->id, false);
|
3782 |
$data = array(
|
3986 |
$data = [
|
3783 |
'grademodified_' . $student->id => '',
|
3987 |
'grademodified_' . $student->id => '',
|
3784 |
'gradeattempt_' . $student->id => $submission->attemptnumber,
|
3988 |
'gradeattempt_' . $student->id => $submission->attemptnumber,
|
3785 |
'quickgrade_' . $student->id => '40.0'
|
3989 |
'quickgrade_' . $student->id => '40.0',
|
3786 |
);
|
3990 |
];
|
3787 |
$result = $assign->testable_process_save_quick_grades($data);
|
3991 |
$result = $assign->testable_process_save_quick_grades($data);
|
3788 |
$this->assertStringContainsString(get_string('quickgradingchangessaved', 'assign'), $result);
|
3992 |
$this->assertStringContainsString(get_string('quickgradingchangessaved', 'assign'), $result);
|
Línea 3789... |
Línea 3993... |
3789 |
$grade = $assign->get_user_grade($student->id, false);
|
3993 |
$grade = $assign->get_user_grade($student->id, false);
|
3790 |
$this->assertEquals(40.0, $grade->grade);
|
3994 |
$this->assertEquals(40.0, $grade->grade);
|
3791 |
|
3995 |
|
3792 |
// Catch grade update conflicts.
|
3996 |
// Catch grade update conflicts.
|
3793 |
// Save old data for later.
|
3997 |
// Save old data for later.
|
3794 |
$pastdata = $data;
|
3998 |
$pastdata = $data;
|
3795 |
// Update the grade the 'good' way.
|
3999 |
// Update the grade the 'good' way.
|
3796 |
$data = array(
|
4000 |
$data = [
|
3797 |
'grademodified_' . $student->id => $grade->timemodified,
|
4001 |
'grademodified_' . $student->id => $grade->timemodified,
|
3798 |
'gradeattempt_' . $student->id => $grade->attemptnumber,
|
4002 |
'gradeattempt_' . $student->id => $grade->attemptnumber,
|
3799 |
'quickgrade_' . $student->id => '30.0'
|
4003 |
'quickgrade_' . $student->id => '30.0',
|
3800 |
);
|
4004 |
];
|
3801 |
$result = $assign->testable_process_save_quick_grades($data);
|
4005 |
$result = $assign->testable_process_save_quick_grades($data);
|
Línea 3836... |
Línea 4040... |
3836 |
$completiondata = $completion->get_data($cm, false, $student->id);
|
4040 |
$completiondata = $completion->get_data($cm, false, $student->id);
|
3837 |
$this->assertEquals(0, $completiondata->completionstate);
|
4041 |
$this->assertEquals(0, $completiondata->completionstate);
|
Línea 3838... |
Línea 4042... |
3838 |
|
4042 |
|
3839 |
// Update to mark as complete.
|
4043 |
// Update to mark as complete.
|
3840 |
$submission = $assign->get_user_submission($student->id, true);
|
4044 |
$submission = $assign->get_user_submission($student->id, true);
|
- |
|
4045 |
$assign->testable_update_activity_completion_records(
|
- |
|
4046 |
0,
|
- |
|
4047 |
0,
|
- |
|
4048 |
$submission,
|
3841 |
$assign->testable_update_activity_completion_records(0, 0, $submission,
|
4049 |
$student->id,
|
- |
|
4050 |
COMPLETION_COMPLETE,
|
- |
|
4051 |
$completion
|
Línea 3842... |
Línea 4052... |
3842 |
$student->id, COMPLETION_COMPLETE, $completion);
|
4052 |
);
|
3843 |
|
4053 |
|
3844 |
// Completion should now be met.
|
4054 |
// Completion should now be met.
|
3845 |
$completiondata = $completion->get_data($cm, false, $student->id);
|
4055 |
$completiondata = $completion->get_data($cm, false, $student->id);
|
Línea 3855... |
Línea 4065... |
3855 |
$course = $this->getDataGenerator()->create_course(['enablecompletion' => 1]);
|
4065 |
$course = $this->getDataGenerator()->create_course(['enablecompletion' => 1]);
|
3856 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
4066 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
3857 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
4067 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3858 |
$otherstudent = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
4068 |
$otherstudent = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
Línea 3859... |
Línea 4069... |
3859 |
|
4069 |
|
3860 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
4070 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
Línea 3861... |
Línea 4071... |
3861 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
4071 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
3862 |
|
4072 |
|
Línea 3906... |
Línea 4116... |
3906 |
$course = $this->getDataGenerator()->create_course(['enablecompletion' => 1]);
|
4116 |
$course = $this->getDataGenerator()->create_course(['enablecompletion' => 1]);
|
3907 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
4117 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
3908 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
4118 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
3909 |
$otherstudent = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
4119 |
$otherstudent = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
Línea 3910... |
Línea 4120... |
3910 |
|
4120 |
|
3911 |
$grouping = $this->getDataGenerator()->create_grouping(array('courseid' => $course->id));
|
4121 |
$grouping = $this->getDataGenerator()->create_grouping(['courseid' => $course->id]);
|
Línea 3912... |
Línea 4122... |
3912 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
4122 |
$group1 = $this->getDataGenerator()->create_group(['courseid' => $course->id]);
|
3913 |
|
4123 |
|
Línea 3914... |
Línea 4124... |
3914 |
groups_add_member($group1, $student);
|
4124 |
groups_add_member($group1, $student);
|
3915 |
groups_add_member($group1, $otherstudent);
|
4125 |
groups_add_member($group1, $otherstudent);
|
3916 |
|
4126 |
|
3917 |
$assign = $this->create_instance($course, [
|
4127 |
$assign = $this->create_instance($course, [
|
3918 |
'submissiondrafts' => 0,
|
4128 |
'submissiondrafts' => 0,
|
3919 |
'completion' => COMPLETION_TRACKING_AUTOMATIC,
|
4129 |
'completion' => COMPLETION_TRACKING_AUTOMATIC,
|
3920 |
'completionsubmit' => 1,
|
4130 |
'completionsubmit' => 1,
|
Línea 3921... |
Línea 4131... |
3921 |
'teamsubmission' => 1,
|
4131 |
'teamsubmission' => 1,
|
Línea 3922... |
Línea 4132... |
3922 |
'assignsubmission_onlinetext_enabled' => 1
|
4132 |
'assignsubmission_onlinetext_enabled' => 1,
|
Línea 3938... |
Línea 4148... |
3938 |
|
4148 |
|
3939 |
/**
|
4149 |
/**
|
3940 |
* Data provider for test_fix_null_grades
|
4150 |
* Data provider for test_fix_null_grades
|
3941 |
* @return array[] Test data for test_fix_null_grades. Each element should contain grade, expectedcount and gradebookvalue
|
4151 |
* @return array[] Test data for test_fix_null_grades. Each element should contain grade, expectedcount and gradebookvalue
|
3942 |
*/
|
4152 |
*/
|
3943 |
public function fix_null_grades_provider() {
|
4153 |
public static function fix_null_grades_provider(): array {
|
3944 |
return [
|
4154 |
return [
|
3945 |
'Negative less than one is errant' => [
|
4155 |
'Negative less than one is errant' => [
|
3946 |
'grade' => -0.64,
|
4156 |
'grade' => -0.64,
|
3947 |
'gradebookvalue' => null,
|
4157 |
'gradebookvalue' => null,
|
Línea 4007... |
Línea 4217... |
4007 |
$assigntemp->cmidnumber = $assign->get_course_module()->idnumber;
|
4217 |
$assigntemp->cmidnumber = $assign->get_course_module()->idnumber;
|
4008 |
assign_update_grades($assigntemp);
|
4218 |
assign_update_grades($assigntemp);
|
Línea 4009... |
Línea 4219... |
4009 |
|
4219 |
|
4010 |
// Check that the gradebook was updated with the assign grade. So we can guarentee test results later on.
|
4220 |
// Check that the gradebook was updated with the assign grade. So we can guarentee test results later on.
|
4011 |
$expectedgrade = $grade == -1 ? null : $grade; // Assign sends null to the gradebook for -1 grades.
|
4221 |
$expectedgrade = $grade == -1 ? null : $grade; // Assign sends null to the gradebook for -1 grades.
|
4012 |
$gradegrade = \grade_grade::fetch(array('userid' => $student->id, 'itemid' => $assign->get_grade_item()->id));
|
4222 |
$gradegrade = \grade_grade::fetch(['userid' => $student->id, 'itemid' => $assign->get_grade_item()->id]);
|
4013 |
$this->assertEquals(-1, $gradegrade->usermodified);
|
4223 |
$this->assertEquals(-1, $gradegrade->usermodified);
|
Línea 4014... |
Línea 4224... |
4014 |
$this->assertEquals($expectedgrade, $gradegrade->rawgrade);
|
4224 |
$this->assertEquals($expectedgrade, $gradegrade->rawgrade);
|
4015 |
|
4225 |
|
4016 |
// Call fix_null_grades().
|
4226 |
// Call fix_null_grades().
|
Línea 4017... |
Línea 4227... |
4017 |
$method = new \ReflectionMethod(\assign::class, 'fix_null_grades');
|
4227 |
$method = new \ReflectionMethod(\assign::class, 'fix_null_grades');
|
Línea 4018... |
Línea 4228... |
4018 |
$result = $method->invoke($assign);
|
4228 |
$result = $method->invoke($assign);
|
Línea 4019... |
Línea 4229... |
4019 |
|
4229 |
|
4020 |
$this->assertSame(true, $result);
|
4230 |
$this->assertSame(true, $result);
|
Línea 4021... |
Línea 4231... |
4021 |
|
4231 |
|
Línea 4092... |
Línea 4302... |
4092 |
|
4302 |
|
4093 |
$course = $this->getDataGenerator()->create_course();
|
4303 |
$course = $this->getDataGenerator()->create_course();
|
4094 |
$assign = $this->create_instance($course);
|
4304 |
$assign = $this->create_instance($course);
|
Línea 4095... |
Línea 4305... |
4095 |
$valid = $assign->get_filters();
|
4305 |
$valid = $assign->get_filters();
|
4096 |
|
4306 |
|
Línea 4097... |
Línea 4307... |
4097 |
$this->assertEquals(count($valid), 6);
|
4307 |
$this->assertEquals(count($valid), 7);
|
4098 |
}
|
4308 |
}
|
4099 |
|
4309 |
|
Línea 4104... |
Línea 4314... |
4104 |
* @param array $courseconfig the config to use when creating the course.
|
4314 |
* @param array $courseconfig the config to use when creating the course.
|
4105 |
* @param array $assignconfig the config to use when creating the assignment.
|
4315 |
* @param array $assignconfig the config to use when creating the assignment.
|
4106 |
* @param array $enrolconfig the config to use when enrolling the user (this will be the active user).
|
4316 |
* @param array $enrolconfig the config to use when enrolling the user (this will be the active user).
|
4107 |
* @param array $expectedproperties an map containing the expected names and values for the assign instance data.
|
4317 |
* @param array $expectedproperties an map containing the expected names and values for the assign instance data.
|
4108 |
*/
|
4318 |
*/
|
4109 |
public function test_assign_get_instance(array $courseconfig, array $assignconfig, array $enrolconfig,
|
4319 |
public function test_assign_get_instance(
|
- |
|
4320 |
array $courseconfig,
|
- |
|
4321 |
array $assignconfig,
|
- |
|
4322 |
array $enrolconfig,
|
4110 |
array $expectedproperties): void {
|
4323 |
array $expectedproperties
|
- |
|
4324 |
): void {
|
4111 |
$this->resetAfterTest();
|
4325 |
$this->resetAfterTest();
|
Línea 4112... |
Línea 4326... |
4112 |
|
4326 |
|
Línea 4113... |
Línea 4327... |
4113 |
set_config('enablecourserelativedates', true); // Enable relative dates at site level.
|
4327 |
set_config('enablecourserelativedates', true); // Enable relative dates at site level.
|
Línea 4123... |
Línea 4337... |
4123 |
}
|
4337 |
}
|
4124 |
}
|
4338 |
}
|
Línea 4125... |
Línea 4339... |
4125 |
|
4339 |
|
4126 |
/**
|
4340 |
/**
|
- |
|
4341 |
* The test_assign_get_instance data provider.
|
- |
|
4342 |
*
|
4127 |
* The test_assign_get_instance data provider.
|
4343 |
* @return array[]
|
4128 |
*/
|
4344 |
*/
|
4129 |
public function assign_get_instance_provider() {
|
4345 |
public static function assign_get_instance_provider(): array {
|
Línea 4130... |
Línea 4346... |
4130 |
$timenow = time();
|
4346 |
$timenow = time();
|
4131 |
|
4347 |
|
4132 |
// The get_default_instance() method shouldn't calculate any properties per-user. It should just return the record data.
|
4348 |
// The get_default_instance() method shouldn't calculate any properties per-user. It should just return the record data.
|
4133 |
// We'll confirm this works for a few different user types anyway, just like we do for get_instance().
|
4349 |
// We'll confirm this works for a few different user types anyway, just like we do for get_instance().
|
4134 |
return [
|
4350 |
return [
|
4135 |
'Teacher whose enrolment starts after the course start date, relative dates mode enabled' => [
|
4351 |
'Teacher whose enrolment starts after the course start date, relative dates mode enabled' => [
|
4136 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4352 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4137 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4353 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4138 |
'enrolconfig' => ['shortname' => 'teacher', 'userparams' => null, 'method' => 'manual',
|
4354 |
'enrolconfig' => ['shortname' => 'teacher', 'userparams' => null, 'method' => 'manual',
|
4139 |
'startdate' => $timenow - 8 * DAYSECS],
|
4355 |
'startdate' => $timenow - 8 * DAYSECS],
|
4140 |
'expectedproperties' => ['duedate' => $timenow + 6 * DAYSECS]
|
4356 |
'expectedproperties' => ['duedate' => $timenow + 6 * DAYSECS],
|
4141 |
],
|
4357 |
],
|
4142 |
'Teacher whose enrolment starts before the course start date, relative dates mode enabled' => [
|
4358 |
'Teacher whose enrolment starts before the course start date, relative dates mode enabled' => [
|
4143 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4359 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4144 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4360 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4145 |
'enrolconfig' => ['shortname' => 'teacher', 'userparams' => null, 'method' => 'manual',
|
4361 |
'enrolconfig' => ['shortname' => 'teacher', 'userparams' => null, 'method' => 'manual',
|
4146 |
'startdate' => $timenow - 12 * DAYSECS],
|
4362 |
'startdate' => $timenow - 12 * DAYSECS],
|
4147 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS]
|
4363 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS],
|
4148 |
],
|
4364 |
],
|
4149 |
'Teacher whose enrolment starts after the course start date, relative dates mode disabled' => [
|
4365 |
'Teacher whose enrolment starts after the course start date, relative dates mode disabled' => [
|
4150 |
'courseconfig' => ['relativedatesmode' => false, 'startdate' => $timenow - 10 * DAYSECS],
|
4366 |
'courseconfig' => ['relativedatesmode' => false, 'startdate' => $timenow - 10 * DAYSECS],
|
4151 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4367 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4152 |
'enrolconfig' => ['shortname' => 'teacher', 'userparams' => null, 'method' => 'manual',
|
4368 |
'enrolconfig' => ['shortname' => 'teacher', 'userparams' => null, 'method' => 'manual',
|
4153 |
'startdate' => $timenow - 8 * DAYSECS],
|
4369 |
'startdate' => $timenow - 8 * DAYSECS],
|
4154 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS]
|
4370 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS],
|
4155 |
],
|
4371 |
],
|
4156 |
'Student whose enrolment starts after the course start date, relative dates mode enabled' => [
|
4372 |
'Student whose enrolment starts after the course start date, relative dates mode enabled' => [
|
4157 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4373 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4158 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4374 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4159 |
'enrolconfig' => ['shortname' => 'student', 'userparams' => null, 'method' => 'manual',
|
4375 |
'enrolconfig' => ['shortname' => 'student', 'userparams' => null, 'method' => 'manual',
|
4160 |
'startdate' => $timenow - 8 * DAYSECS],
|
4376 |
'startdate' => $timenow - 8 * DAYSECS],
|
4161 |
'expectedproperties' => ['duedate' => $timenow + 6 * DAYSECS]
|
4377 |
'expectedproperties' => ['duedate' => $timenow + 6 * DAYSECS],
|
4162 |
],
|
4378 |
],
|
4163 |
'Student whose enrolment starts before the course start date, relative dates mode enabled' => [
|
4379 |
'Student whose enrolment starts before the course start date, relative dates mode enabled' => [
|
4164 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4380 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4165 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4381 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4166 |
'enrolconfig' => ['shortname' => 'student', 'userparams' => null, 'method' => 'manual',
|
4382 |
'enrolconfig' => ['shortname' => 'student', 'userparams' => null, 'method' => 'manual',
|
4167 |
'startdate' => $timenow - 12 * DAYSECS],
|
4383 |
'startdate' => $timenow - 12 * DAYSECS],
|
4168 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS]
|
4384 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS],
|
4169 |
],
|
4385 |
],
|
4170 |
'Student whose enrolment starts after the course start date, relative dates mode disabled' => [
|
4386 |
'Student whose enrolment starts after the course start date, relative dates mode disabled' => [
|
4171 |
'courseconfig' => ['relativedatesmode' => false, 'startdate' => $timenow - 10 * DAYSECS],
|
4387 |
'courseconfig' => ['relativedatesmode' => false, 'startdate' => $timenow - 10 * DAYSECS],
|
4172 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4388 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4173 |
'enrolconfig' => ['shortname' => 'student', 'userparams' => null, 'method' => 'manual',
|
4389 |
'enrolconfig' => ['shortname' => 'student', 'userparams' => null, 'method' => 'manual',
|
4174 |
'startdate' => $timenow - 8 * DAYSECS],
|
4390 |
'startdate' => $timenow - 8 * DAYSECS],
|
4175 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS]
|
4391 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS],
|
4176 |
],
|
4392 |
],
|
Línea 4177... |
Línea 4393... |
4177 |
];
|
4393 |
];
|
Línea 4184... |
Línea 4400... |
4184 |
* @param array $courseconfig the config to use when creating the course.
|
4400 |
* @param array $courseconfig the config to use when creating the course.
|
4185 |
* @param array $assignconfig the config to use when creating the assignment.
|
4401 |
* @param array $assignconfig the config to use when creating the assignment.
|
4186 |
* @param array $enrolconfig the config to use when enrolling the user (this will be the active user).
|
4402 |
* @param array $enrolconfig the config to use when enrolling the user (this will be the active user).
|
4187 |
* @param array $expectedproperties an map containing the expected names and values for the assign instance data.
|
4403 |
* @param array $expectedproperties an map containing the expected names and values for the assign instance data.
|
4188 |
*/
|
4404 |
*/
|
4189 |
public function test_assign_get_default_instance(array $courseconfig, array $assignconfig, array $enrolconfig,
|
4405 |
public function test_assign_get_default_instance(
|
- |
|
4406 |
array $courseconfig,
|
- |
|
4407 |
array $assignconfig,
|
- |
|
4408 |
array $enrolconfig,
|
4190 |
array $expectedproperties): void {
|
4409 |
array $expectedproperties
|
- |
|
4410 |
): void {
|
4191 |
$this->resetAfterTest();
|
4411 |
$this->resetAfterTest();
|
Línea 4192... |
Línea 4412... |
4192 |
|
4412 |
|
Línea 4193... |
Línea 4413... |
4193 |
set_config('enablecourserelativedates', true); // Enable relative dates at site level.
|
4413 |
set_config('enablecourserelativedates', true); // Enable relative dates at site level.
|
Línea 4204... |
Línea 4424... |
4204 |
}
|
4424 |
}
|
4205 |
}
|
4425 |
}
|
Línea 4206... |
Línea 4426... |
4206 |
|
4426 |
|
4207 |
/**
|
4427 |
/**
|
- |
|
4428 |
* The test_assign_get_default_instance data provider.
|
- |
|
4429 |
*
|
4208 |
* The test_assign_get_default_instance data provider.
|
4430 |
* @return array[]
|
4209 |
*/
|
4431 |
*/
|
4210 |
public function assign_get_default_instance_provider() {
|
4432 |
public static function assign_get_default_instance_provider(): array {
|
Línea 4211... |
Línea 4433... |
4211 |
$timenow = time();
|
4433 |
$timenow = time();
|
4212 |
|
4434 |
|
4213 |
// The get_default_instance() method shouldn't calculate any properties per-user. It should just return the record data.
|
4435 |
// The get_default_instance() method shouldn't calculate any properties per-user. It should just return the record data.
|
4214 |
// We'll confirm this works for a few different user types anyway, just like we do for get_instance().
|
4436 |
// We'll confirm this works for a few different user types anyway, just like we do for get_instance().
|
4215 |
return [
|
4437 |
return [
|
4216 |
'Teacher whose enrolment starts after the course start date, relative dates mode enabled' => [
|
4438 |
'Teacher whose enrolment starts after the course start date, relative dates mode enabled' => [
|
4217 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4439 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4218 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4440 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4219 |
'enrolconfig' => ['shortname' => 'teacher', 'userparams' => null, 'method' => 'manual',
|
4441 |
'enrolconfig' => ['shortname' => 'teacher', 'userparams' => null, 'method' => 'manual',
|
4220 |
'startdate' => $timenow - 8 * DAYSECS],
|
4442 |
'startdate' => $timenow - 8 * DAYSECS],
|
4221 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS]
|
4443 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS],
|
4222 |
],
|
4444 |
],
|
4223 |
'Teacher whose enrolment starts before the course start date, relative dates mode enabled' => [
|
4445 |
'Teacher whose enrolment starts before the course start date, relative dates mode enabled' => [
|
4224 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4446 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4225 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4447 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4226 |
'enrolconfig' => ['shortname' => 'teacher', 'userparams' => null, 'method' => 'manual',
|
4448 |
'enrolconfig' => ['shortname' => 'teacher', 'userparams' => null, 'method' => 'manual',
|
4227 |
'startdate' => $timenow - 12 * DAYSECS],
|
4449 |
'startdate' => $timenow - 12 * DAYSECS],
|
4228 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS]
|
4450 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS],
|
4229 |
],
|
4451 |
],
|
4230 |
'Teacher whose enrolment starts after the course start date, relative dates mode disabled' => [
|
4452 |
'Teacher whose enrolment starts after the course start date, relative dates mode disabled' => [
|
4231 |
'courseconfig' => ['relativedatesmode' => false, 'startdate' => $timenow - 10 * DAYSECS],
|
4453 |
'courseconfig' => ['relativedatesmode' => false, 'startdate' => $timenow - 10 * DAYSECS],
|
4232 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4454 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4233 |
'enrolconfig' => ['shortname' => 'teacher', 'userparams' => null, 'method' => 'manual',
|
4455 |
'enrolconfig' => ['shortname' => 'teacher', 'userparams' => null, 'method' => 'manual',
|
4234 |
'startdate' => $timenow - 8 * DAYSECS],
|
4456 |
'startdate' => $timenow - 8 * DAYSECS],
|
4235 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS]
|
4457 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS],
|
4236 |
],
|
4458 |
],
|
4237 |
'Student whose enrolment starts after the course start date, relative dates mode enabled' => [
|
4459 |
'Student whose enrolment starts after the course start date, relative dates mode enabled' => [
|
4238 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4460 |
'courseconfig' => ['relativedatesmode' => true, 'startdate' => $timenow - 10 * DAYSECS],
|
4239 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4461 |
'assignconfig' => ['duedate' => $timenow + 4 * DAYSECS],
|
4240 |
'enrolconfig' => ['shortname' => 'student', 'userparams' => null, 'method' => 'manual',
|
4462 |
'enrolconfig' => ['shortname' => 'student', 'userparams' => null, 'method' => 'manual',
|
4241 |
'startdate' => $timenow - 8 * DAYSECS],
|
4463 |
'startdate' => $timenow - 8 * DAYSECS],
|
4242 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS]
|
4464 |
'expectedproperties' => ['duedate' => $timenow + 4 * DAYSECS],
|
4243 |
],
|
4465 |
],
|
Línea 4244... |
Línea 4466... |
4244 |
];
|
4466 |
];
|
Línea 4270... |
Línea 4492... |
4270 |
|
4492 |
|
4271 |
// Set last run time 2 days ago.
|
4493 |
// Set last run time 2 days ago.
|
Línea 4272... |
Línea 4494... |
4272 |
$DB->set_field('task_scheduled', 'lastruntime', time() - 2 * DAYSECS, ['classname' => '\mod_assign\task\cron_task']);
|
4494 |
$DB->set_field('task_scheduled', 'lastruntime', time() - 2 * DAYSECS, ['classname' => '\mod_assign\task\cron_task']);
|
4273 |
|
4495 |
|
4274 |
// Remove events to make sure cron will update calendar and re-create one of them.
|
4496 |
// Remove events to make sure cron will update calendar and re-create one of them.
|
4275 |
$params = array('modulename' => 'assign', 'instance' => $assign1->get_instance()->id);
|
4497 |
$params = ['modulename' => 'assign', 'instance' => $assign1->get_instance()->id];
|
4276 |
$DB->delete_records('event', $params);
|
4498 |
$DB->delete_records('event', $params);
|
Línea 4277... |
Línea 4499... |
4277 |
$params = array('modulename' => 'assign', 'instance' => $assign2->get_instance()->id);
|
4499 |
$params = ['modulename' => 'assign', 'instance' => $assign2->get_instance()->id];
|
4278 |
$DB->delete_records('event', $params);
|
4500 |
$DB->delete_records('event', $params);
|
Línea 4279... |
Línea 4501... |
4279 |
|
4501 |
|
4280 |
// Run cron.
|
4502 |
// Run cron.
|
4281 |
\assign::cron();
|
4503 |
\assign::cron();
|
4282 |
|
4504 |
|
4283 |
// Assert that calendar hasn't been updated for the first assignment as it's supposed to be
|
4505 |
// Assert that calendar hasn't been updated for the first assignment as it's supposed to be
|
Línea 4284... |
Línea 4506... |
4284 |
// updated as part of previous cron runs (allowsubmissionsfromdate is less than lastruntime).
|
4506 |
// updated as part of previous cron runs (allowsubmissionsfromdate is less than lastruntime).
|
4285 |
$params = array('modulename' => 'assign', 'instance' => $assign1->get_instance()->id);
|
4507 |
$params = ['modulename' => 'assign', 'instance' => $assign1->get_instance()->id];
|
4286 |
$event1 = $DB->get_record('event', $params);
|
4508 |
$event1 = $DB->get_record('event', $params);
|
4287 |
$this->assertEmpty($event1);
|
4509 |
$this->assertEmpty($event1);
|
4288 |
|
4510 |
|
4289 |
// Assert that calendar has been updated for the second assignment
|
4511 |
// Assert that calendar has been updated for the second assignment
|
4290 |
// because its allowsubmissionsfromdate is greater than lastruntime.
|
4512 |
// because its allowsubmissionsfromdate is greater than lastruntime.
|
Línea 4291... |
Línea 4513... |
4291 |
$params = array('modulename' => 'assign', 'instance' => $assign2->get_instance()->id);
|
4513 |
$params = ['modulename' => 'assign', 'instance' => $assign2->get_instance()->id];
|
4292 |
$event2 = $DB->get_record('event', $params);
|
- |
|
4293 |
$this->assertNotEmpty($event2);
|
- |
|
4294 |
$this->assertSame('This one should be re-created', $event2->description);
|
- |
|
4295 |
}
|
- |
|
4296 |
|
- |
|
4297 |
/**
|
- |
|
4298 |
* Test submissions that need grading output after one ungraded submission
|
- |
|
4299 |
*/
|
- |
|
4300 |
public function test_submissions_need_grading(): void {
|
- |
|
4301 |
global $PAGE;
|
- |
|
4302 |
|
- |
|
4303 |
$this->resetAfterTest();
|
- |
|
4304 |
$course = $this->getDataGenerator()->create_course();
|
- |
|
4305 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
- |
|
4306 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
- |
|
4307 |
|
- |
|
4308 |
// Setup the assignment.
|
- |
|
4309 |
$this->setUser($teacher);
|
- |
|
4310 |
$time = time();
|
- |
|
4311 |
$assign = $this->create_instance($course, [
|
- |
|
4312 |
'assignsubmission_onlinetext_enabled' => 1,
|
- |
|
4313 |
]);
|
- |
|
4314 |
$PAGE->set_url(new \moodle_url('/mod/assign/view.php', [
|
- |
|
4315 |
'id' => $assign->get_course_module()->id,
|
- |
|
4316 |
'action' => 'grading',
|
- |
|
4317 |
]));
|
- |
|
4318 |
|
- |
|
4319 |
// Check for 0 submissions.
|
- |
|
4320 |
$summary = $assign->view('viewcourseindex');
|
- |
|
4321 |
|
- |
|
4322 |
$this->assertStringContainsString('/mod/assign/view.php?id=' .
|
- |
|
4323 |
$assign->get_course_module()->id . '&action=grading">' .
|
- |
|
4324 |
get_string('numberofsubmissionsneedgradinglabel', 'assign', 0) . '</a>', $summary);
|
- |
|
4325 |
|
- |
|
4326 |
// Simulate an assignment submission.
|
- |
|
4327 |
$this->setUser($student);
|
- |
|
4328 |
$submission = $assign->get_user_submission($student->id, true);
|
- |
|
4329 |
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
|
- |
|
4330 |
$assign->testable_update_submission($submission, $student->id, true, false);
|
- |
|
4331 |
$data = new \stdClass();
|
- |
|
4332 |
$data->onlinetext_editor = [
|
- |
|
4333 |
'itemid' => file_get_unused_draft_itemid(),
|
- |
|
4334 |
'text' => 'Submission text',
|
- |
|
4335 |
'format' => FORMAT_MOODLE,
|
- |
|
4336 |
];
|
- |
|
4337 |
$plugin = $assign->get_submission_plugin_by_type('onlinetext');
|
- |
|
4338 |
$plugin->save($submission, $data);
|
- |
|
4339 |
|
- |
|
4340 |
// Check for 1 ungraded submission.
|
- |
|
4341 |
$this->setUser($teacher);
|
- |
|
4342 |
|
- |
|
4343 |
$summary = $assign->view('viewcourseindex');
|
- |
|
4344 |
|
- |
|
4345 |
$this->assertStringContainsString('/mod/assign/view.php?id=' .
|
4514 |
$event2 = $DB->get_record('event', $params);
|
4346 |
$assign->get_course_module()->id . '&action=grading">' .
|
4515 |
$this->assertNotEmpty($event2);
|
4347 |
get_string('numberofsubmissionsneedgradinglabel', 'assign', 1) . '</a>', $summary);
|
4516 |
$this->assertSame('This one should be re-created', $event2->description);
|
4348 |
}
|
4517 |
}
|
4349 |
|
4518 |
|
4350 |
/**
|
4519 |
/**
|
4351 |
* Test that attachments should not be provided if \assign->show_intro returns false.
|
4520 |
* Test that attachments should not be provided if \assign->show_intro returns false.
|
4352 |
*
|
4521 |
*
|
4353 |
* @covers \assign::should_provide_intro_attachments
|
4522 |
* @covers \assign::should_provide_intro_attachments
|
4354 |
*/
|
4523 |
*/
|
4355 |
public function test_should_provide_intro_attachments_with_show_intro_disabled(): void {
|
4524 |
public function test_should_provide_intro_attachments_with_show_intro_disabled(): void {
|
4356 |
$this->resetAfterTest();
|
4525 |
$this->resetAfterTest();
|
4357 |
$futuredate = time() + 300;
|
4526 |
$futuredate = time() + 300;
|
Línea 4367... |
Línea 4536... |
4367 |
*
|
4536 |
*
|
4368 |
* @covers \assign::should_provide_intro_attachments
|
4537 |
* @covers \assign::should_provide_intro_attachments
|
4369 |
*/
|
4538 |
*/
|
4370 |
public function test_should_provide_intro_attachments_with_bypass_capability(): void {
|
4539 |
public function test_should_provide_intro_attachments_with_bypass_capability(): void {
|
4371 |
$this->resetAfterTest();
|
4540 |
$this->resetAfterTest();
|
4372 |
list($assign, $instance, $student) = $this->create_submission([
|
4541 |
[$assign, $instance, $student] = $this->create_submission([
|
4373 |
'submissionattachments' => 1,
|
4542 |
'submissionattachments' => 1,
|
4374 |
]);
|
4543 |
]);
|
4375 |
// Provide teaching role to student1 so they are able to bypass time limit restrictions on viewing attachments.
|
4544 |
// Provide teaching role to student1 so they are able to bypass time limit restrictions on viewing attachments.
|
4376 |
$this->getDataGenerator()->enrol_user($student->id, $instance->course, 'editingteacher');
|
4545 |
$this->getDataGenerator()->enrol_user($student->id, $instance->course, 'editingteacher');
|
4377 |
$this->assertTrue($assign->should_provide_intro_attachments($student->id));
|
4546 |
$this->assertTrue($assign->should_provide_intro_attachments($student->id));
|
Línea 4382... |
Línea 4551... |
4382 |
*
|
4551 |
*
|
4383 |
* @covers \assign::should_provide_intro_attachments
|
4552 |
* @covers \assign::should_provide_intro_attachments
|
4384 |
*/
|
4553 |
*/
|
4385 |
public function test_should_provide_intro_attachments_with_submissionattachments_disabled(): void {
|
4554 |
public function test_should_provide_intro_attachments_with_submissionattachments_disabled(): void {
|
4386 |
$this->resetAfterTest();
|
4555 |
$this->resetAfterTest();
|
4387 |
list($assign, $instance, $student) = $this->create_submission();
|
4556 |
[$assign, $instance, $student] = $this->create_submission();
|
4388 |
$this->assertTrue($assign->should_provide_intro_attachments($student->id));
|
4557 |
$this->assertTrue($assign->should_provide_intro_attachments($student->id));
|
4389 |
}
|
4558 |
}
|
Línea 4390... |
Línea 4559... |
4390 |
|
4559 |
|
4391 |
/**
|
4560 |
/**
|
Línea 4394... |
Línea 4563... |
4394 |
* @covers \assign::should_provide_intro_attachments
|
4563 |
* @covers \assign::should_provide_intro_attachments
|
4395 |
*/
|
4564 |
*/
|
4396 |
public function test_should_provide_intro_attachments_with_submissionattachments_enabled_and_submissions_closed(): void {
|
4565 |
public function test_should_provide_intro_attachments_with_submissionattachments_enabled_and_submissions_closed(): void {
|
4397 |
$this->resetAfterTest();
|
4566 |
$this->resetAfterTest();
|
4398 |
// Set cut-off date to the past.
|
4567 |
// Set cut-off date to the past.
|
4399 |
list($assign, $instance, $student) = $this->create_submission([
|
4568 |
[$assign, $instance, $student] = $this->create_submission([
|
4400 |
'timelimit' => '300',
|
4569 |
'timelimit' => '300',
|
4401 |
'submissionattachments' => 1,
|
4570 |
'submissionattachments' => 1,
|
4402 |
'cutoffdate' => time() - 300,
|
4571 |
'cutoffdate' => time() - 300,
|
4403 |
]);
|
4572 |
]);
|
4404 |
$this->assertFalse($assign->should_provide_intro_attachments($student->id));
|
4573 |
$this->assertFalse($assign->should_provide_intro_attachments($student->id));
|
Línea 4410... |
Línea 4579... |
4410 |
* @covers \assign::should_provide_intro_attachments
|
4579 |
* @covers \assign::should_provide_intro_attachments
|
4411 |
*/
|
4580 |
*/
|
4412 |
public function test_should_provide_intro_attachments_submissionattachments_enabled_and_an_open_submission(): void {
|
4581 |
public function test_should_provide_intro_attachments_submissionattachments_enabled_and_an_open_submission(): void {
|
4413 |
$this->resetAfterTest();
|
4582 |
$this->resetAfterTest();
|
4414 |
set_config('enabletimelimit', '1', 'assign');
|
4583 |
set_config('enabletimelimit', '1', 'assign');
|
4415 |
list($assign, $instance, $student) = $this->create_submission([
|
4584 |
[$assign, $instance, $student] = $this->create_submission([
|
4416 |
'timelimit' => '300',
|
4585 |
'timelimit' => '300',
|
4417 |
'submissionattachments' => 1,
|
4586 |
'submissionattachments' => 1,
|
4418 |
]);
|
4587 |
]);
|
Línea 4419... |
Línea 4588... |
4419 |
|
4588 |
|
Línea 4430... |
Línea 4599... |
4430 |
*/
|
4599 |
*/
|
4431 |
public function test_is_attempt_in_progress_with_open_submission(): void {
|
4600 |
public function test_is_attempt_in_progress_with_open_submission(): void {
|
4432 |
global $DB;
|
4601 |
global $DB;
|
4433 |
$this->resetAfterTest();
|
4602 |
$this->resetAfterTest();
|
4434 |
set_config('enabletimelimit', '1', 'assign');
|
4603 |
set_config('enabletimelimit', '1', 'assign');
|
4435 |
list($assign, $instance, $student) = $this->create_submission([
|
4604 |
[$assign, $instance, $student] = $this->create_submission([
|
4436 |
'timelimit' => '300',
|
4605 |
'timelimit' => '300',
|
4437 |
]);
|
4606 |
]);
|
4438 |
$submission = $assign->get_user_submission($student->id, true);
|
4607 |
$submission = $assign->get_user_submission($student->id, true);
|
4439 |
// Set a timestarted.
|
4608 |
// Set a timestarted.
|
4440 |
$submission->timestarted = time() - 300;
|
4609 |
$submission->timestarted = time() - 300;
|
Línea 4448... |
Línea 4617... |
4448 |
* @covers \assign::is_attempt_in_progress
|
4617 |
* @covers \assign::is_attempt_in_progress
|
4449 |
*/
|
4618 |
*/
|
4450 |
public function test_is_attempt_in_progress_with_open_submission_and_no_timestarted(): void {
|
4619 |
public function test_is_attempt_in_progress_with_open_submission_and_no_timestarted(): void {
|
4451 |
$this->resetAfterTest();
|
4620 |
$this->resetAfterTest();
|
4452 |
set_config('enabletimelimit', '1', 'assign');
|
4621 |
set_config('enabletimelimit', '1', 'assign');
|
4453 |
list($assign, $instance, $student) = $this->create_submission([
|
4622 |
[$assign, $instance, $student] = $this->create_submission([
|
4454 |
'timelimit' => '300',
|
4623 |
'timelimit' => '300',
|
4455 |
]);
|
4624 |
]);
|
4456 |
$assign->get_user_submission($student->id, true);
|
4625 |
$assign->get_user_submission($student->id, true);
|
4457 |
$this->assertFalse($assign->is_attempt_in_progress());
|
4626 |
$this->assertFalse($assign->is_attempt_in_progress());
|
4458 |
}
|
4627 |
}
|
Línea 4464... |
Línea 4633... |
4464 |
*/
|
4633 |
*/
|
4465 |
public function test_is_attempt_in_progress_with_no_open_submission(): void {
|
4634 |
public function test_is_attempt_in_progress_with_no_open_submission(): void {
|
4466 |
global $DB;
|
4635 |
global $DB;
|
4467 |
$this->resetAfterTest();
|
4636 |
$this->resetAfterTest();
|
4468 |
set_config('enabletimelimit', '1', 'assign');
|
4637 |
set_config('enabletimelimit', '1', 'assign');
|
4469 |
list($assign, $instance, $student) = $this->create_submission([
|
4638 |
[$assign, $instance, $student] = $this->create_submission([
|
4470 |
'timelimit' => '300',
|
4639 |
'timelimit' => '300',
|
4471 |
]);
|
4640 |
]);
|
4472 |
// Clear all current submissions.
|
4641 |
// Clear all current submissions.
|
4473 |
$DB->delete_records('assign_submission', ['assignment' => $instance->id]);
|
4642 |
$DB->delete_records('assign_submission', ['assignment' => $instance->id]);
|
4474 |
$this->assertFalse($assign->is_attempt_in_progress());
|
4643 |
$this->assertFalse($assign->is_attempt_in_progress());
|
Línea 4481... |
Línea 4650... |
4481 |
*/
|
4650 |
*/
|
4482 |
protected function create_submission(array $params = []) {
|
4651 |
protected function create_submission(array $params = []) {
|
4483 |
global $DB;
|
4652 |
global $DB;
|
Línea 4484... |
Línea 4653... |
4484 |
|
4653 |
|
4485 |
// Create a course and assignment and users.
|
4654 |
// Create a course and assignment and users.
|
Línea 4486... |
Línea 4655... |
4486 |
$course = self::getDataGenerator()->create_course(array('groupmode' => SEPARATEGROUPS, 'groupmodeforce' => 1));
|
4655 |
$course = self::getDataGenerator()->create_course(['groupmode' => SEPARATEGROUPS, 'groupmodeforce' => 1]);
|
4487 |
|
4656 |
|
4488 |
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
4657 |
$generator = $this->getDataGenerator()->get_plugin_generator('mod_assign');
|
4489 |
$params = array_merge(array(
|
4658 |
$params = array_merge([
|
4490 |
'course' => $course->id,
|
4659 |
'course' => $course->id,
|
4491 |
'assignsubmission_file_maxfiles' => 1,
|
4660 |
'assignsubmission_file_maxfiles' => 1,
|
4492 |
'assignsubmission_file_maxsizebytes' => 1024 * 1024,
|
4661 |
'assignsubmission_file_maxsizebytes' => 1024 * 1024,
|
4493 |
'assignsubmission_onlinetext_enabled' => 1,
|
4662 |
'assignsubmission_onlinetext_enabled' => 1,
|
4494 |
'assignsubmission_file_enabled' => 1,
|
4663 |
'assignsubmission_file_enabled' => 1,
|
4495 |
'submissiondrafts' => 1,
|
4664 |
'submissiondrafts' => 1,
|
4496 |
'assignfeedback_file_enabled' => 1,
|
4665 |
'assignfeedback_file_enabled' => 1,
|
4497 |
'assignfeedback_comments_enabled' => 1,
|
4666 |
'assignfeedback_comments_enabled' => 1,
|
4498 |
'attemptreopenmethod' => ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL,
|
4667 |
'attemptreopenmethod' => ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL,
|
Línea 4499... |
Línea 4668... |
4499 |
'sendnotifications' => 0
|
4668 |
'sendnotifications' => 0,
|
Línea 4500... |
Línea 4669... |
4500 |
), $params);
|
4669 |
], $params);
|
4501 |
|
4670 |
|
4502 |
set_config('submissionreceipts', 0, 'assign');
|
4671 |
set_config('submissionreceipts', 0, 'assign');
|
Línea 4503... |
Línea 4672... |
4503 |
|
4672 |
|
Línea 4504... |
Línea 4673... |
4504 |
$instance = $generator->create_instance($params);
|
4673 |
$instance = $generator->create_instance($params);
|
4505 |
$cm = get_coursemodule_from_instance('assign', $instance->id);
|
4674 |
$cm = get_coursemodule_from_instance('assign', $instance->id);
|
4506 |
$context = \context_module::instance($cm->id);
|
4675 |
$context = \context_module::instance($cm->id);
|
Línea 4507... |
Línea 4676... |
4507 |
|
4676 |
|
Línea 4508... |
Línea 4677... |
4508 |
$assign = new \mod_assign_testable_assign($context, $cm, $course);
|
4677 |
$assign = new \mod_assign_testable_assign($context, $cm, $course);
|
4509 |
|
4678 |
|
4510 |
$student = self::getDataGenerator()->create_user();
|
4679 |
$student = self::getDataGenerator()->create_user();
|
Línea 4511... |
Línea 4680... |
4511 |
$studentrole = $DB->get_record('role', array('shortname' => 'student'));
|
4680 |
$studentrole = $DB->get_record('role', ['shortname' => 'student']);
|
4512 |
$this->getDataGenerator()->enrol_user($student->id, $course->id, $studentrole->id);
|
4681 |
$this->getDataGenerator()->enrol_user($student->id, $course->id, $studentrole->id);
|
4513 |
|
4682 |
|
4514 |
$this->setUser($student);
|
4683 |
$this->setUser($student);
|
4515 |
|
4684 |
|
Línea 4516... |
Línea 4685... |
4516 |
// Create a student1 with an online text submission.
|
4685 |
// Create a student1 with an online text submission.
|
4517 |
// Simulate a submission.
|
4686 |
// Simulate a submission.
|
4518 |
$submission = $assign->get_user_submission($student->id, true);
|
4687 |
$submission = $assign->get_user_submission($student->id, true);
|
4519 |
|
4688 |
|
4520 |
$data = new \stdClass();
|
4689 |
$data = new \stdClass();
|
4521 |
$data->onlinetext_editor = array(
|
4690 |
$data->onlinetext_editor = [
|
4522 |
'itemid' => file_get_unused_draft_itemid(),
|
4691 |
'itemid' => file_get_unused_draft_itemid(),
|
4523 |
'text' => 'Submission text with a <a href="@@PLUGINFILE@@/intro.txt">link</a>',
|
4692 |
'text' => 'Submission text with a <a href="@@PLUGINFILE@@/intro.txt">link</a>',
|
4524 |
'format' => FORMAT_MOODLE);
|
4693 |
'format' => FORMAT_MOODLE];
|
4525 |
|
4694 |
|
4526 |
$draftidfile = file_get_unused_draft_itemid();
|
4695 |
$draftidfile = file_get_unused_draft_itemid();
|
4527 |
$usercontext = \context_user::instance($student->id);
|
4696 |
$usercontext = \context_user::instance($student->id);
|
Línea 4528... |
Línea 4697... |
4528 |
$filerecord = array(
|
4697 |
$filerecord = [
|
Línea 4529... |
Línea 4698... |
4529 |
'contextid' => $usercontext->id,
|
4698 |
'contextid' => $usercontext->id,
|
4530 |
'component' => 'user',
|
4699 |
'component' => 'user',
|
Línea 4531... |
Línea 4700... |
4531 |
'filearea' => 'draft',
|
4700 |
'filearea' => 'draft',
|
4532 |
'itemid' => $draftidfile,
|
4701 |
'itemid' => $draftidfile,
|
Línea 4533... |
Línea 4702... |
4533 |
'filepath' => '/',
|
4702 |
'filepath' => '/',
|
4534 |
'filename' => 't.txt',
|
4703 |
'filename' => 't.txt',
|
4535 |
);
|
4704 |
];
|
Línea 4608... |
Línea 4777... |
4608 |
// Reset the filter.
|
4777 |
// Reset the filter.
|
4609 |
set_user_preference('assign_filter', '');
|
4778 |
set_user_preference('assign_filter', '');
|
4610 |
$this->AssertTrue($assign->is_userid_filtered($student1->id));
|
4779 |
$this->AssertTrue($assign->is_userid_filtered($student1->id));
|
4611 |
$this->AssertTrue($assign->is_userid_filtered($student2->id));
|
4780 |
$this->AssertTrue($assign->is_userid_filtered($student2->id));
|
4612 |
}
|
4781 |
}
|
- |
|
4782 |
|
- |
|
4783 |
/**
|
- |
|
4784 |
* Test get_error_messages like a public function.
|
- |
|
4785 |
*
|
- |
|
4786 |
* @covers \assign::get_error_messages
|
- |
|
4787 |
*/
|
- |
|
4788 |
public function test_get_error_messages(): void {
|
- |
|
4789 |
$this->resetAfterTest();
|
- |
|
4790 |
|
- |
|
4791 |
// Generate data.
|
- |
|
4792 |
$course = $this->getDataGenerator()->create_course();
|
- |
|
4793 |
$assign = $this->create_instance($course);
|
- |
|
4794 |
|
- |
|
4795 |
// Get the empty error message list.
|
- |
|
4796 |
$result = $assign->get_error_messages();
|
- |
|
4797 |
$this->assertIsArray($result);
|
- |
|
4798 |
$this->assertEmpty($result);
|
- |
|
4799 |
|
- |
|
4800 |
// Generate users.
|
- |
|
4801 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
|
- |
|
4802 |
$student1 = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
- |
|
4803 |
|
- |
|
4804 |
// Set the teacher as user and try to delete the user's submission to create the error.
|
- |
|
4805 |
$this->setUser($teacher);
|
- |
|
4806 |
$assign->remove_submission($student1->id);
|
- |
|
4807 |
|
- |
|
4808 |
// Get the created error messages.
|
- |
|
4809 |
$result = $assign->get_error_messages();
|
- |
|
4810 |
$this->assertIsArray($result);
|
- |
|
4811 |
$this->assertNotEmpty($result);
|
- |
|
4812 |
}
|
- |
|
4813 |
|
- |
|
4814 |
/**
|
- |
|
4815 |
* Test that assignment grades are pushed to the gradebook when anonymous
|
- |
|
4816 |
* submissions and marking workflow are enabled (MDL-83195).
|
- |
|
4817 |
* @covers \assign::gradebook_item_update
|
- |
|
4818 |
*/
|
- |
|
4819 |
public function test_release_grade_anon(): void {
|
- |
|
4820 |
$this->resetAfterTest();
|
- |
|
4821 |
$course = $this->getDataGenerator()->create_course();
|
- |
|
4822 |
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
|
- |
|
4823 |
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
|
- |
|
4824 |
|
- |
|
4825 |
$assign = $this->create_instance($course, [
|
- |
|
4826 |
'blindmarking' => 1,
|
- |
|
4827 |
'markingworkflow' => 1,
|
- |
|
4828 |
'markinganonymous' => 1,
|
- |
|
4829 |
]);
|
- |
|
4830 |
|
- |
|
4831 |
// Add a grade and change the workflow status to "Released".
|
- |
|
4832 |
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
- |
|
4833 |
'workflowstate' => ASSIGN_MARKING_WORKFLOW_STATE_RELEASED,
|
- |
|
4834 |
]);
|
- |
|
4835 |
|
- |
|
4836 |
// Make sure the grade has been pushed to the gradebook.
|
- |
|
4837 |
$gradinginfo = grade_get_grades($course->id, 'mod', 'assign', $assign->get_instance()->id, $student->id);
|
- |
|
4838 |
$this->assertEquals(50, (int)$gradinginfo->items[0]->grades[$student->id]->grade);
|
- |
|
4839 |
}
|
4613 |
}
|
4840 |
}
|