Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added the new popup window mode

  • Loading branch information...
commit 77f18d3936089b45cb8888b34e1336c7e3bd3686 1 parent 27a10b8
bobopinna authored
View
2  mod/scorm/datamodel.php
@@ -34,7 +34,7 @@
if (confirm_sesskey() && (!empty($scoid))) {
$result = true;
- if (isstudent($course->id)) {
+ if (isstudent($course->id) || (isteacher($course->id) && !isadmin()) {
foreach ($_POST as $element => $value) {
if (substr($element,0,3) == 'cmi') {
$element = str_replace('__','.',$element);
View
5 mod/scorm/db/mysql.php
@@ -197,6 +197,11 @@ function scorm_upgrade($oldversion) {
}
}
+
+ if ($oldversion < 2005092500) {
+ table_column("scorm", "", "hidenav", "TINYINT", "1", "UNSIGNED", "0", "NOT NULL", "hidetoc");
+ table_column("scorm", "", "options", "VARCHAR", "255", "", "", "NOT NULL","popup");
+ }
return true;
}
?>
View
2  mod/scorm/db/mysql.sql
@@ -14,8 +14,10 @@ CREATE TABLE prefix_scorm (
summary text NOT NULL,
hidebrowse tinyint(1) NOT NULL default '0',
hidetoc tinyint(1) NOT NULL default '0',
+ hidenav tinyint(1) NOT NULL default '0',
auto tinyint(1) unsigned NOT NULL default '0',
popup tinyint(1) unsigned NOT NULL default '0',
+ options varchar(255) NOT NULL default '',
width int(10) unsigned NOT NULL default '800',
height int(10) unsigned NOT NULL default '600',
timemodified int(10) unsigned NOT NULL default '0',
View
5 mod/scorm/db/postgres7.php
@@ -210,6 +210,11 @@ function scorm_upgrade($oldversion) {
}
}
}
+
+ if ($oldversion < 2005092500) {
+ table_column("scorm", "", "hidenav", "integer", "", "", "0", "NOT NULL", "hidetoc");
+ table_column("scorm", "", "options", "varchar", "255", "", "", "NOT NULL","popup");
+ }
return true;
}
View
2  mod/scorm/db/postgres7.sql
@@ -13,8 +13,10 @@ CREATE TABLE prefix_scorm (
summary text NOT NULL default '',
hidebrowse integer NOT NULL default '0',
hidetoc integer NOT NULL default '0',
+ hidenav integer NOT NULL default '0',
auto integer NOT NULL default '0',
popup integer NOT NULL default '0',
+ options varchar(255) NOT NULL default '',
width integer NOT NULL default '800',
height integer NOT NULL default '600',
timemodified integer NOT NULL default '0'
View
52 mod/scorm/lib.php
@@ -10,6 +10,15 @@
VALUEHIGHEST => get_string('gradehighest', 'scorm'),
VALUEAVERAGE => get_string('gradeaverage', 'scorm'),
VALUESUM => get_string('gradesum', 'scorm'));
+$SCORM_POPUP_OPTIONS = array('resizable', 'scrollbars', 'directories', 'location',
+ 'menubar', 'toolbar', 'status');
+$stdoptions = '';
+foreach ($SCORM_POPUP_OPTIONS as $popupopt) {
+ $stdoptions .= $popupopt.'=1';
+ if ($popupopt != 'status') {
+ $stdoptions .= ',';
+ }
+}
/*if (!isset($CFG->scorm_validate)) {
$scormvalidate = 'none';
@@ -41,10 +50,27 @@
*/
function scorm_add_instance($scorm) {
+ global $CFG,$SCORM_POPUP_OPTIONS;
$scorm->timemodified = time();
- # May have to add extra stuff in here #
- global $CFG;
+ if (isset($scorm->popup)) {
+ if ($scorm->popup) {
+ $optionlist = array();
+ foreach ($SCORM_POPUP_OPTIONS as $option) {
+ if (isset($scorm->$option)) {
+ $optionlist[] = $option.'='.$scorm->$option;
+ } else {
+ $optionlist[] = $option.'=0';
+ }
+ }
+ $scorm->options = implode(',', $optionlist);
+ } else {
+ $scorm->options = '';
+ }
+ } else {
+ $scorm->popup = 0;
+ $scorm->options = '';
+ }
$id = insert_record('scorm', $scorm);
@@ -82,10 +108,29 @@ function scorm_add_instance($scorm) {
*/
function scorm_update_instance($scorm) {
+ global $CFG,$SCORM_POPUP_OPTIONS;
+
$scorm->timemodified = time();
$scorm->id = $scorm->instance;
- global $CFG;
+ if (isset($scorm->popup)) {
+ if ($scorm->popup) {
+ $optionlist = array();
+ foreach ($SCORM_POPUP_OPTIONS as $option) {
+ if (isset($scorm->$option)) {
+ $optionlist[] = $option.'='.$scorm->$option;
+ } else {
+ $optionlist[] = $option.'=0';
+ }
+ }
+ $scorm->options = implode(',', $optionlist);
+ } else {
+ $scorm->options = '';
+ }
+ } else {
+ $scorm->popup = 0;
+ $scorm->options = '';
+ }
// Check if scorm manifest needs to be reparsed
if ($scorm->launch == 0) {
@@ -1466,6 +1511,7 @@ function scorm_get_toc($scorm,$liststyle,$currentorg='',$scoid='',$mode='normal'
$sco->showprev = $showprev;
$sco->shownext = $shownext;
$result->sco = $sco;
+ $result->incomplete = $incomplete;
} else {
$result->incomplete = $incomplete;
}
View
2  mod/scorm/loadSCO.php
@@ -4,7 +4,7 @@
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
- $scoid = optional_param('scoid', '', PARAM_INT); // sco ID
+ $scoid = required_param('scoid', '', PARAM_INT); // sco ID
$mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode
if (!empty($id)) {
View
101 mod/scorm/mod.html
@@ -33,12 +33,31 @@
if (empty($form->hidetoc)) {
$form->hidetoc = "0";
}
+ if (empty($form->hidenav)) {
+ $form->hidenav = "0";
+ }
if (empty($form->width)) {
$form->width = $CFG->scorm_framewidth;
}
+ if ($form->width <= 100) {
+ $form->width .= '%';
+ }
if (empty($form->height)) {
$form->height = $CFG->scorm_frameheight;
}
+ if ($form->height <= 100) {
+ $form->height .= '%';
+ }
+ if (empty($form->options)) {
+ $form->options = $stdoptions;
+ }
+ $options = explode(',',$form->options);
+ $window = new stdClass();
+ foreach ($options as $option) {
+ list($element,$value) = explode('=',$option);
+ $element = trim($element);
+ $window->$element = trim($value)==1?'checked':'';
+ }
$scormid = '';
if (!empty($form->instance)) {
@@ -55,6 +74,19 @@
$strfilename = get_string("coursepacket", "scorm");
$strchooseafile = get_string("chooseapacket", "scorm");
+ $striframe = get_string("iframe", "scorm");
+ $striframedisplay = get_string("iframedisplay", "scorm");
+ $strnewwindow = get_string("popup", "scorm");
+ $strnewwindowopen = get_string("popupopen", "scorm");
+ $strheight = get_string("height", "scorm");
+ $strwidth = get_string("width", "scorm");
+ $strresizable = get_string("resizable", "scorm");
+ $strscrollbars = get_string("scrollbars", "scorm");
+ $strdirectories = get_string("directories", "scorm");
+ $strlocation = get_string("location", "scorm");
+ $strmenubar = get_string("menubar", "scorm");
+ $strtoolbar = get_string("toolbar", "scorm");
+ $strstatus = get_string("statusbar", "scorm");
?>
<script type="text/javascript" src="<?php p($CFG->wwwroot) ?>/mod/scorm/request.js" ></script>
@@ -220,7 +252,6 @@
$options[0]=get_string("no");
$options[1]=get_string("yes");
choose_from_menu ($options, "auto", $form->auto,'');
- helpbutton("autocontinue", get_string("autocontinue", "scorm"), "scorm", true);
?>
</td>
</tr>
@@ -232,7 +263,6 @@
$options[0]=get_string("no");
$options[1]=get_string("yes");
choose_from_menu ($options, "hidebrowse", $form->hidebrowse, '');
- helpbutton("browsemode", get_string("hidebrowse", "scorm"), "scorm", true);
?>
</td>
</tr>
@@ -244,7 +274,17 @@
$options[0]=get_string("no");
$options[1]=get_string("yes");
choose_from_menu ($options, "hidetoc", $form->hidetoc, '');
- helpbutton("tocdisplay", get_string("hidetoc", "scorm"), "scorm", true);
+ ?>
+ </td>
+ </tr>
+ <tr>
+ <td align="right"><b><?php print_string("hidenav","scorm") ?>:</b></td>
+ <td>
+ <?php
+ $options = array();
+ $options[0]=get_string("no");
+ $options[1]=get_string("yes");
+ choose_from_menu ($options, "hidenav", $form->hidenav, '');
?>
</td>
</tr>
@@ -265,6 +305,59 @@
<td colspan="2">
<div id="windowsettings">
<table align="center">
+ <tr valign="top">
+ <td>
+ <b><?php print_string('stagesize','scorm'); ?></b><br />
+ <input name="width" type="text" size="4" value="<?php p($form->width) ?>" alt="<?php p($strwidth) ?>" />
+ <label for="width"><?php p($strwidth) ?></label><br />
+ <input name="height" type="text" size="4" value="<?php p($form->height) ?>" alt="<?php p($strheight) ?>" />
+ <label for="height"><?php p($strheight) ?></label>
+ </td>
+ </tr>
+ <tr valign="top">
+ <td>
+ <script type="text/javascript">
+ var popupitems = ["<?php echo implode('","',$SCORM_POPUP_OPTIONS); ?>"];
+ </script>
+ <br /><b><?php print_string('display','scorm'); ?>:</b><br />
+ <input type="radio"
+ name="popup"
+ value="0" alt="<?php p($striframe) ?>"
+ <?php echo ($form->popup == 0) ? "checked=\"checked\"" : "" ?>
+ onclick="return lockoptions('form', 'popup[1]', popupitems);"
+ />
+ <b title="<?php p($striframedisplay) ?>"><?php p($striframe) ?></b>
+ </td>
+ </tr>
+ <tr valign="top">
+ <td>
+ <input name="popup"
+ type="radio"
+ value="1"
+ alt="<?php p($strnewwindow)?>"
+ <?php echo ($form->popup == 1) ? "checked=\"checked\"" : "" ?>
+ onclick="return lockoptions('form', 'popup[1]', popupitems);"
+ />
+ <b title="<?php p($strnewwindowopen) ?>"><?php p($strnewwindow) ?></b>
+ <blockquote>
+ <?php
+ foreach ($window as $name => $value) {
+ echo "<input name=\"h$name\" type=\"hidden\" value=\"0\"/>\n";
+ echo "<input name=\"$name\" type=\"checkbox\" value=\"1\" ".$window->$name." alt=\"$name\" />\n";
+ $stringname = "str$name";
+ echo $$stringname."<br />\n";
+ }
+ ?>
+ <script type="text/javascript">
+ lockoptions('form','popup[1]', popupitems);
+ </script>
+ </blockquote>
+ </td>
+ </tr>
+ </table>
+ </div>
+<!-- <div id="windowsettings">
+ <table align="center">
<tr>
<td align="right"><b><?php print_string("popup","scorm") ?>:</b></td>
<td>
@@ -297,7 +390,7 @@
</td>
</tr>
</table>
- </div>
+ </div> -->
<script language="javascript" type="text/javascript">
showhide('advancedsettings', true);
showhide('windowsettings', true);
View
110 mod/scorm/playscorm.php
@@ -87,8 +87,13 @@
}
}
add_to_log($course->id, 'scorm', 'view', "playscorm.php?id=$cm->id&scoid=$sco->id", "$scorm->id");
- $scoidstring = '&amp;scoid='.$sco->id;
- $modestring = '&amp;mode='.$mode;
+ if ($scorm->popup == 0) {
+ $scoidstring = '&amp;scoid='.$sco->id;
+ $modestring = '&amp;mode='.$mode;
+ } else {
+ $scoidstring = '&scoid='.$sco->id;
+ $modestring = '&mode='.$mode;
+ }
$SESSION->scorm_scoid = $sco->id;
$SESSION->scorm_status = 'Not Initialized';
@@ -97,16 +102,14 @@
//
// Print the page header
//
+ $bodyscript = '';
if ($scorm->popup == 1) {
- print_header($pagetitle);
- echo ' <script language="Javascript">'."\n";
- echo " top.resizeTo({$scorm->width},{$scorm->height});\n";
- echo ' </script>'."\n";
- } else {
- print_header($pagetitle, "$course->fullname",
- "$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
- '', '', true, update_module_button($cm->id, $course->id, $strscorm), '', false);
+ $bodyscript = 'onunload="main.close();"';
}
+ $exitbutton = '<input name="exit" type="button" value="'.get_string('exit','scorm').'" onClick="document.location = \''.$CFG->wwwroot.'/course/view.php?id='.$cm->course.'\';" />';
+ print_header($pagetitle, "$course->fullname",
+ "$navigation <a target='{$CFG->framename}' href='view.php?id=$cm->id'>".format_string($scorm->name,true)."</a>",
+ '', '', true, $exitbutton.update_module_button($cm->id, $course->id, $strscorm), '', false, $bodyscript);
?>
<script language="JavaScript" type="text/javascript" src="request.js"></script>
<script language="JavaScript" type="text/javascript" src="api.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>"></script>
@@ -114,7 +117,7 @@
<table class="fullscreen">
<tr>
<?php
- if (($scorm->hidetoc == 0) && ($scorm->popup == 0)) {
+ if ($scorm->hidetoc == 0) {
?>
<td class="top">
<table class='generalbox'>
@@ -138,29 +141,60 @@
<input name="scoid" type="hidden" />
<input name="currentorg" type="hidden" value="<?php echo $currentorg ?>" />
<input name="mode" type="hidden" value="<?php echo $mode ?>" />
+<?php
+ if ($scorm->hidenav == 0) {
+?>
<input name="prev" type="<?php if (($sco->prev == 0) || ($sco->showprev == 1)) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('prev','scorm') ?>" onClick="prevSCO();" />
<input name="next" type="<?php if (($sco->next == 0) || ($sco->shownext == 1)) { echo 'hidden'; } else { echo 'button'; } ?>" value="<?php print_string('next','scorm') ?>" onClick="nextSCO();" />
- <input name="exit" type="button" value="<?php print_string('exit','scorm') ?>" onClick="playSCO(0)" />
+<?php
+ }
+?>
</form>
</td>
</tr>
<tr><td <?php echo $mode=='browse'?'colspan="2" ':'' ?>class="right">
<?php
- if ($result->prerequisites) {
- $width = $scorm->width;
- if ($scorm->popup) {
- $width = '100%';
- } else {
- if ($width<=100) {
- $width = $width.'%';
- }
- }
+ if ($result->prerequisites) {
+ if ($scorm->popup == 0) {
?>
- <iframe name="main" class="scoframe" width="<?php echo $width ?>" height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>" src="loadSCO.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>"></iframe>
+ <iframe name="main"
+ class="scoframe"
+ width="<?php echo $scorm->width<=100 ? $scorm->width.'%' : $scorm->width ?>"
+ height="<?php echo $scorm->height<=100 ? $scorm->height.'%' : $scorm->height ?>"
+ src="loadSCO.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>">
+ </iframe>
<?php
} else {
- print_simple_box(get_string('noprerequisites','scorm'),'center');
+?>
+ <script lanuguage="javascript">
+ function openpopup(url,name,options,width,height) {
+ fullurl = "http://tiger.local/develop/mod/scorm/" + url;
+ windowobj = window.open(fullurl,name,options);
+ if ((width==100) && (height==100)) {
+ // Fullscreen
+ windowobj.moveTo(0,0);
+ }
+ if (width<=100) {
+ width = Math.round(screen.availWidth * width / 100);
+ }
+ if (height<=100) {
+ height = Math.round(screen.availHeight * height / 100);
+ }
+ windowobj.resizeTo(width,height);
+ windowobj.focus();
+ return windowobj;
+ }
+
+ url = "loadSCO.php?id=<?php echo $cm->id.$scoidstring.$modestring ?>";
+ width = <?php p($scorm->width) ?>;
+ height = <?php p($scorm->height) ?>;
+ var main = openpopup(url, "<?php p($scorm->name) ?>", "<?php p($scorm->options) ?>", width, height);
+ </script>
+<?php
}
+ } else {
+ print_simple_box(get_string('noprerequisites','scorm'),'center');
+ }
?>
</td></tr>
</table>
@@ -171,21 +205,8 @@
<script language="javascript" type="text/javascript">
<!--
function playSCO(scoid) {
-<?php if ($scorm->popup == 1) { ?>
- if (self.opener && !self.opener.closed){
- self.opener.location.reload();
- }
-<?php } ?>
- if (scoid == 0) {
-<?php if ($scorm->popup == 1) { ?>
- self.close();
-<?php } else { ?>
- document.location = '<?php echo $CFG->wwwroot ?>/course/view.php?id=<?php echo $cm->course ?>';
-<?php } ?>
- } else {
- document.navform.scoid.value=scoid;
- document.navform.submit();
- }
+ document.navform.scoid.value=scoid;
+ document.navform.submit();
}
function prevSCO() {
@@ -195,7 +216,13 @@ function prevSCO() {
function nextSCO() {
playSCO(<?php echo $sco->next ?>);
}
-
+ -->
+ </script>
+<?php
+ if ($scorm->hidetoc == 0) {
+?>
+ <script language="javascript" type="text/javascript">
+ <!--
function expandCollide(which,list) {
var nn=document.ids?true:false
var w3c=document.getElementById?true:false
@@ -212,7 +239,10 @@ function expandCollide(which,list) {
}
-->
</script>
+<?php
+ }
+?>
</div> <!-- Content -->
</div> <!-- Page -->
</body>
-</html>
+</html>
View
2  mod/scorm/version.php
@@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2005071500; // The (date) version of this module
+$module->version = 2005092500; // The (date) version of this module
$module->requires = 2005060300; // The version of Moodle that is required
$module->cron = 0; // How often should cron check this module (seconds)?
View
2  mod/scorm/view.php
@@ -113,7 +113,7 @@
print_simple_box_end();
?>
<div class="center">
- <form name="theform" method="post" action="playscorm.php?id=<?php echo $cm->id ?>"<?php echo $scorm->popup == 1?' target="newwin"':'' ?>>
+ <form name="theform" method="post" action="playscorm.php?id=<?php echo $cm->id ?>">
<?php
if ($scorm->hidebrowse == 0) {
print_string("mode","scorm");
Please sign in to comment.
Something went wrong with that request. Please try again.