weekly version bump
[moodle.git] / question / type / description / questiontype.php
CommitLineData
aeb15530 1<?php
516cf3eb 2
b974f947 3///////////////////////////////////////////////////////////////////////////
4// //
5// NOTICE OF COPYRIGHT //
6// //
7// Moodle - Modular Object-Oriented Dynamic Learning Environment //
8// http://moodle.org //
9// //
10// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
11// //
12// This program is free software; you can redistribute it and/or modify //
13// it under the terms of the GNU General Public License as published by //
14// the Free Software Foundation; either version 2 of the License, or //
15// (at your option) any later version. //
16// //
17// This program is distributed in the hope that it will be useful, //
18// but WITHOUT ANY WARRANTY; without even the implied warranty of //
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
20// GNU General Public License for more details: //
21// //
22// http://www.gnu.org/copyleft/gpl.html //
23// //
24///////////////////////////////////////////////////////////////////////////
516cf3eb 25
1976496e 26/**
b974f947 27 * The description question type is not acutally a question, it is just a way
28 * to add some static content in the middle of a quiz, or other place that
29 * questions are used.
30 *
1976496e 31 * @package questionbank
32 * @subpackage questiontypes
7375c542 33 */
7518b645 34class description_qtype extends default_questiontype {
516cf3eb 35
36 function name() {
37 return 'description';
38 }
271e6dec 39
b974f947 40 function is_real_question_type() {
41 return false;
42 }
43
a2156789 44 function is_usable_by_random() {
45 return false;
46 }
516cf3eb 47
94dbfb3a 48 function save_question($question, $form) {
bfbafdfe 49 // Make very sure that descriptions can'e be created with a grade of
50 // anything other than 0.
51 $form->defaultgrade = 0;
94dbfb3a 52 return parent::save_question($question, $form);
bfbafdfe 53 }
54
516cf3eb 55 function get_question_options(&$question) {
516cf3eb 56 return true;
57 }
58
59 function save_question_options($question) {
516cf3eb 60 return true;
61 }
62
63 function print_question(&$question, &$state, $number, $cmoptions, $options) {
37a12367 64 global $CFG;
e31a98a6 65 $isfinished = question_state_is_graded($state->last_graded) || $state->event == QUESTION_EVENTCLOSE;
37a12367 66
67 // For editing teachers print a link to an editing popup window
aafdb447 68 $editlink = $this->get_question_edit_link($question, $cmoptions, $options);
37a12367 69
365e53d1
DC
70 $context = $this->get_context_by_category_id($question->category);
71 $question->questiontext = quiz_rewrite_question_urls($question->questiontext, 'pluginfile.php', $context->id, 'question', 'questiontext', array($state->attempt, $state->question), $question->id);
b2ba9f6e 72 $questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);
37a12367 73
e31a98a6 74 $generalfeedback = '';
75 if ($isfinished && $options->generalfeedback) {
365e53d1 76 $question->generalfeedback = quiz_rewrite_question_urls($question->generalfeedback, 'pluginfile.php', $context->id, 'question', 'generalfeedback', array($state->attempt, $state->question), $question->id);
e31a98a6 77 $generalfeedback = $this->format_text($question->generalfeedback,
a9efae50 78 $question->generalfeedbackformat, $cmoptions);
e31a98a6 79 }
80
aaae75b0 81 include "$CFG->dirroot/question/type/description/question.html";
516cf3eb 82 }
83
84 function actual_number_of_questions($question) {
516cf3eb 85 return 0;
86 }
87
88 function grade_responses(&$question, &$state, $cmoptions) {
89 $state->raw_grade = 0;
90 $state->penalty = 0;
373f0afd 91 return true;
516cf3eb 92 }
516cf3eb 93}
b974f947 94// Register this question type with questionlib.php.
a2156789 95question_register_questiontype(new description_qtype());