7 /// QUESTION TYPE CLASS //////////////////
10 // The question type 'description' is not really a question type
11 // and it therefore often sticks to some kind of odd behaviour
14 * @package questionbank
15 * @subpackage questiontypes
17 class description_qtype
extends default_questiontype
{
23 function is_usable_by_random() {
27 function save_question($question, $form, $course) {
28 // Make very sure that descriptions can'e be created with a grade of
29 // anything other than 0.
30 $form->defaultgrade
= 0;
31 return parent
::save_question($question, $form, $course);
34 function get_question_options(&$question) {
35 // No options to be restored for this question type
39 function save_question_options($question) {
40 /// No options to be saved for this question type:
44 function print_question(&$question, &$state, $number, $cmoptions, $options) {
46 $isfinished = question_state_is_graded($state->last_graded
) ||
$state->event
== QUESTION_EVENTCLOSE
;
48 if (!empty($cmoptions->id
)) {
49 $cm = get_coursemodule_from_instance('quiz', $cmoptions->id
);
50 $cmorcourseid = '&cmid='.$cm->id
;
51 } else if (!empty($cmoptions->course
)) {
52 $cmorcourseid = '&courseid='.$cmoptions->course
;
54 error('Need to provide courseid or cmid to print_question.');
57 // For editing teachers print a link to an editing popup window
59 if (question_has_capability_on($question, 'edit')) {
60 $stredit = get_string('edit');
61 $linktext = '<img src="'.$CFG->pixpath
.'/t/edit.gif" alt="'.$stredit.'" />';
62 $editlink = link_to_popup_window('/question/question.php?id='.$question->id
.$cmorcourseid,
63 $stredit, $linktext, 450, 550, $stredit, '', true);
66 $questiontext = $this->format_text($question->questiontext
, $question->questiontextformat
, $cmoptions);
67 $image = get_question_image($question);
69 $generalfeedback = '';
70 if ($isfinished && $options->generalfeedback
) {
71 $generalfeedback = $this->format_text($question->generalfeedback
,
72 $question->questiontextformat
, $cmoptions);
75 include "$CFG->dirroot/question/type/description/question.html";
78 function actual_number_of_questions($question) {
79 /// Used for the feature number-of-questions-per-page
80 /// to determine the actual number of questions wrapped
82 /// The question type description is not even a question
83 /// in itself so it will return ZERO!
87 function grade_responses(&$question, &$state, $cmoptions) {
88 $state->raw_grade
= 0;
94 //// END OF CLASS ////
96 //////////////////////////////////////////////////////////////////////////
97 //// INITIATION - Without this line the question type is not in use... ///
98 //////////////////////////////////////////////////////////////////////////
99 question_register_questiontype(new description_qtype());