ScormAnswerTrueFalse.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This class handles the SCORM export of true/false questions.
  5. *
  6. * @package chamilo.exercise.scorm
  7. */
  8. class ScormAnswerTrueFalse extends Answer
  9. {
  10. /**
  11. * Return the XML flow for the possible answers.
  12. * That's one <response_lid>, containing several <flow_label>.
  13. *
  14. * @author Amand Tihon <amand@alrj.org>
  15. */
  16. public function export()
  17. {
  18. $js = '';
  19. $html = '<tr><td colspan="2"><table width="100%">';
  20. $identifier = 'question_'.$this->questionJSId.'_tf';
  21. $identifier_true = $identifier.'_true';
  22. $identifier_false = $identifier.'_false';
  23. $html .=
  24. '<tr>
  25. <td align="center" width="5%">
  26. <input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" />
  27. </td>
  28. <td width="95%">
  29. <label for="'.$identifier_true.'">'.get_lang('True').'</label>
  30. </td>
  31. </tr>';
  32. $html .=
  33. '<tr>
  34. <td align="center" width="5%">
  35. <input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" />
  36. </td>
  37. <td width="95%">
  38. <label for="'.$identifier_false.'">'.get_lang('False').'</label>
  39. </td>
  40. </tr></table></td></tr>';
  41. $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n";
  42. $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n";
  43. if ($this->response === 'TRUE') {
  44. $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n";
  45. } else {
  46. $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n";
  47. }
  48. $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n";
  49. $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n";
  50. $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n";
  51. $js .= $jstmpw;
  52. return [$js, $html];
  53. }
  54. }