hotspot.class.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php //$id:$
  2. /* For licensing terms, see /dokeos_license.txt */
  3. /**
  4. * File containing the HotSpot class.
  5. * @package chamilo.exercise
  6. * @author Eric Marguin
  7. * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  8. */
  9. /**
  10. * Code
  11. */
  12. if(!class_exists('HotSpot')):
  13. /**
  14. CLASS HotSpot
  15. *
  16. * This class allows to instantiate an object of type HotSpot (MULTIPLE CHOICE, UNIQUE ANSWER),
  17. * extending the class question
  18. *
  19. * @author Eric Marguin
  20. * @package chamilo.exercise
  21. **/
  22. class HotSpot extends Question {
  23. static $typePicture = 'hotspot.gif';
  24. static $explanationLangVar = 'HotSpot';
  25. function HotSpot() {
  26. parent::question();
  27. $this -> type = HOT_SPOT;
  28. }
  29. function display() {
  30. }
  31. function createForm ($form) {
  32. parent::createForm ($form);
  33. global $text, $class;
  34. if(!isset($_GET['editQuestion'])) {
  35. $renderer = $form->defaultRenderer();
  36. $form->addElement('html', '<div class="row"><div class="label"></div><div class="formw">'.get_lang('UploadJpgPicture').'</div></div>');
  37. $form->addElement('file','imageUpload','<span class="form_required">*</span><img src="../img/hotspots.png" />');
  38. // setting the save button here and not in the question class.php
  39. // Saving a question
  40. $form->addElement('style_submit_button','submitQuestion',get_lang('GoToQuestion'), 'class="'.$class.'"');
  41. $renderer->setElementTemplate('<div class="row"><div class="label" style="margin-top:-30px;">{label}</div><div class="formw" >{element}</div></div>','imageUpload');
  42. $form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif'));
  43. $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
  44. } else {
  45. // setting the save button here and not in the question class.php
  46. // Editing a question
  47. $form->addElement('style_submit_button','submitQuestion',get_lang('langModifyExercise'), 'class="'.$class.'"');
  48. }
  49. }
  50. function processCreation ($form, $objExercise) {
  51. $file_info = $form -> getSubmitValue('imageUpload');
  52. parent::processCreation ($form, $objExercise);
  53. if(!empty($file_info['tmp_name'])) {
  54. $this->uploadPicture($file_info['tmp_name'], $file_info['name']);
  55. global $picturePath;
  56. //fixed width ang height
  57. if (file_exists($picturePath.'/'.$this->picture)) {
  58. //list($width,$height) = @getimagesize($file_info['tmp_name']); does not work
  59. list($width,$height) = @getimagesize($picturePath.'/'.$this->picture);
  60. if($width>$height) {
  61. $this->resizePicture('width',545);
  62. } else {
  63. $this->resizePicture('height',350);
  64. }
  65. $this->save();
  66. } else {
  67. return false;
  68. }
  69. }
  70. }
  71. function createAnswersForm ($form) {
  72. // nothing
  73. }
  74. function processAnswersCreation ($form) {
  75. // nothing
  76. }
  77. }
  78. /**
  79. * @package chamilo.exercise
  80. */
  81. class HotSpotDelineation extends HotSpot {
  82. static $typePicture = 'hotspot_delineation.gif';
  83. static $explanationLangVar = 'HotspotDelineation';
  84. function HotSpotDelineation(){
  85. parent::question();
  86. $this -> type = HOT_SPOT_DELINEATION;
  87. }
  88. function createForm ($form) {
  89. parent::createForm ($form);
  90. }
  91. function processCreation ($form, $objExercise) {
  92. $file_info = $form -> getSubmitValue('imageUpload');
  93. parent::processCreation ($form, $objExercise);
  94. }
  95. function createAnswersForm ($form) {
  96. parent::createAnswersForm ($form);
  97. // nothing
  98. }
  99. function processAnswersCreation ($form) {
  100. parent::processAnswersCreation ($form);
  101. // nothing
  102. }
  103. }
  104. endif;