freeanswer.class.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * File containing the FreeAnswer class.
  5. * This class allows to instantiate an object of type FREE_ANSWER,
  6. * extending the class question
  7. * @package chamilo.exercise
  8. * @author Eric Marguin
  9. * @version $Id: admin.php 10680 2007-01-11 21:26:23Z pcool $
  10. */
  11. if(!class_exists('FreeAnswer')):
  12. class FreeAnswer extends Question {
  13. static $typePicture = 'open_answer.gif';
  14. static $explanationLangVar = 'FreeAnswer';
  15. /**
  16. * Constructor
  17. */
  18. function FreeAnswer(){
  19. parent::question();
  20. $this -> type = FREE_ANSWER;
  21. $this -> isContent = $this-> getIsContent();
  22. }
  23. /**
  24. * function which redifines Question::createAnswersForm
  25. * @param the formvalidator instance
  26. */
  27. function createAnswersForm ($form)
  28. {
  29. $form -> addElement('text','weighting',get_lang('Weighting'),'size="5"');
  30. global $text, $class;
  31. // setting the save button here and not in the question class.php
  32. $form->addElement('style_submit_button','submitQuestion',$text, 'class="'.$class.'"');
  33. if (!empty($this->id)) {
  34. $form -> setDefaults(array('weighting' => float_format($this->weighting, 1)));
  35. } else {
  36. if ($this -> isContent == 1) {
  37. $form -> setDefaults(array('weighting' => '10'));
  38. }
  39. }
  40. }
  41. /**
  42. * abstract function which creates the form to create / edit the answers of the question
  43. * @param the formvalidator instance
  44. */
  45. function processAnswersCreation($form)
  46. {
  47. $this -> weighting = $form -> getSubmitValue('weighting');
  48. $this->save();
  49. }
  50. function return_header($feedback_type, $counter = null) {
  51. parent::return_header($feedback_type, $counter);
  52. $header = '<table width="100%" border="0" cellspacing="3" cellpadding="3">
  53. <tr>
  54. <td>&nbsp;</td>
  55. </tr>
  56. <tr>
  57. <td><i><?php echo get_lang("Answer"); ?></i> </td>
  58. </tr>
  59. <tr>
  60. <td>&nbsp;</td>
  61. </tr>';
  62. return $header;
  63. }
  64. }
  65. endif;
  66. ?>