hotspot.class.php 3.6 KB

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