41
41
class qbehaviour_manualgraded_walkthrough_testcase extends qbehaviour_walkthrough_test_base {
42
42
public function test_manual_graded_essay() {
44
// The current text editor depends on the users profile setting - so it needs a valid user.
45
$this->setAdminUser();
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);
109
112
public function test_manual_graded_essay_not_answered() {
114
// The current text editor depends on the users profile setting - so it needs a valid user.
115
$this->setAdminUser();
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);
269
275
public function test_manual_graded_essay_can_grade_0() {
277
// The current text editor depends on the users profile setting - so it needs a valid user.
278
$this->setAdminUser();
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);
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.
326
// The current text editor depends on the users profile setting - so it needs a valid user.
327
$this->setAdminUser();
329
// Create an essay question.
330
$essay = test_question_maker::make_an_essay_question();
331
$this->start_attempt_at_question($essay, 'deferredfeedback', 10);
333
// Check the right model is being used.
334
$this->assertEquals('manualgraded', $this->quba->get_question_attempt(
335
$this->slot)->get_behaviour_name());
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());
343
// Simulate some data submitted by the student.
344
$this->process_submission(array('answer' => 'This is my wonderful essay!', 'answerformat' => FORMAT_HTML));
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());
354
// Finish the attempt.
355
$this->quba->finish_all_questions();
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));
363
// Process a comment and a grade.
364
$this->manual_grade('This should only appear if the displya options allow it', 5, FORMAT_HTML);
367
$this->check_current_state(question_state::$mangrpartial);
368
$this->check_current_mark(5);
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');