freeanswer.class.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. $this -> isContent = $this-> getIsContent();
  35. }
  36. /**
  37. * function which redifines Question::createAnswersForm
  38. * @param the formvalidator instance
  39. */
  40. function createAnswersForm ($form)
  41. {
  42. $form -> addElement('text','weighting',get_lang('Weighting'),'size="5"');
  43. global $text, $class;
  44. // setting the save button here and not in the question class.php
  45. $form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
  46. if (!empty($this->id)) {
  47. $form -> setDefaults(array('weighting' => float_format($this->weighting, 1)));
  48. } else {
  49. if ($this -> isContent == 1) {
  50. $form -> setDefaults(array('weighting' => '10'));
  51. }
  52. }
  53. }
  54. /**
  55. * abstract function which creates the form to create / edit the answers of the question
  56. * @param the formvalidator instance
  57. */
  58. function processAnswersCreation($form)
  59. {
  60. $this -> weighting = $form -> getSubmitValue('weighting');
  61. $this->save();
  62. }
  63. }
  64. endif;
  65. ?>