oral_expression.class.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class OralExpression
  5. * This class allows to instantiate an object of type FREE_ANSWER,
  6. * extending the class question
  7. * @author Eric Marguin
  8. * @package chamilo.exercise
  9. */
  10. class OralExpression extends Question
  11. {
  12. static $typePicture = 'audio_question.png';
  13. static $explanationLangVar = 'OralExpression';
  14. /**
  15. * Constructor
  16. */
  17. public function __construct()
  18. {
  19. parent::__construct();
  20. $this -> type = ORAL_EXPRESSION;
  21. $this -> isContent = $this-> getIsContent();
  22. }
  23. /**
  24. * function which redefine Question::createAnswersForm
  25. * @param FormValidator $form
  26. */
  27. function createAnswersForm($form)
  28. {
  29. $form -> addElement('text','weighting', get_lang('Weighting'), array('class' => 'span1'));
  30. global $text, $class;
  31. // setting the save button here and not in the question class.php
  32. $form->addButtonSave($text, 'submitQuestion');
  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 $form
  44. */
  45. function processAnswersCreation($form)
  46. {
  47. $this->weighting = $form ->getSubmitValue('weighting');
  48. $this->save();
  49. }
  50. /**
  51. * @param null $feedback_type
  52. * @param null $counter
  53. * @param null $score
  54. * @return null|string
  55. */
  56. function return_header($feedback_type = null, $counter = null, $score = null)
  57. {
  58. $header = parent::return_header($feedback_type, $counter, $score);
  59. $header .= '<table class="'.$this->question_table_class.'">
  60. <tr>
  61. <th>&nbsp;</th>
  62. </tr>
  63. <tr>
  64. <th>'.get_lang("Answer").'</th>
  65. </tr>
  66. <tr>
  67. <th>&nbsp;</th>
  68. </tr>';
  69. return $header;
  70. }
  71. }