~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

Viewing changes to question/behaviour/manualgraded/tests/walkthrough_test.php

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthrough_test_base {
42
42
    public function test_manual_graded_essay() {
43
43
 
 
44
        // The current text editor depends on the users profile setting - so it needs a valid user.
 
45
        $this->setAdminUser();
 
46
 
44
47
        // Create an essay question.
45
48
        $essay = test_question_maker::make_an_essay_question();
46
49
        $this->start_attempt_at_question($essay, 'deferredfeedback', 10);
108
111
 
109
112
    public function test_manual_graded_essay_not_answered() {
110
113
 
 
114
        // The current text editor depends on the users profile setting - so it needs a valid user.
 
115
        $this->setAdminUser();
 
116
 
111
117
        // Create an essay question.
112
118
        $essay = test_question_maker::make_an_essay_question();
113
119
        $this->start_attempt_at_question($essay, 'deferredfeedback', 10);
268
274
 
269
275
    public function test_manual_graded_essay_can_grade_0() {
270
276
 
 
277
        // The current text editor depends on the users profile setting - so it needs a valid user.
 
278
        $this->setAdminUser();
 
279
 
271
280
        // Create an essay question.
272
281
        $essay = test_question_maker::make_an_essay_question();
273
282
        $this->start_attempt_at_question($essay, 'deferredfeedback', 10);
309
318
        $this->check_current_state(question_state::$mangrwrong);
310
319
        $this->check_current_mark(0);
311
320
    }
 
321
 
 
322
    public function test_manual_graded_respects_display_options() {
 
323
        // This test is for MDL-43874. Manual comments were not respecting the
 
324
        // Display options for feedback.
 
325
 
 
326
        // The current text editor depends on the users profile setting - so it needs a valid user.
 
327
        $this->setAdminUser();
 
328
 
 
329
        // Create an essay question.
 
330
        $essay = test_question_maker::make_an_essay_question();
 
331
        $this->start_attempt_at_question($essay, 'deferredfeedback', 10);
 
332
 
 
333
        // Check the right model is being used.
 
334
        $this->assertEquals('manualgraded', $this->quba->get_question_attempt(
 
335
                $this->slot)->get_behaviour_name());
 
336
 
 
337
        // Check the initial state.
 
338
        $this->check_current_state(question_state::$todo);
 
339
        $this->check_current_mark(null);
 
340
        $this->check_current_output($this->get_contains_question_text_expectation($essay),
 
341
                $this->get_does_not_contain_feedback_expectation());
 
342
 
 
343
        // Simulate some data submitted by the student.
 
344
        $this->process_submission(array('answer' => 'This is my wonderful essay!', 'answerformat' => FORMAT_HTML));
 
345
 
 
346
        // Verify.
 
347
        $this->check_current_state(question_state::$complete);
 
348
        $this->check_current_mark(null);
 
349
        $this->check_current_output(
 
350
                new question_contains_tag_with_attribute('textarea', 'name',
 
351
                $this->quba->get_question_attempt($this->slot)->get_qt_field_name('answer')),
 
352
                $this->get_does_not_contain_feedback_expectation());
 
353
 
 
354
        // Finish the attempt.
 
355
        $this->quba->finish_all_questions();
 
356
 
 
357
        // Verify.
 
358
        $this->check_current_state(question_state::$needsgrading);
 
359
        $this->check_current_mark(null);
 
360
        $this->assertEquals('This is my wonderful essay!',
 
361
                $this->quba->get_response_summary($this->slot));
 
362
 
 
363
        // Process a comment and a grade.
 
364
        $this->manual_grade('This should only appear if the displya options allow it', 5, FORMAT_HTML);
 
365
 
 
366
        // Verify.
 
367
        $this->check_current_state(question_state::$mangrpartial);
 
368
        $this->check_current_mark(5);
 
369
 
 
370
        $this->displayoptions->manualcomment = question_display_options::HIDDEN;
 
371
        $this->check_output_does_not_contain('This should only appear if the displya options allow it');
 
372
        $this->displayoptions->manualcomment = question_display_options::VISIBLE;
 
373
        $this->check_output_contains('This should only appear if the displya options allow it');
 
374
    }
312
375
}