qti2_classes.test.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <?php
  2. require_once(api_get_path(SYS_CODE_PATH).'/exercice/answer.class.php');
  3. require_once(api_get_path(SYS_CODE_PATH).'/exercice/question.class.php');
  4. require_once(api_get_path(SYS_CODE_PATH).'/exercice/exercise.class.php');
  5. require_once(api_get_path(SYS_CODE_PATH).'/exercice/hotspot.class.php');
  6. require_once(api_get_path(SYS_CODE_PATH).'/exercice/unique_answer.class.php');
  7. require_once(api_get_path(SYS_CODE_PATH).'/exercice/multiple_answer.class.php');
  8. require_once(api_get_path(SYS_CODE_PATH).'/exercice/matching.class.php');
  9. require_once(api_get_path(SYS_CODE_PATH).'/exercice/freeanswer.class.php');
  10. require_once(api_get_path(SYS_CODE_PATH).'/exercice/fill_blanks.class.php');
  11. class TestQti2 extends UnitTestCase {
  12. public $qIms2Question;
  13. public $qImsAnswerFillInBlanks;
  14. public $qImsAnswerFree;
  15. public $qImsAnswerHotspot;
  16. public $qImsAnswerMatching;
  17. public $qImsAnswerMultipleChoice;
  18. public function __construct() {
  19. $this->UnitTestCase('QTI2 library - main/exercice/export/qti2/qti2_classes.test.php');
  20. }
  21. public function setUp() {
  22. $this->qIms2Question = new Ims2Question();
  23. $this->qImsAnswerFillInBlanks = new ImsAnswerFillInBlanks(1);
  24. $this->qImsAnswerFree = new ImsAnswerFree(1);
  25. $this->qImsAnswerHotspot = new ImsAnswerHotspot(1);
  26. $this->qImsAnswerMatching = new ImsAnswerMatching(1);
  27. $this->qImsAnswerMultipleChoice = new ImsAnswerMultipleChoice(1);
  28. }
  29. public function tearDown() {
  30. $this-> qIms2Question = null;
  31. $this-> qImsAnswerFillInBlanks = null;
  32. $this-> qImsAnswerFree = null;
  33. $this-> qImsAnswerHotspot = null;
  34. $this-> qImsAnswerMatching = null;
  35. $this-> qImsAnswerMultipleChoice = null;
  36. }
  37. //Class qIms2Question
  38. /**
  39. * Include the correct answer class and create answer
  40. */
  41. function testsetAnswer() {
  42. $res=Ims2Question::setAnswer();
  43. if(!is_null){
  44. $this->assertTrue(is_bool($res));
  45. }
  46. //var_dump($res);
  47. }
  48. function testcreateAnswersForm() {
  49. $form = array(1);
  50. $res=Ims2Question::createAnswersForm($form);
  51. $this->assertTrue(is_bool($res));
  52. //var_dump($res);
  53. }
  54. function testprocessAnswersCreation() {
  55. $form = array(1);
  56. $res=Ims2Question::processAnswersCreation($form);
  57. $this->assertTrue(is_bool($res));
  58. //var_dump($res);
  59. }
  60. //Class qImsAnswerFillInBlanks
  61. /**
  62. * Export the text with missing words.
  63. *
  64. *
  65. */
  66. function testimsExportResponses() {
  67. $questionIdent = array(1);
  68. $questionStatment = array(1);
  69. $res=$this->qImsAnswerFillInBlanks->imsExportResponses($questionIdent, $questionStatment);
  70. if(!is_null){
  71. $this->assertTrue(is_bool($res));
  72. }
  73. //var_dump($res);
  74. }
  75. function testimsExportResponsesDeclaration() {
  76. $questionIdent = array(1);
  77. $res=$this->qImsAnswerFillInBlanks->imsExportResponsesDeclaration($questionIdent);
  78. if(!is_null){
  79. $this->assertTrue(is_bool($res));
  80. }
  81. //var_dump($res);
  82. }
  83. //Class qImsAnswerFree
  84. /**
  85. * TODO implement
  86. * Export the question part as a matrix-choice, with only one possible answer per line.
  87. */
  88. function testImsExportResponsesqImsAnswerFree() {
  89. $questionIdent = array('');
  90. $questionStatment = array('');
  91. $res=$this->qImsAnswerFree->imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='');
  92. $this->assertTrue(is_string($res));
  93. //var_dump($res);
  94. }
  95. function testImsExportResponsesDeclarationqImsAnswerFree() {
  96. $questionIdent = array(1);
  97. $res=$this->qImsAnswerFree->imsExportResponsesDeclaration($questionIdent);
  98. $this->assertTrue(is_string($res));
  99. //var_dump($res);
  100. }
  101. //Class qImsAnswerHotspot
  102. /**
  103. * TODO update this to match hotspots instead of copying matching
  104. * Export the question part as a matrix-choice, with only one possible answer per line.
  105. */
  106. function testimsExportResponsesqImsAnswerHotspot() {
  107. $questionIdent = array(1);
  108. $questionStatment = array(1);
  109. $res=$this->qImsAnswerHotspot->imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='');
  110. $this->assertTrue(is_string($res));
  111. //var_dump($res);
  112. }
  113. function testimsExportResponsesDeclarationqImsAnswerHotspot() {
  114. $questionIdent = array(1);
  115. $res=$this->qImsAnswerHotspot->imsExportResponsesDeclaration($questionIdent);
  116. $this->assertTrue(is_string($res));
  117. //var_dump($res);
  118. }
  119. //Class qImsAnswerMatching
  120. /**
  121. * Export the question part as a matrix-choice, with only one possible answer per line.
  122. */
  123. function testimsExportResponsesqImsAnswerMatching() {
  124. $questionIdent = array(1);
  125. $questionStatment = array(1);
  126. $res=$this->qImsAnswerMatching->imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='');
  127. $this->assertTrue(is_string($res));
  128. //var_dump($res);
  129. }
  130. function testimsExportResponsesDeclarationqImsAnswerMatching() {
  131. $questionIdent = array(1);
  132. $res=$this->qImsAnswerMatching->imsExportResponsesDeclaration($questionIdent);
  133. $this->assertTrue(is_string($res));
  134. //var_dump($res);
  135. }
  136. //Class qImsAnswerMultipleChoice
  137. /**
  138. * Return the XML flow for the possible answers.
  139. *
  140. */
  141. function testimsExportResponsesqImsAnswerMultipleChoice() {
  142. $questionIdent = array(1);
  143. $questionStatment = array(1);
  144. $res=$this->qImsAnswerMultipleChoice->imsExportResponses($questionIdent, $questionStatment, $questionDesc='', $questionMedia='');
  145. $this->assertTrue(is_string($res));
  146. //var_dump($res);
  147. }
  148. function testimsExportResponsesDeclarationqImsAnswerMultipleChoice() {
  149. $questionIdent = array(1);
  150. $res=$this->qImsAnswerMultipleChoice->imsExportResponsesDeclaration($questionIdent);
  151. $this->assertTrue(is_string($res));
  152. //var_dump($res);
  153. }
  154. }
  155. ?>