hotspot.class.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. * @param FormValidator $form
  30. * @param int $fck_config
  31. */
  32. public function createForm(&$form, $fck_config = 0)
  33. {
  34. parent::createForm($form, $fck_config);
  35. if (!isset($_GET['editQuestion'])) {
  36. $icon = Display::return_icon(
  37. 'hotspot.png',
  38. null,
  39. null,
  40. ICON_SIZE_BIG,
  41. false,
  42. true
  43. );
  44. $form->addElement(
  45. 'file',
  46. 'imageUpload',
  47. array(
  48. '<img src="'.$icon.'" />',
  49. get_lang('UploadJpgPicture'),
  50. )
  51. );
  52. // setting the save button here and not in the question class.php
  53. // Saving a question
  54. $form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
  55. //$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
  56. $form->addRule(
  57. 'imageUpload',
  58. get_lang('OnlyImagesAllowed'),
  59. 'filetype',
  60. array('jpg', 'jpeg', 'png', 'gif')
  61. );
  62. $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
  63. } else {
  64. // setting the save button here and not in the question class.php
  65. // Editing a question
  66. $form->addButtonUpdate(get_lang('ModifyExercise'), 'submitQuestion');
  67. }
  68. }
  69. /**
  70. * @param FormValidator $form
  71. * @param null $objExercise
  72. * @return bool
  73. */
  74. public function processCreation($form, $objExercise = null)
  75. {
  76. $file_info = $form->getSubmitValue('imageUpload');
  77. parent::processCreation($form, $objExercise);
  78. if (!empty($file_info['tmp_name'])) {
  79. $result = $this->uploadPicture($file_info['tmp_name']);
  80. if ($result) {
  81. $this->save();
  82. return true;
  83. } else {
  84. return false;
  85. }
  86. }
  87. return false;
  88. }
  89. function createAnswersForm($form)
  90. {
  91. // nothing
  92. }
  93. function processAnswersCreation($form)
  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. public function createForm(&$form, $fck_config = 0)
  114. {
  115. parent::createForm($form, $fck_config);
  116. }
  117. public function processCreation($form, $objExercise = null)
  118. {
  119. $file_info = $form->getSubmitValue('imageUpload');
  120. parent::processCreation($form, $objExercise);
  121. }
  122. public function createAnswersForm($form)
  123. {
  124. parent::createAnswersForm($form);
  125. }
  126. public function processAnswersCreation($form)
  127. {
  128. parent::processAnswersCreation($form);
  129. }
  130. }