hotspot.class.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. static $typePicture = 'hotspot.png';
  15. static $explanationLangVar = 'HotSpot';
  16. public function __construct()
  17. {
  18. parent::__construct();
  19. $this -> type = HOT_SPOT;
  20. }
  21. public function display()
  22. {
  23. }
  24. /**
  25. * @param FormValidator $form
  26. * @param int $fck_config
  27. */
  28. public function createForm (&$form, $fck_config=0)
  29. {
  30. parent::createForm($form, $fck_config);
  31. if (!isset($_GET['editQuestion'])) {
  32. $form->addElement('file','imageUpload',array('<img src="../img/icons/22/hotspots.png" />', get_lang('UploadJpgPicture')) );
  33. // setting the save button here and not in the question class.php
  34. // Saving a question
  35. $form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
  36. //$form->addButtonSave(get_lang('GoToQuestion'), 'submitQuestion');
  37. $form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif'));
  38. $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
  39. } else {
  40. // setting the save button here and not in the question class.php
  41. // Editing a question
  42. $form->addButtonUpdate(get_lang('ModifyExercise'), 'submitQuestion');
  43. }
  44. }
  45. /**
  46. * @param FormValidator $form
  47. * @param null $objExercise
  48. * @return bool
  49. */
  50. public function processCreation($form, $objExercise = null)
  51. {
  52. $file_info = $form->getSubmitValue('imageUpload');
  53. $_course = api_get_course_info();
  54. parent::processCreation($form, $objExercise);
  55. if(!empty($file_info['tmp_name'])) {
  56. $this->uploadPicture($file_info['tmp_name'], $file_info['name']);
  57. $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
  58. $picturePath = $documentPath.'/images';
  59. // fixed width ang height
  60. if (file_exists($picturePath.'/'.$this->picture)) {
  61. $this->resizePicture('width', 800);
  62. $this->save();
  63. } else {
  64. return false;
  65. }
  66. }
  67. }
  68. function createAnswersForm ($form)
  69. {
  70. // nothing
  71. }
  72. function processAnswersCreation ($form)
  73. {
  74. // nothing
  75. }
  76. }
  77. /**
  78. * Class HotSpotDelineation
  79. */
  80. class HotSpotDelineation extends HotSpot
  81. {
  82. static $typePicture = 'hotspot-delineation.png';
  83. static $explanationLangVar = 'HotspotDelineation';
  84. function __construct()
  85. {
  86. parent::__construct();
  87. $this -> type = HOT_SPOT_DELINEATION;
  88. }
  89. function createForm (&$form, $fck_config=0)
  90. {
  91. parent::createForm ($form, $fck_config);
  92. }
  93. function processCreation ($form, $objExercise = null)
  94. {
  95. $file_info = $form -> getSubmitValue('imageUpload');
  96. parent::processCreation ($form, $objExercise);
  97. }
  98. function createAnswersForm ($form)
  99. {
  100. parent::createAnswersForm ($form);
  101. }
  102. function processAnswersCreation ($form)
  103. {
  104. parent::processAnswersCreation ($form);
  105. }
  106. }