| Línea 40... |
Línea 40... |
| 40 |
* @category test
|
40 |
* @category test
|
| 41 |
* @copyright 2009 The Open University
|
41 |
* @copyright 2009 The Open University
|
| 42 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
42 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
| 43 |
*/
|
43 |
*/
|
| 44 |
class questionattempt_db_test extends \data_loading_method_test_base {
|
44 |
class questionattempt_db_test extends \data_loading_method_test_base {
|
| 45 |
public function test_load() {
|
45 |
public function test_load(): void {
|
| 46 |
$records = new question_test_recordset(array(
|
46 |
$records = new question_test_recordset(array(
|
| 47 |
array('questionattemptid', 'contextid', 'questionusageid', 'slot',
|
47 |
array('questionattemptid', 'contextid', 'questionusageid', 'slot',
|
| 48 |
'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'maxfraction', 'flagged',
|
48 |
'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'maxfraction', 'flagged',
|
| 49 |
'questionsummary', 'rightanswer', 'responsesummary', 'timemodified',
|
49 |
'questionsummary', 'rightanswer', 'responsesummary', 'timemodified',
|
| 50 |
'attemptstepid', 'sequencenumber', 'state', 'fraction',
|
50 |
'attemptstepid', 'sequencenumber', 'state', 'fraction',
|
| Línea 113... |
Línea 113... |
| 113 |
$this->assertEquals(1, $step->get_user_id());
|
113 |
$this->assertEquals(1, $step->get_user_id());
|
| 114 |
$this->assertEquals(array('-comment' => 'Not good enough!', '-mark' => '1', '-maxmark' => '2'),
|
114 |
$this->assertEquals(array('-comment' => 'Not good enough!', '-mark' => '1', '-maxmark' => '2'),
|
| 115 |
$step->get_all_data());
|
115 |
$step->get_all_data());
|
| 116 |
}
|
116 |
}
|
| Línea 117... |
Línea 117... |
| 117 |
|
117 |
|
| 118 |
public function test_load_missing_question() {
|
118 |
public function test_load_missing_question(): void {
|
| 119 |
$records = new question_test_recordset(array(
|
119 |
$records = new question_test_recordset(array(
|
| 120 |
array('questionattemptid', 'contextid', 'questionusageid', 'slot',
|
120 |
array('questionattemptid', 'contextid', 'questionusageid', 'slot',
|
| 121 |
'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'maxfraction', 'flagged',
|
121 |
'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'maxfraction', 'flagged',
|
| 122 |
'questionsummary', 'rightanswer', 'responsesummary', 'timemodified',
|
122 |
'questionsummary', 'rightanswer', 'responsesummary', 'timemodified',
|
| Línea 140... |
Línea 140... |
| 140 |
$this->assertEquals(1256233700, $step->get_timecreated());
|
140 |
$this->assertEquals(1256233700, $step->get_timecreated());
|
| 141 |
$this->assertEquals(1, $step->get_user_id());
|
141 |
$this->assertEquals(1, $step->get_user_id());
|
| 142 |
$this->assertEquals(array(), $step->get_all_data());
|
142 |
$this->assertEquals(array(), $step->get_all_data());
|
| 143 |
}
|
143 |
}
|
| Línea 144... |
Línea 144... |
| 144 |
|
144 |
|
| 145 |
public function test_load_with_autosaved_data() {
|
145 |
public function test_load_with_autosaved_data(): void {
|
| 146 |
$records = new question_test_recordset(array(
|
146 |
$records = new question_test_recordset(array(
|
| 147 |
array('questionattemptid', 'contextid', 'questionusageid', 'slot',
|
147 |
array('questionattemptid', 'contextid', 'questionusageid', 'slot',
|
| 148 |
'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'maxfraction', 'flagged',
|
148 |
'behaviour', 'questionid', 'variant', 'maxmark', 'minfraction', 'maxfraction', 'flagged',
|
| 149 |
'questionsummary', 'rightanswer', 'responsesummary', 'timemodified',
|
149 |
'questionsummary', 'rightanswer', 'responsesummary', 'timemodified',
|
| Línea 195... |
Línea 195... |
| 195 |
$this->assertEquals(1256233715, $step->get_timecreated());
|
195 |
$this->assertEquals(1256233715, $step->get_timecreated());
|
| 196 |
$this->assertEquals(1, $step->get_user_id());
|
196 |
$this->assertEquals(1, $step->get_user_id());
|
| 197 |
$this->assertEquals(array('answer' => '1'), $step->get_all_data());
|
197 |
$this->assertEquals(array('answer' => '1'), $step->get_all_data());
|
| 198 |
}
|
198 |
}
|
| Línea 199... |
Línea 199... |
| 199 |
|
199 |
|
| 200 |
public function test_load_with_unnecessary_autosaved_data() {
|
200 |
public function test_load_with_unnecessary_autosaved_data(): void {
|
| 201 |
// The point here is that the somehow (probably due to two things
|
201 |
// The point here is that the somehow (probably due to two things
|
| 202 |
// happening concurrently, we have autosaved data in the database that
|
202 |
// happening concurrently, we have autosaved data in the database that
|
| 203 |
// has already been superceded by real data, so it should be ignored.
|
203 |
// has already been superceded by real data, so it should be ignored.
|
| 204 |
// There is also a second lot of redundant data to delete.
|
204 |
// There is also a second lot of redundant data to delete.
|