422
422
$this->assertRegExp('/I refuse to draw you a picture, so there!/', $this->currentoutput);
425
public function test_deferred_feedback_plain_attempt_on_last() {
428
$this->resetAfterTest(true);
429
$this->setAdminUser();
430
$usercontextid = context_user::instance($USER->id)->id;
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));
437
// Start attempt at the question.
438
$q = question_bank::load_question($question->id);
439
$this->start_attempt_at_question($q, 'deferredfeedback', 1);
441
$this->check_current_state(question_state::$todo);
442
$this->check_current_mark(null);
443
$this->check_step_count(1);
445
// Process a response and check the expected result.
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,
452
$this->check_current_state(question_state::$complete);
453
$this->check_current_mark(null);
454
$this->check_step_count(2);
457
// Now submit all and finish.
459
$this->check_current_state(question_state::$needsgrading);
460
$this->check_current_mark(null);
461
$this->check_step_count(3);
464
// Now start a new attempt based on the old one.
466
$oldqa = $this->get_question_attempt();
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);
475
$this->check_current_state(question_state::$complete);
476
$this->check_current_mark(null);
477
$this->check_step_count(1);
480
// Check the display.
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);