hotspot.class.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. /* For licensing terms, see /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, $fck_config=0) {
  32. parent::createForm ($form, $fck_config);
  33. global $text, $class;
  34. if(!isset($_GET['editQuestion'])) {
  35. $renderer = $form->defaultRenderer();
  36. $form->addElement('file','imageUpload',array('<img src="../img/hotspots.png" />', get_lang('UploadJpgPicture')) );
  37. // setting the save button here and not in the question class.php
  38. // Saving a question
  39. $form->addElement('style_submit_button','submitQuestion',get_lang('GoToQuestion'), 'class="'.$class.'"');
  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('ModifyExercise'), 'class="'.$class.'"');
  46. }
  47. }
  48. function processCreation ($form, $objExercise = null) {
  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($picturePath.'/'.$this->picture);
  57. if($width>$height) {
  58. $this->resizePicture('width',545);
  59. } else {
  60. $this->resizePicture('height',350);
  61. }
  62. $this->save();
  63. } else {
  64. return false;
  65. }
  66. }
  67. }
  68. function createAnswersForm ($form) {
  69. // nothing
  70. }
  71. function processAnswersCreation ($form) {
  72. // nothing
  73. }
  74. }
  75. /**
  76. * @package chamilo.exercise
  77. */
  78. class HotSpotDelineation extends HotSpot {
  79. static $typePicture = 'hotspot_delineation.gif';
  80. static $explanationLangVar = 'HotspotDelineation';
  81. function HotSpotDelineation(){
  82. parent::question();
  83. $this -> type = HOT_SPOT_DELINEATION;
  84. }
  85. function createForm (&$form, $fck_config=0) {
  86. parent::createForm ($form, $fck_config);
  87. }
  88. function processCreation ($form, $objExercise = null) {
  89. $file_info = $form -> getSubmitValue('imageUpload');
  90. parent::processCreation ($form, $objExercise);
  91. }
  92. function createAnswersForm ($form) {
  93. parent::createAnswersForm ($form);
  94. }
  95. function processAnswersCreation ($form) {
  96. parent::processAnswersCreation ($form);
  97. }
  98. }
  99. endif;