Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
/**
18
 * Drag-and-drop onto image question definition class.
19
 *
20
 * @package    qtype_ddimageortext
21
 * @copyright  2009 The Open University
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
 
26
defined('MOODLE_INTERNAL') || die();
27
 
28
require_once($CFG->dirroot . '/question/type/ddimageortext/questionbase.php');
29
 
30
 
31
/**
32
 * Represents a drag-and-drop onto image question.
33
 *
34
 * @copyright  2009 The Open University
35
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 */
37
class qtype_ddimageortext_question extends qtype_ddtoimage_question_base {
1441 ariadna 38
    /** @var string Whether the dropzone transparent or not. */
39
    public $dropzonevisibility;
1 efrain 40
}
41
 
42
 
43
/**
44
 * Represents one of the choices (draggable images).
45
 *
46
 * @copyright  2009 The Open University
47
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
48
 */
49
class qtype_ddimageortext_drag_item {
50
    /** @var int Drag item id */
51
    public $id;
52
 
53
    /** @var string Text for the drag item */
54
    public $text;
55
 
56
    /** @var int Number of the item */
57
    public $no;
58
 
59
    /** @var int Group of the item */
60
    public $group;
61
 
62
    /** @var bool If the drag item can be used multiple times or not */
63
    public $infinite;
64
 
65
    /**
66
     * Drag item object setup.
67
     *
68
     * @param string $alttextlabel The alt text of the drag item
69
     * @param int $no Which number drag item this is
70
     * @param int $group Group of the drag item
71
     * @param bool $infinite True if the item can be used an unlimited number of times
72
     * @param int $id id of the item
73
     */
74
    public function __construct($alttextlabel, $no, $group = 1, $infinite = false, $id = 0) {
75
        $this->id = $id;
76
        $this->text = $alttextlabel;
77
        $this->no = $no;
78
        $this->group = $group;
79
        $this->infinite = $infinite;
80
    }
81
 
82
    /**
83
     * Returns the group of this item.
84
     *
85
     * @return int
86
     */
87
    public function choice_group() {
88
        return $this->group;
89
    }
90
 
91
    /**
92
     * Creates summary text of for the drag item.
93
     *
94
     * @return string
95
     */
96
    public function summarise() {
97
        if (trim($this->text) != '') {
98
            return get_string('summarisechoice', 'qtype_ddimageortext', $this);
99
        } else {
100
            return get_string('summarisechoiceno', 'qtype_ddimageortext', $this->no);
101
        }
102
    }
103
}
104
/**
105
 * Represents one of the places (drop zones).
106
 *
107
 * @copyright  2009 The Open University
108
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
109
 */
110
class qtype_ddimageortext_drop_zone {
111
    /** @var int Number of the item */
112
    public $no;
113
 
114
    /** @var string Alt text for the drop zone item */
115
    public $text;
116
 
117
    /** @var int Group of the item */
118
    public $group;
119
 
120
    /** @var array X and Y location of the drop zone */
121
    public $xy;
122
 
123
    /**
124
     * Create a drop zone object.
125
     *
126
     * @param string $alttextlabel The alt text of the drop zone
127
     * @param int $no Which number drop zone this is
128
     * @param int $group Group of the drop zone
129
     * @param int $x X location
130
     * @param int $y Y location
131
     */
132
    public function __construct($alttextlabel, $no, $group = 1, $x = '', $y = '') {
133
        $this->no = $no;
134
        $this->text = $alttextlabel;
135
        $this->group = $group;
136
        $this->xy = array($x, $y);
137
    }
138
 
139
    /**
140
     * Creates summary text of for the drop zone
141
     *
142
     * @return string
143
     */
144
    public function summarise() {
145
        if (trim($this->text) != '') {
146
            $summariseplace =
147
                        get_string('summariseplace', 'qtype_ddimageortext', $this);
148
        } else {
149
            $summariseplace =
150
                    get_string('summariseplaceno', 'qtype_ddimageortext', $this->no);
151
        }
152
        return $summariseplace;
153
    }
154
}