hotspot.class.php 2.8 KB

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