scorm.php 4.2 KB

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