Merge branch 'MDL-26435_rem_commented_out_code' of git://github.com/andyjdavis/moodle
[moodle.git] / mod / scorm / index.php
blob3d16f2a06ab680e5cbcf8496879df58307a3154f
1 <?php
3 require_once("../../config.php");
4 require_once($CFG->dirroot.'/mod/scorm/locallib.php');
6 $id = required_param('id', PARAM_INT); // course id
8 $PAGE->set_url('/mod/scorm/index.php', array('id'=>$id));
10 if (!empty($id)) {
11 if (!$course = $DB->get_record('course', array('id'=>$id))) {
12 print_error('invalidcourseid');
14 } else {
15 print_error('missingparameter');
18 require_course_login($course);
19 $PAGE->set_pagelayout('incourse');
21 add_to_log($course->id, "scorm", "view all", "index.php?id=$course->id", "");
23 $strscorm = get_string("modulename", "scorm");
24 $strscorms = get_string("modulenameplural", "scorm");
25 $strsectionname = get_string('sectionname', 'format_'.$course->format);
26 $strname = get_string("name");
27 $strsummary = get_string("summary");
28 $strreport = get_string("report",'scorm');
29 $strlastmodified = get_string("lastmodified");
31 $PAGE->set_title($strscorms);
32 $PAGE->set_heading($course->fullname);
33 $PAGE->navbar->add($strscorms);
34 echo $OUTPUT->header();
36 $usesections = course_format_uses_sections($course->format);
37 if ($usesections) {
38 $sections = get_all_sections($course->id);
41 if ($usesections) {
42 $sortorder = "cw.section ASC";
43 } else {
44 $sortorder = "m.timemodified DESC";
47 if (! $scorms = get_all_instances_in_course("scorm", $course)) {
48 notice(get_string('thereareno', 'moodle', $strscorms), "../../course/view.php?id=$course->id");
49 exit;
52 $table = new html_table();
54 if ($usesections) {
55 $table->head = array ($strsectionname, $strname, $strsummary, $strreport);
56 $table->align = array ("center", "left", "left", "left");
57 } else {
58 $table->head = array ($strlastmodified, $strname, $strsummary, $strreport);
59 $table->align = array ("left", "left", "left", "left");
62 foreach ($scorms as $scorm) {
64 $context = get_context_instance(CONTEXT_MODULE,$scorm->coursemodule);
65 $tt = "";
66 if ($usesections) {
67 if ($scorm->section) {
68 $tt = get_section_name($course, $sections[$scorm->section]);
70 } else {
71 $tt = userdate($scorm->timemodified);
73 $report = '&nbsp;';
74 $reportshow = '&nbsp;';
75 if (has_capability('mod/scorm:viewreport', $context)) {
76 $trackedusers = scorm_get_count_users($scorm->id, $scorm->groupingid);
77 if ($trackedusers > 0) {
78 $reportshow = '<a href="report.php?id='.$scorm->coursemodule.'">'.get_string('viewallreports','scorm',$trackedusers).'</a></div>';
79 } else {
80 $reportshow = get_string('noreports','scorm');
82 } else if (has_capability('mod/scorm:viewscores', $context)) {
83 require_once('locallib.php');
84 $report = scorm_grade_user($scorm, $USER->id);
85 $reportshow = get_string('score','scorm').": ".$report;
87 $options = (object)array('noclean'=>true);
88 if (!$scorm->visible) {
89 //Show dimmed if the mod is hidden
90 $table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
91 format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
92 } else {
93 //Show normal if the mod is visible
94 $table->data[] = array ($tt, "<a href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name)."</a>",
95 format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
99 echo "<br />";
101 echo html_writer::table($table);
103 echo $OUTPUT->footer();