| Línea 34... |
Línea 34... |
| 34 |
* @category test
|
34 |
* @category test
|
| 35 |
* @copyright 2014 Tim Hunt
|
35 |
* @copyright 2014 Tim Hunt
|
| 36 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
36 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 37 |
* @covers \mod_quiz\quiz_attempt
|
37 |
* @covers \mod_quiz\quiz_attempt
|
| 38 |
*/
|
38 |
*/
|
| 39 |
class attempt_test extends \advanced_testcase {
|
39 |
final class attempt_test extends \advanced_testcase {
|
| Línea 40... |
Línea 40... |
| 40 |
|
40 |
|
| 41 |
/**
|
41 |
/**
|
| 42 |
* Create quiz and attempt data with layout.
|
42 |
* Create quiz and attempt data with layout.
|
| 43 |
*
|
43 |
*
|
| Línea 306... |
Línea 306... |
| 306 |
|
306 |
|
| 307 |
$this->getDataGenerator()->enrol_user(2, $course->id);
|
307 |
$this->getDataGenerator()->enrol_user(2, $course->id);
|
| 308 |
$this->assertEquals(true, $quizobj->is_participant($USER->id),
|
308 |
$this->assertEquals(true, $quizobj->is_participant($USER->id),
|
| Línea 309... |
Línea 309... |
| 309 |
'Admin is enrolled and can participate');
|
309 |
'Admin is enrolled and can participate');
|
| 310 |
|
310 |
|
| 311 |
$this->getDataGenerator()->enrol_user(2, $course->id, [], 'manual', 0, 0, ENROL_USER_SUSPENDED);
|
311 |
$this->getDataGenerator()->enrol_user(2, $course->id, null, 'manual', 0, 0, ENROL_USER_SUSPENDED);
|
| 312 |
$this->assertEquals(true, $quizobj->is_participant($USER->id),
|
312 |
$this->assertEquals(true, $quizobj->is_participant($USER->id),
|
| Línea 313... |
Línea 313... |
| 313 |
'Admin is enrolled, suspended and can participate');
|
313 |
'Admin is enrolled, suspended and can participate');
|
| Línea 569... |
Línea 569... |
| 569 |
$this->assertEquals(2, $grades[$listeninggrade->id]->maxgrade);
|
569 |
$this->assertEquals(2, $grades[$listeninggrade->id]->maxgrade);
|
| 570 |
$this->assertEquals('Reading', $grades[$readinggrade->id]->name);
|
570 |
$this->assertEquals('Reading', $grades[$readinggrade->id]->name);
|
| 571 |
$this->assertEquals(0, $grades[$readinggrade->id]->grade);
|
571 |
$this->assertEquals(0, $grades[$readinggrade->id]->grade);
|
| 572 |
$this->assertEquals(1, $grades[$readinggrade->id]->maxgrade);
|
572 |
$this->assertEquals(1, $grades[$readinggrade->id]->maxgrade);
|
| 573 |
}
|
573 |
}
|
| - |
|
574 |
|
| - |
|
575 |
/**
|
| - |
|
576 |
* When creating a new quiz attempt, question attempts should be created with the first step's timecreated set to null.
|
| - |
|
577 |
*
|
| - |
|
578 |
* When the question attempt is rendered, it should be set to the current time.
|
| - |
|
579 |
*
|
| - |
|
580 |
* @return void
|
| - |
|
581 |
* @throws \coding_exception
|
| - |
|
582 |
* @covers ::quiz_start_new_attempt
|
| - |
|
583 |
*/
|
| - |
|
584 |
public function test_step_timecreated_unset_when_starting_quiz_attempt(): void {
|
| - |
|
585 |
$attempt = $this->create_quiz_and_attempt_with_layout('1');
|
| - |
|
586 |
$questionattempt = $attempt->get_question_attempt(1);
|
| - |
|
587 |
$this->assertEquals(\question_attempt_step::TIMECREATED_ON_FIRST_RENDER, $questionattempt->get_step(0)->get_timecreated());
|
| - |
|
588 |
$questionattempt->render(new \question_display_options(), 1);
|
| - |
|
589 |
$this->assertEqualsWithDelta(time(), $questionattempt->get_step(0)->get_timecreated(), 1);
|
| - |
|
590 |
}
|
| 574 |
}
|
591 |
}
|