First step for SCORM2004, new communication subsystem
[moodle.git] / mod / scorm / mod.html
CommitLineData
98ca59f6 1<?php
2a0407b7 2 require_once("$CFG->dirroot/mod/scorm/lib.php");
98ca59f6 3 if (empty($form->name)) {
2a0407b7 4 $form->name = "";
98ca59f6 5 }
e84ce5c8 6 if (empty($form->reference)) {
2a0407b7 7 $form->reference = "";
e84ce5c8 8 }
98ca59f6 9 if (empty($form->summary)) {
2a0407b7 10 $form->summary = "";
98ca59f6 11 }
5d8790cb 12 if (empty($form->launch)) {
2a0407b7 13 $form->launch = "";
14 }
15 if (empty($form->auto)) {
16 $form->auto = "";
17 }
18 if (empty($form->datadir)) {
19 $form->datadir = "";
20 }
21 if (empty($form->popup)) {
22 $form->popup = "";
23 }
24 if (empty($form->maxgrade)) {
25 $form->maxgrade = "";
26 }
27 if (empty($form->grademethod)) {
28 $form->grademethod = "0";
29 }
30 $scormid ='';
31 if (!empty($form->instance)) {
32 $scormid = '&instance='.$form->instance;
33 }
34 $datadir ='';
35 if (!empty($form->datadir)) {
36 $datadir = '&datadir='.$form->datadir;
5d8790cb 37 }
98ca59f6 38?>
39
2a0407b7 40<script type="text/javascript" src="<?php p($CFG->wwwroot) ?>/mod/scorm/request.js" >
41</script>
42<script type="text/javascript">
43 function validate_scorm(theform,filename) {
44 //alert(filename);
45 var myRequest = NewHttpReq();
46 result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/validate.php?id=<?php p($form->course) ?>&reference="+filename+"<?php p($scormid.$datadir) ?>");
47 //alert(result);
48 results = result.split('\n');
49 if ((results[0] == "found") || (results[0] == "regular")) {
50 theform.launch.value = results[1];
51 theform.datadir.value = results[2];
52 } else {
53 result = 'Result: '+ results[0] + '\n';
54 result.concat('Errorlog:\n',results[3]);
55 alert(result);
56 exit;
57 }
58 return false;
59 }
60</script>
98ca59f6 61
2a0407b7 62<form name="form" method="post" action="mod.php" onsubmit="validate_scorm(document.form,document.form.reference.value);">
d1290cec 63 <table cellpadding="5">
2a0407b7 64 <tr valign="top">
65 <td align="right"><b><?php print_string("name") ?>:</b></td>
66 <td>
67 <input type="text" name="name" size="50" value="<?php p($form->name) ?>" alt="<?php print_string("name") ?>" />
68 </td>
69 </tr>
98ca59f6 70<?php
71 $strfilename = get_string("coursepacket", "scorm");
72 $strchooseafile = get_string("chooseapacket", "scorm");
73?>
2a0407b7 74 <tr valign="top">
75 <td align="right"><b><?php print_string("summary") ?>:</b><br />
76 <font size="1">
77 <?php helpbutton("summary", get_string("summary"), "scorm", true, true) ?>
78 </font>
79 </td>
80 <td>
81 <?php print_textarea($usehtmleditor, 10, 50, 680, 400, "summary", $form->summary); ?>
82 </td>
83 </tr>
84 <tr valign="top">
85 <td align="right" nowrap="nowrap">
86 <b><?php echo $strfilename?>:</b>
87 </td>
88 <td>
89 <?php
90 echo "<input name=\"reference\" size=\"50\" value=\"$form->reference\" alt=\"$strfilename\" />&nbsp;";
91 button_to_popup_window ("/files/index.php?id=$course->id&amp;choose=form.reference",
92 "coursefiles", $strchooseafile, 500, 750, $strchooseafile);
93 helpbutton("package", get_string("coursepacket", "scorm"), "scorm", true);
94 ?>
95 </td>
96 </tr>
97<?php
98 $strnewwindow = get_string("newwindow", "scorm");
99 $strnewwindowopen = get_string("newwindowopen", "scorm");
100 foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
101 $stringname = "str$optionname";
102 $$stringname = get_string("new$optionname", "scorm");
103 $window->$optionname = "";
104 $jsoption[] = "\"$optionname\"";
105 }
106 $alljsoptions = implode(",", $jsoption);
107
108 if ($form->instance) { // Re-editing
109 if ($form->popup == "") {
110 $newwindow = ""; // Disable the new window
111 foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
112 $defaultvalue = "scorm_popup$optionname";
113 $window->$optionname = $CFG->$defaultvalue;
114 }
115 } else {
116 $newwindow = "checked";
117 $rawoptions = explode(',', $form->popup);
118 foreach ($rawoptions as $rawoption) {
119 $option = explode('=', trim($rawoption));
120 if (($option[0] != 'location') && ($option[0] != 'menubar') && ($option[0] != 'toolbar')) {
121 $optionname = $option[0];
122 $optionvalue = $option[1];
123 if ($optionname == "height" or $optionname == "width") {
124 $window->$optionname = $optionvalue;
125 } else if ($optionvalue == 1) {
126 $window->$optionname = "checked";
127 }
128 }
129 }
130 }
131 } else {
132 foreach ($SCORM_WINDOW_OPTIONS as $optionname) {
133 $defaultvalue = "scorm_popup$optionname";
134 $window->$optionname = $CFG->$defaultvalue;
135 }
136 $newwindow = $CFG->scorm_popup;
137 }
138?>
139 <tr valign="top">
140 <td align="right"><b><?php print_string("grademethod", "scorm") ?>:</b></td>
141 <td>
142 <?php
143 $options = array();
144 $options[0] = get_string("gradescoes", "scorm");
145 $options[1] = get_string("gradehighest", "scorm");
146 $options[2] = get_string("gradeaverage", "scorm");
147 choose_from_menu($SCORM_GRADE_METHOD, "grademethod", "$form->grademethod", "");
148 helpbutton("grademethod", get_string("grademethod","scorm"), "scorm");
149 ?>
150 </td>
151 </tr>
152 <tr valign="top">
153 <td align="right"><b><?php print_string("maximumgrade") ?>:</b></td>
154 <td>
155 <?php
156 for ($i=100; $i>=1; $i--) {
157 $grades[$i] = $i;
158 }
159
160 choose_from_menu($grades, "maxgrade", "$form->maxgrade", "");
161 helpbutton("maxgrade", get_string("maximumgrade"), "scorm");
162 ?>
163 </td>
164 </tr>
165 <tr>
166 <td align="right"><b><?php print_string("display", "scorm") ?>:</b></td>
167 <td>
168 <input type="button" value="hide settings" id="windowsettingsbutton" onclick="javascript: return showhide('windowsettings');" />
169 <input type="hidden" name="windowsettingspref" id="windowsettingspref"
170 value="<?php echo get_user_preferences('windowsettingspref', $CFG->scorm_windowsettings); ?>" />
171 <?php helpbutton("window", get_string("display", "scorm"), "scorm", true) ?>
172 </td>
173 </tr>
98ca59f6 174 </table>
2a0407b7 175 <script type="text/javascript">
176 var subitems = [<?php echo $alljsoptions; ?>];
177
178 function autowindow(set) {
179 divobj = document.getElementById('autocontinue');
180 if (document.form.newwindow.checked) {
181 divobj.style.display = 'none';
182 } else {
183 divobj.style.display = 'block';
184 }
185 }
186
187 function showhide (id, set) {
188 divobj = document.getElementById(id);
189 butobj = document.getElementById(id+'button');
190 prefobj = document.getElementById(id+'pref');
191 if (set == true) {
192 if (prefobj.value == '1') {
193 divobj.style.display = 'block';
194 butobj.value = '<?php print_string("hidesettings") ?>';
195 } else {
196 divobj.style.display = 'none';
197 butobj.value = '<?php print_string("showsettings") ?>...';
198 }
199 } else {
200 if (prefobj.value == '1') {
201 divobj.style.display = 'none';
202 butobj.value = '<?php print_string("showsettings") ?>...';
203 prefobj.value = '0';
204 } else {
205 divobj.style.display = 'block';
206 butobj.value = '<?php print_string("hidesettings") ?>';
207 prefobj.value = '1';
208 }
209 }
210 }
211 </script>
212
213 <div id="windowsettings" align="center">
214 <table>
215 <tr valign="top">
216 <td align="right" nowrap="nowrap">
217 <b><?php p($strnewwindow) ?>:</b>
218 </td>
219 <td>
220 <input name="setnewwindow" type="hidden" value="1" />
221 <input name="newwindow" type="checkbox" value="1" onclick="autowindow();return lockoptions('form','newwindow', subitems);" <?php echo $newwindow ?> />
222 <?php echo $strnewwindowopen."\n"; ?>
223 <ul style='list-style-type:none;'><li>
224 <?php
225 foreach ($window as $name => $value) {
226 if ($name == "height" or $name == "width") {
227 continue;
228 }
229 echo "\t\t<input name=\"h$name\" type=\"hidden\" value=\"0\" />\n";
230 if ($window->$name == 'checked') {
231 $window->$name = 'checked="checked"';
232 }
233 echo "\t\t<input name=\"$name\" type=\"checkbox\" value=\"1\" ".$window->$name." /> ";
234 $stringname = "str$name";
235 echo $$stringname."<br />\n";
236 }
237 ?>
238
239 <input name="hwidth" type="hidden" value="0" />
240 <input name="width" type="text" size="4" value="<?php p($window->width) ?>" alt="width" /> <?php p($strwidth) ?><br />
241 <input name="hheight" type="hidden" value="0" />
242 <input name="height" type="text" size="4" value="<?php p($window->height) ?>" alt="height" /> <?php p($strheight) ?><br />
243 <?php
244 if (!$newwindow) {
245 echo "<script type=\"text/javascript\">\n<!--\n";
246 echo "\tlockoptions('form','newwindow', subitems);";
247 echo "\n-->\n</script>";
248 }
249 ?>
250 </li></ul>
251 </td>
252 </tr>
253 </table>
254 <div id="autocontinue">
255 <table>
256 <tr>
257 <td align="right"><b><?php print_string("autocontinue","scorm") ?>:</b></td>
258 <td>
259 <?php
260 $options = array();
261 $options[0]=get_string("no");
262 $options[1]=get_string("yes");
263 choose_from_menu ($options, "auto", $form->auto);
264 helpbutton("autocontinue", get_string("autocontinue", "scorm"), "scorm", true);
265 ?>
266 </td>
267 </tr>
268 </table>
269 </div>
270 </div>
271 <script type="text/javascript">
272 <?php
273 if ($newwindow == "checked") {
274 echo "autowindow();\n";
275 echo "showhide('windowsettings',false);\n";
276 $newwindow = "checked='checked'";
277 } else {
278 echo "showhide('windowsettings',true);\n";
279 }
280 ?>
281 </script>
282 <input type="hidden" name="datadir" value="<?php p($form->datadir) ?>" />
283 <input type="hidden" name="launch" value="<?php p($form->launch) ?>" />
284 <input type="hidden" name="popup" value="<?php p($form->popup) ?>" />
285 <input type="hidden" name="auto" value="<?php p($form->auto) ?>" />
286 <input type="hidden" name="maxgrade" value="<?php p($form->maxgrade) ?>" />
287 <input type="hidden" name="grademethod" value="<?php p($form->grademethod) ?>" />
288
289 <input type="hidden" name="course" value="<?php p($form->course) ?>" />
290 <input type="hidden" name="sesskey" value="<?php p($form->sesskey) ?>" />
291 <input type="hidden" name="coursemodule" value="<?php p($form->coursemodule) ?>" />
292 <input type="hidden" name="section" value="<?php p($form->section) ?>" />
293 <input type="hidden" name="module" value="<?php p($form->module) ?>" />
294 <input type="hidden" name="modulename" value="<?php p($form->modulename) ?>" />
295 <input type="hidden" name="instance" value="<?php p($form->instance) ?>" />
296 <input type="hidden" name="mode" value="<?php p($form->mode) ?>" />
98ca59f6 297 <center>
2a0407b7 298 <input type="submit" value="<?php print_string("savechanges") ?>" />
299 <input type="submit" name="cancel" value="<?php print_string("cancel") ?>" />
98ca59f6 300 </center>
e84ce5c8 301</form>