~ubuntu-branches/ubuntu/jaunty/moodle/jaunty

« back to all changes in this revision

Viewing changes to question/type/description/questiontype.php

  • Committer: Bazaar Package Importer
  • Author(s): Jordan Mantha, Matt Oquist
  • Date: 2009-02-25 15:16:22 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090225151622-0ekt1liwhv2obfza
Tags: 1.9.4.dfsg-0ubuntu1
* Merge with Debian git (Closes LP: #322961, #239481, #334611):
  - use Ubuntu's smarty lib directory for linking
  - use internal yui library 
  - add update-notifier support back in

[Matt Oquist]
  * renamed prerm script
  * significantly rewrote postinst and other maintainer scripts to improve
    user experience and package maintainability
    (Closes LP: #225662, #325450, #327843, #303078, #234609)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php  // $Id: questiontype.php,v 1.5 2007/01/08 07:58:22 vyshane Exp $
 
1
<?php  // $Id: questiontype.php,v 1.11.2.6 2008/12/10 06:22:04 tjhunt Exp $
2
2
 
3
3
///////////////////
4
4
/// DESCRIPTION ///
10
10
// The question type 'description' is not really a question type
11
11
// and it therefore often sticks to some kind of odd behaviour
12
12
//
13
 
 
 
13
/**
 
14
 * @package questionbank
 
15
 * @subpackage questiontypes
 
16
 */
14
17
class description_qtype extends default_questiontype {
15
18
 
16
19
    function name() {
17
20
        return 'description';
18
21
    }
19
 
    
 
22
 
20
23
    function is_usable_by_random() {
21
24
        return false;
22
25
    }
23
26
 
 
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);
 
32
    }
 
33
 
24
34
    function get_question_options(&$question) {
25
35
        // No options to be restored for this question type
26
36
        return true;
33
43
 
34
44
    function print_question(&$question, &$state, $number, $cmoptions, $options) {
35
45
        global $CFG;
 
46
        $isfinished = question_state_is_graded($state->last_graded) || $state->event == QUESTION_EVENTCLOSE;
36
47
 
37
48
        // For editing teachers print a link to an editing popup window
38
 
        $editlink = '';
39
 
        if (has_capability('moodle/question:manage', get_context_instance(CONTEXT_COURSE, $cmoptions->course))) {
40
 
            $stredit = get_string('edit');
41
 
            $linktext = '<img src="'.$CFG->pixpath.'/t/edit.gif" alt="'.$stredit.'" />';
42
 
            $editlink = link_to_popup_window('/question/question.php?id='.$question->id, $stredit, $linktext, 450, 550, $stredit, '', true);
 
49
        $editlink = $this->get_question_edit_link($question, $cmoptions, $options);
 
50
 
 
51
        $questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);
 
52
        $image = get_question_image($question);
 
53
 
 
54
        $generalfeedback = '';
 
55
        if ($isfinished && $options->generalfeedback) {
 
56
            $generalfeedback = $this->format_text($question->generalfeedback,
 
57
                    $question->questiontextformat, $cmoptions);
43
58
        }
44
59
 
45
 
        $questiontext = $this->format_text($question->questiontext, $question->questiontextformat, $cmoptions);
46
 
        $image = get_question_image($question, $cmoptions->course);
47
 
 
48
60
        include "$CFG->dirroot/question/type/description/question.html";
49
61
    }
50
62
 
60
72
    function grade_responses(&$question, &$state, $cmoptions) {
61
73
        $state->raw_grade = 0;
62
74
        $state->penalty = 0;
 
75
        return true;
63
76
    }
64
77
 
65
78
}