hotspot.class.php 2.8 KB

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