MDL-20636 Fix @package names in question/behaviour, question/engine and question...
[moodle.git] / question / type / essay / question.php
CommitLineData
6d03299d
TH
1<?php
2
3// This file is part of Moodle - http://moodle.org/
4//
5// Moodle is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// Moodle is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17
18
19/**
20 * Essay question definition class.
21 *
22 * @package qtype_essay
23 * @copyright 2009 The Open University
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 */
26
27
28/**
29 * Represents an essay question.
30 *
31 * @copyright 2009 The Open University
32 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33 */
34class qtype_essay_question extends question_with_responses {
35 public function make_behaviour(question_attempt $qa, $preferredbehaviour) {
36 question_engine::load_behaviour_class('manualgraded');
37 return new qbehaviour_manualgraded($qa, $preferredbehaviour);
38 }
39
40 public function get_expected_data() {
41 return array('answer' => PARAM_CLEANHTML);
42 }
43
44 public function summarise_response(array $response) {
45 if (isset($response['answer'])) {
46 $formatoptions = new stdClass();
47 $formatoptions->para = false;
48 return shorten_text(html_to_text(format_text($response['answer'], FORMAT_HTML, $formatoptions), 0, false), 200);
49 } else {
50 return null;
51 }
52 }
53
54 public function get_correct_response() {
55 return null;
56 }
57
58 public function is_complete_response(array $response) {
59 return !empty($response['answer']);
60 }
61
62 public function is_same_response(array $prevresponse, array $newresponse) {
63 return question_utils::arrays_same_at_key_missing_is_blank(
64 $prevresponse, $newresponse, 'answer');
65 }
66}