hotspot.class.php 3.0 KB

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