hotspot.class.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /*
  3. DOKEOS - elearning and course management software
  4. For a full list of contributors, see documentation/credits.html
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. See "documentation/licence.html" more details.
  10. Contact:
  11. Dokeos
  12. Rue des Palais 44 Paleizenstraat
  13. B-1030 Brussels - Belgium
  14. Tel. +32 (2) 211 34 56
  15. */
  16. /**
  17. * File containing the HotSpot class.
  18. * @package dokeos.exercise
  19. * @author Eric Marguin
  20. * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  21. */
  22. if(!class_exists('HotSpot')):
  23. /**
  24. CLASS HotSpot
  25. *
  26. * This class allows to instantiate an object of type HotSpot (MULTIPLE CHOICE, UNIQUE ANSWER),
  27. * extending the class question
  28. *
  29. * @author Eric Marguin
  30. * @package dokeos.exercise
  31. **/
  32. class HotSpot extends Question {
  33. static $typePicture = 'hotspot.gif';
  34. static $explanationLangVar = 'Hotspot';
  35. function HotSpot(){
  36. parent::question();
  37. $this -> type = HOT_SPOT;
  38. }
  39. function display(){
  40. }
  41. function createForm ($form) {
  42. parent::createForm ($form);
  43. if(!isset($_GET['editQuestion'])) {
  44. $renderer = $form->defaultRenderer();
  45. $form->addElement('html', '<div class="row"><div class="label"></div><div class="formw">'.get_lang('UploadJpgPicture').'</div></div>');
  46. $form->addElement('file','imageUpload','<span class="form_required">*</span><img src="../img/hotspots.png" />');
  47. $renderer->setElementTemplate('<div class="row"><div class="label" style="margin-top:-30px;">{label}</div><div class="formw" >{element}</div></div>','imageUpload');
  48. $form->addRule('imageUpload', get_lang('OnlyImagesAllowed'), 'filetype', array ('jpg', 'jpeg', 'png', 'gif'));
  49. $form->addRule('imageUpload', get_lang('NoImage'), 'uploadedfile');
  50. }
  51. }
  52. function processCreation ($form, $objExercise) {
  53. $file_info = $form -> getSubmitValue('imageUpload');
  54. parent::processCreation ($form, $objExercise);
  55. if(!empty($file_info['tmp_name']))
  56. {
  57. $this->uploadPicture($file_info['tmp_name'], $file_info['name']);
  58. list($width,$height) = @getimagesize($file_info['tmp_name']);
  59. if($width>=$height) {
  60. $this->resizePicture('width',544);
  61. } else {
  62. $this->resizePicture('height',408);
  63. }
  64. $this->save();
  65. }
  66. }
  67. function createAnswersForm ($form) {
  68. // nothing
  69. }
  70. function processAnswersCreation ($form) {
  71. // nothing
  72. }
  73. }
  74. endif;
  75. ?>