hotspot.class.php 3.0 KB

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