Clean up for role_assign()
[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
8 //$organization = optional_param('organization', '', PARAM_INT); // organization ID
9
10 if (!empty($id)) {
11 if (! $cm = $cm = get_coursemodule_from_id('scorm', $id)) {
12 error("Course Module ID was incorrect");
13 }
14 if (! $course = get_record("course", "id", $cm->course)) {
15 error("Course is misconfigured");
16 }
17 if (! $scorm = get_record("scorm", "id", $cm->instance)) {
18 error("Course module is incorrect");
19 }
20 } else if (!empty($a)) {
21 if (! $scorm = get_record("scorm", "id", $a)) {
22 error("Course module is incorrect");
23 }
24 if (! $course = get_record("course", "id", $scorm->course)) {
25 error("Course is misconfigured");
26 }
27 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
28 error("Course Module ID was incorrect");
29 }
30 } else {
31 error('A required parameter is missing');
32 }
33
34 require_login($course->id, false, $cm);
35
36 if (isset($SESSION->scorm_scoid)) {
37 unset($SESSION->scorm_scoid);
38 }
39
40 $strscorms = get_string("modulenameplural", "scorm");
41 $strscorm = get_string("modulename", "scorm");
42
43 if ($course->category != 0) {
44 $navigation = "<a target=\"{$CFG->framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
45 if ($scorms = get_all_instances_in_course('scorm', $course)) {
46 // The module SCORM activity with the least id is the course
47 $firstscorm = current($scorms);
48 if (!(($course->format == 'scorm') && ($firstscorm->id == $scorm->id))) {
49 $navigation .= "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
50 }
51 }
52 } else {
53 $navigation = "<a target=\"{$CFG->framename}\" href=\"index.php?id=$course->id\">$strscorms</a> ->";
54 }
55
56 $pagetitle = strip_tags($course->shortname.': '.format_string($scorm->name));
57
58 add_to_log($course->id, 'scorm', 'pre-view', 'view.php?id='.$cm->id, "$scorm->id");
59
60 //
61 // Print the page header
62 //
63 if (!$cm->visible and !isteacher($course->id)) {
64 print_header($pagetitle, "$course->fullname", "$navigation ".format_string($scorm->name), '', '', true,
65 update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
66 notice(get_string('activityiscurrentlyhidden'));
67 } else {
68 print_header($pagetitle, "$course->fullname",
69 "$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\">".format_string($scorm->name,true)."</a>",
70 '', '', true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
71
72 if (isteacher($course->id)) {
73
74 //Phan thiet lap he so diem
75 $examNumber = get_record_select('scorm_scoes', 'scorm ='.($scorm->id).' and minnormalizedmeasure > -1','count(id) as examCount');
76 //fwrite($ft,"\n So bai kiem tra la ".($examNumber->examCount));
77 if ($examNumber->examCount > 0){
78 echo "<div class=\"reportlink\"><img src='pix\SuaHeSoDiem.png' /><a target=\"{$CFG->framename}\" href=\"coefficientSetting.php?id=$cm->id\"> ".get_string('scorecoefficientsetting','scorm',$examNumber->examCount).'</a></div>';
79 }
80
81 //-----------------------
82 $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
83 if ($trackedusers->c > 0) {
84 echo "<div class=\"reportlink\"><img src='pix\ThongKe.png' /><a target=\"{$CFG->framename}\" href=\"report.php?id=$cm->id\"> ".get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
85 } else {
86 echo '<div class="reportlink">'.get_string('noreports','scorm').'</div>';
87 }
88 }
89
90 $USER->setAttempt = 'notset';
91 // Print the main part of the page
92 print_heading(format_string($scorm->name));
93 print_simple_box(format_text($scorm->summary), 'center', '70%', '', 5, 'generalbox', 'intro');
94 scorm_view_display($USER, $scorm, 'view.php?id='.$cm->id, $cm);
95 print_footer($course);
96 }
97?>