1
|
|
|
<?php |
2
|
|
|
/* For licensing terms, see /license.txt */ |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Class HotSpot. |
6
|
|
|
* |
7
|
|
|
* This class allows to instantiate an object of |
8
|
|
|
* type HotSpot (MULTIPLE CHOICE, UNIQUE ANSWER) |
9
|
|
|
* extending the class question |
10
|
|
|
* |
11
|
|
|
* @author Eric Marguin |
12
|
|
|
* |
13
|
|
|
* @package chamilo.exercise |
14
|
|
|
*/ |
15
|
|
|
class HotSpot extends Question |
16
|
|
|
{ |
17
|
|
|
public $typePicture = 'hotspot.png'; |
18
|
|
|
public $explanationLangVar = 'HotSpot'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* HotSpot constructor. |
22
|
|
|
*/ |
23
|
|
|
public function __construct() |
24
|
|
|
{ |
25
|
|
|
parent::__construct(); |
26
|
|
|
$this->type = HOT_SPOT; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
public function display() |
30
|
|
|
{ |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* {@inheritdoc} |
35
|
|
|
*/ |
36
|
|
|
public function createForm(&$form, $exercise) |
37
|
|
|
{ |
38
|
|
|
parent::createForm($form, $exercise); |
39
|
|
|
|
40
|
|
|
if (!isset($_GET['editQuestion'])) { |
41
|
|
|
$icon = Display::return_icon( |
42
|
|
|
'hotspot.png', |
43
|
|
|
null, |
44
|
|
|
null, |
45
|
|
|
ICON_SIZE_BIG, |
46
|
|
|
false, |
47
|
|
|
true |
48
|
|
|
); |
49
|
|
|
$form->addElement( |
50
|
|
|
'file', |
51
|
|
|
'imageUpload', |
52
|
|
|
[ |
53
|
|
|
'<img src="'.$icon.'" />', |
54
|
|
|
get_lang('UploadJpgPicture'), |
55
|
|
|
] |
56
|
|
|
); |
57
|
|
|
|
58
|
|
|
// setting the save button here and not in the question class.php |
59
|
|
|
// Saving a question |
60
|
|
|
$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion'); |
61
|
|
|
$form->addRule( |
62
|
|
|
'imageUpload', |
63
|
|
|
get_lang('OnlyImagesAllowed'), |
64
|
|
|
'filetype', |
65
|
|
|
['jpg', 'jpeg', 'png', 'gif'] |
66
|
|
|
); |
67
|
|
|
$form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile'); |
68
|
|
|
} else { |
69
|
|
|
// setting the save button here and not in the question class.php |
70
|
|
|
// Editing a question |
71
|
|
|
$form->addButtonUpdate(get_lang('ModifyQuestion'), 'submitQuestion'); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* {@inheritdoc} |
77
|
|
|
*/ |
78
|
|
|
public function processCreation($form, $exercise) |
79
|
|
|
{ |
80
|
|
|
$fileInfo = $form->getSubmitValue('imageUpload'); |
81
|
|
|
parent::processCreation($form, $exercise); |
82
|
|
|
|
83
|
|
|
if (!empty($fileInfo['tmp_name'])) { |
84
|
|
|
$result = $this->uploadPicture($fileInfo['tmp_name']); |
85
|
|
|
if ($result) { |
86
|
|
|
$this->save($exercise); |
87
|
|
|
|
88
|
|
|
return true; |
89
|
|
|
} |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
return false; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function createAnswersForm($form) |
96
|
|
|
{ |
97
|
|
|
// nothing |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* {@inheritdoc} |
102
|
|
|
*/ |
103
|
|
|
public function processAnswersCreation($form, $exercise) |
104
|
|
|
{ |
105
|
|
|
// nothing |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|