MDL-70153 qtype_essay: Add behat test for attachments max size
[moodle.git] / question / type / ddimageortext / question.php
CommitLineData
a2bb148a 1<?php
a2bb148a
TH
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
a2bb148a 17/**
c109c901 18 * Drag-and-drop onto image question definition class.
a2bb148a 19 *
c109c901 20 * @package qtype_ddimageortext
5b4602d2
TH
21 * @copyright 2009 The Open University
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
a2bb148a
TH
23 */
24
42536280
TH
25
26defined('MOODLE_INTERNAL') || die();
27
d2c112fd 28require_once($CFG->dirroot . '/question/type/ddimageortext/questionbase.php');
a2bb148a 29
42536280 30
a2bb148a 31/**
c109c901 32 * Represents a drag-and-drop onto image question.
a2bb148a 33 *
5b4602d2
TH
34 * @copyright 2009 The Open University
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
a2bb148a 36 */
d2c112fd 37class qtype_ddimageortext_question extends qtype_ddtoimage_question_base {
104059b3 38
a2bb148a
TH
39}
40
41
42/**
b5990048 43 * Represents one of the choices (draggable images).
a2bb148a 44 *
5b4602d2
TH
45 * @copyright 2009 The Open University
46 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
a2bb148a 47 */
31077627 48class qtype_ddimageortext_drag_item {
8bc1d28b 49 /** @var int Drag item id */
3c2b258d 50 public $id;
8bc1d28b
EM
51
52 /** @var string Text for the drag item */
8bfaad3b 53 public $text;
8bc1d28b
EM
54
55 /** @var int Number of the item */
b5990048 56 public $no;
8bc1d28b
EM
57
58 /** @var int Group of the item */
b5990048 59 public $group;
8bc1d28b
EM
60
61 /** @var bool If the drag item can be used multiple times or not */
48b39366 62 public $infinite;
a2bb148a 63
8bc1d28b
EM
64 /**
65 * Drag item object setup.
66 *
67 * @param string $alttextlabel The alt text of the drag item
68 * @param int $no Which number drag item this is
69 * @param int $group Group of the drag item
70 * @param bool $infinite True if the item can be used an unlimited number of times
71 * @param int $id id of the item
72 */
48b39366 73 public function __construct($alttextlabel, $no, $group = 1, $infinite = false, $id = 0) {
3c2b258d 74 $this->id = $id;
b5990048
JP
75 $this->text = $alttextlabel;
76 $this->no = $no;
77 $this->group = $group;
48b39366 78 $this->infinite = $infinite;
a2bb148a 79 }
8bc1d28b
EM
80
81 /**
82 * Returns the group of this item.
83 *
84 * @return int
85 */
944829e9 86 public function choice_group() {
b5990048 87 return $this->group;
a2bb148a 88 }
104059b3 89
8bc1d28b
EM
90 /**
91 * Creates summary text of for the drag item.
92 *
93 * @return string
94 */
104059b3
JP
95 public function summarise() {
96 if (trim($this->text) != '') {
31077627 97 return get_string('summarisechoice', 'qtype_ddimageortext', $this);
104059b3 98 } else {
31077627 99 return get_string('summarisechoiceno', 'qtype_ddimageortext', $this->no);
104059b3
JP
100 }
101 }
a2bb148a 102}
b5990048
JP
103/**
104 * Represents one of the places (drop zones).
105 *
106 * @copyright 2009 The Open University
107 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
108 */
31077627 109class qtype_ddimageortext_drop_zone {
8bc1d28b 110 /** @var int Number of the item */
104059b3 111 public $no;
8bc1d28b
EM
112
113 /** @var string Alt text for the drop zone item */
104059b3 114 public $text;
8bc1d28b
EM
115
116 /** @var int Group of the item */
b5990048 117 public $group;
8bc1d28b
EM
118
119 /** @var array X and Y location of the drop zone */
b5990048
JP
120 public $xy;
121
8bc1d28b
EM
122 /**
123 * Create a drop zone object.
124 *
125 * @param string $alttextlabel The alt text of the drop zone
126 * @param int $no Which number drop zone this is
127 * @param int $group Group of the drop zone
128 * @param int $x X location
129 * @param int $y Y location
130 */
104059b3
JP
131 public function __construct($alttextlabel, $no, $group = 1, $x = '', $y = '') {
132 $this->no = $no;
b5990048
JP
133 $this->text = $alttextlabel;
134 $this->group = $group;
135 $this->xy = array($x, $y);
136 }
104059b3 137
8bc1d28b
EM
138 /**
139 * Creates summary text of for the drop zone
140 *
141 * @return string
142 */
104059b3
JP
143 public function summarise() {
144 if (trim($this->text) != '') {
145 $summariseplace =
31077627 146 get_string('summariseplace', 'qtype_ddimageortext', $this);
104059b3
JP
147 } else {
148 $summariseplace =
31077627 149 get_string('summariseplaceno', 'qtype_ddimageortext', $this->no);
104059b3
JP
150 }
151 return $summariseplace;
152 }
8bc1d28b 153}