hotspot.class.php 3.4 KB

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