~ubuntu-branches/ubuntu/trusty/moodle/trusty

« back to all changes in this revision

Viewing changes to question/type/essay/tests/walkthrough_test.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-01-21 13:40:52 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20140121134052-ym2qvsp2cd9vq0p6
Tags: 2.5.4-1
* New upstream release, fixing security issues:
  - MSA-14-0001 Config passwords visibility issue [CVE-2014-0008]
  - MSA-14-0002 Group constraints lacking in "login as" [CVE-2014-0009]
  - MSA-14-0003 CSRF vulnerability in profile fields [CVE-2014-0010]
* Move /var/lib/moodle directory into package.
* Revert back to bundled yui3. Unfortunately, version in Debian and
  of upstream are not compatible (closes: #735312).

Show diffs side-by-side

added added

removed removed

Lines of Context:
421
421
        $this->render();
422
422
        $this->assertRegExp('/I refuse to draw you a picture, so there!/', $this->currentoutput);
423
423
    }
 
424
 
 
425
    public function test_deferred_feedback_plain_attempt_on_last() {
 
426
        global $CFG, $USER;
 
427
 
 
428
        $this->resetAfterTest(true);
 
429
        $this->setAdminUser();
 
430
        $usercontextid = context_user::instance($USER->id)->id;
 
431
 
 
432
        // Create an essay question in the DB.
 
433
        $generator = $this->getDataGenerator()->get_plugin_generator('core_question');
 
434
        $cat = $generator->create_question_category();
 
435
        $question = $generator->create_question('essay', 'plain', array('category' => $cat->id));
 
436
 
 
437
        // Start attempt at the question.
 
438
        $q = question_bank::load_question($question->id);
 
439
        $this->start_attempt_at_question($q, 'deferredfeedback', 1);
 
440
 
 
441
        $this->check_current_state(question_state::$todo);
 
442
        $this->check_current_mark(null);
 
443
        $this->check_step_count(1);
 
444
 
 
445
        // Process a response and check the expected result.
 
446
 
 
447
        $this->process_submission(array(
 
448
            'answer' => 'Once upon a time there was a frog called Freddy. He lived happily ever after.',
 
449
            'answerformat' => FORMAT_PLAIN,
 
450
        ));
 
451
 
 
452
        $this->check_current_state(question_state::$complete);
 
453
        $this->check_current_mark(null);
 
454
        $this->check_step_count(2);
 
455
        $this->save_quba();
 
456
 
 
457
        // Now submit all and finish.
 
458
        $this->finish();
 
459
        $this->check_current_state(question_state::$needsgrading);
 
460
        $this->check_current_mark(null);
 
461
        $this->check_step_count(3);
 
462
        $this->save_quba();
 
463
 
 
464
        // Now start a new attempt based on the old one.
 
465
        $this->load_quba();
 
466
        $oldqa = $this->get_question_attempt();
 
467
 
 
468
        $q = question_bank::load_question($question->id);
 
469
        $this->quba = question_engine::make_questions_usage_by_activity('unit_test',
 
470
                context_system::instance());
 
471
        $this->quba->set_preferred_behaviour('deferredfeedback');
 
472
        $this->slot = $this->quba->add_question($q, 1);
 
473
        $this->quba->start_question_based_on($this->slot, $oldqa);
 
474
 
 
475
        $this->check_current_state(question_state::$complete);
 
476
        $this->check_current_mark(null);
 
477
        $this->check_step_count(1);
 
478
        $this->save_quba();
 
479
 
 
480
        // Check the display.
 
481
        $this->load_quba();
 
482
        $this->render();
 
483
        // Test taht no HTML comment has been added to the response.
 
484
        $this->assertRegExp('/Once upon a time there was a frog called Freddy. He lived happily ever after.(?!<!--)/', $this->currentoutput);
 
485
        // Test for the hash of an empty file area.
 
486
        $this->assertNotContains('d41d8cd98f00b204e9800998ecf8427e', $this->currentoutput);
 
487
    }
424
488
}