freeanswer.class.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. if(!empty($this->id)) {
  43. $form -> setDefaults(array('weighting' => float_format($this->weighting, 1)));
  44. } else {
  45. $form -> setDefaults(array('weighting' => '10'));
  46. }
  47. }
  48. /**
  49. * abstract function which creates the form to create / edit the answers of the question
  50. * @param the formvalidator instance
  51. */
  52. function processAnswersCreation($form)
  53. {
  54. $this -> weighting = $form -> getSubmitValue('weighting');
  55. $this->save();
  56. }
  57. }
  58. endif;
  59. ?>