First step for SCORM2004, new communication subsystem
[moodle.git] / mod / scorm / report.php
CommitLineData
d1290cec 1<?php // $Id$
98ca59f6 2
3// This script uses installed report plugins to print quiz reports
4
5 require_once("../../config.php");
6 require_once("lib.php");
7
8 optional_variable($id); // Course Module ID, or
9
10 if ($id) {
11 if (! $cm = get_record("course_modules", "id", $id)) {
12 error("Course Module ID was incorrect");
13 }
ec81373f 14
98ca59f6 15 if (! $course = get_record("course", "id", $cm->course)) {
16 error("Course is misconfigured");
17 }
ec81373f 18
98ca59f6 19 if (! $scorm = get_record("scorm", "id", $cm->instance)) {
20 error("Course module is incorrect");
21 }
22
23 } else {
24 if (! $scorm = get_record("scorm", "id", $q)) {
25 error("Course module is incorrect");
26 }
27 if (! $course = get_record("course", "id", $scorm->course)) {
28 error("Course is misconfigured");
29 }
30 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
31 error("Course Module ID was incorrect");
32 }
33 }
34
2a0407b7 35 require_login($course->id, false, $cm);
98ca59f6 36
37 if (!isteacher($course->id)) {
38 error("You are not allowed to use this script");
39 }
40
41 add_to_log($course->id, "scorm", "report", "report.php?id=$cm->id", "$scorm->id");
42
43/// Print the page header
44 if (empty($noheader)) {
45
46 if ($course->category) {
47 $navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
27d394ca 48 } else {
49 $navigation = '';
98ca59f6 50 }
ec81373f 51
98ca59f6 52 $strscorms = get_string("modulenameplural", "scorm");
53 $strscorm = get_string("modulename", "scorm");
54 $strreport = get_string("report", "scorm");
ec81373f 55
98ca59f6 56 print_header("$course->shortname: $scorm->name", "$course->fullname",
ec81373f 57 "$navigation <a href=\"index.php?id=$course->id\">$strscorms</a>
58 -> <a href=\"view.php?id=$cm->id\">$scorm->name</a> -> $strreport",
98ca59f6 59 "", "", true);
ec81373f 60
98ca59f6 61 print_heading($scorm->name);
62 }
63 if ($scoes =get_records_select("scorm_scoes","scorm='$scorm->id' ORDER BY id")) {
ec81373f 64 if ($sco_users=get_records_select("scorm_sco_users", "scormid='$scorm->id' GROUP BY userid")) {
65
66 $strname = get_string("name");
67
68 $table->head = array("&nbsp;", $strname);
69 $table->align = array("center", "left");
70 $table->wrap = array("nowrap", "nowrap");
71 $table->width = "100%";
72 $table->size = array(10, "*");
73 foreach ($scoes as $sco) {
74 if ($sco->launch!="") {
75 $table->head[]=scorm_string_round($sco->title);
76 $table->align[] = "center";
77 $table->wrap[] = "nowrap";
78 $table->size[] = "*";
79 }
80 }
98ca59f6 81
3f8eeff2 82 foreach ($sco_users as $sco_user) {
83 $user_data = scorm_get_scoes_records($sco_user);
84
85 $row = array();
86 $data = current($user_data);
87 $row[] = print_user_picture($sco_user->userid, $course->id, $data->picture, false, true);
88 $row[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$data->userid&course=$course->id\">".
89 "$data->firstname $data->lastname</a>";
90 foreach ($user_data as $data) {
91 $scoreview = "";
92 if ($data->cmi_core_score_raw > 0)
93 $scoreview = "<br />".get_string("score","scorm").":&nbsp;".$data->cmi_core_score_raw;
94 if ( $data->cmi_core_lesson_status == "")
95 $data->cmi_core_lesson_status = "not attempted";
ec81373f 96 $row[]="<img src=\"pix/".scorm_remove_spaces($data->cmi_core_lesson_status).".gif\"
3f8eeff2 97 alt=\"".get_string(scorm_remove_spaces($data->cmi_core_lesson_status),"scorm")."\"
98 title=\"".get_string(scorm_remove_spaces($data->cmi_core_lesson_status),"scorm")."\">&nbsp;"
99 .$data->cmi_core_total_time.$scoreview;
100 }
ec81373f 101 $table->data[] = $row;
3f8eeff2 102 }
ec81373f 103
104 print_table($table);
105
106 } else {
107 notice("No users to report");
108 }
98ca59f6 109 }
110 if (empty($noheader)) {
111 print_footer($course);
112 }
113
114
115?>