oral_expression.class.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. *
  9. * @package chamilo.exercise
  10. */
  11. class OralExpression extends Question
  12. {
  13. static $typePicture = 'audio_question.png';
  14. static $explanationLangVar = 'OralExpression';
  15. /**
  16. * Constructor
  17. */
  18. public function __construct()
  19. {
  20. parent::__construct();
  21. $this -> type = ORAL_EXPRESSION;
  22. $this -> isContent = $this-> getIsContent();
  23. }
  24. /**
  25. * function which redefine Question::createAnswersForm
  26. * @param FormValidator $form
  27. */
  28. function createAnswersForm($form)
  29. {
  30. $form -> addElement('text','weighting', get_lang('Weighting'), array('class' => 'span1'));
  31. global $text, $class;
  32. // setting the save button here and not in the question class.php
  33. $form->addButtonSave($text, 'submitQuestion');
  34. if (!empty($this->id)) {
  35. $form -> setDefaults(array('weighting' => float_format($this->weighting, 1)));
  36. } else {
  37. if ($this -> isContent == 1) {
  38. $form -> setDefaults(array('weighting' => '10'));
  39. }
  40. }
  41. }
  42. /**
  43. * abstract function which creates the form to create / edit the answers of the question
  44. * @param the FormValidator $form
  45. */
  46. function processAnswersCreation($form)
  47. {
  48. $this->weighting = $form ->getSubmitValue('weighting');
  49. $this->save();
  50. }
  51. /**
  52. * @param null $feedback_type
  53. * @param null $counter
  54. * @param null $score
  55. * @return null|string
  56. */
  57. function return_header($feedback_type = null, $counter = null, $score = null)
  58. {
  59. $header = parent::return_header($feedback_type, $counter, $score);
  60. $header .= '<table class="'.$this->question_table_class.'">
  61. <tr>
  62. <th>&nbsp;</th>
  63. </tr>
  64. <tr>
  65. <th>'.get_lang("Answer").'</th>
  66. </tr>
  67. <tr>
  68. <th>&nbsp;</th>
  69. </tr>';
  70. return $header;
  71. }
  72. }