Permalink
Browse files

Added ITEM parameters support.

  • Loading branch information...
1 parent 5e0c182 commit d0dd5c4b3d9ce6344ea62f6a18d0a3abc716cb3b bobopinna committed Apr 4, 2005
Showing with 99 additions and 57 deletions.
  1. +4 −0 mod/scorm/db/mysql.php
  2. +3 −1 mod/scorm/db/mysql.sql
  3. +4 −0 mod/scorm/db/postgres7.php
  4. +4 −2 mod/scorm/db/postgres7.sql
  5. +23 −14 mod/scorm/lib.php
  6. +10 −2 mod/scorm/loadSCO.php
  7. +51 −38 mod/scorm/playscorm.php
View
@@ -93,6 +93,10 @@ function scorm_upgrade($oldversion) {
execute_sql('ALTER TABLE `'.$CFG->prefix.'scorm` DROP `popup`'); // Old field
}
+ if ($oldversion < 2005040400) {
+ table_column("scorm_scoes", "", "parameters", "VARCHAR", "255", "", "", "NOT NULL", "launch");
+ }
+
return true;
}
View
@@ -27,6 +27,7 @@ CREATE TABLE prefix_scorm_scoes (
parent varchar(255) NOT NULL default '',
identifier varchar(255) NOT NULL default '',
launch varchar(255) NOT NULL default '',
+ parameters varchar(255) NOT NULL default '',
scormtype set('sco','asset') NOT NULL default '',
title varchar(255) NOT NULL default '',
prerequisites varchar(200) NOT NULL default '',
@@ -50,7 +51,8 @@ CREATE TABLE prefix_scorm_scoes_track (
value longtext NOT NULL default '',
PRIMARY KEY (id),
UNIQUE (userid, scormid, scoid, element),
- KEY userdata (userid, scormid, scoid)
+ KEY userdata (userid, scormid, scoid),
+ KEY id (id)
) TYPE=MyISAM;
#
@@ -92,6 +92,10 @@ function scorm_upgrade($oldversion) {
if ($oldversion < 2005040200) {
execute_sql('ALTER TABLE `'.$CFG->prefix.'scorm` DROP `popup`'); // Old field
}
+
+ if ($oldversion < 2005040400) {
+ table_column("scorm_scoes", "", "parameters", "VARCHAR", "255", "", "", "NOT NULL", "launch");
+ }
return true;
}
@@ -26,6 +26,7 @@ CREATE TABLE prefix_scorm_scoes (
parent varchar(255) NOT NULL default '',
identifier varchar(255) NOT NULL default '',
launch varchar(255) NOT NULL default '',
+ parameters varchar(255) NOT NULL default '',
scormtype varchar(5) NOT NULL default '',
title varchar(255) NOT NULL default '',
datafromlms text NOT NULL default '',
@@ -35,7 +36,7 @@ CREATE TABLE prefix_scorm_scoes (
CREATE INDEX prefix_scorm_scoes_scorm_idx ON prefix_scorm_scoes (scorm);
-CREATE TABLE prefix_scorm_sco_users (
+CREATE TABLE prefix_scorm_scoes_track (
id SERIAL KEY,
userid integer NOT NULL default '0',
scormid integer NOT NULL default '0',
@@ -44,7 +45,8 @@ CREATE TABLE prefix_scorm_sco_users (
value text NOT NULL default '',
PRIMARY KEY (userid, scormid, scoid, element),
UNIQUE (userid, scormid, scoid, element),
- INDEX userdata (userid, scormid, scoid)
+ INDEX userdata (userid, scormid, scoid),
+ INDEX id (id)
);
View
@@ -370,8 +370,9 @@ function scorm_scandir($directory) {
function scorm_startElement($parser, $name, $attrs) {
global $scoes,$i,$resources,$parent,$level,$organization,$manifest,$defaultorg;
-
- if ($name == 'ITEM') {
+
+ switch ($name) {
+ case 'ITEM':
$i++;
$scoes[$i]['manifest'] = $manifest;
$scoes[$i]['organization'] = $organization;
@@ -382,11 +383,14 @@ function scorm_startElement($parser, $name, $attrs) {
if (empty($attrs['ISVISIBLE']))
$attrs['ISVISIBLE'] = '';
$scoes[$i]['isvisible'] = $attrs['ISVISIBLE'];
+ if (empty($attrs['PARAMETERS']))
+ $attrs['PARAMETERS'] = '';
+ $scoes[$i]['parameters'] = $attrs['PARAMETERS'];
$scoes[$i]['parent'] = $parent[$level];
$level++;
$parent[$level] = $attrs['IDENTIFIER'];
- }
- if ($name == 'RESOURCE') {
+ break;
+ case 'RESOURCE':
if (!isset($attrs['HREF'])) {
$attrs['HREF'] = '';
}
@@ -395,8 +399,8 @@ function scorm_startElement($parser, $name, $attrs) {
$attrs['ADLCP:SCORMTYPE'] = '';
}
$resources[$attrs['IDENTIFIER']]['scormtype']=$attrs['ADLCP:SCORMTYPE'];
- }
- if ($name == 'ORGANIZATION') {
+ break;
+ case 'ORGANIZATION':
$i++;
$scoes[$i]['manifest'] = $manifest;
$scoes[$i]['organization'] = '';
@@ -408,15 +412,15 @@ function scorm_startElement($parser, $name, $attrs) {
$parent[$level] = $attrs['IDENTIFIER'];
$organization = $attrs['IDENTIFIER'];
}
- if ($name == 'MANIFEST') {
+ case 'MANIFEST':
$manifest = $attrs['IDENTIFIER'];
- }
- if ($name == 'ORGANIZATIONS') {
+ break;
+ case 'ORGANIZATIONS':
if (!isset($attrs['DEFAULT'])) {
$attrs['DEFAULT'] = '';
}
$defaultorg = $attrs['DEFAULT'];
- }
+ break;
}
function scorm_endElement($parser, $name) {
@@ -507,24 +511,29 @@ function scorm_parse($basedir,$file,$scorm_id) {
if (!isset($scoes[$j]['prerequisites'])) {
$scoes[$j]['prerequisites'] = '';
}
- $sco->datafromlms = $scoes[$j]['prerequisites'];
+ $sco->prerequisites = $scoes[$j]['prerequisites'];
if (!isset($scoes[$j]['maxtimeallowed'])) {
$scoes[$j]['maxtimeallowed'] = '';
}
- $sco->datafromlms = $scoes[$j]['maxtimeallowed'];
+ $sco->maxtimeallowed = $scoes[$j]['maxtimeallowed'];
if (!isset($scoes[$j]['timelimitaction'])) {
$scoes[$j]['timelimitaction'] = '';
}
- $sco->datafromlms = $scoes[$j]['timelimitaction'];
+ $sco->timelimitaction = $scoes[$j]['timelimitaction'];
if (!isset($scoes[$j]['masteryscore'])) {
$scoes[$j]['masteryscore'] = '';
}
- $sco->datafromlms = $scoes[$j]['masteryscore'];
+ $sco->masteryscore = $scoes[$j]['masteryscore'];
if (!isset($resources[($scoes[$j]['identifierref'])]['href'])) {
$resources[($scoes[$j]['identifierref'])]['href'] = '';
}
$sco->launch = $resources[($scoes[$j]['identifierref'])]['href'];
+
+ if (!isset($scoes[$j]['parameters'])) {
+ $scoes[$j]['paramenters'] = '';
+ }
+ $sco->paramenters = $scoes[$j]['parameters'];
if (!isset($resources[($scoes[$j]['identifierref'])]['type'])) {
$resources[($scoes[$j]['identifierref'])]['type'] = '';
View
@@ -70,13 +70,21 @@
//
// Forge SCO URL
//
+ $connector = '';
+ if (!empty($sco->parameters)) {
+ if (stripos($sco->launch,'?') !== false) {
+ $connector = '&';
+ } else {
+ $connector = '?';
+ }
+ }
if (scorm_external_link($sco->launch)) {
$result = $sco->launch;
} else {
if ($CFG->slasharguments) {
- $result = "$CFG->wwwroot/file.php/$scorm->course/moddata/scorm$scorm->datadir/$sco->launch";
+ $result = $CFG->wwwroot.'/file.php/'.$scorm->course.'/moddata/scorm'.$scorm->datadir.'/'.$sco->launch.$connector.$sco->parameters;
} else {
- $result = "$CFG->wwwroot/file.php?file=/$scorm->course/moddata/scorm$scorm->datadir/$sco->launch";
+ $result = $CFG->wwwroot.'/file.php?file=/'.$scorm->course.'/moddata/scorm'.$scorm->datadir.'/'.$sco->launch.$connector.$sco->parameters;
}
}
?>
View
@@ -189,48 +189,61 @@ function expandCollide(which,list) {
if ($sco->launch) {
$startbold = '';
$endbold = '';
- if ($sco->id == $scoid) {
- $startbold = '-> <b>';
- $endbold = '</b> <-';
- if ($nextsco !== false) {
- $nextid = $nextsco->id;
- } else {
- $nextid = 0;
- }
- } else if ($nextid == 0) {
- $previd = $sco->id;
- }
- if (($scoid == "") && ($mode != "normal")) {
- $scoid = $sco->id;
- $startbold = '-> <b>';
- $endbold = '</b> <-';
- }
- $score = "";
- if ($user_tracks=scorm_get_tracks($sco->id,$USER->id)) {
- if ( $user_tracks->status == '') {
- $user_tracks->status = 'notattempted';
+ $score = '';
+ if ($scoid != '') {
+ if ($sco->id == $scoid) {
+ $startbold = '-> <b>';
+ $endbold = '</b> <-';
+ if ($nextsco !== false) {
+ $nextid = $nextsco->id;
+ } else {
+ $nextid = 0;
+ }
}
- $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')) {
- if ($scoid == '') {
- $incomplete = true;
- $scoid = $sco->id;
- $startbold = '-> <b>';
- $endbold = '</b> <-';
+ } 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 ($sco->scormtype == 'sco') {
- echo "<img src='pix/notattempted.gif' alt='".get_string('notattempted','scorm')."' />";
- $incomplete = true;
+ if ($user_tracks->score_raw != "") {
+ $score = '('.get_string('score','scorm').':&nbsp;'.$user_tracks->score_raw.')';
+ }
} else {
- echo "<img src='pix/asset.gif' alt='".get_string('asset','scorm')."' />";
+ 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";

0 comments on commit d0dd5c4

Please sign in to comment.