Added link to Markdown format help.
[moodle.git] / mod / scorm / datamodel.php
CommitLineData
98ca59f6 1<?php
1a12b1f1 2 require_once('../../config.php');
3 require_once('lib.php');
2a0407b7 4
98ca59f6 5 optional_variable($id); // Course Module ID, or
6 optional_variable($a); // scorm ID
7
8 if ($id) {
1a12b1f1 9 if (! $cm = get_record('course_modules', 'id', $id)) {
10 error('Course Module ID was incorrect');
98ca59f6 11 }
2a0407b7 12
1a12b1f1 13 if (! $course = get_record('course', 'id', $cm->course)) {
14 error('Course is misconfigured');
98ca59f6 15 }
2a0407b7 16
1a12b1f1 17 if (! $scorm = get_record('scorm', 'id', $cm->instance)) {
18 error('Course module is incorrect');
98ca59f6 19 }
20
21 } else {
1a12b1f1 22 if (! $scorm = get_record('scorm', 'id', $a)) {
23 error('Course module is incorrect');
98ca59f6 24 }
1a12b1f1 25 if (! $course = get_record('course', 'id', $scorm->course)) {
26 error('Course is misconfigured');
98ca59f6 27 }
1a12b1f1 28 if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
29 error('Course Module ID was incorrect');
98ca59f6 30 }
31 }
32
ec81373f 33 require_login($course->id, false, $cm);
1a12b1f1 34 if (!empty($_POST['scoid'])) {
35 //echo 'scoid: '.$_POST['scoid']."\n";
36 if (!empty($_POST['cmi_core_lesson_location'])) {
2a0407b7 37 set_field('scorm_sco_users','cmi_core_lesson_location',$_POST['cmi_core_lesson_location'],'scoid',$_POST['scoid'],'userid',$USER->id);
38 //echo 'cmi_core_lesson_location: '.$_POST['cmi_core_lesson_location']."\n";
39 }
40 if (!empty($_POST['cmi_core_lesson_status'])) {
1a12b1f1 41 set_field('scorm_sco_users','cmi_core_lesson_status',$_POST['cmi_core_lesson_status'],'scoid',$_POST['scoid'],'userid',$USER->id);
42 //echo 'cmi_core_lesson_status: '.$_POST['cmi_core_lesson_status']."\n";
6d9c91c7 43 }
2a0407b7 44 if (!empty($_POST['cmi_core_exit'])) {
1a12b1f1 45 set_field('scorm_sco_users','cmi_core_exit',$_POST['cmi_core_exit'],'scoid',$_POST['scoid'],'userid',$USER->id);
46 //echo 'cmi_core_exit: '.$_POST['cmi_core_exit']."\n";
6d9c91c7 47 }
2a0407b7 48 if (!empty($_POST['cmi_core_score_raw'])) {
1a12b1f1 49 set_field('scorm_sco_users','cmi_core_score_raw',$_POST['cmi_core_score_raw'],'scoid',$_POST['scoid'],'userid',$USER->id);
50 //echo 'cmi_core_score_raw: '.$_POST['cmi_core_score_raw']."\n";
6d9c91c7 51 }
2a0407b7 52 if (!empty($_POST['cmi_suspend_data'])) {
1a12b1f1 53 set_field('scorm_sco_users','cmi_suspend_data',$_POST['cmi_suspend_data'],'scoid',$_POST['scoid'],'userid',$USER->id);
54 //echo 'cmi_suspend_data: '.$_POST['cmi_suspend_data']."\n";
6d9c91c7 55 }
1a12b1f1 56 if (!empty($_POST['cmi_core_total_time'])) {
57 set_field('scorm_sco_users','cmi_core_total_time',$_POST['cmi_core_total_time'],'scoid',$_POST['scoid'],'userid',$USER->id);
58 //echo 'cmi_core_total_time: '.$_POST['cmi_core_total_time']."\n";
6d9c91c7 59 }
98ca59f6 60 }
61?>
62<html>
63<head>
64 <title>cmi</title>
65</head>
66<body>
2a0407b7 67 <form name="theform" method="POST" action="<?php echo $ME ?>?id=<?php echo $cm->id ?>">
68 <input type="hidden" name="scoid" />
69 <input type="hidden" name="cmi_core_lesson_location" />
70 <input type="hidden" name="cmi_core_lesson_status" />
71 <input type="hidden" name="cmi_core_exit" />
72 <input type="hidden" name="cmi_core_total_time" />
73 <input type="hidden" name="cmi_core_score_raw" />
74 <input type="hidden" name="cmi_suspend_data" />
98ca59f6 75 </form>
98ca59f6 76</body>
77</html>