Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 33... Línea 33...
33
 * @copyright 2013 The Open University
33
 * @copyright 2013 The Open University
34
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
 */
35
 */
36
class questionusage_autosave_test extends \qbehaviour_walkthrough_test_base {
36
class questionusage_autosave_test extends \qbehaviour_walkthrough_test_base {
Línea 37... Línea 37...
37
 
37
 
38
    public function test_autosave_then_display() {
38
    public function test_autosave_then_display(): void {
39
        $this->resetAfterTest();
39
        $this->resetAfterTest();
40
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
40
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
41
        $cat = $generator->create_question_category();
41
        $cat = $generator->create_question_category();
42
        $question = $generator->create_question('shortanswer', null,
42
        $question = $generator->create_question('shortanswer', null,
Línea 78... Línea 78...
78
        $this->check_output_contains_hidden_input(':sequencecheck', 2);
78
        $this->check_output_contains_hidden_input(':sequencecheck', 2);
Línea 79... Línea 79...
79
 
79
 
80
        $this->delete_quba();
80
        $this->delete_quba();
Línea 81... Línea 81...
81
    }
81
    }
82
 
82
 
83
    public function test_autosave_then_autosave_different_data() {
83
    public function test_autosave_then_autosave_different_data(): void {
84
        $this->resetAfterTest();
84
        $this->resetAfterTest();
85
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
85
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
86
        $cat = $generator->create_question_category();
86
        $cat = $generator->create_question_category();
Línea 137... Línea 137...
137
        $this->check_output_contains_hidden_input(':sequencecheck', 2);
137
        $this->check_output_contains_hidden_input(':sequencecheck', 2);
Línea 138... Línea 138...
138
 
138
 
139
        $this->delete_quba();
139
        $this->delete_quba();
Línea 140... Línea 140...
140
    }
140
    }
141
 
141
 
142
    public function test_autosave_then_autosave_same_data() {
142
    public function test_autosave_then_autosave_same_data(): void {
143
        $this->resetAfterTest();
143
        $this->resetAfterTest();
144
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
144
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
145
        $cat = $generator->create_question_category();
145
        $cat = $generator->create_question_category();
Línea 202... Línea 202...
202
        $this->check_output_contains_hidden_input(':sequencecheck', 2);
202
        $this->check_output_contains_hidden_input(':sequencecheck', 2);
Línea 203... Línea 203...
203
 
203
 
204
        $this->delete_quba();
204
        $this->delete_quba();
Línea 205... Línea 205...
205
    }
205
    }
206
 
206
 
207
    public function test_autosave_then_autosave_original_data() {
207
    public function test_autosave_then_autosave_original_data(): void {
208
        $this->resetAfterTest();
208
        $this->resetAfterTest();
209
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
209
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
210
        $cat = $generator->create_question_category();
210
        $cat = $generator->create_question_category();
Línea 262... Línea 262...
262
        $this->check_output_contains_hidden_input(':sequencecheck', 2);
262
        $this->check_output_contains_hidden_input(':sequencecheck', 2);
Línea 263... Línea 263...
263
 
263
 
264
        $this->delete_quba();
264
        $this->delete_quba();
Línea 265... Línea 265...
265
    }
265
    }
266
 
266
 
267
    public function test_autosave_then_real_save() {
267
    public function test_autosave_then_real_save(): void {
268
        $this->resetAfterTest();
268
        $this->resetAfterTest();
269
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
269
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
270
        $cat = $generator->create_question_category();
270
        $cat = $generator->create_question_category();
Línea 318... Línea 318...
318
        $this->render();
318
        $this->render();
319
        $this->check_output_contains_text_input('answer', 'third response');
319
        $this->check_output_contains_text_input('answer', 'third response');
320
        $this->check_output_contains_hidden_input(':sequencecheck', 3);
320
        $this->check_output_contains_hidden_input(':sequencecheck', 3);
321
    }
321
    }
Línea 322... Línea 322...
322
 
322
 
323
    public function test_autosave_then_real_save_same() {
323
    public function test_autosave_then_real_save_same(): void {
324
        $this->resetAfterTest();
324
        $this->resetAfterTest();
325
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
325
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
326
        $cat = $generator->create_question_category();
326
        $cat = $generator->create_question_category();
327
        $question = $generator->create_question('shortanswer', null,
327
        $question = $generator->create_question('shortanswer', null,
Línea 374... Línea 374...
374
        $this->render();
374
        $this->render();
375
        $this->check_output_contains_text_input('answer', 'second response');
375
        $this->check_output_contains_text_input('answer', 'second response');
376
        $this->check_output_contains_hidden_input(':sequencecheck', 3);
376
        $this->check_output_contains_hidden_input(':sequencecheck', 3);
377
    }
377
    }
Línea 378... Línea 378...
378
 
378
 
379
    public function test_autosave_then_submit() {
379
    public function test_autosave_then_submit(): void {
380
        $this->resetAfterTest();
380
        $this->resetAfterTest();
381
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
381
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
382
        $cat = $generator->create_question_category();
382
        $cat = $generator->create_question_category();
383
        $question = $generator->create_question('shortanswer', null,
383
        $question = $generator->create_question('shortanswer', null,
Línea 431... Línea 431...
431
        $this->render();
431
        $this->render();
432
        $this->check_output_contains_text_input('answer', 'third response', false);
432
        $this->check_output_contains_text_input('answer', 'third response', false);
433
        $this->check_output_contains_hidden_input(':sequencecheck', 4);
433
        $this->check_output_contains_hidden_input(':sequencecheck', 4);
434
    }
434
    }
Línea 435... Línea 435...
435
 
435
 
436
    public function test_autosave_and_save_concurrently() {
436
    public function test_autosave_and_save_concurrently(): void {
437
        // This test simulates the following scenario:
437
        // This test simulates the following scenario:
438
        // 1. Student looking at a page of the quiz, and edits a field then waits.
438
        // 1. Student looking at a page of the quiz, and edits a field then waits.
439
        // 2. Autosave starts.
439
        // 2. Autosave starts.
440
        // 3. Student immediately clicks Next, which submits the current page.
440
        // 3. Student immediately clicks Next, which submits the current page.
Línea 504... Línea 504...
504
        $this->check_output_contains_hidden_input(':sequencecheck', 2);
504
        $this->check_output_contains_hidden_input(':sequencecheck', 2);
Línea 505... Línea 505...
505
 
505
 
506
        $DB2->dispose();
506
        $DB2->dispose();
Línea 507... Línea 507...
507
    }
507
    }
508
 
508
 
509
    public function test_concurrent_autosaves() {
509
    public function test_concurrent_autosaves(): void {
510
        // This test simulates the following scenario:
510
        // This test simulates the following scenario:
511
        // 1. Student opens  a page of the quiz in two separate browser.
511
        // 1. Student opens  a page of the quiz in two separate browser.
512
        // 2. Autosave starts in both at the same time.
512
        // 2. Autosave starts in both at the same time.
Línea 576... Línea 576...
576
        $this->check_output_contains_hidden_input(':sequencecheck', 1);
576
        $this->check_output_contains_hidden_input(':sequencecheck', 1);
Línea 577... Línea 577...
577
 
577
 
578
        $DB2->dispose();
578
        $DB2->dispose();
Línea 579... Línea 579...
579
    }
579
    }
580
 
580
 
581
    public function test_autosave_with_wrong_seq_number_ignored() {
581
    public function test_autosave_with_wrong_seq_number_ignored(): void {
582
        $this->resetAfterTest();
582
        $this->resetAfterTest();
583
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
583
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
584
        $cat = $generator->create_question_category();
584
        $cat = $generator->create_question_category();
Línea 623... Línea 623...
623
        $this->check_output_contains_hidden_input(':sequencecheck', 2);
623
        $this->check_output_contains_hidden_input(':sequencecheck', 2);
Línea 624... Línea 624...
624
 
624
 
625
        $this->delete_quba();
625
        $this->delete_quba();
Línea 626... Línea 626...
626
    }
626
    }
627
 
627
 
628
    public function test_finish_with_unhandled_autosave_data() {
628
    public function test_finish_with_unhandled_autosave_data(): void {
629
        $this->resetAfterTest();
629
        $this->resetAfterTest();
630
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
630
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
631
        $cat = $generator->create_question_category();
631
        $cat = $generator->create_question_category();
Línea 685... Línea 685...
685
    /**
685
    /**
686
     * Test that regrading doesn't convert autosave steps to finished steps.
686
     * Test that regrading doesn't convert autosave steps to finished steps.
687
     * This can result in students loosing data (due to question_out_of_sequence_exception) if a teacher
687
     * This can result in students loosing data (due to question_out_of_sequence_exception) if a teacher
688
     * regrades an attempt while it is in progress.
688
     * regrades an attempt while it is in progress.
689
     */
689
     */
690
    public function test_autosave_and_regrade_then_display() {
690
    public function test_autosave_and_regrade_then_display(): void {
691
        $this->resetAfterTest();
691
        $this->resetAfterTest();
692
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
692
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
693
        $cat = $generator->create_question_category();
693
        $cat = $generator->create_question_category();
694
        $question = $generator->create_question('shortanswer', null,
694
        $question = $generator->create_question('shortanswer', null,
695
                array('category' => $cat->id));
695
                array('category' => $cat->id));