Skip to content

Commit

Permalink
Uniformed view and playscorm course structure
Browse files Browse the repository at this point in the history
  • Loading branch information
bobopinna committed Apr 4, 2005
1 parent b198a10 commit 867b2a5
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 210 deletions.
118 changes: 117 additions & 1 deletion mod/scorm/lib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -585,6 +585,8 @@ function scorm_get_tracks($scoid,$userid) {
if ($tracks = get_records_select("scorm_scoes_track","userid=$userid AND scoid=$scoid")) { if ($tracks = get_records_select("scorm_scoes_track","userid=$userid AND scoid=$scoid")) {
$user_tracks->userid = $userid; $user_tracks->userid = $userid;
$user_tracks->scoid = $scoid; $user_tracks->scoid = $scoid;
$user_tracks->score_raw = '';
$user_tracks->status = '';
foreach ($tracks as $track) { foreach ($tracks as $track) {
$element = str_replace('.','_',$track->element); $element = str_replace('.','_',$track->element);
switch ($element) { switch ($element) {
Expand Down Expand Up @@ -653,5 +655,119 @@ function scorm_external_link($link) {
else if (substr($link,0,4) == 'www.') else if (substr($link,0,4) == 'www.')
$result = true; $result = true;
return $result; 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;
}
}
?> ?>
133 changes: 7 additions & 126 deletions mod/scorm/playscorm.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -121,14 +121,13 @@ function expandCollide(which,list) {
which.src = "pix/minus.gif"; which.src = "pix/minus.gif";
eval(beg+list+mid+".display='block';"); eval(beg+list+mid+".display='block';");
} }

} }
--> -->
</script> </script>


<script language="JavaScript" type="text/javascript" src="request.js"></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> <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"> <tr><td valign="top">
<p><?php echo text_to_html($scorm->summary, false, false) ?></p> <p><?php echo text_to_html($scorm->summary, false, false) ?></p>
<p><?php echo $mode == 'browse' ? get_string('browsemode','scorm') : '&nbsp;'; ?></p> <p><?php echo $mode == 'browse' ? get_string('browsemode','scorm') : '&nbsp;'; ?></p>
Expand All @@ -143,143 +142,25 @@ function expandCollide(which,list) {
</div> </div>
</th> </th>
</tr> </tr>
<tr><td nowrap> <tr><td nowrap>
<ul id='0' class='scormlist'>
<?php <?php
$incomplete = false; $sco = scorm_display_structure($scorm,'scormlist',$currentorg,$scoid,$mode,true);
if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' AND organization='$currentorg' order by id ASC")){ add_to_log($course->id, 'scorm', 'view', "reviewscorm.php?id=$cm->id&uid=$USER->id&scoid=$sco->id", "$scorm->id");
$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");
?> ?>
</ul>
</td></tr> </td></tr>
<tr><td align="center"> <tr><td align="center">
<form name="navform" method="post" action="playscorm.php?id=<?php echo $cm->id ?>" target="_top"> <form name="navform" method="post" action="playscorm.php?id=<?php echo $cm->id ?>" target="_top">
<input name="scoid" type="hidden" /> <input name="scoid" type="hidden" />
<input name="currentorg" type="hidden" value="<?php echo $currentorg ?>" /> <input name="currentorg" type="hidden" value="<?php echo $currentorg ?>" />
<input name="mode" type="hidden" value="<?php echo $mode ?>" /> <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="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 ($nextid == 0) { print_string('exit','scorm'); } else { print_string('next','scorm'); } ?>" onClick="playSCO(<?php echo $nextid ?>)" /> <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> </form>
</td></tr> </td></tr>
</table> </table>
</td> </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> <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> </td></tr>
</table> </table>
</body> </body>
Expand Down
Loading

0 comments on commit 867b2a5

Please sign in to comment.