tracking.lib.test.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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. $res=Tracking::count_student_messages($student_id, $course_code);
  104. $this->assertTrue(is_object($this->tracking));
  105. if(!is_numeric($res))$this->assertTrue(is_null($res));
  106. //var_dump($res);
  107. }
  108. function testcount_student_visited_links() {
  109. global $_user,$_course;
  110. $student_id=$_user;
  111. $course_code=$_course;
  112. $this->tracking = new Tracking();
  113. $res=$this->tracking->count_student_visited_links($student_id, $course_code);
  114. $this->assertTrue(is_object($this->tracking));
  115. if(!is_numeric($res))$this->assertTrue(is_null($res));
  116. //var_dump($res);
  117. }
  118. function testget_average_test_scorm_and_lp () {
  119. global $_user,$_course;
  120. $user_id=$_user;
  121. $course_id=$_course;
  122. $this->tracking = new Tracking();
  123. $res=$this->tracking->get_average_test_scorm_and_lp($user_id,$course_id);
  124. $this->assertTrue(is_object($this->tracking));
  125. if(!is_numeric($res))$this->assertTrue(is_null($res));
  126. //var_dump($res);
  127. }
  128. function testget_avg_student_exercise_score() {
  129. global $_user,$_course;
  130. $student_id=$_user;
  131. $course_code=$_course;
  132. $this->tracking = new Tracking();
  133. $res=$this->tracking->get_avg_student_exercise_score($student_id, $course_code);
  134. $this->assertTrue(is_object($this->tracking));
  135. if(!is_numeric($res))$this->assertTrue(is_null($res));
  136. //var_dump($res);
  137. }
  138. function testget_avg_student_progress() {
  139. require_once (api_get_path(LIBRARY_PATH) . 'course.lib.php');
  140. global $_user,$_course;
  141. $this->tracking = new Tracking();
  142. $res = $this->tracking->get_avg_student_progress($_user['user_id'], $_course['cidReq']);
  143. $this->assertWithinMargin(0,100,$res);
  144. $res = $this->tracking->get_avg_student_progress($_user['user_id'], $_course['cidReq'], $_SESSION['id_session']);
  145. $this->assertWithinMargin(0,100,$res);
  146. $res = $this->tracking->get_avg_student_progress(null, $_course['cidReq']);
  147. $this->assertNull($res);
  148. $res = $this->tracking->get_avg_student_progress(array(1,2,3), $_course['cidReq']);
  149. $this->assertWithinMargin(0,100,$res);
  150. // manda un usuario que no existe para entrar en condicion de retorno de 0
  151. $res = $this->tracking->get_avg_student_progress(500, $_course['cidReq']);
  152. $this->assertEqual(0,$res);
  153. $res = $this->tracking->get_avg_student_progress($_user['user_id'], $_course['cidReq'], 0);
  154. $this->assertWithinMargin(0,100,$res);
  155. $res = $this->tracking->get_avg_student_progress($_user['user_id'], $_course['cidReq'], 1);
  156. $this->assertWithinMargin(0,100,$res);
  157. $res = $this->tracking->get_avg_student_progress($_user['user_id'], $_course['cidReq'], 5000);
  158. $this->assertWithinMargin(0,100,$res);
  159. }
  160. function testget_avg_student_score() {
  161. global $_user,$_course;
  162. $student_id=$_user;
  163. $course_code=$_course;
  164. $res=$this->tracking->get_avg_student_score($student_id, $course_code, $lp_ids=array());
  165. if(!is_string($res))$this->assertTrue(is_null($res));
  166. //var_dump($res);
  167. }
  168. function testget_course_list_in_session_from_student() {
  169. global $_user;
  170. $user_id = $_user;
  171. $session_id= 1;
  172. $res=Tracking::get_course_list_in_session_from_student($user_id, $session_id);
  173. $this->assertTrue(is_array($res));
  174. }
  175. function testget_courses_followed_by_coach() {
  176. $coach_id='';
  177. $res=Tracking::get_courses_followed_by_coach($coach_id, $id_session='');
  178. if(!is_null($res))$this->assertTrue(is_array($res));
  179. //var_dump($res);
  180. }
  181. function testget_courses_list_from_session() {
  182. $session_id='';
  183. $res=Tracking::get_courses_list_from_session($session_id);
  184. if(!is_null($res))$this->assertTrue(is_array($res));
  185. //var_dump($res);
  186. }
  187. function testget_inactives_students_in_course() {
  188. global $_course;
  189. $course_code = $_course;
  190. $since='2010-10-02';
  191. $session_id='';
  192. $res=Tracking::get_inactives_students_in_course($course_code, $since, $session_id);
  193. if(!is_null($res))$this->assertTrue(is_array($res));
  194. //var_dump($res);
  195. }
  196. function testget_sessions_coached_by_user() {
  197. $coach_id='';
  198. $res=Tracking::get_sessions_coached_by_user($coach_id);
  199. if(!is_null($res))$this->assertTrue(is_array($res));
  200. //var_dump($res);
  201. }
  202. function testget_student_followed_by_coach() {
  203. $coach_id='';
  204. $res=Tracking::get_student_followed_by_coach($coach_id);
  205. if(!is_null($res))$this->assertTrue(is_array($res));
  206. //var_dump($res);
  207. }
  208. function testget_student_followed_by_coach_in_a_session() {
  209. $id_session='';
  210. $coach_id='';
  211. $res=Tracking::get_student_followed_by_coach_in_a_session($id_session, $coach_id);
  212. if(!is_null($res))$this->assertTrue(is_array($res));
  213. //var_dump($res);
  214. }
  215. function testget_student_followed_by_drh() {
  216. $hr_dept_id='';
  217. $res=Tracking::get_student_followed_by_drh($hr_dept_id);
  218. if(!is_null($res))$this->assertTrue(is_array($res));
  219. //var_dump($res);
  220. }
  221. function testget_time_spent_on_the_course() {
  222. $user_id='';
  223. $course_code='';
  224. $res=Tracking::get_time_spent_on_the_course($user_id, $course_code);
  225. if(!is_null($res))$this->assertTrue(is_numeric($res));
  226. //var_dump($res);
  227. }
  228. function testget_time_spent_on_the_platform(){
  229. $user_id='';
  230. $res=Tracking::get_time_spent_on_the_platform($user_id);
  231. if(!is_null($res))$this->assertTrue(is_numeric($res));
  232. //var_dump($res);
  233. }
  234. function testis_allowed_to_coach_student() {
  235. $coach_id='';
  236. $student_id='';
  237. $res=Tracking::is_allowed_to_coach_student($coach_id, $student_id);
  238. if(!is_null($res))$this->assertTrue(is_bool($res));
  239. //var_dump($res);
  240. }
  241. function testchat_last_connection() {
  242. require_once (api_get_path(LIBRARY_PATH) . 'course.lib.php');
  243. global $_course;
  244. $student_id= $_POST['student_id'];
  245. $course_code= $_course;
  246. $this->tracking = new Tracking();
  247. $res=$this->tracking->chat_last_connection($student_id,$course_code);
  248. $this->assertTrue(is_object($this->tracking));
  249. if(!is_string($res))$this->assertTrue(is_null($res));
  250. }
  251. function testget_last_connection_date() {
  252. $student_id=1;
  253. $res=Tracking::get_last_connection_date($student_id);
  254. if(!is_bool($res))$this->assertTrue(is_string($res));
  255. }
  256. function testget_last_connection_date_on_the_course() {
  257. $student_id='';
  258. $course_code='';
  259. $res=Tracking::get_last_connection_date_on_the_course($student_id, $course_code);
  260. if(!is_null($res))$this->assertTrue(is_bool($res));
  261. //var_dump($res);
  262. }
  263. }
  264. class TestTrackingCourseLog extends UnitTestCase {
  265. function testCountItemResources() {
  266. //ob_start();
  267. $res = TrackingCourseLog::count_item_resources();
  268. $this->assertTrue(is_numeric($res));
  269. //ob_end_clean();
  270. //var_dump($res);
  271. }
  272. function testDisplayAdditionalProfileFields() {
  273. //ob_start();
  274. $res = TrackingCourseLog::display_additional_profile_fields();
  275. $this->assertTrue(is_string($res));
  276. //ob_end_clean();
  277. //var_dump($res);
  278. }
  279. function testGetAddtionalProfileInformationOfField() {
  280. //ob_start();
  281. $field_id=1;
  282. $res = TrackingCourseLog::get_addtional_profile_information_of_field($field_id);
  283. $this->assertTrue(is_null($res));
  284. //ob_end_clean();
  285. //var_dump($res);
  286. }
  287. function testGetAddtionalProfileInformationOfFieldByUser() {
  288. //ob_start();
  289. $field_id=1;
  290. $users=array(1,2,3);
  291. $res = TrackingCourseLog::get_addtional_profile_information_of_field_by_user($field_id, $users);
  292. $this->assertTrue(is_null($res));
  293. //ob_end_clean();
  294. //var_dump($res);
  295. }
  296. function testGetItemResourcesData() {
  297. //ob_start();
  298. $from=3;
  299. $number_of_items=2;
  300. $column=1;
  301. $direction='ASC';
  302. $res = TrackingCourseLog::get_item_resources_data($from, $number_of_items, $column, $direction);
  303. $this->assertTrue(is_array($res));
  304. //ob_end_clean();
  305. //var_dump($res);
  306. }
  307. function testGetNumberOfUsers() {
  308. //ob_start();
  309. $res = TrackingCourseLog::get_number_of_users();
  310. $this->assertTrue(is_numeric($res));
  311. //ob_end_clean();
  312. //var_dump($res);
  313. }
  314. function testGetToolNameTable() {
  315. //ob_start();
  316. $tool='';
  317. $res = TrackingCourseLog::get_tool_name_table($tool);
  318. $this->assertTrue(is_array($res));
  319. //ob_end_clean();
  320. //var_dump($res);
  321. }
  322. function testGetUserData() {
  323. //ob_start();
  324. $from='';
  325. $number_of_items='';
  326. $column='';
  327. $direction='';
  328. $res = TrackingCourseLog::get_user_data($from, $number_of_items, $column, $direction);
  329. $this->assertTrue(is_array($res));
  330. //ob_end_clean();
  331. //var_dump($res);
  332. }
  333. }
  334. class TestTrackingUserLog extends UnitTestCase {
  335. function testDisplayDocumentTrackingInfo() {
  336. ob_start();
  337. $view = '';
  338. $user_id = 1;
  339. $course_id = 1;
  340. $res = TrackingUserLog::display_document_tracking_info($view, $user_id, $course_id);
  341. $this->assertTrue(is_null($res));
  342. ob_end_clean();
  343. //var_dump($res);
  344. }
  345. function testDisplayExerciseTrackingInfo() {
  346. ob_start();
  347. $view = '';
  348. $user_id = 1;
  349. $course_id = 1;
  350. $res = TrackingUserLog::display_exercise_tracking_info($view, $user_id, $course_id);
  351. $this->assertTrue(is_null($res));
  352. ob_end_clean();
  353. //var_dump($res);
  354. }
  355. function testDisplayLinksTrackingInfo() {
  356. ob_start();
  357. $view = '';
  358. $user_id = 1;
  359. $course_id = 1;
  360. $res = TrackingUserLog::display_links_tracking_info($view, $user_id, $course_id);
  361. $this->assertTrue(is_null($res));
  362. ob_end_clean();
  363. //var_dump($res);
  364. }
  365. function testDisplayLoginTrackingInfo() {
  366. ob_start();
  367. $view = '';
  368. $user_id = 1;
  369. $course_id = 1;
  370. $res = TrackingUserLog::display_login_tracking_info($view, $user_id, $course_id);
  371. $this->assertTrue(is_null($res));
  372. ob_end_clean();
  373. //var_dump($res);
  374. }
  375. function testDisplayStudentPublicationsTrackingInfo() {
  376. ob_start();
  377. $view = '';
  378. $user_id = 1;
  379. $course_id = 1;
  380. $res = TrackingUserLog::display_student_publications_tracking_info($view, $user_id, $course_id);
  381. $this->assertTrue(is_null($res));
  382. ob_end_clean();
  383. //var_dump($res);
  384. }
  385. }
  386. class TestTrackingUserLogCSV extends UnitTestCase {
  387. function testDisplayDocumentTrackingInfo() {
  388. //ob_start();
  389. $view = '';
  390. $user_id = 1;
  391. $course_id = 1;
  392. $res = TrackingUserLogCSV::display_document_tracking_info($view, $user_id, $course_id);
  393. $this->assertTrue(is_array($res));
  394. //ob_end_clean();
  395. //var_dump($res);
  396. }
  397. function testDisplayExerciseTrackingInfo() {
  398. //ob_start();
  399. $view = '';
  400. $user_id = 1;
  401. $course_id = 1;
  402. $res = TrackingUserLogCSV::display_exercise_tracking_info($view, $user_id, $course_id);
  403. $this->assertTrue(is_array($res));
  404. //ob_end_clean();
  405. //var_dump($res);
  406. }
  407. function testDisplayLinksTrackingInfo() {
  408. //ob_start();
  409. $view = '';
  410. $user_id = 1;
  411. $course_id = 1;
  412. $res = TrackingUserLogCSV::display_links_tracking_info($view, $user_id, $course_id);
  413. $this->assertTrue(is_array($res));
  414. //ob_end_clean();
  415. //var_dump($res);
  416. }
  417. function testDisplayLoginTrackingInfo() {
  418. //ob_start();
  419. $view = '';
  420. $user_id = 1;
  421. $course_id = 1;
  422. $res = TrackingUserLogCSV::display_login_tracking_info($view, $user_id, $course_id);
  423. $this->assertTrue(is_array($res));
  424. //ob_end_clean();
  425. //var_dump($res);
  426. }
  427. function testDisplayStudentPublicationsTrackingInfo() {
  428. //ob_start();
  429. $view = '';
  430. $user_id = 1;
  431. $course_id = 1;
  432. $res = TrackingUserLogCSV::display_student_publications_tracking_info($view, $user_id, $course_id);
  433. $this->assertTrue(is_array($res));
  434. //ob_end_clean();
  435. //var_dump($res);
  436. }
  437. }
  438. ?>