PageRenderTime 26ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/ASTRA_Demo_Server/udrive/www/astra/interact/modules/scorm/report.php

https://github.com/shafiqissani/ASTRA-College-Website
PHP | 230 lines | 160 code | 39 blank | 31 comment | 12 complexity | 2a6893d96760735cbfa7a0f7e670b43d MD5 | raw file
  1. <?php // $Id: report.php,v 1.11 2007/01/07 22:25:27 glendavies Exp $
  2. // This script uses installed report plugins to print quiz reports
  3. require_once("../../local/config.inc.php");
  4. require_once("lib.inc.php");
  5. require_once($CONFIG['LANGUAGE_CPATH'].'/scorm_strings.inc.php');
  6. //set variables
  7. $space_key = get_space_key();
  8. $module_key = $_GET['module_key'];
  9. $link_key = get_link_key($module_key,$space_key);
  10. $group_key = isset($_GET['group_key'])?$_GET['group_key']:'';
  11. $message = isset($_GET['message'])?$_GET['message']:'';
  12. $userlevel_key = isset($_SESSION['userlevel_key'])?$_SESSION['userlevel_key']:'';
  13. //check we have the variables we need
  14. check_variables(true,true,true);
  15. //autenticate the user.
  16. $access_levels = authenticate();
  17. $accesslevel_key = $access_levels['accesslevel_key'];
  18. $group_access = $access_levels['groups'];
  19. $group_accesslevel = isset($access_levels['group_accesslevel'][$group_key])?$access_levels['group_accesslevel'][$group_key]:'';
  20. $is_admin=(check_module_edit_rights($module_key));
  21. //get the required templates for this page
  22. require_once($CONFIG['TEMPLATE_CLASS_PATH'].'/template.inc');
  23. $t = new Template($CONFIG['TEMPLATES_PATH']);
  24. $t->set_file(array(
  25. 'header' => 'header.ihtml',
  26. 'navigation' => 'navigation.ihtml',
  27. 'footer' => 'footer.ihtml'
  28. ));
  29. // get details of this page, space name, module name, etc.
  30. $page_details = get_page_details($space_key,$link_key);
  31. set_common_template_vars($space_key,$module_key,$page_details, $message, $accesslevel_key, $group_accesslevel);
  32. $output='';
  33. $scoid=getvar('scoid');
  34. $user=getvar('user');
  35. $CONN->SetFetchMode(ADODB_FETCH_ASSOC);
  36. $rs=$CONN->Execute("SELECT * FROM {$CONFIG['DB_PREFIX']}scorm WHERE module_key=$module_key");
  37. $scorm=(object)$rs->fields;
  38. $CONN->SetFetchMode(ADODB_FETCH_NUM);
  39. if (!$is_admin) {
  40. $output.= "You are not allowed to use this script";exit;
  41. }
  42. $strscorms = get_string("modulenameplural", "scorm");
  43. $strscorm = get_string("modulename", "scorm");
  44. $strreport = get_string("report", "scorm");
  45. $strname = get_string('name');
  46. if (!class_exists('InteractUser')) {
  47. require_once($CONFIG['BASE_PATH'].'/includes/lib/user.inc.php');
  48. }
  49. $userobj = new InteractUser();
  50. $t->parse('CONTENTS', 'header', true);
  51. $t->set_var('BREADCRUMBS',$scorm_strings['report'],true);
  52. get_navigation();
  53. $t->set_var('CONTENTS','<h2 id="moduleHeading"><img src="'.$CONFIG['PATH'].'/images/scorm.gif" height="16" width="16" alt="Icon"> '.$page_details['module_name'].': '.$scorm_strings['report']."</h2><div align=\"center\"><a href=\"scorm.php?space_key=$space_key&module_key=$module_key&link_key=$link_key&group_key=$group_key\">{$general_strings['back_to']} {$page_details['module_name']}</a>",true);
  54. // add_to_log($course->id, "scorm", "report", "report.php?id=$cm->id", "$scorm->id");
  55. /// Print the page header
  56. /* if (empty($noheader)) {
  57. if ($course->category) {
  58. $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
  59. } else {
  60. $navigation = '';
  61. }
  62. if (!empty($id)) {
  63. print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
  64. "$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
  65. -> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a> -> $strreport",
  66. "", "", true);
  67. } else {
  68. print_header("$course->shortname: ".format_string($scorm->name), "$course->fullname",
  69. "$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
  70. -> <a href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>
  71. -> <a href=\"report.php?id=$cm->id\">$strreport</a> -> $sco->title",
  72. "", "", true);
  73. }
  74. print_heading(format_string($scorm->name));
  75. }
  76. */ if (is_null($user)) {
  77. // if (!empty($module_key)) { //check variable already redirects if module_key is missing.
  78. $CONN->SetFetchMode(ADODB_FETCH_ASSOC);
  79. $scoArray = $CONN->GetAssoc("SELECT id,title FROM {$CONFIG['DB_PREFIX']}scorm_scoes WHERE module_key=$module_key AND launch>'' order by id ASC");
  80. $rs= $CONN->Execute("SELECT DISTINCT userid FROM {$CONFIG['DB_PREFIX']}scorm_scoes_track WHERE module_key=$module_key ORDER BY userid");
  81. $CONN->SetFetchMode(ADODB_FETCH_NUM);
  82. if ($scoArray) {
  83. $tabl="<table><tr><th>$strname</th>";
  84. foreach($scoArray as $title) {
  85. $tabl.="<th>$title&nbsp;&nbsp;</th>";
  86. }
  87. $tabl.="</tr>";
  88. while ($rs && !$rs->EOF) {
  89. $scouser=(object)$rs->fields;
  90. $uid=$scouser->userid;
  91. $tabl.="<tr><td>".get_badge($uid);
  92. reset($scoArray);
  93. do {
  94. $tabl.="<td>";
  95. // while (current($scoArray) && $scouser->userid=$uid) {
  96. $anchorstart = '';
  97. $anchorend = '';
  98. $scoreview = '';
  99. if ($trackdata = scorm_get_tracks(key($scoArray),$uid)) {
  100. if ($trackdata->score_raw != '') {
  101. $scoreview = '<br />'.get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
  102. }
  103. if ($trackdata->status == '') {
  104. $trackdata->status = 'notattempted';
  105. } else {
  106. $anchorstart = "<a href=\"report.php?space_key=$space_key&module_key=$module_key&link_key=$link_key&scoid=".key($scoArray)."&user=$uid\" title=\"".get_string('details','scorm').'">';
  107. $anchorend = '</a>';
  108. }
  109. } else {
  110. $trackdata->status = 'notattempted';
  111. $trackdata->total_time = '';
  112. }
  113. $strstatus = get_string($trackdata->status,'scorm');
  114. $tabl .= $anchorstart.'<img style="border:none" src="pix/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.$strstatus.'">&nbsp;'.$trackdata->total_time.$scoreview.$anchorend;
  115. $tabl.="</td>";
  116. }while (next($scoArray));
  117. $tabl.='</tr>';
  118. $rs->MoveNext();
  119. }
  120. $output.= $tabl.'</table>';
  121. } else {
  122. $output.=('No users to report');
  123. }
  124. // } else {
  125. // $output.=('Missing script parameter');
  126. // }
  127. } else {
  128. // if ($userdata = scorm_get_user_data($user)) {
  129. // print_simple_box_start('center');
  130. // print_heading(format_string($sco->title));
  131. $output.= '<div align="center"><table><tr><th colspan="2">'.$CONN->GetOne("SELECT title FROM {$CONFIG['DB_PREFIX']}scorm_scoes WHERE id=$scoid").'</th></tr><tr><td colspan="2">'.get_badge($user).'</td></tr><tr><td colspan="2">';
  132. // print_user_picture($user, $course->id, $userdata->picture, false, false);
  133. // $output.= "<a href=\"$CFG->wwwroot/user/view.php?id=$user&course=$course->id\">".
  134. // "$userdata->firstname $userdata->lastname</a><br />";
  135. $scoreview = '';
  136. if ($trackdata = scorm_get_tracks($scoid,$user)) {
  137. if ($trackdata->score_raw != '') {
  138. $scoreview = get_string('score','scorm').':&nbsp;'.$trackdata->score_raw;
  139. }
  140. if ($trackdata->status == '') {
  141. $trackdata->status = 'notattempted';
  142. }
  143. } else {
  144. $trackdata->status = 'notattempted';
  145. $trackdata->total_time = '';
  146. }
  147. $strstatus = get_string($trackdata->status,'scorm');
  148. $output.= '<img src="pix/'.$trackdata->status.'.gif" alt="'.$strstatus.'" title="'.
  149. $strstatus.'">&nbsp;'.$trackdata->total_time.'<br />'.$scoreview.'<br /><br /></td></tr>';
  150. foreach($trackdata as $element => $value) {
  151. if (substr($element,0,3) == 'cmi') {
  152. $output.='<tr><th>';
  153. if (substr($element,0,8) == 'cmi.core') {
  154. $output.= substr($element,9);
  155. } else {
  156. $output.= substr($element,4);
  157. }
  158. $output.= '&nbsp;</th><td>'.$value.'</td></tr>';
  159. }
  160. }
  161. $output.= '</table></div>'."\n";
  162. // print_simple_box_end();
  163. // }
  164. $t->set_var('CONTENTS',"&nbsp;&nbsp;&nbsp;<a href=\"report.php?space_key=$space_key&module_key=$module_key&link_key=$link_key&group_key=$group_key\">{$general_strings['back_to']} {$scorm_strings['report']}</a>",true);
  165. }
  166. $t->set_var('CONTENTS',"</div><br />$output",true);
  167. $t->parse('CONTENTS', 'footer', true);
  168. //output page
  169. $t->p('CONTENTS');
  170. exit;
  171. function get_badge($uid) {
  172. global $CONFIG,$CONN,$userobj,$space_key;
  173. $rs=$CONN->Execute("SELECT first_name,last_name FROM {$CONFIG['DB_PREFIX']}users WHERE user_key='$uid'");
  174. return '<span style="float:left">'.$userobj->getUserphotoTag($uid, '35', $space_key)."</span>&nbsp;".$rs->fields[0].' '.$rs->fields[1];
  175. }
  176. ?>