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