Permalink
Browse files

Fixed some bugs and typos

  • Loading branch information...
1 parent 0bbc6f5 commit 0f995ab206aaf9c70e9f3da5cbe1c8ee647072c1 bobopinna committed Feb 3, 2006
Showing with 180 additions and 132 deletions.
  1. +2 −2 mod/scorm/config.html
  2. +39 −14 mod/scorm/lib.php
  3. +0 −12 mod/scorm/loadSCO.php
  4. +21 −8 mod/scorm/locallib.php
  5. +60 −44 mod/scorm/mod.html
  6. +54 −49 mod/scorm/player.php
  7. +3 −2 mod/scorm/report.php
  8. +1 −1 mod/scorm/request.js
View
@@ -1,8 +1,8 @@
<?php
- if (empty($CFG->scorm_frameheight)) {
+ if (!isset($CFG->scorm_frameheight)) {
$CFG->scorm_frameheight = '500';
}
- if (empty($CFG->scorm_framewidth)) {
+ if (!isset($CFG->scorm_framewidth)) {
$CFG->scorm_framewidth = '100%';
}
?>
View
@@ -2,24 +2,43 @@
/// Library of functions and constants for module scorm
-define('VALUESCOES', '0');
-define('VALUEHIGHEST', '1');
-define('VALUEAVERAGE', '2');
-define('VALUESUM', '3');
-$SCORM_GRADE_METHOD = array (VALUESCOES => get_string('gradescoes', 'scorm'),
- 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');
+define('GRADESCOES', '0');
+define('GRADEHIGHEST', '1');
+define('GRADEAVERAGE', '2');
+define('GRADESUM', '3');
+$SCORM_GRADE_METHOD = array (GRADESCOES => get_string('gradescoes', 'scorm'),
+ GRADEHIGHEST => get_string('gradehighest', 'scorm'),
+ GRADEAVERAGE => get_string('gradeaverage', 'scorm'),
+ GRADESUM => get_string('gradesum', 'scorm'));
+
+define('VALUEHIGHEST', '0');
+define('VALUEAVERAGE', '1');
+define('VALUEFIRST', '2');
+define('VALUELAST', '3');
+$SCORM_WHAT_GRADE = array (VALUEHIGHEST => get_string('highestattempt', 'scorm'),
+ VALUEAVERAGE => get_string('averageattempt', 'scorm'),
+ VALUEFIRST => get_string('firstattempt', 'scorm'),
+ VALUELAST => get_string('lastattempt', 'scorm'));
+
+$SCORM_POPUP_OPTIONS = array('resizable'=>1,
+ 'scrollbars'=>1,
+ 'directories'=>0,
+ 'location'=>0,
+ 'menubar'=>0,
+ 'toolbar'=>0,
+ 'status'=>0);
$stdoptions = '';
-foreach ($SCORM_POPUP_OPTIONS as $popupopt) {
- $stdoptions .= $popupopt.'=1';
+foreach ($SCORM_POPUP_OPTIONS as $popupopt => $value) {
+ $stdoptions .= $popupopt.'='.$value;
if ($popupopt != 'status') {
$stdoptions .= ',';
}
}
+if (!isset($CFG->scorm_maxattempts)) {
+ set_config('scorm_maxattempts','6');
+}
+
if (!isset($CFG->scorm_frameheight)) {
set_config('scorm_frameheight','500');
}
@@ -39,10 +58,12 @@
*/
function scorm_add_instance($scorm) {
- global $CFG,$SCORM_POPUP_OPTIONS;
+ global $CFG;
$scorm->timemodified = time();
$scorm = scorm_option2text($scorm);
+ $scorm->width = str_replace('%','',$scorm->width);
+ $scorm->height = str_replace('%','',$scorm->height);
$id = insert_record('scorm', $scorm);
@@ -73,12 +94,14 @@ function scorm_add_instance($scorm) {
*/
function scorm_update_instance($scorm) {
- global $CFG,$SCORM_POPUP_OPTIONS;
+ global $CFG;
$scorm->timemodified = time();
$scorm->id = $scorm->instance;
$scorm = scorm_option2text($scorm);
+ $scorm->width = str_replace('%','',$scorm->width);
+ $scorm->height = str_replace('%','',$scorm->height);
// Check if scorm manifest needs to be reparsed
if ($scorm->launch == 0) {
@@ -483,6 +506,8 @@ function scorm_scandir($directory) {
}
function scorm_option2text($scorm) {
+ global $SCORM_POPUP_OPTIONS;
+
if (isset($scorm->popup)) {
if ($scorm->popup) {
$optionlist = array();
View
@@ -5,7 +5,6 @@
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scorm ID
$scoid = required_param('scoid', '', PARAM_INT); // sco ID
- $mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
@@ -44,17 +43,6 @@
}
}
}
- } else {
- //
- // Search for first incomplete sco
- //
- if ( $scoes_track = get_records_select("scorm_scoes_track","userid=".$USER->id." AND element='cmi.core.lesson_status' AND scormid=".$scorm->id,"scoid ASC") ) {
- $sco_track = current($scoes_track);
- while ((($sco_track->value == "completed") || ($sco_track->value == "passed") || ($sco_track->value == "failed")) && ($mode == "normal")) {
- $sco_track = next($scoes_track);
- }
- $sco = get_record("scorm_scoes","id",$sco_track->scoid);
- }
}
//
// If no sco was found get the first of SCORM package
View
@@ -27,7 +27,7 @@ function scorm_datadir($strPath)
$randstring .= $char;
$lchar = $char;
}
- $datadir='/'.randstring;
+ $datadir='/'.$randstring;
} while (file_exists($strPath.$datadir));
mkdir($strPath.$datadir, $CFG->directorypermissions);
@chmod($strPath.$datadir, $CFG->directorypermissions); // Just in case mkdir didn't do it
@@ -391,27 +391,40 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
global $CFG;
$strexpand = get_string('expcoll','scorm');
+ $modestr = '';
+ if ($mode == 'browse') {
+ $modestr = '&amp;mode='.$mode;
+ }
$scormpixdir = $CFG->modpixpath.'/scorm/pix';
$result = new stdClass();
$result->toc = "<ul id='0' class='$liststyle'>\n";
$tocmenus = array();
$result->prerequisites = true;
$incomplete = false;
- $organizationsql = '';
+ //
+ // Get the current organization infos
+ //
+ $organizationsql = '';
if (!empty($currentorg)) {
if (($organizationtitle = get_field('scorm_scoes','title','scorm',$scorm->id,'identifier',$currentorg)) != '') {
$result->toc .= "\t<li>$organizationtitle</li>\n";
$tocmenus[] = $organizationtitle;
}
$organizationsql = "AND organization='$currentorg'";
}
+ //
+ // If not specified retrieve the last attempt number
+ //
if (empty($attempt)) {
$attempt = scorm_get_last_attempt($scorm->id, $user->id);
}
$result->attemptleft = $scorm->maxattempt - $attempt;
if ($scoes = get_records_select('scorm_scoes',"scorm='$scorm->id' $organizationsql order by id ASC")){
+ //
+ // Retrieve user tracking data for each learning object
+ //
$usertracks = array();
foreach ($scoes as $sco) {
if (!empty($sco->launch)) {
@@ -514,7 +527,7 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n
if ($sco->id == $scoid) {
$result->prerequisites = true;
}
- $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.'&amp;mode='.$mode.'&amp;scoid='.$sco->id;
+ $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid='.$sco->id;
$result->toc .= '&nbsp'.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
$tocmenus[$sco->id] = scorm_repeater('&minus;',$level) . '&gt;' . format_string($sco->title);
} else {
@@ -569,7 +582,7 @@ function expandCollide(which,list) {
</script>'."\n";
}
- $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.'&amp;mode='.$mode.'&amp;scoid=';
+ $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&amp;currentorg='.$currentorg.$modestr.'&amp;scoid=';
$result->tocmenu = popup_form($url,$tocmenus, "tocmenu", $sco->id, '', '', '', true);
return $result;
@@ -1097,7 +1110,7 @@ function scorm_course_format_display($user,$course) {
}
$headertext .= '</td></tr><tr><td'.$colspan.'>'.format_text(get_string('summary').':<br />'.$scorm->summary).'</td></tr></table>';
print_simple_box($headertext,'','100%');
- scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm);
+ scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm, '100%');
} else {
if (isteacheredit($course->id, $user->id)) {
// Create a new activity
@@ -1109,12 +1122,12 @@ function scorm_course_format_display($user,$course) {
echo '</div>';
}
-function scorm_view_display ($user, $scorm, $action, $cm) {
+function scorm_view_display ($user, $scorm, $action, $cm, $blockwidth='') {
global $CFG;
$organization = optional_param('organization', '', PARAM_INT);
- print_simple_box_start('center','100%');
+ print_simple_box_start('center',$blockwidth);
?>
<div class="structurehead"><?php print_string('coursestruct','scorm') ?></div>
<?php
@@ -1164,7 +1177,7 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
echo '<input type="hidden" name="mode" value="review" />'."\n";
}
}
- if (($incomplete === false) && ($result->attemptleft > 0)) {
+ if (($incomplete === false) && (($result->attemptleft > 0)||($scorm->maxattempt == 0))) {
?>
<br />
<input type="checkbox" id="a" name="newattempt" />
Oops, something went wrong.

0 comments on commit 0f995ab

Please sign in to comment.