diff --git a/lang/en_utf8/scorm.php b/lang/en_utf8/scorm.php
index e115e36506c..d15f71e62fd 100644
--- a/lang/en_utf8/scorm.php
+++ b/lang/en_utf8/scorm.php
@@ -133,6 +133,7 @@ $string['scorm:skipview'] = 'Skip overview';
$string['scorm:viewreport'] = 'View reports';
$string['scorm:viewscores'] = 'View scores';
$string['scormcourse'] = 'Learning Course';
+$string['scormresponsedeleted'] = 'Deleted user attempts';
$string['scrollbars'] = 'Allow the window to be scrolled';
$string['sided'] = 'On the left side';
$string['skipview'] = 'Student skip content structure page';
diff --git a/mod/scorm/db/access.php b/mod/scorm/db/access.php
index 3f4a7dfbfe2..173bf64f2c2 100644
--- a/mod/scorm/db/access.php
+++ b/mod/scorm/db/access.php
@@ -75,8 +75,17 @@ $mod_scorm_capabilities = array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
- )
+ ),
+ 'mod/scorm:deleteresponses' => array(
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'legacy' => array(
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'admin' => CAP_ALLOW
+ )
+ )
);
-?>
+?>
\ No newline at end of file
diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php
index 5c9e9ef1621..4f3137f9673 100755
--- a/mod/scorm/locallib.php
+++ b/mod/scorm/locallib.php
@@ -22,18 +22,18 @@ define('LASTATTEMPT', '3');
/**
* Returns an array of the popup options for SCORM and each options default value
- *
+ *
* @return array an array of popup options as the key and their defaults as the value
*/
function scorm_get_popup_options_array(){
global $CFG;
- return array('resizable'=> isset($CFG->scorm_resizable) ? $CFG->scorm_resizable : 0,
- 'scrollbars'=> isset($CFG->scorm_scrollbars) ? $CFG->scorm_scrollbars : 0,
- 'directories'=> isset($CFG->scorm_directories) ? $CFG->scorm_directories : 0,
+ return array('resizable'=> isset($CFG->scorm_resizable) ? $CFG->scorm_resizable : 0,
+ 'scrollbars'=> isset($CFG->scorm_scrollbars) ? $CFG->scorm_scrollbars : 0,
+ 'directories'=> isset($CFG->scorm_directories) ? $CFG->scorm_directories : 0,
'location'=> isset($CFG->scorm_location) ? $CFG->scorm_location : 0,
- 'menubar'=> isset($CFG->scorm_menubar) ? $CFG->scorm_menubar : 0,
- 'toolbar'=> isset($CFG->scorm_toolbar) ? $CFG->scorm_toolbar : 0,
- 'status'=> isset($CFG->scorm_status) ? $CFG->scorm_status : 0);
+ 'menubar'=> isset($CFG->scorm_menubar) ? $CFG->scorm_menubar : 0,
+ 'toolbar'=> isset($CFG->scorm_toolbar) ? $CFG->scorm_toolbar : 0,
+ 'status'=> isset($CFG->scorm_status) ? $CFG->scorm_status : 0);
}
$stdoptions = '';
@@ -59,19 +59,19 @@ if (!isset($CFG->scorm_windowsettings)) {
/// Local Library of functions for module scorm
/**
* Returns an array of the array of what grade options
- *
+ *
* @return array an array of what grade options
*/
function scorm_get_grade_method_array(){
return array (GRADESCOES => get_string('gradescoes', 'scorm'),
GRADEHIGHEST => get_string('gradehighest', 'scorm'),
GRADEAVERAGE => get_string('gradeaverage', 'scorm'),
- GRADESUM => get_string('gradesum', 'scorm'));
+ GRADESUM => get_string('gradesum', 'scorm'));
}
/**
* Returns an array of the array of what grade options
- *
+ *
* @return array an array of what grade options
*/
function scorm_get_what_grade_array(){
@@ -83,7 +83,7 @@ function scorm_get_what_grade_array(){
/**
* Returns an array of the array of skip view options
- *
+ *
* @return array an array of skip view options
*/
function scorm_get_skip_view_array(){
@@ -94,7 +94,7 @@ function scorm_get_skip_view_array(){
/**
* Returns an array of the array of hide table of contents options
- *
+ *
* @return array an array of hide table of contents options
*/
function scorm_get_hidetoc_array(){
@@ -105,7 +105,7 @@ function scorm_get_hidetoc_array(){
/**
* Returns an array of the array of update frequency options
- *
+ *
* @return array an array of update frequency options
*/
function scorm_get_updatefreq_array(){
@@ -116,7 +116,7 @@ function scorm_get_updatefreq_array(){
/**
* Returns an array of the array of popup display options
- *
+ *
* @return array an array of popup display options
*/
function scorm_get_popup_display_array(){
@@ -126,17 +126,17 @@ function scorm_get_popup_display_array(){
/**
* Returns an array of the array of attempt options
- *
+ *
* @return array an array of attempt options
*/
function scorm_get_attempts_array(){
$attempts = array(0 => get_string('nolimit','scorm'),
1 => get_string('attempt1','scorm'));
-
+
for ($i=2; $i<=6; $i++) {
$attempts[$i] = get_string('attemptsx','scorm', $i);
}
-
+
return $attempts;
}
@@ -211,7 +211,7 @@ function scorm_tempdir($strPath)
}
$randstring .= $char;
$lchar = $char;
- }
+ }
$datadir='/'.$randstring;
} while (file_exists($strPath.$datadir));
mkdir($strPath.$datadir, $CFG->directorypermissions);
@@ -279,7 +279,7 @@ function scorm_get_sco($id,$what=SCO_ALL) {
$sco->{$scodata->name} = $scodata->value;
}
} else if (($what != SCO_ONLY) && (!($scodatas = get_records('scorm_scoes_data','scoid',$id)))) {
- $sco->parameters = '';
+ $sco->parameters = '';
}
return $sco;
} else {
@@ -332,15 +332,15 @@ function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value) {
$track->timemodified = time();
$id = insert_record('scorm_scoes_track',$track);
}
-
- if (strstr($element, '.score.raw') ||
+
+ if (strstr($element, '.score.raw') ||
(($element == 'cmi.core.lesson_status' || $element == 'cmi.completion_status') && ($track->value == 'completed' || $track->value == 'passed'))) {
$scorm = get_record('scorm', 'id', $scormid);
$grademethod = $scorm->grademethod % 10;
include_once('lib.php');
scorm_update_grades($scorm, $userid);
}
-
+
return $id;
}
@@ -358,7 +358,7 @@ function scorm_get_tracks($scoid,$userid,$attempt='') {
$attemptsql = ' AND attempt=' . $attempt;
if ($tracks = get_records_select('scorm_scoes_track',"userid=$userid AND scoid=$scoid".$attemptsql,'element ASC')) {
$usertrack->userid = $userid;
- $usertrack->scoid = $scoid;
+ $usertrack->scoid = $scoid;
// Defined in order to unify scorm1.2 and scorm2004
$usertrack->score_raw = '';
$usertrack->status = '';
@@ -373,27 +373,27 @@ function scorm_get_tracks($scoid,$userid,$attempt='') {
case 'cmi.completion_status':
if ($track->value == 'not attempted') {
$track->value = 'notattempted';
- }
+ }
$usertrack->status = $track->value;
- break;
+ break;
case 'cmi.core.score.raw':
case 'cmi.score.raw':
$usertrack->score_raw = $track->value;
- break;
+ break;
case 'cmi.core.session_time':
case 'cmi.session_time':
$usertrack->session_time = $track->value;
- break;
+ break;
case 'cmi.core.total_time':
case 'cmi.total_time':
$usertrack->total_time = $track->value;
- break;
- }
+ break;
+ }
if (isset($track->timemodified) && ($track->timemodified > $usertrack->timemodified)) {
$usertrack->timemodified = $track->timemodified;
- }
+ }
}
- if (is_array($usertrack)) {
+ if (is_array($usertrack)) {
ksort($usertrack);
}
return $usertrack;
@@ -410,13 +410,13 @@ function scorm_get_user_data($userid) {
}
function scorm_grade_user_attempt($scorm, $userid, $attempt=1, $time=false) {
- $attemptscore = NULL;
+ $attemptscore = NULL;
$attemptscore->scoes = 0;
$attemptscore->values = 0;
$attemptscore->max = 0;
$attemptscore->sum = 0;
$attemptscore->lastmodify = 0;
-
+
if (!$scoes = get_records('scorm_scoes','scorm',$scorm->id)) {
return NULL;
}
@@ -426,11 +426,11 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1, $time=false) {
// and 1s are grademethod
$grademethod = $scorm->grademethod % 10;
- foreach ($scoes as $sco) {
+ foreach ($scoes as $sco) {
if ($userdata = scorm_get_tracks($sco->id, $userid, $attempt)) {
if (($userdata->status == 'completed') || ($userdata->status == 'passed')) {
$attemptscore->scoes++;
- }
+ }
if (!empty($userdata->score_raw)) {
$attemptscore->values++;
$attemptscore->sum += $userdata->score_raw;
@@ -440,23 +440,23 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1, $time=false) {
} else {
$attemptscore->lastmodify = 0;
}
- }
- }
+ }
+ }
}
switch ($grademethod) {
case GRADEHIGHEST:
$score = $attemptscore->max;
- break;
+ break;
case GRADEAVERAGE:
if ($attemptscore->values > 0) {
$score = $attemptscore->sum/$attemptscore->values;
} else {
$score = 0;
- }
- break;
+ }
+ break;
case GRADESUM:
$score = $attemptscore->sum;
- break;
+ break;
case GRADESCOES:
$score = $attemptscore->scoes;
break;
@@ -480,17 +480,17 @@ function scorm_grade_user($scorm, $userid, $time=false) {
// and so whatgrade and grademethod are combined in grademethod 10s are whatgrade
// and 1s are grademethod
$whatgrade = intval($scorm->grademethod / 10);
-
+
// insure we dont grade user beyond $scorm->maxattempt settings
$lastattempt = scorm_get_last_attempt($scorm->id, $userid);
if($scorm->maxattempt != 0 && $lastattempt >= $scorm->maxattempt){
$lastattempt = $scorm->maxattempt;
}
-
+
switch ($whatgrade) {
case FIRSTATTEMPT:
return scorm_grade_user_attempt($scorm, $userid, 1, $time);
- break;
+ break;
case LASTATTEMPT:
return scorm_grade_user_attempt($scorm, $userid, scorm_get_last_attempt($scorm->id, $userid), $time);
break;
@@ -575,7 +575,7 @@ function scorm_course_format_display($user,$course) {
echo '
';
if ($scorms = get_all_instances_in_course('scorm', $course)) {
- // The module SCORM activity with the least id is the course
+ // The module SCORM activity with the least id is the course
$scorm = current($scorms);
if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
error('Course Module ID was incorrect');
@@ -601,7 +601,7 @@ function scorm_course_format_display($user,$course) {
$headertext .= '
';
print_table($table);
- }
+ }
print_simple_box_end();
} else {
error('Missing script parameter');
diff --git a/mod/scorm/version.php b/mod/scorm/version.php
index ea46420ba7e..89c512c11e1 100755
--- a/mod/scorm/version.php
+++ b/mod/scorm/version.php
@@ -10,8 +10,8 @@
// catch up now, so until 27th October please only increment in very tiny steps
// in HEAD, until we get past that date..
-$module->version = 2007110501; // The (date) version of this module
+$module->version = 2007110502; // The (date) version of this module
$module->requires = 2007101509; // The version of Moodle that is required
$module->cron = 300; // How often should cron check this module (seconds)?
-?>
+?>
\ No newline at end of file