tracking.lib.test.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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 testGetInactiveStudentsInCourse() {
  188. global $_course;
  189. $course_code = $_course;
  190. $since='2010-10-02';
  191. $session_id='';
  192. $res=Tracking::getInactiveStudentsInCourse($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 testGetAddtionalProfileInformationOfFieldByUser() {
  280. //ob_start();
  281. $field_id=1;
  282. $users=array(1,2,3);
  283. $res = TrackingCourseLog::get_addtional_profile_information_of_field_by_user($field_id, $users);
  284. $this->assertTrue(is_null($res));
  285. //ob_end_clean();
  286. //var_dump($res);
  287. }
  288. function testGetItemResourcesData() {
  289. //ob_start();
  290. $from=3;
  291. $number_of_items=2;
  292. $column=1;
  293. $direction='ASC';
  294. $res = TrackingCourseLog::get_item_resources_data($from, $number_of_items, $column, $direction);
  295. $this->assertTrue(is_array($res));
  296. //ob_end_clean();
  297. //var_dump($res);
  298. }
  299. function testGetNumberOfUsers() {
  300. //ob_start();
  301. $res = TrackingCourseLog::get_number_of_users();
  302. $this->assertTrue(is_numeric($res));
  303. //ob_end_clean();
  304. //var_dump($res);
  305. }
  306. function testGetToolNameTable() {
  307. //ob_start();
  308. $tool='';
  309. $res = TrackingCourseLog::get_tool_name_table($tool);
  310. $this->assertTrue(is_array($res));
  311. //ob_end_clean();
  312. //var_dump($res);
  313. }
  314. function testGetUserData() {
  315. //ob_start();
  316. $from='';
  317. $number_of_items='';
  318. $column='';
  319. $direction='';
  320. $res = TrackingCourseLog::get_user_data($from, $number_of_items, $column, $direction);
  321. $this->assertTrue(is_array($res));
  322. //ob_end_clean();
  323. //var_dump($res);
  324. }
  325. }
  326. class TestTrackingUserLog extends UnitTestCase {
  327. function testDisplayDocumentTrackingInfo() {
  328. ob_start();
  329. $view = '';
  330. $user_id = 1;
  331. $course_id = 1;
  332. $res = TrackingUserLog::display_document_tracking_info($view, $user_id, $course_id);
  333. $this->assertTrue(is_null($res));
  334. ob_end_clean();
  335. //var_dump($res);
  336. }
  337. function testDisplayExerciseTrackingInfo() {
  338. ob_start();
  339. $view = '';
  340. $user_id = 1;
  341. $courseCode = 'TEST';
  342. $res = TrackingUserLog::display_exercise_tracking_info($view, $user_id, $courseCode);
  343. $this->assertTrue(is_null($res));
  344. ob_end_clean();
  345. //var_dump($res);
  346. }
  347. function testDisplayLinksTrackingInfo() {
  348. ob_start();
  349. $view = '';
  350. $user_id = 1;
  351. $course_id = 1;
  352. $res = TrackingUserLog::display_links_tracking_info($view, $user_id, $course_id);
  353. $this->assertTrue(is_null($res));
  354. ob_end_clean();
  355. //var_dump($res);
  356. }
  357. function testDisplayLoginTrackingInfo() {
  358. ob_start();
  359. $view = '';
  360. $user_id = 1;
  361. $course_id = 1;
  362. $res = TrackingUserLog::display_login_tracking_info($view, $user_id, $course_id);
  363. $this->assertTrue(is_null($res));
  364. ob_end_clean();
  365. //var_dump($res);
  366. }
  367. function testDisplayStudentPublicationsTrackingInfo() {
  368. ob_start();
  369. $view = '';
  370. $user_id = 1;
  371. $course_id = 1;
  372. $res = TrackingUserLog::display_student_publications_tracking_info($view, $user_id, $course_id);
  373. $this->assertTrue(is_null($res));
  374. ob_end_clean();
  375. //var_dump($res);
  376. }
  377. }
  378. class TestTrackingUserLogCSV extends UnitTestCase {
  379. function testDisplayDocumentTrackingInfo() {
  380. //ob_start();
  381. $view = '';
  382. $user_id = 1;
  383. $course_id = 1;
  384. $res = TrackingUserLogCSV::display_document_tracking_info($view, $user_id, $course_id);
  385. $this->assertTrue(is_array($res));
  386. //ob_end_clean();
  387. //var_dump($res);
  388. }
  389. function testDisplayExerciseTrackingInfo() {
  390. //ob_start();
  391. $view = '';
  392. $user_id = 1;
  393. $courseCode = 'TEST';
  394. $res = TrackingUserLogCSV::display_exercise_tracking_info($view, $user_id, $courseCode);
  395. $this->assertTrue(is_array($res));
  396. //ob_end_clean();
  397. //var_dump($res);
  398. }
  399. function testDisplayLinksTrackingInfo() {
  400. //ob_start();
  401. $view = '';
  402. $user_id = 1;
  403. $course_id = 1;
  404. $res = TrackingUserLogCSV::display_links_tracking_info($view, $user_id, $course_id);
  405. $this->assertTrue(is_array($res));
  406. //ob_end_clean();
  407. //var_dump($res);
  408. }
  409. function testDisplayLoginTrackingInfo() {
  410. //ob_start();
  411. $view = '';
  412. $user_id = 1;
  413. $course_id = 1;
  414. $res = TrackingUserLogCSV::display_login_tracking_info($view, $user_id, $course_id);
  415. $this->assertTrue(is_array($res));
  416. //ob_end_clean();
  417. //var_dump($res);
  418. }
  419. function testDisplayStudentPublicationsTrackingInfo() {
  420. //ob_start();
  421. $view = '';
  422. $user_id = 1;
  423. $course_id = 1;
  424. $res = TrackingUserLogCSV::display_student_publications_tracking_info($view, $user_id, $course_id);
  425. $this->assertTrue(is_array($res));
  426. //ob_end_clean();
  427. //var_dump($res);
  428. }
  429. }
  430. ?>