MDL-14741: use the default html editor, as chosen in the admin settings
[moodle.git] / mod / scorm / view.php
CommitLineData
f9d5371b 1<?php // $Id$
2
3 require_once("../../config.php");
4 require_once('locallib.php');
5
6 $id = optional_param('id', '', PARAM_INT); // Course Module ID, or
7 $a = optional_param('a', '', PARAM_INT); // scorm ID
0d699c24 8 $organization = optional_param('organization', '', PARAM_INT); // organization ID
f9d5371b 9
10 if (!empty($id)) {
0d699c24 11 if (! $cm = get_coursemodule_from_id('scorm', $id)) {
5a2a5331 12 print_error("Course Module ID was incorrect");
f9d5371b 13 }
14 if (! $course = get_record("course", "id", $cm->course)) {
5a2a5331 15 print_error("Course is misconfigured");
f9d5371b 16 }
17 if (! $scorm = get_record("scorm", "id", $cm->instance)) {
5a2a5331 18 print_error("Course module is incorrect");
f9d5371b 19 }
20 } else if (!empty($a)) {
21 if (! $scorm = get_record("scorm", "id", $a)) {
5a2a5331 22 print_error("Course module is incorrect");
f9d5371b 23 }
24 if (! $course = get_record("course", "id", $scorm->course)) {
5a2a5331 25 print_error("Course is misconfigured");
f9d5371b 26 }
27 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
5a2a5331 28 print_error("Course Module ID was incorrect");
f9d5371b 29 }
30 } else {
5a2a5331 31 print_error('A required parameter is missing');
f9d5371b 32 }
33
34 require_login($course->id, false, $cm);
35
77bf0c29 36 $context = get_context_instance(CONTEXT_COURSE, $course->id);
0d699c24 37
f9d5371b 38 if (isset($SESSION->scorm_scoid)) {
39 unset($SESSION->scorm_scoid);
40 }
41
42 $strscorms = get_string("modulenameplural", "scorm");
43 $strscorm = get_string("modulename", "scorm");
44
1936c10e 45 if ($course->id != SITEID) {
afd97d1c 46
f9d5371b 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))) {
3b27b0fe 51 $navlinks[] = array('name' => $strscorms, 'link' => "index.php?id=$course->id", 'type' => 'activity');
f9d5371b 52 }
53 }
f9d5371b 54 }
f9d5371b 55 $pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
56
57 add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id");
58
8e45ba45 59 if ((has_capability('mod/scorm:skipview', get_context_instance(CONTEXT_MODULE,$cm->id))) && scorm_simple_play($scorm,$USER)) {
60 exit;
61 }
62
f9d5371b 63 //
64 // Print the page header
65 //
01e38388 66 $navlinks = array();
3b27b0fe 67 $navlinks[] = array('name' => format_string($scorm->name,true), 'link' => "view.php?id=$cm->id", 'type' => 'activityinstance');
68 $navigation = build_navigation($navlinks);
afd97d1c 69
70 print_header($pagetitle, $course->fullname, $navigation,
2b3447c3 71 '', '', true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
f9d5371b 72
dfe2fbc6 73 if (has_capability('mod/scorm:viewreport', $context)) {
d8c9d8a1 74
75 $trackedusers = scorm_get_count_users($scorm->id, $cm->groupingid);
76 if ($trackedusers > 0) {
9c5ba974 77 echo "<div class=\"reportlink\"><a $CFG->frametarget href=\"report.php?id=$cm->id\"> ".get_string('viewalluserreports','scorm',$trackedusers).'</a></div>';
2b3447c3 78 } else {
79 echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
80 }
f9d5371b 81 }
2b3447c3 82
2b3447c3 83 // Print the main part of the page
84 print_heading(format_string($scorm->name));
c1afef80 85 print_box(format_text($scorm->summary), 'generalbox', 'intro');
2b3447c3 86 scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
87 print_footer($course);
f9d5371b 88?>