Permalink
Browse files

General review to support XHTML Strict

First step in multi-attempt feature (requested by SCORM 2004)
Removed javascript use as much as possible in button and link
  • Loading branch information...
1 parent 25fc865 commit 133c5c2792367e7f53f08f19821fdfe2d558ca05 bobopinna committed Nov 15, 2005
@@ -54,7 +54,7 @@ view.php
||
||
\/
-playscorm.php -- load --> request.js
+player.php -- load --> request.js
|| api.php -- include --> datamodels/(SCORM1_2.js.php || SCORM1_3.js.php || AICC.js.php)
|| /\
iframe ||
View
@@ -1,6 +1,6 @@
<?php
require_once('../../config.php');
- require_once('lib.php');
+ require_once('locallib.php');
$command = required_param('command', '', PARAM_ALPHA);
$sessionid = required_param('session_id', '', PARAM_ALPHANUM);
@@ -24,6 +24,22 @@
if (isset($SESSION->scorm_status)) {
$status = $SESSION->scorm_status;
}
+ if (isset($SESSION->newattempt)) {
+ $newattempt = $SESSION->newattempt;
+ $SESSION->newattempt = '';
+ } else {
+ $newattempt = '';
+ }
+ if ($lastattempt = get_record('scorm_sco_tracks', 'user', $USER->id, 'scorm', $scorm->id, 'sco', $scoid,'max(attempt) as a')) {
+ if ($newattempt == 'new') {
+ $attempt = $lastattempt['a']+1;
+ } else {
+ $attempt = $lastattempt['a'];
+ }
+ } else {
+ $attempt = 1;
+ }
+
if ($sco = get_record('scorm_scoes','id',$scoid)) {
if (!$scorm = get_record('scorm','id',$sco->scorm)) {
error('Invalid script call');
@@ -152,7 +168,7 @@
$element = $datamodel[$element];
switch ($element) {
case 'cmi.core.lesson_location':
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $element, $value);
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
break;
case 'cmi.core.lesson_status':
$statuses = array(
@@ -187,12 +203,12 @@
}
if (empty($value) || isset($exites[$value])) {
$subelement = 'cmi.core.exit';
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $subelement, $value);
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
}
$value = trim(strtolower($values[0]));
if (isset($statuses[$value]) && ($mode == 'normal')) {
$value = $statuses[$value];
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $element, $value);
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
$lessonstatus = $value;
break;
@@ -201,18 +217,18 @@
if ((count($values) > 1) && ($values[1] >= $values[0]) && is_numeric($values[1])) {
$subelement = 'cmi.core.score.max';
$value = trim($values[1]);
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $subelement, $value);
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
if ((count($values) == 3) && ($values[2] <= $values[0]) && is_numeric($values[2])) {
$subelement = 'cmi.core.score.min';
$value = trim($values[2]);
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $subelement, $value);
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $subelement, $value);
}
}
$value = '';
if (is_numeric($values[0])) {
$value = trim($values[0]);
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $element, $value);
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
$score = $value;
break;
@@ -229,13 +245,13 @@
$value .= $datarow;
next($datarows);
}
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $element, $value);
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
}
}
if (($mode == 'browse') && ($initlessonstatus == 'not attempted')){
$lessonstatus = 'browsed';
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, 'cmi.core.lesson_status', 'browsed');
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', 'browsed');
}
if ($mode == 'normal') {
if ($lessonstatus == 'completed') {
@@ -244,7 +260,7 @@
} else {
$lessonstatus = 'failed';
}
- $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, 'cmi.core.lesson_status', $lessonstatus);
+ $id = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, 'cmi.core.lesson_status', $lessonstatus);
}
}
}
View
@@ -1,12 +1,13 @@
<?php
require_once("../../config.php");
- require_once("lib.php");
+ require_once('locallib.php');
$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
+ $attempt = optional_param('attempt', '', PARAM_ALPHA); // new attempt
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
@@ -38,10 +39,10 @@
$userdata = $usertrack;
} else {
$userdata->status = '';
- $userdata->scorre_raw = '';
+ $userdata->score_raw = '';
}
- $userdata->student_id = $USER->username;
- $userdata->student_name = $USER->lastname .', '. $USER->firstname;
+ $userdata->student_id = addslashes($USER->username);
+ $userdata->student_name = addslashes($USER->lastname .', '. $USER->firstname);
$userdata->mode = 'normal';
if (isset($mode)) {
$userdata->mode = $mode;
@@ -1,9 +1,9 @@
<?php
if (empty($CFG->scorm_frameheight)) {
- $CFG->scorm_frameheight = 600;
+ $CFG->scorm_frameheight = '500';
}
if (empty($CFG->scorm_framewidth)) {
- $CFG->scorm_structurewidth = 800;
+ $CFG->scorm_framewidth = '100%';
}
?>
@@ -33,7 +33,7 @@
<tr valign="top">
<td align="right">scorm_framewidth:</td>
<td>
- <input type="text" name="scorm_framewidth" value="<?php echo $CFG->scorm_framewidth ?>" size="3" />
+ <input type="text" name="scorm_framewidth" value="<?php echo $CFG->scorm_framewidth ?>" size="5" />
</td>
<td>
<?php print_string("framewidth", "scorm") ?>
@@ -42,7 +42,7 @@
<tr valign="top">
<td align="right">scorm_frameheight:</td>
<td>
- <input type="text" name="scorm_frameheight" value="<?php echo $CFG->scorm_frameheight ?>" size="4" />
+ <input type="text" name="scorm_frameheight" value="<?php echo $CFG->scorm_frameheight ?>" size="5" />
</td>
<td>
<?php print_string("frameheight", "scorm") ?>
@@ -1,10 +1,11 @@
<?php
require_once('../../config.php');
- require_once('lib.php');
+ require_once('locallib.php');
$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
+ $newattempt = optional_param('attempt', '', PARAM_ALPHA); // new attempt ?
if (!empty($id)) {
if (! $cm = get_record("course_modules", "id", $id)) {
@@ -35,11 +36,20 @@
if (confirm_sesskey() && (!empty($scoid))) {
$result = true;
if (isstudent($course->id) || (isteacher($course->id) && !isadmin()) {
+ if ($lastattempt = get_record('scorm_sco_tracks', 'user', $USER->id, 'scorm', $scorm->id, 'sco', $scoid,'max(attempt) as a')) {
+ if ($newattempt == 'new') {
+ $attempt = $lastattempt['a']+1;
+ } else {
+ $attempt = $lastattempt['a'];
+ }
+ } else {
+ $attempt = 1;
+ }
foreach ($_POST as $element => $value) {
if (substr($element,0,3) == 'cmi') {
$element = str_replace('__','.',$element);
$element = preg_replace('/_(\d+)/',".\$1",$element);
- $result = scorm_insert_track($USER->id, $scorm->id, $scoid, $element, $value) && $result;
+ $result = scorm_insert_track($USER->id, $scorm->id, $scoid, $attempt, $element, $value) && $result;
}
}
}
@@ -529,6 +529,11 @@ function StoreData(data,storetotaltime) {
datastring = CollectData(data,'cmi');
}
datastring += '&scoid=<?php echo $sco->id ?>';
+ <?php
+ if (!empty($attempt)) {
+ echo "datastring += '&attempt=$attempt';";
+ }
+ ?>
//popupwin(datastring);
var myRequest = NewHttpReq();
result = DoRequest(myRequest,"<?php p($CFG->wwwroot) ?>/mod/scorm/datamodel.php","id=<?php p($id) ?>&sesskey=<?php p($USER->sesskey) ?>"+datastring);
@@ -197,11 +197,17 @@ 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");
}
+
+ if ($oldversion < 2005092600) {
+ table_column("scorm_scoes_track", "", "attempt", "INT", "10", "UNSIGNED", "1", "NOT NULL", "scoid");
+ execute_sql("ALTER TABLE {$CFG->prefix}scorm_scoes_track DROP INDEX track");
+ modify_database('','ALTER TABLE prefix_scorm_scoes_track ADD UNIQUE track (userid,scormid,scoid,attempt,element);');
+ }
+
return true;
}
?>
@@ -54,15 +54,16 @@ CREATE TABLE prefix_scorm_scoes_track (
userid int(10) unsigned NOT NULL default '0',
scormid int(10) NOT NULL default '0',
scoid int(10) unsigned NOT NULL default '0',
+ attempt int(10) unsigned NOT NULL default '1',
element varchar(255) NOT NULL default '',
value longtext NOT NULL default '',
timemodified int(10) unsigned NOT NULL default '0',
PRIMARY KEY (id),
KEY userid (userid),
KEY scormid (scormid),
KEY scoid (scoid),
- KEY elemeny (element),
- UNIQUE track (userid, scormid, scoid, element)
+ KEY element (element),
+ UNIQUE track (userid, scormid, scoid, attempt, element)
) TYPE=MyISAM;
#
View
@@ -22,6 +22,7 @@
$strtopic = get_string("topic");
$strname = get_string("name");
$strsummary = get_string("summary");
+ $strreport = get_string("report",'scorm');
$strlastmodified = get_string("lastmodified");
print_header_simple("$strscorms", "", "$strscorms",
@@ -39,14 +40,14 @@
}
if ($course->format == "weeks") {
- $table->head = array ($strweek, $strname, $strsummary);
- $table->align = array ("center", "left", "left");
+ $table->head = array ($strweek, $strname, $strsummary, $strreport);
+ $table->align = array ("center", "left", "left", "left");
} else if ($course->format == "topics") {
- $table->head = array ($strtopic, $strname, $strsummary);
- $table->align = array ("center", "left", "left");
+ $table->head = array ($strtopic, $strname, $strsummary, $strreport);
+ $table->align = array ("center", "left", "left", "left");
} else {
- $table->head = array ($strlastmodified, $strname, $strsummary);
- $table->align = array ("left", "left", "left");
+ $table->head = array ($strlastmodified, $strname, $strsummary, $strreport);
+ $table->align = array ("left", "left", "left", "left");
}
foreach ($scorms as $scorm) {
@@ -57,16 +58,28 @@
$tt = "$scorm->section";
}
} else {
- $tt = "<font size=\"1\">".userdate($scorm->timemodified);
+ $tt = userdate($scorm->timemodified);
+ }
+ $report = '&nbsp;';
+ if (isteacher($course->id)) {
+ $trackedusers = get_record('scorm_scoes_track', 'scormid', $scorm->id, '', '', '', '', 'count(distinct(userid)) as c');
+ if ($trackedusers->c > 0) {
+ $report = '<a href="report.php?a='.$scorm->id.'">'.get_string('viewallreports','scorm',$trackedusers->c).'</a></div>';
+ } else {
+ $report = get_string('noreports','scorm');
+ }
+ } else if (isstudent($course->id)) {
+ require_once('locallib.php');
+ $report = scorm_grade_user(get_records('scorm_scoes','scorm',$scorm->id), $USER->id, $scorm->grademethod);
}
if (!$scorm->visible) {
//Show dimmed if the mod is hidden
$table->data[] = array ($tt, "<a class=\"dimmed\" href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name,true)."</a>",
- format_text($scorm->summary));
+ format_text($scorm->summary), $report);
} else {
//Show normal if the mod is visible
$table->data[] = array ($tt, "<a href=\"view.php?id=$scorm->coursemodule\">".format_string($scorm->name,true)."</a>",
- format_text($scorm->summary));
+ format_text($scorm->summary), $report);
}
}
Oops, something went wrong.

0 comments on commit 133c5c2

Please sign in to comment.