SCORM MDL-25781 fix links in TOC on view.php
[moodle.git] / mod / scorm / datamodels / aicclib.php
CommitLineData
e5dd8e3b 1<?php
e23cc5d2 2
dc383b6f 3function scorm_add_time($a, $b) {
4 $aes = explode(':',$a);
5 $bes = explode(':',$b);
6 $aseconds = explode('.',$aes[2]);
7 $bseconds = explode('.',$bes[2]);
8 $change = 0;
9
10 $acents = 0; //Cents
11 if (count($aseconds) > 1) {
12 $acents = $aseconds[1];
13 }
14 $bcents = 0;
15 if (count($bseconds) > 1) {
16 $bcents = $bseconds[1];
17 }
18 $cents = $acents + $bcents;
19 $change = floor($cents / 100);
20 $cents = $cents - ($change * 100);
21 if (floor($cents) < 10) {
22 $cents = '0'. $cents;
23 }
24
25 $secs = $aseconds[0] + $bseconds[0] + $change; //Seconds
26 $change = floor($secs / 60);
27 $secs = $secs - ($change * 60);
28 if (floor($secs) < 10) {
29 $secs = '0'. $secs;
30 }
31
32 $mins = $aes[1] + $bes[1] + $change; //Minutes
33 $change = floor($mins / 60);
34 $mins = $mins - ($change * 60);
35 if ($mins < 10) {
36 $mins = '0' . $mins;
37 }
38
39 $hours = $aes[0] + $bes[0] + $change; //Hours
40 if ($hours < 10) {
41 $hours = '0' . $hours;
42 }
43
44 if ($cents != '0') {
45 return $hours . ":" . $mins . ":" . $secs . '.' . $cents;
46 } else {
47 return $hours . ":" . $mins . ":" . $secs;
48 }
49}
50
51/**
52* Take the header row of an AICC definition file
53* and returns sequence of columns and a pointer to
54* the sco identifier column.
55*
56* @param string $row AICC header row
57* @param string $mastername AICC sco identifier column
58* @return mixed
59*/
60function scorm_get_aicc_columns($row,$mastername='system_id') {
61 $tok = strtok(strtolower($row),"\",\n\r");
39790bd8 62 $result = new stdClass();
dc383b6f 63 $result->columns = array();
64 $i=0;
65 while ($tok) {
66 if ($tok !='') {
67 $result->columns[] = $tok;
68 if ($tok == $mastername) {
69 $result->mastercol = $i;
70 }
71 $i++;
72 }
73 $tok = strtok("\",\n\r");
74 }
75 return $result;
76}
77
78/**
79* Given a colums array return a string containing the regular
80* expression to match the columns in a text row.
81*
82* @param array $column The header columns
83* @param string $remodule The regular expression module for a single column
84* @return string
85*/
86function scorm_forge_cols_regexp($columns,$remodule='(".*")?,') {
87 $regexp = '/^';
88 foreach ($columns as $column) {
89 $regexp .= $remodule;
90 }
91 $regexp = substr($regexp,0,-1) . '/';
92 return $regexp;
93}
94
9528568b 95
96function scorm_parse_aicc($scorm) {
bf347041 97 global $DB;
98
9528568b 99 if (!isset($scorm->cmid)) {
100 $cm = get_coursemodule_from_instance('scorm', $scorm->id);
101 $scorm->cmid = $cm->id;
102 }
e23cc5d2 103 $context = get_context_instance(CONTEXT_MODULE, $scorm->cmid);
9528568b 104
105 $fs = get_file_storage();
106
64f93798 107 $files = $fs->get_area_files($context->id, 'mod_scorm', 'content', 0, '', false);
9528568b 108
109
dc383b6f 110 $version = 'AICC';
111 $ids = array();
112 $courses = array();
113 $extaiccfiles = array('crs','des','au','cst','ort','pre','cmp');
9528568b 114
115 foreach ($files as $file) {
116 $filename = $file->get_filename();
117 $ext = substr($filename,strrpos($filename,'.'));
118 $extension = strtolower(substr($ext,1));
119 if (in_array($extension,$extaiccfiles)) {
120 $id = strtolower(basename($filename,$ext));
121 $ids[$id]->$extension = $file;
dc383b6f 122 }
dc383b6f 123 }
9528568b 124
dc383b6f 125 foreach ($ids as $courseid => $id) {
126 if (isset($id->crs)) {
e23cc5d2 127 $contents = $id->crs->get_content();
128 $rows = explode("\r\n", $contents);
129 if (is_array($rows)) {
130 foreach ($rows as $row) {
131 if (preg_match("/^(.+)=(.+)$/",$row,$matches)) {
132 switch (strtolower(trim($matches[1]))) {
133 case 'course_id':
134 $courses[$courseid]->id = trim($matches[2]);
135 break;
136 case 'course_title':
137 $courses[$courseid]->title = trim($matches[2]);
138 break;
139 case 'version':
140 $courses[$courseid]->version = 'AICC_'.trim($matches[2]);
141 break;
142 }
dc383b6f 143 }
144 }
145 }
146 }
147 if (isset($id->des)) {
e23cc5d2 148 $contents = $id->des->get_content();
149 $rows = explode("\r\n", $contents);
dc383b6f 150 $columns = scorm_get_aicc_columns($rows[0]);
151 $regexp = scorm_forge_cols_regexp($columns->columns);
152 for ($i=1;$i<count($rows);$i++) {
153 if (preg_match($regexp,$rows[$i],$matches)) {
154 for ($j=0;$j<count($columns->columns);$j++) {
155 $column = $columns->columns[$j];
156 $courses[$courseid]->elements[substr(trim($matches[$columns->mastercol+1]),1,-1)]->$column = substr(trim($matches[$j+1]),1,-1);
157 }
158 }
159 }
160 }
161 if (isset($id->au)) {
e23cc5d2 162 $contents = $id->au->get_content();
163 $rows = explode("\r\n", $contents);
dc383b6f 164 $columns = scorm_get_aicc_columns($rows[0]);
165 $regexp = scorm_forge_cols_regexp($columns->columns);
166 for ($i=1;$i<count($rows);$i++) {
167 if (preg_match($regexp,$rows[$i],$matches)) {
168 for ($j=0;$j<count($columns->columns);$j++) {
169 $column = $columns->columns[$j];
170 $courses[$courseid]->elements[substr(trim($matches[$columns->mastercol+1]),1,-1)]->$column = substr(trim($matches[$j+1]),1,-1);
171 }
172 }
173 }
174 }
175 if (isset($id->cst)) {
e23cc5d2 176 $contents = $id->cst->get_content();
177 $rows = explode("\r\n", $contents);
dc383b6f 178 $columns = scorm_get_aicc_columns($rows[0],'block');
179 $regexp = scorm_forge_cols_regexp($columns->columns,'(.+)?,');
180 for ($i=1;$i<count($rows);$i++) {
181 if (preg_match($regexp,$rows[$i],$matches)) {
182 for ($j=0;$j<count($columns->columns);$j++) {
183 if ($j != $columns->mastercol) {
184 $courses[$courseid]->elements[substr(trim($matches[$j+1]),1,-1)]->parent = substr(trim($matches[$columns->mastercol+1]),1,-1);
185 }
186 }
187 }
188 }
189 }
190 if (isset($id->ort)) {
e23cc5d2 191 $contents = $id->ort->get_content();
192 $rows = explode("\r\n", $contents);
f6520280 193 $columns = scorm_get_aicc_columns($rows[0],'course_element');
194 $regexp = scorm_forge_cols_regexp($columns->columns,'(.+)?,');
195 for ($i=1;$i<count($rows);$i++) {
196 if (preg_match($regexp,$rows[$i],$matches)) {
197 for ($j=0;$j<count($matches)-1;$j++) {
198 if ($j != $columns->mastercol) {
199 $courses[$courseid]->elements[substr(trim($matches[$j+1]),1,-1)]->parent = substr(trim($matches[$columns->mastercol+1]),1,-1);
200 }
201 }
202 }
203 }
dc383b6f 204 }
205 if (isset($id->pre)) {
e23cc5d2 206 $contents = $id->pre->get_content();
207 $rows = explode("\r\n", $contents);
dc383b6f 208 $columns = scorm_get_aicc_columns($rows[0],'structure_element');
209 $regexp = scorm_forge_cols_regexp($columns->columns,'(.+),');
210 for ($i=1;$i<count($rows);$i++) {
211 if (preg_match($regexp,$rows[$i],$matches)) {
212 $courses[$courseid]->elements[$columns->mastercol+1]->prerequisites = substr(trim($matches[1-$columns->mastercol+1]),1,-1);
213 }
214 }
215 }
216 if (isset($id->cmp)) {
e23cc5d2 217 $contents = $id->cmp->get_content();
218 $rows = explode("\r\n", $contents);
dc383b6f 219 }
220 }
221 //print_r($courses);
222
9528568b 223 $oldscoes = $DB->get_records('scorm_scoes', array('scorm'=>$scorm->id));
d9e6517a 224
dc383b6f 225 $launch = 0;
226 if (isset($courses)) {
227 foreach ($courses as $course) {
39790bd8 228 $sco = new stdClass();
dc383b6f 229 $sco->identifier = $course->id;
9528568b 230 $sco->scorm = $scorm->id;
dc383b6f 231 $sco->organization = '';
232 $sco->title = $course->title;
233 $sco->parent = '/';
234 $sco->launch = '';
235 $sco->scormtype = '';
236
237 //print_r($sco);
9528568b 238 if ($ss = $DB->get_record('scorm_scoes', array('scorm'=>$scorm->id,'identifier'=>$sco->identifier))) {
bf347041 239 $id = $ss->id;
240 $DB->update_record('scorm_scoes',$sco);
dc383b6f 241 unset($oldscoes[$id]);
242 } else {
bf347041 243 $id = $DB->insert_record('scorm_scoes',$sco);
dc383b6f 244 }
245
246 if ($launch == 0) {
247 $launch = $id;
248 }
249 if (isset($course->elements)) {
250 foreach($course->elements as $element) {
251 unset($sco);
252 $sco->identifier = $element->system_id;
9528568b 253 $sco->scorm = $scorm->id;
dc383b6f 254 $sco->organization = $course->id;
255 $sco->title = $element->title;
d9e6517a 256
f6520280 257 if (!isset($element->parent) || strtolower($element->parent) == 'root') {
dc383b6f 258 $sco->parent = '/';
259 } else {
260 $sco->parent = $element->parent;
261 }
262 if (isset($element->file_name)) {
263 $sco->launch = $element->file_name;
264 $sco->scormtype = 'sco';
f6520280 265 $sco->previous = 0;
266 $sco->next = 0;
267 $id = null;
268 if ($oldscoid = scorm_array_search('identifier',$sco->identifier,$oldscoes)) {
269 $sco->id = $oldscoid;
dd88de0e
PS
270 $DB->update_record('scorm_scoes',$sco);
271 $id = $oldscoid;
bf347041 272 $DB->delete_records('scorm_scoes_data', array('scoid'=>$oldscoid));
f6520280 273 unset($oldscoes[$oldscoid]);
274 } else {
bf347041 275 $id = $DB->insert_record('scorm_scoes',$sco);
f6520280 276 }
277 if (!empty($id)) {
39790bd8 278 $scodata = new stdClass();
f6520280 279 $scodata->scoid = $id;
280 if (isset($element->web_launch)) {
281 $scodata->name = 'parameters';
282 $scodata->value = $element->web_launch;
bf347041 283 $dataid = $DB->insert_record('scorm_scoes_data',$scodata);
f6520280 284 }
285 if (isset($element->prerequisites)) {
286 $scodata->name = 'prerequisites';
287 $scodata->value = $element->prerequisites;
bf347041 288 $dataid = $DB->insert_record('scorm_scoes_data',$scodata);
f6520280 289 }
290 if (isset($element->max_time_allowed)) {
291 $scodata->name = 'max_time_allowed';
292 $scodata->value = $element->max_time_allowed;
bf347041 293 $dataid = $DB->insert_record('scorm_scoes_data',$scodata);
f6520280 294 }
295 if (isset($element->time_limit_action)) {
296 $scodata->name = 'time_limit_action';
297 $scodata->value = $element->time_limit_action;
bf347041 298 $dataid = $DB->insert_record('scorm_scoes_data',$scodata);
f6520280 299 }
300 if (isset($element->mastery_score)) {
301 $scodata->name = 'mastery_score';
302 $scodata->value = $element->mastery_score;
bf347041 303 $dataid = $DB->insert_record('scorm_scoes_data',$scodata);
f6520280 304 }
52005f34 305 if (isset($element->core_vendor)) {
306 $scodata->name = 'datafromlms';
6dbcacee 307 $scodata->value = preg_replace('/<cr>/i', "\r\n", $element->core_vendor);
c6089d93 308 $dataid = $DB->insert_record('scorm_scoes_data',$scodata);
52005f34 309 }
f6520280 310 }
311 if ($launch==0) {
312 $launch = $id;
313 }
dc383b6f 314 }
315 }
316 }
317 }
318 }
319 if (!empty($oldscoes)) {
320 foreach($oldscoes as $oldsco) {
bf347041 321 $DB->delete_records('scorm_scoes', array('id'=>$oldsco->id));
322 $DB->delete_records('scorm_scoes_track', array('scoid'=>$oldsco->id));
dc383b6f 323 }
324 }
9528568b 325
326 $scorm->version = 'AICC';
327
328 $scorm->launch = $launch;
329
330 return true;
dc383b6f 331}
332
08868f58 333function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
d436d197 334 global $CFG, $DB, $PAGE, $OUTPUT;
d9e6517a 335
dc383b6f 336 $strexpand = get_string('expcoll','scorm');
337 $modestr = '';
338 if ($mode == 'browse') {
339 $modestr = '&amp;mode='.$mode;
d9e6517a 340 }
d9e6517a 341
dc383b6f 342 $result = new stdClass();
5c2aa157 343 //$result->toc = "<ul id='s0' class='$liststyle'>\n";
eea0c8ea
PH
344 if ($tocheader) {
345 $result->toc = '<div id="scorm_layout">';
346 $result->toc .= '<div id="scorm_toc">';
347 $result->toc .= '<div id="scorm_tree">';
348 }
349 $result->toc .= '<ul>';
dc383b6f 350 $tocmenus = array();
351 $result->prerequisites = true;
352 $incomplete = false;
d9e6517a 353
dc383b6f 354 //
355 // Get the current organization infos
356 //
dc383b6f 357 if (!empty($currentorg)) {
bf347041 358 if (($organizationtitle = $DB->get_field('scorm_scoes','title', array('scorm'=>$scorm->id,'identifier'=>$currentorg))) != '') {
5c2aa157
DM
359 if ($play) {
360 $result->toctitle = "$organizationtitle";
361 }
362 else {
363 $result->toc .= "\t<li>$organizationtitle</li>\n";
364 }
dc383b6f 365 $tocmenus[] = $organizationtitle;
366 }
dc383b6f 367 }
368 //
369 // If not specified retrieve the last attempt number
370 //
371 if (empty($attempt)) {
372 $attempt = scorm_get_last_attempt($scorm->id, $user->id);
373 }
374 $result->attemptleft = $scorm->maxattempt - $attempt;
82605bea 375 if ($scoes = scorm_get_scoes($scorm->id, $currentorg)){
dc383b6f 376 //
377 // Retrieve user tracking data for each learning object
d9e6517a 378 //
dc383b6f 379 $usertracks = array();
380 foreach ($scoes as $sco) {
381 if (!empty($sco->launch)) {
f3f58e0b
DM
382 if (empty($scoid)) {
383 $scoid = $sco->id;
384 }
82605bea 385 if ($usertrack = scorm_get_tracks($sco->id,$user->id,$attempt)) {
dc383b6f 386 if ($usertrack->status == '') {
387 $usertrack->status = 'notattempted';
388 }
389 $usertracks[$sco->identifier] = $usertrack;
390 }
391 }
392 }
393
394 $level=0;
395 $sublist=1;
396 $previd = 0;
397 $nextid = 0;
398 $findnext = false;
399 $parents[$level]='/';
d9e6517a 400
82605bea 401 foreach ($scoes as $pos => $sco) {
f6520280 402 $isvisible = false;
bf347041 403 $sco->title = $sco->title;
82605bea 404 if (!isset($sco->isvisible) || (isset($sco->isvisible) && ($sco->isvisible == 'true'))) {
405 $isvisible = true;
f6520280 406 }
dc383b6f 407 if ($parents[$level]!=$sco->parent) {
408 if ($newlevel = array_search($sco->parent,$parents)) {
409 for ($i=0; $i<($level-$newlevel); $i++) {
eea0c8ea 410 $result->toc .= "\t\t</li></ul></li>\n";
dc383b6f 411 }
412 $level = $newlevel;
413 } else {
414 $i = $level;
415 $closelist = '';
416 while (($i > 0) && ($parents[$level] != $sco->parent)) {
eea0c8ea 417 $closelist .= "\t\t</li></ul></li>\n";
dc383b6f 418 $i--;
419 }
420 if (($i == 0) && ($sco->parent != $currentorg)) {
421 $style = '';
422 if (isset($_COOKIE['hide:SCORMitem'.$sco->id])) {
423 $style = ' style="display: none;"';
424 }
5c2aa157
DM
425 //$result->toc .= "\t\t<li><ul id='s$sublist' class='$liststyle'$style>\n";
426 $result->toc .= "\t\t<ul>\n";
dc383b6f 427 $level++;
428 } else {
429 $result->toc .= $closelist;
430 $level = $i;
431 }
432 $parents[$level]=$sco->parent;
433 }
434 }
f6520280 435 if ($isvisible) {
436 $result->toc .= "\t\t<li>";
437 }
9fb2de4e 438 if (isset($scoes[$pos+1])) {
439 $nextsco = $scoes[$pos+1];
440 } else {
441 $nextsco = false;
442 }
f6520280 443 $nextisvisible = false;
82605bea 444 if (!isset($nextsco->isvisible) || (isset($nextsco->isvisible) && ($nextsco->isvisible == 'true'))) {
445 $nextisvisible = true;
f6520280 446 }
447 if ($nextisvisible && ($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
dc383b6f 448 $sublist++;
449 $icon = 'minus';
450 if (isset($_COOKIE['hide:SCORMitem'.$nextsco->id])) {
451 $icon = 'plus';
452 }
5c2aa157 453 //$result->toc .= '<a href="javascript:expandCollide(\'img'.$sublist.'\',\'s'.$sublist.'\','.$nextsco->id.');"><img id="img'.$sublist.'" src="'.$OUTPUT->pix_url($icon, 'scorm').'" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
f6520280 454 } else if ($isvisible) {
5c2aa157 455 //$result->toc .= '<img src="'.$OUTPUT->pix_url('spacer', 'scorm').'" alt="" />';
dc383b6f 456 }
457 if (empty($sco->title)) {
458 $sco->title = $sco->identifier;
459 }
460 if (!empty($sco->launch)) {
f6520280 461 if ($isvisible) {
462 $startbold = '';
463 $endbold = '';
464 $score = '';
465 if (empty($scoid) && ($mode != 'normal')) {
466 $scoid = $sco->id;
530a61d5 467 }
f6520280 468 if (isset($usertracks[$sco->identifier])) {
469 $usertrack = $usertracks[$sco->identifier];
470 $strstatus = get_string($usertrack->status,'scorm');
471 if ($sco->scormtype == 'sco') {
485f4ce6 472 $statusicon = '<img src="'.$OUTPUT->pix_url($usertrack->status, 'scorm').'" alt="'.$strstatus.'" title="'.$strstatus.'" />';
f6520280 473 } else {
485f4ce6 474 $statusicon = '<img src="'.$OUTPUT->pix_url('assetc', 'scorm').'" alt="'.get_string('assetlaunched','scorm').'" title="'.get_string('assetlaunched','scorm').'" />';
f6520280 475 }
d9e6517a 476
f6520280 477 if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete') || ($usertrack->status == 'browsed')) {
478 $incomplete = true;
479 if ($play && empty($scoid)) {
480 $scoid = $sco->id;
481 }
482 }
483 if ($usertrack->score_raw != '') {
484 $score = '('.get_string('score','scorm').':&nbsp;'.$usertrack->score_raw.')';
485 }
486 $strsuspended = get_string('suspended','scorm');
946b6f0d 487 if ($incomplete && isset($usertrack->{'cmi.core.exit'}) && ($usertrack->{'cmi.core.exit'} == 'suspend')) {
485f4ce6 488 $statusicon = '<img src="'.$OUTPUT->pix_url('suspend', 'scorm').'" alt="'.$strstatus.' - '.$strsuspended.'" title="'.$strstatus.' - '.$strsuspended.'" />';
f6520280 489 }
490 } else {
dc383b6f 491 if ($play && empty($scoid)) {
492 $scoid = $sco->id;
493 }
f6520280 494 $incomplete = true;
495 if ($sco->scormtype == 'sco') {
485f4ce6 496 $statusicon = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
f6520280 497 } else {
485f4ce6 498 $statusicon = '<img src="'.$OUTPUT->pix_url('asset', 'scorm').'" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
f6520280 499 }
530a61d5 500 }
f6520280 501 if ($sco->id == $scoid) {
f6520280 502 $startbold = '<b>';
503 $endbold = '</b>';
504 $findnext = true;
82605bea 505 $shownext = isset($sco->next) ? $sco->next : 0;
506 $showprev = isset($sco->previous) ? $sco->previous : 0;
dc383b6f 507 }
d9e6517a 508
f6520280 509 if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
510 if (!empty($sco->launch)) {
511 $previd = $sco->id;
512 }
dc383b6f 513 }
f6520280 514 if (empty($sco->prerequisites) || scorm_eval_prerequisites($sco->prerequisites,$usertracks)) {
515 if ($sco->id == $scoid) {
516 $result->prerequisites = true;
517 }
08868f58 518
5c2aa157 519 $thisscoidstr = '&scoid='.$sco->id;
821aa03d 520 $link = 'a='.$scorm->id.$thisscoidstr.'&currentorg='.$currentorg.$modestr.'&attempt='.$attempt;
08868f58
DM
521
522 if ($toclink == TOCFULLURL) { //display toc with urls for structure page
523 $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
524 $result->toc .= $statusicon.'&nbsp;<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score."\n";
525 } else {
526 if ($sco->launch) {
527 $result->toc .= '<a title="'.$link.'">'.$statusicon.'&nbsp;'.format_string($sco->title).'&nbsp;'.$score.'</a>';
528 } else {
529 $result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
530 }
eea0c8ea 531 }
f6520280 532 $tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
533 } else {
534 if ($sco->id == $scoid) {
535 $result->prerequisites = false;
536 }
eea0c8ea
PH
537 if ($play) {
538 // should be disabled
539 $result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
540 }
541 else {
542 $result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n";
543 }
544 }
545 if (($nextsco === false) || $nextsco->parent == $sco->parent) {
546 $result->toc .= '</li>';
dc383b6f 547 }
dc383b6f 548 }
549 } else {
c852a628 550 $result->toc .= '&nbsp;'.format_string($sco->title)."</li>\n";
dc383b6f 551 }
552 if (($nextsco !== false) && ($nextid == 0) && ($findnext)) {
553 if (!empty($nextsco->launch)) {
554 $nextid = $nextsco->id;
555 }
556 }
557 }
558 for ($i=0;$i<$level;$i++) {
559 $result->toc .= "\t\t</ul></li>\n";
560 }
d9e6517a 561
dc383b6f 562 if ($play) {
f6520280 563 $sco = scorm_get_sco($scoid);
dc383b6f 564 $sco->previd = $previd;
565 $sco->nextid = $nextid;
566 $result->sco = $sco;
567 $result->incomplete = $incomplete;
568 } else {
569 $result->incomplete = $incomplete;
570 }
571 }
eea0c8ea 572 $result->toc .= '</ul>';
5c2aa157
DM
573
574 // NEW IMS TOC
eea0c8ea
PH
575 if ($tocheader) {
576 $result->toc .= '</div></div></div>';
577 $result->toc .= '<div id="scorm_navpanel"></div>';
578 }
5c2aa157
DM
579
580
dc383b6f 581 if ($scorm->hidetoc == 0) {
25b6fe05 582 $result->toc .= html_writer::script(js_writer::set_variable('scormdata', array(
485f4ce6
PH
583 'plusicon' => $OUTPUT->pix_url('plus', 'scorm'),
584 'minusicon' => $OUTPUT->pix_url('minus', 'scorm'))));
25b6fe05
PS
585 $result->toc .= html_writer::script('', $CFG->wwwroot.'/lib/cookies.js');
586 $result->toc .= html_writer::script('', $CFG->wwwroot.'/mod/scorm/datamodels/scorm_datamodels.js');
dc383b6f 587 }
d9e6517a 588
f8dab966
PS
589 $url = new moodle_url('/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr);
590 $result->tocmenu = $OUTPUT->single_select($url, 'scoid', $tocmenus, $sco->id, null, "tocmenu");
dc383b6f 591
592 return $result;
593}
594
e5dd8e3b 595