constant values changed to reflect changes in database
[moodle.git] / mod / scorm / cmi.php
CommitLineData
98ca59f6 1<?php
2 require_once("../../config.php");
3 require_once("lib.php");
4
5 optional_variable($id); // Course Module ID, or
6 optional_variable($a); // scorm ID
7
8 if ($id) {
9 if (! $cm = get_record("course_modules", "id", $id)) {
10 error("Course Module ID was incorrect");
11 }
12
13 if (! $course = get_record("course", "id", $cm->course)) {
14 error("Course is misconfigured");
15 }
16
17 if (! $scorm = get_record("scorm", "id", $cm->instance)) {
18 error("Course module is incorrect");
19 }
20
21 } else {
22 if (! $scorm = get_record("scorm", "id", $a)) {
23 error("Course module is incorrect");
24 }
25 if (! $course = get_record("course", "id", $scorm->course)) {
26 error("Course is misconfigured");
27 }
28 if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
29 error("Course Module ID was incorrect");
30 }
31 }
32
33 require_login($course->id);
34
35 if ($_POST["scoid"]) {
36 set_field("scorm_sco_users","cmi_core_lesson_location",$_POST["cmi_core_lesson_location"],"scoid",$_POST["scoid"],"userid",$USER->id);
37 set_field("scorm_sco_users","cmi_core_lesson_status",$_POST["cmi_core_lesson_status"],"scoid",$_POST["scoid"],"userid",$USER->id);
38 set_field("scorm_sco_users","cmi_core_exit",$_POST["cmi_core_exit"],"scoid",$_POST["scoid"],"userid",$USER->id);
39 set_field("scorm_sco_users","cmi_core_session_time",$_POST["cmi_core_session_time"],"scoid",$_POST["scoid"],"userid",$USER->id);
40 set_field("scorm_sco_users","cmi_core_total_time",$_POST["cmi_core_total_time"],"scoid",$_POST["scoid"],"userid",$USER->id);
41 set_field("scorm_sco_users","cmi_core_score_raw",$_POST["cmi_core_score_raw"],"scoid",$_POST["scoid"],"userid",$USER->id);
42 set_field("scorm_sco_users","cmi_suspend_data",$_POST["cmi_suspend_data"],"scoid",$_POST["scoid"],"userid",$USER->id);
43 /* if ($scorm->auto)
44 $result="<script language=\"Javascript\">\n\ttop.nav.document.navform.next.click();\n </script>\n"; */
45 }
46?>
47<html>
48<head>
49 <title>cmi</title>
50</head>
51<body>
5d8790cb 52 <form name="theform" method="POST" action="<?php echo $ME ?>?id=<?php echo $cm->id ?>">
98ca59f6 53 <input type="hidden" name="scoid" />
54 <input type="hidden" name="cmi_core_lesson_location" />
55 <input type="hidden" name="cmi_core_lesson_status" />
56 <input type="hidden" name="cmi_core_exit" />
57 <input type="hidden" name="cmi_core_session_time" />
58 <input type="hidden" name="cmi_core_total_time" />
59 <input type="hidden" name="cmi_core_score_raw" />
60 <input type="hidden" name="cmi_suspend_data" />
61 </form>
62 <?php echo $result?>
63</body>
64</html>