hotspot.class.php 3.1 KB

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