hotspot.class.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. {
  53. $this->uploadPicture($file_info['tmp_name'], $file_info['name']);
  54. list($width,$height) = @getimagesize($file_info['tmp_name']);
  55. if($width>=$height) {
  56. $this->resizePicture('width',550);
  57. } else {
  58. $this->resizePicture('height',350);
  59. }
  60. $this->save();
  61. }
  62. }
  63. function createAnswersForm ($form) {
  64. // nothing
  65. }
  66. function processAnswersCreation ($form) {
  67. // nothing
  68. }
  69. }
  70. endif;
  71. ?>