Putting in Bobo's latest changes (from the contrib version)
This commit is contained in:
+6
-24
@@ -119,6 +119,12 @@ function SCORMapi() {
|
||||
if ((parseFloat(value,10)).toString() != value) {
|
||||
errorCode = 405;
|
||||
return "false";
|
||||
} else {
|
||||
rawvalue = parseFloat(value,10);
|
||||
if ((rawvalue<0) || (rawvalue>100)) {
|
||||
errorCode = 405;
|
||||
return "false";
|
||||
}
|
||||
}
|
||||
eval(param+'="'+value+'";');
|
||||
errorCode = 0;
|
||||
@@ -278,27 +284,3 @@ function SCORMapi() {
|
||||
}
|
||||
|
||||
var API = new SCORMapi();
|
||||
|
||||
function SCOInitialize() {
|
||||
<?php
|
||||
if ( $sco->previous || $first) {
|
||||
print "\ttop.nav.document.navform.prev.disabled = true;\n";
|
||||
print "\ttop.nav.document.navform.prev.style.display = 'none';\n";
|
||||
}
|
||||
if ( $sco->next || $last) {
|
||||
print "\ttop.nav.document.navform.next.disabled = true;\n";
|
||||
print "\ttop.nav.document.navform.next.style.display = 'none';\n";
|
||||
}
|
||||
?>
|
||||
top.main.location="<?php echo $result ?>";
|
||||
}
|
||||
|
||||
function changeSco(direction) {
|
||||
if (direction == "prev")
|
||||
top.nav.document.navform.scoid.value="<?php echo $prevsco ?>";
|
||||
else
|
||||
top.nav.document.navform.scoid.value="<?php echo $nextsco ?>";
|
||||
|
||||
//alert ("Prev: <?php echo $prevsco ?>\nNext: <?php echo $nextsco ?>\nNew SCO: "+top.nav.document.navform.scoid.value);
|
||||
top.nav.document.navform.submit();
|
||||
}
|
||||
|
||||
+4
-5
@@ -4,9 +4,7 @@
|
||||
/// (replace scorm with the name of your module and delete this line)
|
||||
|
||||
|
||||
$scorm_CONSTANT = 7; /// for example
|
||||
$SCORM_TOP_FRAME_SIZE = 120;
|
||||
$SCORM_LEFT_FRAME_SIZE = 210;
|
||||
$SCORM_FRAME_SIZE = 140;
|
||||
|
||||
function scorm_add_instance($scorm) {
|
||||
/// Given an object containing all the necessary data,
|
||||
@@ -175,12 +173,13 @@ function scorm_randstring($len = "8")
|
||||
|
||||
function scorm_mkdirs($strPath)
|
||||
{
|
||||
global $CFG;
|
||||
if (is_dir($strPath))
|
||||
return true;
|
||||
$pStrPath = dirname($strPath);
|
||||
if (!scorm_mkdirs($pStrPath))
|
||||
return false;
|
||||
return mkdir($strPath);
|
||||
return mkdir($strPath, $CFG->directorypermissions);
|
||||
}
|
||||
|
||||
function scorm_datadir($strPath, $existingdir="", $prefix = "SCORM")
|
||||
@@ -192,7 +191,7 @@ function scorm_datadir($strPath, $existingdir="", $prefix = "SCORM")
|
||||
do {
|
||||
$datadir="/".$prefix.scorm_randstring();
|
||||
} while (file_exists($strPath.$datadir));
|
||||
mkdir($strPath.$datadir);
|
||||
mkdir($strPath.$datadir, $CFG->directorypermissions);
|
||||
return $strPath.$datadir;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
+53
-138
@@ -54,150 +54,65 @@
|
||||
update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
|
||||
notice(get_string("activityiscurrentlyhidden"));
|
||||
}
|
||||
switch ($frameset) {
|
||||
case "top":
|
||||
add_to_log($course->id, "scorm", "view", "playscorm.php?id=$cm->id", "$scorm->id");
|
||||
//
|
||||
// Print the page header
|
||||
//
|
||||
print_header($pagetitle, "$course->fullname",
|
||||
if ($frameset) {
|
||||
add_to_log($course->id, "scorm", "view", "playscorm.php?id=$cm->id", "$scorm->id");
|
||||
//
|
||||
// Print the page header
|
||||
//
|
||||
print_header($pagetitle, "$course->fullname",
|
||||
"$navigation <a target=\"{$CFG->framename}\" href=\"view.php?id=$cm->id\" title=\"$scorm->summary\">$scorm->name</a>",
|
||||
"", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm));
|
||||
"", "", true, update_module_button($cm->id, $course->id, $strscorm), navmenu($course, $cm, '_top'));
|
||||
|
||||
echo "<table width=\"100%\"><tr><td align=\"center\">".text_to_html($scorm->summary, true, false)."</td></tr></table>\n";
|
||||
echo "</body>\n</html>\n";
|
||||
break;
|
||||
case "left":
|
||||
//
|
||||
// Print SCORM Nav button
|
||||
//
|
||||
if (file_exists("$CFG->dirroot/theme/$CFG->theme/styles.php")) {
|
||||
$styles = $CFG->stylesheet;
|
||||
require_once("$CFG->dirroot/theme/$CFG->theme/config.php");
|
||||
} else {
|
||||
$styles = "$CFG->wwwroot/theme/standard/styles.php";
|
||||
require_once("$CFG->dirroot/theme/standard/config.php");
|
||||
}
|
||||
if ( get_string("thisdirection") == "rtl" ) {
|
||||
$direction = " dir=\"rtl\"";
|
||||
} else {
|
||||
$direction = " dir=\"ltr\"";
|
||||
}
|
||||
$meta = "<meta http-equiv=\"content-type\" content=\"text/html; charset=$encoding\" />\n$meta\n";
|
||||
echo "<html $direction>\n<head>\n";
|
||||
echo $meta;
|
||||
echo "<title>Navigator</title>\n";
|
||||
echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"".$styles."\" />\n";
|
||||
//echo "<script language=\"JavaScript\" type=\"text/javascript\" src=\"scormAPI.php?id=$cm->id&mode=".$_GET["mode"].$scoid."\"></script>\n";
|
||||
echo "</head>\n<body bgcolor=\"".$THEME->body."\" leftmargin=\"0\">\n";
|
||||
echo "<table width=\"100%\">\n";
|
||||
if ($_GET["mode"] == "browse")
|
||||
echo " <tr><td align=\"center\"><b>".get_string("browsemode","scorm")."</b></td></tr>";
|
||||
echo " <tr><td align=\"center\" width=\"20%\" nowrap>
|
||||
echo "<table width=\"100%\">\n <tr><td align=\"center\">".text_to_html($scorm->summary, true, false)."</td></tr></table>\n";
|
||||
|
||||
if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' order by id ASC")){
|
||||
$level=0;
|
||||
$parents[$level]="/";
|
||||
foreach ($scoes as $sco) {
|
||||
if ($parents[$level]!=$sco->parent) {
|
||||
if ($level>0 && $parents[$level-1]==$sco->parent) {
|
||||
$level--;
|
||||
} else {
|
||||
$level++;
|
||||
$parents[$level]=$sco->parent;
|
||||
}
|
||||
}
|
||||
$indenting = "";
|
||||
for ($i=0;$i<$level;$i++) {
|
||||
$indenting .= "-";
|
||||
}
|
||||
$options[$sco->id] = $indenting."> ".$sco->title;
|
||||
}
|
||||
}
|
||||
|
||||
echo "<table width=\"100%\">\n <tr>\n";
|
||||
echo " <td nowrap>
|
||||
<iframe name=\"cmi\" width=\"1\" height=\"1\" src=\"cmi.php?id=$cm->id\" style=\"visibility: hidden;\"></iframe>
|
||||
<form name=\"navform\" method=\"POST\" action=\"playscorm.php?id=$cm->id\" target=\"_top\">
|
||||
<input name=\"scoid\" type=\"hidden\" />
|
||||
<input name=\"mode\" type=\"hidden\" value=\"".$_GET["mode"]."\" />
|
||||
<input name=\"prev\" type=\"button\" value=\"".get_string("prev","scorm")."\" onClick=\"top.changeSco('prev');\" />
|
||||
<input name=\"next\" type=\"button\" value=\"".get_string("next","scorm")."\" onClick=\"top.changeSco('next')\" />
|
||||
<input name=\"prev\" type=\"button\" value=\"".get_string("prev","scorm")."\" onClick=\"top.changeSco('prev');\" /> \n";
|
||||
choose_from_menu($options, "courseStructure", "", "", "document.navform.scoid.value=document.navform.courseStructure.options[document.navform.courseStructure.selectedIndex].value;document.navform.submit();");
|
||||
echo " <input name=\"next\" type=\"button\" value=\"".get_string("next","scorm")."\" onClick=\"top.changeSco('next')\" />
|
||||
</form>
|
||||
</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
echo "<style type=\"text/css\">.scormlist { list-style-type:none;font-size:small; }</style>\n";
|
||||
echo "<ul class=\"scormlist\">\n";
|
||||
if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' order by id ASC")){
|
||||
$level=0;
|
||||
$sublist=0;
|
||||
$parents[$level]="/";
|
||||
$incomplete=false;
|
||||
foreach ($scoes as $sco) {
|
||||
if ($parents[$level]!=$sco->parent) {
|
||||
if ($level>0 && $parents[$level-1]==$sco->parent) {
|
||||
echo " </ul>\n";
|
||||
$level--;
|
||||
} else {
|
||||
echo " <ul id='".$sublist."' class=\"scormlist\">\n";
|
||||
$level++;
|
||||
$parents[$level]=$sco->parent;
|
||||
}
|
||||
}
|
||||
echo " <li>";
|
||||
$nextsco = next($scoes);
|
||||
if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && ($nextsco->parent != $parents[$level-1])) {
|
||||
$sublist++;
|
||||
echo "<img src=\"pix/minus.gif\" onClick='expandCollide(this,".$sublist.");'/>";
|
||||
} else
|
||||
echo "<img src=\"pix/spacer.gif\" />";
|
||||
if ($sco->launch) {
|
||||
if ($sco_user=get_record("scorm_sco_users","scoid",$sco->id,"userid",$USER->id)) {
|
||||
if ( $sco_user->cmi_core_lesson_status == "")
|
||||
$sco_user->cmi_core_lesson_status = "not attempted";
|
||||
echo "<img src=\"pix/".scorm_remove_spaces($sco_user->cmi_core_lesson_status).".gif\" alt=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" title=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" />";
|
||||
switch ($sco_user->cmi_core_lesson_status) {
|
||||
case "not attempted":
|
||||
case "incomplete":
|
||||
case "browsed":
|
||||
$incomplete = true;
|
||||
}
|
||||
} else {
|
||||
echo "<img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" />";
|
||||
$incomplete = true;
|
||||
}
|
||||
echo " <a href=\"javascript:playSCO(".$sco->id.")\">$sco->title</a></li>\n";
|
||||
} else {
|
||||
echo " $sco->title</li>\n";
|
||||
}
|
||||
}
|
||||
|
||||
for ($i=0;$i<$level;$i++){
|
||||
echo " </ul>\n";
|
||||
}
|
||||
}
|
||||
echo "</ul></p>\n";
|
||||
echo "<script language=\"javascript\">
|
||||
<!--
|
||||
function playSCO(scoid,status) {
|
||||
document.navform.scoid.value = scoid;
|
||||
document.navform.submit();
|
||||
}
|
||||
|
||||
function expandCollide(which,list) {
|
||||
var nn=document.ids?true:false
|
||||
var w3c=document.getElementById?true:false
|
||||
var beg=nn?\"document.ids.\":w3c?\"document.getElementById(\":\"document.all.\";
|
||||
var mid=w3c?\").style\":\".style\";
|
||||
|
||||
if (eval(beg+list+mid+\".display\") != \"none\") {
|
||||
which.src = \"pix/plus.gif\";
|
||||
eval(beg+list+mid+\".display='none';\");
|
||||
} else {
|
||||
which.src = \"pix/minus.gif\";
|
||||
eval(beg+list+mid+\".display='block';\");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-->
|
||||
</script>\n";
|
||||
echo "</body>\n</html>\n";
|
||||
break;
|
||||
default:
|
||||
//
|
||||
// Frameset
|
||||
//
|
||||
if ($_POST["scoid"])
|
||||
$scoid = "&scoid=".$_POST["scoid"];
|
||||
echo "<html>\n";
|
||||
echo "<head><title>$course->shortname: $scorm->name</title></head>\n";
|
||||
echo "<script id=\"scormAPI\" language=\"JavaScript\" type=\"text/javascript\" src=\"scormAPI.php?id=$cm->id&mode=".$_GET["mode"].$scoid."\"></script>\n";
|
||||
echo "<frameset rows=\"$SCORM_TOP_FRAME_SIZE,*\">\n";
|
||||
echo " <frame name=\"upper\" src=\"playscorm.php?id=$cm->id&mode=".$_POST["mode"]."&frameset=top\">\n";
|
||||
echo " <frameset cols=\"$SCORM_LEFT_FRAME_SIZE,*\" onload=\"SCOInitialize();\">\n";
|
||||
echo " <frame name=\"nav\" src=\"playscorm.php?id=$cm->id&mode=".$_POST["mode"]."&frameset=left\">\n";
|
||||
echo " <frame name=\"main\" src=\"\">\n";
|
||||
echo " </frameset>\n";
|
||||
echo "</frameset>\n";
|
||||
echo "</html>\n";
|
||||
break;
|
||||
</td>\n";
|
||||
if ($_GET["mode"] == "browse")
|
||||
echo "<td align=\"right\">".get_string("browsemode","scorm")."</td>\n";
|
||||
echo "</tr>\n</table>\n";
|
||||
echo "</body>\n</html>\n";
|
||||
} else {
|
||||
//
|
||||
// Frameset
|
||||
//
|
||||
if ($_POST["scoid"])
|
||||
$scoid = "&scoid=".$_POST["scoid"];
|
||||
echo "<html>\n";
|
||||
echo "<head><title>$course->shortname: $scorm->name</title></head>\n";
|
||||
echo "<script id=\"scormAPI\" language=\"JavaScript\" type=\"text/javascript\" src=\"scormAPI.php?id=$cm->id&mode=".$_POST["mode"].$scoid."\"></script>\n";
|
||||
echo "<frameset rows=\"$SCORM_FRAME_SIZE,*\" onLoad=\"SCOInitialize();\">\n";
|
||||
echo " <frame name=\"nav\" src=\"playscorm.php?id=$cm->id&mode=".$_POST["mode"]."&frameset=top\">\n";
|
||||
echo " <frame name=\"main\" src=\"\">\n";
|
||||
echo "</frameset>\n";
|
||||
echo "</html>\n";
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -87,10 +87,12 @@
|
||||
$row[] = "<a href=\"$CFG->wwwroot/user/view.php?id=$data->userid&course=$course->id\">".
|
||||
"$data->firstname $data->lastname</a>";
|
||||
foreach ($user_data as $data) {
|
||||
$row[]="<img src=\"pix/".scorm_remove_spaces($data->cmi_core_lesson_status).".gif\"
|
||||
if ($data->cmi_core_score_raw > 0)
|
||||
$scoreview = "<br />".get_string("score","scorm").": ".$data->cmi_core_score_raw;
|
||||
$row[]="<img src=\"pix/".scorm_remove_spaces($data->cmi_core_lesson_status).".gif\"
|
||||
alt=\"".get_string(scorm_remove_spaces($data->cmi_core_lesson_status),"scorm")."\"
|
||||
title=\"".get_string(scorm_remove_spaces($data->cmi_core_lesson_status),"scorm")."\"> "
|
||||
.$data->cmi_core_total_time;
|
||||
.$data->cmi_core_total_time.$scoreview;
|
||||
}
|
||||
}
|
||||
$table->data[] = $row;
|
||||
|
||||
+36
-4
@@ -65,11 +65,13 @@
|
||||
else if ($sco->type == "sca")
|
||||
$sco_user->$element = "completed";
|
||||
$ident = insert_record("scorm_sco_users",$sco_user);
|
||||
}
|
||||
}
|
||||
}
|
||||
$sco = $first;
|
||||
if ($_GET["scoid"])
|
||||
$sco = get_record("scorm_scoes","id",$_GET["scoid"]);
|
||||
if ($_GET["scoid"]) {
|
||||
if ($sco = get_record("scorm_scoes","id",$_GET["scoid"]))
|
||||
unset($first);
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
@@ -95,8 +97,9 @@
|
||||
if ($sco->id == $max)
|
||||
$last = $sco;
|
||||
|
||||
// Get User data
|
||||
// Get current sco User data
|
||||
$sco_user = get_record("scorm_sco_users","userid",$USER->id,"scoid",$sco->id);
|
||||
|
||||
if (scorm_external_link($sco->launch)) {
|
||||
$result = $sco->launch;
|
||||
} else {
|
||||
@@ -107,4 +110,33 @@
|
||||
}
|
||||
}
|
||||
include("api1_2.php");
|
||||
|
||||
?>
|
||||
|
||||
function SCOInitialize() {
|
||||
<?php
|
||||
if ( $sco->previous || $first) {
|
||||
print "\ttop.nav.document.navform.prev.disabled = true;\n";
|
||||
print "\ttop.nav.document.navform.prev.style.display = 'none';\n";
|
||||
}
|
||||
if ( $sco->next || $last) {
|
||||
print "\ttop.nav.document.navform.next.disabled = true;\n";
|
||||
print "\ttop.nav.document.navform.next.style.display = 'none';\n";
|
||||
}
|
||||
?>
|
||||
top.main.location="<?php echo $result ?>";
|
||||
for (i=0;i<top.nav.document.navform.courseStructure.options.length;i++) {
|
||||
if ( top.nav.document.navform.courseStructure.options[i].value == <?php echo $sco->id; ?> )
|
||||
top.nav.document.navform.courseStructure.options[i].selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
function changeSco(direction) {
|
||||
if (direction == "prev")
|
||||
top.nav.document.navform.scoid.value="<?php echo $prevsco ?>";
|
||||
else
|
||||
top.nav.document.navform.scoid.value="<?php echo $nextsco ?>";
|
||||
|
||||
//alert ("Prev: <?php echo $prevsco ?>\nNext: <?php echo $nextsco ?>\nNew SCO: "+top.nav.document.navform.scoid.value);
|
||||
top.nav.document.navform.submit();
|
||||
}
|
||||
+7
-10
@@ -89,22 +89,22 @@
|
||||
exit;
|
||||
}
|
||||
echo "<br />";
|
||||
echo "<style type=\"text/css\">.scormlist { list-style-type:none; }</style>\n";
|
||||
print_simple_box_start("CENTER");
|
||||
echo "<table>\n";
|
||||
echo " <tr><th>".get_string("coursestruct","scorm")."</th></tr>\n";
|
||||
echo " <tr><td nowrap>\n<ul compact style='list-style-type:none'>\n";
|
||||
echo " <tr><td nowrap>\n<ul compact class=\"scormlist\"'>\n";
|
||||
if ($scoes = get_records_select("scorm_scoes","scorm='$scorm->id' order by id ASC")){
|
||||
$level=0;
|
||||
$sublist=0;
|
||||
$parents[$level]="/";
|
||||
$incomplete=false;
|
||||
foreach ($scoes as $sco) {
|
||||
if ($parents[$level]!=$sco->parent) {
|
||||
if ($level>0 && $parents[$level-1]==$sco->parent) {
|
||||
echo " </ul>\n";
|
||||
$level--;
|
||||
} else {
|
||||
echo " <ul id='".$sublist."'compact style='list-style-type:none;'>\n";
|
||||
echo " <ul id='".$sublist."' compact class=\"scormlist\"'>\n";
|
||||
$level++;
|
||||
$parents[$level]=$sco->parent;
|
||||
}
|
||||
@@ -121,12 +121,6 @@
|
||||
if ( $sco_user->cmi_core_lesson_status == "")
|
||||
$sco_user->cmi_core_lesson_status = "not attempted";
|
||||
echo " <img src=\"pix/".scorm_remove_spaces($sco_user->cmi_core_lesson_status).".gif\" alt=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" title=\"".get_string(scorm_remove_spaces($sco_user->cmi_core_lesson_status),"scorm")."\" />\n";
|
||||
switch ($sco_user->cmi_core_lesson_status) {
|
||||
case "not attempted":
|
||||
case "incomplete":
|
||||
case "browsed":
|
||||
$incomplete = true;
|
||||
}
|
||||
} else {
|
||||
echo " <img src=\"pix/notattempted.gif\" alt=\"".get_string("notattempted","scorm")."\" />";
|
||||
$incomplete = true;
|
||||
@@ -136,8 +130,11 @@
|
||||
echo " $sco->title\n </li>\n";
|
||||
}
|
||||
}
|
||||
for ($i=0;$i<$level;$i++){
|
||||
echo " </ul>\n";
|
||||
}
|
||||
}
|
||||
echo "</ul>\n</td></tr>\n";
|
||||
echo "</ul></td></tr>\n";
|
||||
echo "</table>\n";
|
||||
print_simple_box_end();
|
||||
echo "<form name=\"theform\" method=\"POST\" action=\"playscorm.php?id=$cm->id\">\n";
|
||||
|
||||
Reference in New Issue
Block a user