MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / scorm / view.php
blobdb9ec88afb9fc5e059b1e8498a6c3d30cd2310a7
1 <?php // $Id$
3 require_once("../../config.php");
4 require_once('locallib.php');
6 $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
7 $a = optional_param('a', '', PARAM_INT); // scorm ID
8 $organization = optional_param('organization', '', PARAM_INT); // organization ID
10 if (!empty($id)) {
11 if (! $cm = get_coursemodule_from_id('scorm', $id)) {
12 error("Course Module ID was incorrect");
14 if (! $course = get_record("course", "id", $cm->course)) {
15 error("Course is misconfigured");
17 if (! $scorm = get_record("scorm", "id", $cm->instance)) {
18 error("Course module is incorrect");
20 } else if (!empty($a)) {
21 if (! $scorm = get_record("scorm", "id", $a)) {
22 error("Course module is incorrect");
24 if (! $course = get_record("course", "id", $scorm->course)) {
25 error("Course is misconfigured");
27 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
28 error("Course Module ID was incorrect");
30 } else {
31 error('A required parameter is missing');
34 require_login($course->id, false, $cm);
36 $context = get_context_instance(CONTEXT_COURSE, $course->id);
38 if (isset($SESSION->scorm_scoid)) {
39 unset($SESSION->scorm_scoid);
42 $strscorms = get_string("modulenameplural", "scorm");
43 $strscorm = get_string("modulename", "scorm");
45 if ($course->id != SITEID) {
47 if ($scorms = get_all_instances_in_course('scorm', $course)) {
48 // The module SCORM activity with the least id is the course
49 $firstscorm = current($scorms);
50 if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) {
51 $navlinks[] = array('name' => $strscorms, 'link' => "index.php?id=$course->id", 'type' => 'activity');
55 $pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
57 add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id");
59 if ((has_capability('mod/scorm:skipview', get_context_instance(CONTEXT_MODULE,$cm->id))) && scorm_simple_play($scorm,$USER)) {
60 exit;
64 // Print the page header
66 $navlinks = array();
67 $navlinks[] = array('name' => format_string($scorm->name,true), 'link' => "view.php?id=$cm->id", 'type' => 'activityinstance');
68 $navigation = build_navigation($navlinks);
70 print_header($pagetitle, $course->fullname, $navigation,
71 '', '', true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
73 if (empty($cm->visible) and !has_capability('moodle/course:manageactivities', $context)) {
74 notice(get_string("activityiscurrentlyhidden"));
77 if (has_capability('moodle/course:manageactivities', $context)) {
79 $trackedusers = scorm_get_count_users($scorm->id, $cm->groupingid);
80 if ($trackedusers > 0) {
81 echo "<div class=\"reportlink\"><a $CFG->frametarget href=\"report.php?id=$cm->id\"> ".get_string('viewallreports','scorm',$trackedusers).'</a></div>';
82 } else {
83 echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
87 // Print the main part of the page
88 print_heading(format_string($scorm->name));
89 print_box(format_text($scorm->summary), 'generalbox', 'intro');
90 scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
91 print_footer($course);