Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / question / type / description / questiontype.php
blob96394a4b650e361fcd85d98e58a996c2aa78b772
1 <?php // $Id$
3 ///////////////////
4 /// DESCRIPTION ///
5 ///////////////////
7 /// QUESTION TYPE CLASS //////////////////
9 //
10 // The question type 'description' is not really a question type
11 // and it therefore often sticks to some kind of odd behaviour
13 /**
14 * @package questionbank
15 * @subpackage questiontypes
17 class description_qtype extends default_questiontype {
19 function name() {
20 return 'description';
23 function is_usable_by_random() {
24 return false;
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
36 return true;
39 function save_question_options($question) {
40 /// No options to be saved for this question type:
41 return true;
44 function print_question(&$question, &$state, $number, $cmoptions, $options) {
45 global $CFG;
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 = '&amp;cmid='.$cm->id;
51 } else if (!empty($cmoptions->course)) {
52 $cmorcourseid = '&amp;courseid='.$cmoptions->course;
53 } else {
54 error('Need to provide courseid or cmid to print_question.');
57 // For editing teachers print a link to an editing popup window
58 $editlink = '';
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
81 /// by this question.
82 /// The question type description is not even a question
83 /// in itself so it will return ZERO!
84 return 0;
87 function grade_responses(&$question, &$state, $cmoptions) {
88 $state->raw_grade = 0;
89 $state->penalty = 0;
90 return true;
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());