Permalink
Browse files

Uniformed view and playscorm course structure

  • Loading branch information...
1 parent b198a10 commit 867b2a5c5b02c53862afc279cff4a9cc63891d20 bobopinna committed Apr 4, 2005
Showing with 136 additions and 210 deletions.
  1. +117 −1 mod/scorm/lib.php
  2. +7 −126 mod/scorm/playscorm.php
  3. +12 −83 mod/scorm/view.php
View
@@ -585,6 +585,8 @@ function scorm_get_tracks($scoid,$userid) {
if ($tracks = get_records_select("scorm_scoes_track","userid=$userid AND scoid=$scoid")) {
$user_tracks->userid = $userid;
$user_tracks->scoid = $scoid;
+ $user_tracks->score_raw = '';
+ $user_tracks->status = '';
foreach ($tracks as $track) {
$element = str_replace('.','_',$track->element);
switch ($element) {
@@ -653,5 +655,119 @@ function scorm_external_link($link) {
else if (substr($link,0,4) == 'www.')
$result = true;
return $result;
-}
+}
+
+function scorm_display_structure($scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$play=false) {
+ global $USER;
+
+ $strexpand = get_string('expcoll','scorm');
+
+ echo "<ul id='0' class='$liststyle'>";
+ $incomplete = false;
+ $organizationSQL = '';
+ if (empty($currentorg)) {
+ //
+ } else {
+ $organizationSQL = "AND organization='$currentorg'";
+ }
+ if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' $organizationSQL order by id ASC")){
+ $level=0;
+ $sublist=1;
+ $previd = 0;
+ $nextid = 0;
+ $parents[$level]="/";
+ foreach ($scoes as $sco) {
+ if ($parents[$level]!=$sco->parent) {
+ if ($level>0 && $parents[$level-1]==$sco->parent) {
+ echo "\t\t</ul></li>\n";
+ $level--;
+ } else {
+ $i = $level;
+ $closelist = '';
+ while (($i > 0) && ($parents[$level] != $sco->parent)) {
+ $closelist .= "\t\t</ul></li>\n";
+ $i--;
+ }
+ if (($i == 0) && ($sco->parent != $currentorg)) {
+ echo "\t\t<li><ul id='".$sublist."' class='$liststyle'>\n";
+ $level++;
+ } else {
+ echo $closelist;
+ $level = $i;
+ }
+ $parents[$level]=$sco->parent;
+ }
+ }
+ echo "\t\t<li>";
+ $nextsco = next($scoes);
+ if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
+ $sublist++;
+ echo "<a href='#' onClick='expandCollide(img".$sublist.",".$sublist.");'><img id='img".$sublist."' src='pix/minus.gif' alt='$strexpand' title='$strexpand'/></a>";
+ } else {
+ echo "<img src='pix/spacer.gif' />";
+ }
+
+ if ($sco->launch) {
+ $startbold = '';
+ $endbold = '';
+ $score = '';
+ if ($user_tracks=scorm_get_tracks($sco->id,$USER->id)) {
+ if ( $user_tracks->status == '') {
+ $user_tracks->status = 'notattempted';
+ }
+ $strstatus = get_string($user_tracks->status,'scorm');
+ echo "<img src='pix/".$user_tracks->status.".gif' alt='$strstatus' title='$strstatus' />";
+ if (($user_tracks->status == 'notattempted') || ($user_tracks->status == 'incomplete')) {
+ $incomplete = true;
+ if ($play && empty($scoid)) {
+ $scoid = $sco->id;
+ }
+ }
+ if ($user_tracks->score_raw != "") {
+ $score = '('.get_string('score','scorm').':&nbsp;'.$user_tracks->score_raw.')';
+ }
+ } else {
+ if ($play && ($mode != 'normal') && empty($scoid)) {
+ $scoid = $sco->id;
+ }
+ if ($sco->scormtype == 'sco') {
+ echo "<img src='pix/notattempted.gif' alt='".get_string('notattempted','scorm')."' />";
+ $incomplete = true;
+ } else {
+ echo "<img src='pix/asset.gif' alt='".get_string('asset','scorm')."' />";
+ }
+ }
+
+ if ($sco->id == $scoid) {
+ $startbold = '&gt; <b>';
+ $endbold = '</b> &lt;';
+ if ($nextsco !== false) {
+ $nextid = $nextsco->id;
+ } else {
+ $nextid = 0;
+ }
+ }
+ if ($nextid == 0) {
+ $previd = $sco->id;
+ }
+
+ echo "&nbsp;$startbold<a href='javascript:playSCO(".$sco->id.");'>$sco->title</a> $score$endbold</li>\n";
+ } else {
+ echo "&nbsp;$sco->title</li>\n";
+ }
+ }
+ for ($i=0;$i<$level;$i++) {
+ echo "\t\t</ul></li>\n";
+ }
+ }
+ echo "\t</ul>\n";
+ if ($play) {
+ $result->id = $scoid;
+ $result->prev = $previd;
+ $result->next = $nextid;
+ return $result;
+ } else {
+ return $incomplete;
+ }
+}
?>
View
@@ -121,14 +121,13 @@ function expandCollide(which,list) {
which.src = "pix/minus.gif";
eval(beg+list+mid+".display='block';");
}
-
}
-->
</script>
<script language="JavaScript" type="text/javascript" src="request.js"></script>
<script language="JavaScript" type="text/javascript" src="api.php?id=<?php echo $cm->id ?>"></script>
- <table border=1 class="fullscreen" height="90%">
+ <table class="fullscreen" height="90%">
<tr><td valign="top">
<p><?php echo text_to_html($scorm->summary, false, false) ?></p>
<p><?php echo $mode == 'browse' ? get_string('browsemode','scorm') : '&nbsp;'; ?></p>
@@ -143,143 +142,25 @@ function expandCollide(which,list) {
</div>
</th>
</tr>
- <tr><td nowrap>
- <ul id='0' class='scormlist'>
+ <tr><td nowrap>
<?php
- $incomplete = false;
- if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' AND organization='$currentorg' order by id ASC")){
- $level=0;
- $sublist=1;
- $previd = 0;
- $nextid = 0;
- $parents[$level]="/";
- foreach ($scoes as $sco) {
- if ($parents[$level]!=$sco->parent) {
- if ($level>0 && $parents[$level-1]==$sco->parent) {
- echo "\t\t</ul></li>\n";
- $level--;
- } else {
- $i = $level;
- $closelist = '';
- while (($i > 0) && ($parents[$level] != $sco->parent)) {
- $closelist .= "\t\t</ul></li>\n";
- $i--;
- }
- if (($i == 0) && ($sco->parent != $currentorg)) {
- echo "\t\t<li><ul id='".$sublist."' class='scormlist'>\n";
- $level++;
- } else {
- echo $closelist;
- $level = $i;
- }
- $parents[$level]=$sco->parent;
- }
- }
- echo "\t\t<li>";
- $nextsco = next($scoes);
- if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) ||
- (($level>0) && ($nextsco->parent == $sco->identifier)))) {
- $sublist++;
-
- echo "<a href='#' onClick='expandCollide(img".$sublist.",".$sublist.");'><img id='img".$sublist."' src='pix/minus.gif' alt='$strexpand' title='$strexpand'/></a>";
- } else {
- echo "<img src='pix/spacer.gif' />";
- }
-
- if ($sco->launch) {
- $startbold = '';
- $endbold = '';
- $score = '';
- if ($scoid != '') {
- if ($sco->id == $scoid) {
- $startbold = '-> <b>';
- $endbold = '</b> <-';
- if ($nextsco !== false) {
- $nextid = $nextsco->id;
- } else {
- $nextid = 0;
- }
- }
- } else {
- if ($user_tracks=scorm_get_tracks($sco->id,$USER->id)) {
- if ( $user_tracks->status == '') {
- $user_tracks->status = 'notattempted';
- }
- $strstatus = get_string($user_tracks->status,'scorm');
- echo "<img src='pix/".$user_tracks->status.".gif' alt='$strstatus' title='$strstatus' />";
- if (($user_tracks->status == 'notattempted') || ($user_tracks->status == 'incomplete')) {
- $incomplete = true;
- $scoid = $sco->id;
- $startbold = '-> <b>';
- $endbold = '</b> <-';
- if ($nextsco !== false) {
- $nextid = $nextsco->id;
- } else {
- $nextid = 0;
- }
- }
- if ($user_tracks->score_raw != "") {
- $score = '('.get_string('score','scorm').':&nbsp;'.$user_tracks->score_raw.')';
- }
- } else {
- if (mode != 'normal') {
- $scoid = $sco->id;
- $startbold = '-> <b>';
- $endbold = '</b> <-';
- if ($nextsco !== false) {
- $nextid = $nextsco->id;
- } else {
- $nextid = 0;
- }
- }
- if ($sco->scormtype == 'sco') {
- echo "<img src='pix/notattempted.gif' alt='".get_string('notattempted','scorm')."' />";
- $incomplete = true;
- } else {
- echo "<img src='pix/asset.gif' alt='".get_string('asset','scorm')."' />";
- }
- }
- }
- if ($nextid == 0) {
- $previd = $sco->id;
- }
-
- echo "&nbsp;$startbold<a href='javascript:playSCO(".$sco->id.");'>$sco->title</a> $score$endbold</li>\n";
- } else {
- echo "&nbsp;$sco->title</li>\n";
- }
- }
- for ($i=0;$i<$level;$i++) {
- echo "\t\t</ul></li>\n";
- }
- }
- add_to_log($course->id, 'scorm', 'view', "reviewscorm.php?id=$cm->id&uid=$USER->id&scoid=$scoid", "$scorm->id");
+ $sco = scorm_display_structure($scorm,'scormlist',$currentorg,$scoid,$mode,true);
+ add_to_log($course->id, 'scorm', 'view', "reviewscorm.php?id=$cm->id&uid=$USER->id&scoid=$sco->id", "$scorm->id");
?>
- </ul>
</td></tr>
<tr><td align="center">
<form name="navform" method="post" action="playscorm.php?id=<?php echo $cm->id ?>" target="_top">
<input name="scoid" type="hidden" />
<input name="currentorg" type="hidden" value="<?php echo $currentorg ?>" />
<input name="mode" type="hidden" value="<?php echo $mode ?>" />
- <input name="prev" type="<?php if ($previd == 0) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('prev','scorm') ?>" onClick="playSCO(<?php echo $previd ?>);" />
- <input name="next" type="button" value="<?php if ($nextid == 0) { print_string('exit','scorm'); } else { print_string('next','scorm'); } ?>" onClick="playSCO(<?php echo $nextid ?>)" />
+ <input name="prev" type="<?php if ($sco->prev == 0) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('prev','scorm') ?>" onClick="playSCO(<?php echo $sco->prev ?>);" />
+ <input name="next" type="button" value="<?php if ($sco->next == 0) { print_string('exit','scorm'); } else { print_string('next','scorm'); } ?>" onClick="playSCO(<?php echo $sco->next ?>)" />
</form>
</td></tr>
</table>
</td>
- <td class="fullscreen">
+ <td class="fullscreen" height="90%">
<iframe name="main" class="fullscreen" height="100%" src="loadSCO.php?id=<?php echo $cm->id.$scoidstring ?>"></iframe>
- <script language="javascript">
- if (parseInt(navigator.appVersion)>3) {
- if (navigator.appName.indexOf("Microsoft")!=-1) {
- winH = document.body.offsetHeight-20;
- } else {
- winH = window.innerHeight-16;
- }
- }
- main.height = winH;
- </script>
</td></tr>
</table>
</body>
Oops, something went wrong.

0 comments on commit 867b2a5

Please sign in to comment.