exercise_result.class.test.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. class TestExerciseResult extends UnitTestCase
  3. {
  4. public $eExerciseResult;
  5. public function TestExerciseResult() {
  6. $this->UnitTestCase('');
  7. }
  8. public function setUp() {
  9. $this->eExerciseResult = new ExerciseResult();
  10. }
  11. public function tearDown() {
  12. $this->eExerciseResult = null;
  13. }
  14. /**
  15. * Gets the results of all students (or just one student if access is limited)
  16. * @param string The document path (for HotPotatoes retrieval)
  17. * @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
  18. */
  19. function test_getExercisesReporting() {
  20. global $user_id;
  21. $document_path = api_get_path(SYS_COURSE_PATH).'document/';
  22. $res = $this->eExerciseResult->_getExercisesReporting($document_path,$user_id,$filter=0);
  23. if(!is_null($res)) {
  24. $this->assertTrue(is_bool($res));
  25. }
  26. //var_dump($res);
  27. }
  28. /**
  29. * Exports the complete report as a CSV file
  30. * @param string Document path inside the document tool
  31. * @param integer Optional user ID
  32. * @param boolean Whether to include user fields or not
  33. * @return boolean False on error
  34. */
  35. function testexportCompleteReportCSV() {
  36. global $user_id;
  37. $document_path = api_get_path(SYS_COURSE_PATH).'document/';
  38. if(!headers_sent()){
  39. $res = $this->eExerciseResult->exportCompleteReportCSV($document_path,$user_id, $export_user_fields = array(), $export_filter = 0);
  40. }
  41. if(!is_null($res)) {
  42. $this->assertTrue(is_bool($res));
  43. }
  44. //var_dump($res);
  45. }
  46. /**
  47. * Exports the complete report as an XLS file
  48. * @return boolean False on error
  49. */
  50. function testexportCompleteReportXLS() {
  51. global $user_id;
  52. $document_path = api_get_path(SYS_COURSE_PATH).'document/';
  53. if(!headers_sent()){
  54. $res = $this->eExerciseResult->exportCompleteReportXLS($document_path='',$user_id, $export_user_fields=array(), $export_filter = 0);
  55. }
  56. if(!is_null($res)) {
  57. $this->assertTrue(is_bool($res));
  58. }
  59. //var_dump($res);
  60. }
  61. }
  62. ?>