scorm.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. $reports_modules['scorm'] = array();
  3. function reports_modules_scorm_init()
  4. {
  5. }
  6. function reports_modules_scorm_init_forEachCourses($course_code, $course_id, $course_db)
  7. {
  8. global $reports_modules;
  9. $reports_modules_scorm_toolid = reports_getToolId(TOOL_LEARNPATH);
  10. // package level
  11. array_push($reports_modules['scorm'],
  12. array(
  13. 'keys_query' =>
  14. 'select '.$course_id.' as course_id, '.
  15. $reports_modules_scorm_toolid.' as tool_id, '.
  16. 'lp.id as child_id, lp.name as child_name, '.
  17. "'".$course_db."'".' as course_db from '.
  18. Database::get_course_table(TABLE_LP_MAIN).' lp',
  19. 'values_query_function' => 'reports_modules_scorm_packageVal'
  20. ));
  21. // sco level
  22. array_push($reports_modules['scorm'],
  23. array(
  24. 'keys_query' =>
  25. 'select '.$course_id.' as course_id, '.
  26. $reports_modules_scorm_toolid.' as tool_id, '.
  27. 'lp.id as child_id, lp.name as child_name, '.
  28. 'lpi.id as subchild_id, lpi.title as subchild_name, '.
  29. "'".$course_db."'".' as course_db from '.
  30. Database::get_course_table(TABLE_LP_MAIN, $course_db).
  31. ' lp,'.
  32. Database::get_course_table(TABLE_LP_ITEM, $course_db).
  33. ' lpi where lp.id = lpi.lp_id',
  34. 'values_query_function' => 'reports_modules_scorm_scoVal'
  35. ));
  36. // objectives level
  37. array_push($reports_modules['scorm'],
  38. array(
  39. 'keys_query' =>
  40. 'select distinct '.$course_id.' as course_id, '.
  41. $reports_modules_scorm_toolid.' as tool_id, '.
  42. 'lp.id as child_id, lp.name as child_name, '.
  43. 'lpi.id as subchild_id, '.
  44. 'lpi.title as subchild_name, '.
  45. 'null as subsubchild_id, '.
  46. 'lpivo.objective_id as subsubchild_name, '.
  47. "'".$course_db."'".' as course_db from '.
  48. Database::get_course_table(TABLE_LP_MAIN, $course_db).
  49. ' lp,'.
  50. Database::get_course_table(TABLE_LP_ITEM, $course_db).
  51. ' lpi, '.
  52. Database::get_course_table(TABLE_LP_ITEM_VIEW, $course_db).
  53. ' lpiv, '.
  54. Database::get_course_table(TABLE_LP_IV_OBJECTIVE, $course_db).
  55. ' lpivo '.
  56. 'where lp.id = lpi.lp_id '.
  57. 'and lpi.id = lpiv.lp_item_id '.
  58. 'and lpiv.id = lpivo.lp_iv_id ',
  59. 'values_query_function' => 'reports_modules_scorm_objVal'
  60. ));
  61. }
  62. function reports_modules_scorm_packageVal($scorm, $key_id)
  63. {
  64. return array(
  65. 'type' => 'sql',
  66. 'sql' =>
  67. 'select '.$key_id.', user_id as uid, '.
  68. 'session_id, view_count as attempt, null as score, '.
  69. 'progress as progress, '.
  70. 'null as time, null as ts from '.
  71. Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']).
  72. ' where lp_id = '.$scorm['child_id']
  73. );
  74. }
  75. function reports_modules_scorm_scoVal($scorm, $key_id)
  76. {
  77. return array(
  78. 'type' => 'sql',
  79. 'sql' =>
  80. 'select '.$key_id.', lpv.user_id as uid, '.
  81. 'lpv.session_id, lpiv.view_count as attempt, '.
  82. 'lpiv.score as score, '.
  83. '(case lpiv.status '.
  84. 'when "incomplete" then 0 '.
  85. 'when "completed" then 1 '.
  86. 'when "passed" then 2 '.
  87. 'when "failed" then 3 '.
  88. 'when "browsed" then 4 '.
  89. 'when "not attempted" then 5 '.
  90. 'else 6 '.
  91. 'end) as progress, '.
  92. 'lpiv.total_time as time, null as ts from '.
  93. Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']).
  94. ' lpv, '.
  95. Database::get_course_table(TABLE_LP_ITEM_VIEW, $scorm['course_db']).
  96. ' lpiv '.
  97. ' where lpv.lp_id = '.$scorm['child_id'].
  98. ' and lpiv.lp_item_id = '.$scorm['subchild_id'].
  99. ' and lpiv.lp_view_id = lpv.id'
  100. );
  101. }
  102. function reports_modules_scorm_objVal($scorm, $key_id)
  103. {
  104. return array(
  105. 'type' => 'sql',
  106. 'sql' =>
  107. 'select '.$key_id.', lpv.user_id as uid, '.
  108. 'lpv.session_id, lpiv.view_count as attempt, '.
  109. 'lpivo.score_raw as score, '.
  110. '(case lpivo.status '.
  111. 'when "incomplete" then 0 '.
  112. 'when "completed" then 1 '.
  113. 'when "passed" then 2 '.
  114. 'when "failed" then 3 '.
  115. 'when "browsed" then 4 '.
  116. 'when "not attempted" then 5 '.
  117. 'else 6 '.
  118. 'end) as progress, '.
  119. 'null as time, null as ts from '.
  120. Database::get_course_table(TABLE_LP_VIEW, $scorm['course_db']).
  121. ' lpv, '.
  122. Database::get_course_table(TABLE_LP_ITEM_VIEW, $scorm['course_db']).
  123. ' lpiv, '.
  124. Database::get_course_table(TABLE_LP_IV_OBJECTIVE, $scorm['course_db']).
  125. ' lpivo '.
  126. ' where lpv.lp_id = '.$scorm['child_id'].
  127. ' and lpiv.lp_item_id = '.$scorm['subchild_id'].
  128. ' and lpivo.objective_id = "'.$scorm['subsubchild_name'].'" '.
  129. ' and lpiv.lp_view_id = lpv.id'.
  130. ' and lpivo.lp_iv_id=lpiv.id'
  131. );
  132. }