tracking.lib.test.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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_avg_student_exercise_score() {
  119. global $_user,$_course;
  120. $student_id=$_user;
  121. $course_code=$_course;
  122. $this->tracking = new Tracking();
  123. $res=$this->tracking->get_avg_student_exercise_score($student_id, $course_code);
  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_progress() {
  129. require_once (api_get_path(LIBRARY_PATH) . 'course.lib.php');
  130. global $_user,$_course;
  131. $this->tracking = new Tracking();
  132. $res = $this->tracking->get_avg_student_progress($_user['user_id'], $_course['cidReq']);
  133. $this->assertWithinMargin(0,100,$res);
  134. $res = $this->tracking->get_avg_student_progress($_user['user_id'], $_course['cidReq'], $_SESSION['id_session']);
  135. $this->assertWithinMargin(0,100,$res);
  136. $res = $this->tracking->get_avg_student_progress(null, $_course['cidReq']);
  137. $this->assertNull($res);
  138. $res = $this->tracking->get_avg_student_progress(array(1,2,3), $_course['cidReq']);
  139. $this->assertWithinMargin(0,100,$res);
  140. // manda un usuario que no existe para entrar en condicion de retorno de 0
  141. $res = $this->tracking->get_avg_student_progress(500, $_course['cidReq']);
  142. $this->assertEqual(0,$res);
  143. $res = $this->tracking->get_avg_student_progress($_user['user_id'], $_course['cidReq'], 0);
  144. $this->assertWithinMargin(0,100,$res);
  145. $res = $this->tracking->get_avg_student_progress($_user['user_id'], $_course['cidReq'], 1);
  146. $this->assertWithinMargin(0,100,$res);
  147. $res = $this->tracking->get_avg_student_progress($_user['user_id'], $_course['cidReq'], 5000);
  148. $this->assertWithinMargin(0,100,$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 testGetInactiveStudentsInCourse() {
  178. global $_course;
  179. $course_code = $_course;
  180. $since='2010-10-02';
  181. $session_id='';
  182. $res=Tracking::getInactiveStudentsInCourse($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 testGetAddtionalProfileInformationOfFieldByUser() {
  270. //ob_start();
  271. $field_id=1;
  272. $users=array(1,2,3);
  273. $res = TrackingCourseLog::get_addtional_profile_information_of_field_by_user($field_id, $users);
  274. $this->assertTrue(is_null($res));
  275. //ob_end_clean();
  276. //var_dump($res);
  277. }
  278. function testGetItemResourcesData() {
  279. //ob_start();
  280. $from=3;
  281. $number_of_items=2;
  282. $column=1;
  283. $direction='ASC';
  284. $res = TrackingCourseLog::get_item_resources_data($from, $number_of_items, $column, $direction);
  285. $this->assertTrue(is_array($res));
  286. //ob_end_clean();
  287. //var_dump($res);
  288. }
  289. function testGetNumberOfUsers() {
  290. //ob_start();
  291. $res = TrackingCourseLog::get_number_of_users();
  292. $this->assertTrue(is_numeric($res));
  293. //ob_end_clean();
  294. //var_dump($res);
  295. }
  296. function testGetToolNameTable() {
  297. //ob_start();
  298. $tool='';
  299. $res = TrackingCourseLog::get_tool_name_table($tool);
  300. $this->assertTrue(is_array($res));
  301. //ob_end_clean();
  302. //var_dump($res);
  303. }
  304. function testGetUserData() {
  305. //ob_start();
  306. $from='';
  307. $number_of_items='';
  308. $column='';
  309. $direction='';
  310. $res = TrackingCourseLog::get_user_data($from, $number_of_items, $column, $direction);
  311. $this->assertTrue(is_array($res));
  312. //ob_end_clean();
  313. //var_dump($res);
  314. }
  315. }
  316. class TestTrackingUserLog extends UnitTestCase {
  317. function testDisplayDocumentTrackingInfo() {
  318. ob_start();
  319. $view = '';
  320. $user_id = 1;
  321. $course_id = 1;
  322. $res = TrackingUserLog::display_document_tracking_info($view, $user_id, $course_id);
  323. $this->assertTrue(is_null($res));
  324. ob_end_clean();
  325. //var_dump($res);
  326. }
  327. function testDisplayExerciseTrackingInfo() {
  328. ob_start();
  329. $view = '';
  330. $user_id = 1;
  331. $courseCode = 'TEST';
  332. $res = TrackingUserLog::display_exercise_tracking_info($view, $user_id, $courseCode);
  333. $this->assertTrue(is_null($res));
  334. ob_end_clean();
  335. //var_dump($res);
  336. }
  337. function testDisplayLinksTrackingInfo() {
  338. ob_start();
  339. $view = '';
  340. $user_id = 1;
  341. $course_id = 1;
  342. $res = TrackingUserLog::display_links_tracking_info($view, $user_id, $course_id);
  343. $this->assertTrue(is_null($res));
  344. ob_end_clean();
  345. //var_dump($res);
  346. }
  347. function testDisplayLoginTrackingInfo() {
  348. ob_start();
  349. $view = '';
  350. $user_id = 1;
  351. $course_id = 1;
  352. $res = TrackingUserLog::display_login_tracking_info($view, $user_id, $course_id);
  353. $this->assertTrue(is_null($res));
  354. ob_end_clean();
  355. //var_dump($res);
  356. }
  357. function testDisplayStudentPublicationsTrackingInfo() {
  358. ob_start();
  359. $view = '';
  360. $user_id = 1;
  361. $course_id = 1;
  362. $res = TrackingUserLog::display_student_publications_tracking_info($view, $user_id, $course_id);
  363. $this->assertTrue(is_null($res));
  364. ob_end_clean();
  365. //var_dump($res);
  366. }
  367. }
  368. class TestTrackingUserLogCSV extends UnitTestCase {
  369. function testDisplayDocumentTrackingInfo() {
  370. //ob_start();
  371. $view = '';
  372. $user_id = 1;
  373. $course_id = 1;
  374. $res = TrackingUserLogCSV::display_document_tracking_info($view, $user_id, $course_id);
  375. $this->assertTrue(is_array($res));
  376. //ob_end_clean();
  377. //var_dump($res);
  378. }
  379. function testDisplayExerciseTrackingInfo() {
  380. //ob_start();
  381. $view = '';
  382. $user_id = 1;
  383. $courseCode = 'TEST';
  384. $res = TrackingUserLogCSV::display_exercise_tracking_info($view, $user_id, $courseCode);
  385. $this->assertTrue(is_array($res));
  386. //ob_end_clean();
  387. //var_dump($res);
  388. }
  389. function testDisplayLinksTrackingInfo() {
  390. //ob_start();
  391. $view = '';
  392. $user_id = 1;
  393. $course_id = 1;
  394. $res = TrackingUserLogCSV::display_links_tracking_info($view, $user_id, $course_id);
  395. $this->assertTrue(is_array($res));
  396. //ob_end_clean();
  397. //var_dump($res);
  398. }
  399. function testDisplayLoginTrackingInfo() {
  400. //ob_start();
  401. $view = '';
  402. $user_id = 1;
  403. $course_id = 1;
  404. $res = TrackingUserLogCSV::display_login_tracking_info($view, $user_id, $course_id);
  405. $this->assertTrue(is_array($res));
  406. //ob_end_clean();
  407. //var_dump($res);
  408. }
  409. function testDisplayStudentPublicationsTrackingInfo() {
  410. //ob_start();
  411. $view = '';
  412. $user_id = 1;
  413. $course_id = 1;
  414. $res = TrackingUserLogCSV::display_student_publications_tracking_info($view, $user_id, $course_id);
  415. $this->assertTrue(is_array($res));
  416. //ob_end_clean();
  417. //var_dump($res);
  418. }
  419. }
  420. ?>