freeanswer.class.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 FreeAnswer class.
  18. * This class allows to instantiate an object of type FREE_ANSWER,
  19. * extending the class question
  20. * @package dokeos.exercise
  21. * @author Eric Marguin
  22. * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  23. */
  24. if(!class_exists('FreeAnswer')):
  25. class FreeAnswer extends Question {
  26. static $typePicture = 'open_answer.gif';
  27. static $explanationLangVar = 'freeAnswer';
  28. /**
  29. * Constructor
  30. */
  31. function FreeAnswer(){
  32. parent::question();
  33. $this -> type = FREE_ANSWER;
  34. }
  35. /**
  36. * function which redifines Question::createAnswersForm
  37. * @param the formvalidator instance
  38. */
  39. function createAnswersForm ($form)
  40. {
  41. $form -> addElement('text','weighting',get_lang('Weighting'),'size="5"');
  42. global $text, $class;
  43. // setting the save button here and not in the question class.php
  44. $form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
  45. if(!empty($this->id)) {
  46. $form -> setDefaults(array('weighting' => float_format($this->weighting, 1)));
  47. } else {
  48. $form -> setDefaults(array('weighting' => '10'));
  49. }
  50. }
  51. /**
  52. * abstract function which creates the form to create / edit the answers of the question
  53. * @param the formvalidator instance
  54. */
  55. function processAnswersCreation($form)
  56. {
  57. $this -> weighting = $form -> getSubmitValue('weighting');
  58. $this->save();
  59. }
  60. }
  61. endif;
  62. ?>