tracking.lib.test.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <?php
  2. require_once(api_get_path(LIBRARY_PATH).'tracking.lib.php');
  3. require_once(api_get_path(LIBRARY_PATH).'document.lib.php');
  4. class TestTracking extends UnitTestCase {
  5. function testget_first_connection_date() {
  6. global $_user;
  7. $student_id=$_user;
  8. $res=Tracking::get_first_connection_date($student_id);
  9. if(!is_bool($res)){
  10. $this->assertTrue(is_string($res));
  11. }
  12. }
  13. function testget_first_connection_date_on_the_course() {
  14. global $_course;
  15. $student_id='';
  16. $course_code=$_course;
  17. $res=Tracking::get_first_connection_date_on_the_course($student_id, $course_code);
  18. if(!is_null($res))$this->assertTrue(is_bool($res));
  19. //var_dump($res);
  20. }
  21. function testchat_connections_during_last_x_days_by_course() {
  22. global $_course;
  23. $course_code=$_course;
  24. $last_days=8;
  25. $this->tracking = new Tracking();
  26. $res=$this->tracking->chat_connections_during_last_x_days_by_course($course_code,$last_days);
  27. $this->assertTrue(is_object($this->tracking));
  28. if(!is_numeric($res))$this->assertTrue(is_null($res));
  29. //var_dump($docman);
  30. }
  31. function testcount_course_per_student() {
  32. $user_id=1;
  33. $this->tracking = new Tracking();
  34. $res=$this->tracking->count_course_per_student($user_id);
  35. $this->assertTrue(is_object($this->tracking));
  36. $this->assertTrue(is_numeric($res));
  37. //var_dump($res);
  38. }
  39. function testcount_login_per_student() {
  40. $student_id=1;
  41. $course_code=001;
  42. $this->tracking = new Tracking();
  43. $res=$this->tracking->count_login_per_student($student_id, $course_code);
  44. $this->assertTrue(is_object($this->tracking));
  45. $this->assertTrue(is_numeric($res));
  46. //var_dump($res);
  47. }
  48. function testcount_number_of_forums_by_course() {
  49. global $_course;
  50. $course_code=$_course;
  51. $this->tracking = new Tracking();
  52. $res=$this->tracking->count_number_of_forums_by_course($course_code);
  53. $this->assertTrue(is_object($this->tracking));
  54. if(!is_numeric($res))$this->assertTrue(is_null($res));
  55. //var_dump($res);
  56. }
  57. function testcount_number_of_posts_by_course() {
  58. global $_course;
  59. $course_code=$_course;
  60. $this->tracking = new Tracking();
  61. $res=$this->tracking->count_number_of_posts_by_course($course_code);
  62. $this->assertTrue(is_object($this->tracking));
  63. if(!is_numeric($res))$this->assertTrue(is_null($res));
  64. //var_dump($res);
  65. }
  66. function testcount_number_of_threads_by_course() {
  67. global $_course;
  68. $course_code=$_course;
  69. $this->tracking = new Tracking();
  70. $res=$this->tracking->count_number_of_threads_by_course($course_code);
  71. $this->assertTrue(is_object($this->tracking));
  72. if(!is_numeric($res))$this->assertTrue(is_null($res));
  73. //var_dump($res);
  74. }
  75. function testcount_student_assignments() {
  76. require_once (api_get_path(LIBRARY_PATH) . 'course.lib.php');
  77. global $_user,$_course;
  78. $student_id=$_user;
  79. $course_code=$_course;
  80. $a_course = CourseManager :: get_course_information($course_code);
  81. $this->tracking = new Tracking();
  82. $res=$this->tracking->count_student_assignments($student_id, $course_code);
  83. $this->assertTrue(is_object($this->tracking));
  84. if(!is_numeric($res))$this->assertTrue(is_null($res));
  85. //var_dump($res);
  86. }
  87. function testcount_student_downloaded_documents() {
  88. global $_user,$_course;
  89. $student_id=$_user;
  90. $course_code=$_course;
  91. $this->tracking = new Tracking();
  92. $res=$this->tracking->count_student_downloaded_documents($student_id, $course_code);
  93. $this->assertTrue(is_object($this->tracking));
  94. if(!is_numeric($res))$this->assertTrue(is_null($res));
  95. //var_dump($res);
  96. }
  97. function testcount_student_messages() {
  98. require_once (api_get_path(LIBRARY_PATH) . 'course.lib.php');
  99. global $_user,$_course;
  100. $student_id=$_user;
  101. $course_code=$_course;
  102. $a_course = CourseManager :: get_course_information($course_code);
  103. $this->tracking = new Tracking();
  104. $res=$this->tracking->count_student_messages($student_id, $course_code);
  105. $this->assertTrue(is_object($this->tracking));
  106. if(!is_numeric($res))$this->assertTrue(is_null($res));
  107. //var_dump($res);
  108. }
  109. function testcount_student_visited_links() {
  110. global $_user,$_course;
  111. $student_id=$_user;
  112. $course_code=$_course;
  113. $this->tracking = new Tracking();
  114. $res=$this->tracking->count_student_visited_links($student_id, $course_code);
  115. $this->assertTrue(is_object($this->tracking));
  116. if(!is_numeric($res))$this->assertTrue(is_null($res));
  117. //var_dump($res);
  118. }
  119. function testget_average_test_scorm_and_lp () {
  120. global $_user,$_course;
  121. $user_id=$_user;
  122. $course_id=$_course;
  123. $this->tracking = new Tracking();
  124. $res=$this->tracking->get_average_test_scorm_and_lp($user_id,$course_id);
  125. $this->assertTrue(is_object($this->tracking));
  126. if(!is_numeric($res))$this->assertTrue(is_null($res));
  127. //var_dump($res);
  128. }
  129. function testget_avg_student_exercise_score() {
  130. global $_user,$_course;
  131. $student_id=$_user;
  132. $course_code=$_course;
  133. $this->tracking = new Tracking();
  134. $res=$this->tracking->get_avg_student_exercise_score($student_id, $course_code);
  135. $this->assertTrue(is_object($this->tracking));
  136. if(!is_numeric($res))$this->assertTrue(is_null($res));
  137. //var_dump($res);
  138. }
  139. function testget_avg_student_progress() {
  140. require_once (api_get_path(LIBRARY_PATH) . 'course.lib.php');
  141. global $_user,$_course;
  142. $student_id=$_user;
  143. $course_code=$_course;
  144. $this->tracking = new Tracking();
  145. $res=$this->tracking->get_avg_student_progress($student_id, $course_code);
  146. $this->assertTrue(is_object($this->tracking));
  147. if(!is_numeric($res))$this->assertTrue(is_null($res));
  148. //var_dump($res);
  149. }
  150. function testget_avg_student_score() {
  151. global $_user,$_course;
  152. $student_id=$_user;
  153. $course_code=$_course;
  154. $res=$this->tracking->get_avg_student_score($student_id, $course_code, $lp_ids=array());
  155. if(!is_string($res))$this->assertTrue(is_null($res));
  156. //var_dump($res);
  157. }
  158. function testget_course_list_in_session_from_student() {
  159. global $_user;
  160. $user_id = $_user;
  161. $session_id= 1;
  162. $res=Tracking::get_course_list_in_session_from_student($user_id, $session_id);
  163. $this->assertTrue(is_array($res));
  164. }
  165. function testget_courses_followed_by_coach() {
  166. $coach_id='';
  167. $res=Tracking::get_courses_followed_by_coach($coach_id, $id_session='');
  168. if(!is_null($res))$this->assertTrue(is_array($res));
  169. //var_dump($res);
  170. }
  171. function testget_courses_list_from_session() {
  172. $session_id='';
  173. $res=Tracking::get_courses_list_from_session($session_id);
  174. if(!is_null($res))$this->assertTrue(is_array($res));
  175. //var_dump($res);
  176. }
  177. function testget_inactives_students_in_course() {
  178. global $_course;
  179. $course_code = $_course;
  180. $since='2010-10-02';
  181. $session_id='';
  182. $res=Tracking::get_inactives_students_in_course($course_code, $since, $session_id);
  183. if(!is_null($res))$this->assertTrue(is_array($res));
  184. //var_dump($res);
  185. }
  186. function testget_sessions_coached_by_user() {
  187. $coach_id='';
  188. $res=Tracking::get_sessions_coached_by_user($coach_id);
  189. if(!is_null($res))$this->assertTrue(is_array($res));
  190. //var_dump($res);
  191. }
  192. function testget_student_followed_by_coach() {
  193. $coach_id='';
  194. $res=Tracking::get_student_followed_by_coach($coach_id);
  195. if(!is_null($res))$this->assertTrue(is_array($res));
  196. //var_dump($res);
  197. }
  198. function testget_student_followed_by_coach_in_a_session() {
  199. $id_session='';
  200. $coach_id='';
  201. $res=Tracking::get_student_followed_by_coach_in_a_session($id_session, $coach_id);
  202. if(!is_null($res))$this->assertTrue(is_array($res));
  203. //var_dump($res);
  204. }
  205. function testget_student_followed_by_drh() {
  206. $hr_dept_id='';
  207. $res=Tracking::get_student_followed_by_drh($hr_dept_id);
  208. if(!is_null($res))$this->assertTrue(is_array($res));
  209. //var_dump($res);
  210. }
  211. function testget_time_spent_on_the_course() {
  212. $user_id='';
  213. $course_code='';
  214. $res=Tracking::get_time_spent_on_the_course($user_id, $course_code);
  215. if(!is_null($res))$this->assertTrue(is_numeric($res));
  216. //var_dump($res);
  217. }
  218. function testget_time_spent_on_the_platform(){
  219. $user_id='';
  220. $res=Tracking::get_time_spent_on_the_platform($user_id);
  221. if(!is_null($res))$this->assertTrue(is_numeric($res));
  222. //var_dump($res);
  223. }
  224. function testis_allowed_to_coach_student() {
  225. $coach_id='';
  226. $student_id='';
  227. $res=Tracking::is_allowed_to_coach_student($coach_id, $student_id);
  228. if(!is_null($res))$this->assertTrue(is_bool($res));
  229. //var_dump($res);
  230. }
  231. function testchat_last_connection() {
  232. require_once (api_get_path(LIBRARY_PATH) . 'course.lib.php');
  233. global $_course;
  234. $student_id= $_POST['student_id'];
  235. $course_code= $_course;
  236. $this->tracking = new Tracking();
  237. $res=$this->tracking->chat_last_connection($student_id,$course_code);
  238. $this->assertTrue(is_object($this->tracking));
  239. if(!is_string($res))$this->assertTrue(is_null($res));
  240. }
  241. function testget_last_connection_date() {
  242. $student_id=1;
  243. $res=Tracking::get_last_connection_date($student_id);
  244. if(!is_bool($res))$this->assertTrue(is_string($res));
  245. }
  246. function testget_last_connection_date_on_the_course() {
  247. $student_id='';
  248. $course_code='';
  249. $res=Tracking::get_last_connection_date_on_the_course($student_id, $course_code);
  250. if(!is_null($res))$this->assertTrue(is_bool($res));
  251. //var_dump($res);
  252. }
  253. }
  254. class TestTrackingCourseLog extends UnitTestCase {
  255. function testCountItemResources() {
  256. //ob_start();
  257. $res = TrackingCourseLog::count_item_resources();
  258. $this->assertTrue(is_numeric($res));
  259. //ob_end_clean();
  260. //var_dump($res);
  261. }
  262. function testDisplayAdditionalProfileFields() {
  263. //ob_start();
  264. $res = TrackingCourseLog::display_additional_profile_fields();
  265. $this->assertTrue(is_string($res));
  266. //ob_end_clean();
  267. //var_dump($res);
  268. }
  269. function testGetAddtionalProfileInformationOfField() {
  270. //ob_start();
  271. $field_id=1;
  272. $res = TrackingCourseLog::get_addtional_profile_information_of_field($field_id);
  273. $this->assertTrue(is_null($res));
  274. //ob_end_clean();
  275. //var_dump($res);
  276. }
  277. function testGetAddtionalProfileInformationOfFieldByUser() {
  278. //ob_start();
  279. $field_id=1;
  280. $users=array(1,2,3);
  281. $res = TrackingCourseLog::get_addtional_profile_information_of_field_by_user($field_id, $users);
  282. $this->assertTrue(is_null($res));
  283. //ob_end_clean();
  284. //var_dump($res);
  285. }
  286. function testGetItemResourcesData() {
  287. //ob_start();
  288. $from=3;
  289. $number_of_items=2;
  290. $column=1;
  291. $direction='ASC';
  292. $res = TrackingCourseLog::get_item_resources_data($from, $number_of_items, $column, $direction);
  293. $this->assertTrue(is_array($res));
  294. //ob_end_clean();
  295. //var_dump($res);
  296. }
  297. function testGetNumberOfUsers() {
  298. //ob_start();
  299. $res = TrackingCourseLog::get_number_of_users();
  300. $this->assertTrue(is_numeric($res));
  301. //ob_end_clean();
  302. //var_dump($res);
  303. }
  304. function testGetToolNameTable() {
  305. //ob_start();
  306. $tool='';
  307. $res = TrackingCourseLog::get_tool_name_table($tool);
  308. $this->assertTrue(is_array($res));
  309. //ob_end_clean();
  310. //var_dump($res);
  311. }
  312. function testGetUserData() {
  313. //ob_start();
  314. $from='';
  315. $number_of_items='';
  316. $column='';
  317. $direction='';
  318. $res = TrackingCourseLog::get_user_data($from, $number_of_items, $column, $direction);
  319. $this->assertTrue(is_array($res));
  320. //ob_end_clean();
  321. //var_dump($res);
  322. }
  323. }
  324. class TestTrackingUserLog extends UnitTestCase {
  325. function testDisplayDocumentTrackingInfo() {
  326. ob_start();
  327. $view = '';
  328. $user_id = 1;
  329. $course_id = 1;
  330. $res = TrackingUserLog::display_document_tracking_info($view, $user_id, $course_id);
  331. $this->assertTrue(is_null($res));
  332. ob_end_clean();
  333. //var_dump($res);
  334. }
  335. function testDisplayExerciseTrackingInfo() {
  336. ob_start();
  337. $view = '';
  338. $user_id = 1;
  339. $course_id = 1;
  340. $res = TrackingUserLog::display_exercise_tracking_info($view, $user_id, $course_id);
  341. $this->assertTrue(is_null($res));
  342. ob_end_clean();
  343. //var_dump($res);
  344. }
  345. function testDisplayLinksTrackingInfo() {
  346. ob_start();
  347. $view = '';
  348. $user_id = 1;
  349. $course_id = 1;
  350. $res = TrackingUserLog::display_links_tracking_info($view, $user_id, $course_id);
  351. $this->assertTrue(is_null($res));
  352. ob_end_clean();
  353. //var_dump($res);
  354. }
  355. function testDisplayLoginTrackingInfo() {
  356. ob_start();
  357. $view = '';
  358. $user_id = 1;
  359. $course_id = 1;
  360. $res = TrackingUserLog::display_login_tracking_info($view, $user_id, $course_id);
  361. $this->assertTrue(is_null($res));
  362. ob_end_clean();
  363. //var_dump($res);
  364. }
  365. function testDisplayStudentPublicationsTrackingInfo() {
  366. ob_start();
  367. $view = '';
  368. $user_id = 1;
  369. $course_id = 1;
  370. $res = TrackingUserLog::display_student_publications_tracking_info($view, $user_id, $course_id);
  371. $this->assertTrue(is_null($res));
  372. ob_end_clean();
  373. //var_dump($res);
  374. }
  375. }
  376. class TestTrackingUserLogCSV extends UnitTestCase {
  377. function testDisplayDocumentTrackingInfo() {
  378. //ob_start();
  379. $view = '';
  380. $user_id = 1;
  381. $course_id = 1;
  382. $res = TrackingUserLogCSV::display_document_tracking_info($view, $user_id, $course_id);
  383. $this->assertTrue(is_array($res));
  384. //ob_end_clean();
  385. //var_dump($res);
  386. }
  387. function testDisplayExerciseTrackingInfo() {
  388. //ob_start();
  389. $view = '';
  390. $user_id = 1;
  391. $course_id = 1;
  392. $res = TrackingUserLogCSV::display_exercise_tracking_info($view, $user_id, $course_id);
  393. $this->assertTrue(is_array($res));
  394. //ob_end_clean();
  395. //var_dump($res);
  396. }
  397. function testDisplayLinksTrackingInfo() {
  398. //ob_start();
  399. $view = '';
  400. $user_id = 1;
  401. $course_id = 1;
  402. $res = TrackingUserLogCSV::display_links_tracking_info($view, $user_id, $course_id);
  403. $this->assertTrue(is_array($res));
  404. //ob_end_clean();
  405. //var_dump($res);
  406. }
  407. function testDisplayLoginTrackingInfo() {
  408. //ob_start();
  409. $view = '';
  410. $user_id = 1;
  411. $course_id = 1;
  412. $res = TrackingUserLogCSV::display_login_tracking_info($view, $user_id, $course_id);
  413. $this->assertTrue(is_array($res));
  414. //ob_end_clean();
  415. //var_dump($res);
  416. }
  417. function testDisplayStudentPublicationsTrackingInfo() {
  418. //ob_start();
  419. $view = '';
  420. $user_id = 1;
  421. $course_id = 1;
  422. $res = TrackingUserLogCSV::display_student_publications_tracking_info($view, $user_id, $course_id);
  423. $this->assertTrue(is_array($res));
  424. //ob_end_clean();
  425. //var_dump($res);
  426. }
  427. }
  428. ?>