exercise_show_functions.lib.test.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. class TestExerciseShowFunctions extends UnitTestCase {
  3. /**
  4. * Shows the answer to a fill-in-the-blanks question, as HTML
  5. * @param string Answer text
  6. * @param int Exercise ID
  7. * @param int Question ID
  8. * @return void
  9. */
  10. function testdisplay_fill_in_blanks_answer() {
  11. $answer= 'test';
  12. $id=1;
  13. $questionId=1;
  14. ob_start();
  15. $res = ExerciseShowFunctions::display_fill_in_blanks_answer($answer,$id,$questionId);
  16. ob_end_clean();
  17. $this->assertTrue(is_null($res));
  18. //var_dump($res);
  19. }
  20. /**
  21. * Shows the answer to a free-answer question, as HTML
  22. * @param string Answer text
  23. * @param int Exercise ID
  24. * @param int Question ID
  25. * @return void
  26. */
  27. function testdisplay_free_answer() {
  28. $answer= 'test';
  29. $id=1;
  30. $questionId=1;
  31. ob_start();
  32. $res = ExerciseShowFunctions::display_free_answer($answer,$id,$questionId);
  33. ob_end_clean();
  34. $this->assertTrue(is_null($res));
  35. //var_dump($res);
  36. }
  37. /**
  38. * Displays the answer to a hotspot question
  39. * @param int $answerId
  40. * @param string $answer
  41. * @param string $studentChoice
  42. * @param string $answerComment
  43. * @return void
  44. */
  45. function testdisplay_hotspot_answer() {
  46. $answerId = 1;
  47. $answer= 'testanswer';
  48. $studentChoice='testchoise';
  49. $answerComment='testcomment';
  50. ob_start();
  51. $res = ExerciseShowFunctions::display_hotspot_answer($answerId, $answer, $studentChoice, $answerComment);
  52. ob_end_clean();
  53. $this->assertTrue(is_null($res));
  54. //var_dump($res);
  55. }
  56. /**
  57. * Display the answers to a multiple choice question
  58. * @param integer Answer type
  59. * @param integer Student choice
  60. * @param string Textual answer
  61. * @param string Comment on answer
  62. * @param string Correct answer comment
  63. * @param integer Exercise ID
  64. * @param integer Question ID
  65. * @param boolean Whether to show the answer comment or not
  66. * @return void
  67. */
  68. function testdisplay_unique_or_multiple_answer() {
  69. global $feedback_type, $_course;
  70. $answerType = 1;
  71. $studentChoice='testchoise';
  72. $answer= 'testanswer';
  73. $answerComment='testcomment';
  74. $answerCorrect='testcorrect';
  75. $id = 1;
  76. $questionId = 1;
  77. $ans=true;
  78. ob_start();
  79. $res = ExerciseShowFunctions::display_unique_or_multiple_answer($answerType, $studentChoice, $answer, $answerComment, $answerCorrect, $id, $questionId, $ans);
  80. ob_end_clean();
  81. $this->assertTrue(is_null($res));
  82. //var_dump($res);
  83. }
  84. /**
  85. * This function gets the comments of an exercise
  86. *
  87. * @param int $id
  88. * @param int $question_id
  89. * @return str the comment
  90. */
  91. function testget_comments() {
  92. $id = 1;
  93. $question_id = 1;
  94. ob_start();
  95. $res = ExerciseShowFunctions::get_comments($id,$question_id);
  96. ob_end_clean();
  97. $this->assertTrue(is_null($res));
  98. //var_dump($res);
  99. }
  100. function testsend_notification() {
  101. $arrques = 'test';
  102. $arrans = 'test';
  103. $to = 'test';
  104. $res = ExerciseShowFunctions::send_notification($arrques, $arrans, $to);
  105. $this->assertTrue(is_string($res));
  106. //var_dump($res);
  107. }
  108. }
  109. ?>