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 .= ''.get_string('noreports','scorm'); } $colspan = ' colspan="2"'; - } + } $headertext .= ''.format_text(get_string('summary').':
'.$scorm->summary).''; print_simple_box($headertext,'','100%'); scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm, '100%'); @@ -707,9 +707,9 @@ function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') { } function scorm_simple_play($scorm,$user) { $result = false; - + $scoes = get_records_select('scorm_scoes','scorm='.$scorm->id.' AND launch<>\''.sql_empty().'\''); - + if ($scoes && (count($scoes) == 1)) { if ($scorm->skipview >= 1) { $sco = current($scoes); @@ -835,7 +835,7 @@ function scorm_validate($data) { } $reference = $data['reference']; // Package/manifest path/location - $scormid = $data['instance']; // scorm ID + $scormid = $data['instance']; // scorm ID $scorm = new stdClass(); if (!empty($scormid)) { if (!$scorm = get_record('scorm','id',$scormid)) { @@ -899,7 +899,7 @@ function scorm_validate($data) { $validation->result = false; } break; - default: + default: $validation->errors['reference'] = get_string('badpackage','scorm'); $validation->result = false; break; @@ -925,7 +925,7 @@ function scorm_check_package($data) { $courseid = $data->course; // Course Module ID $reference = $data->reference; // Package path - $scormid = $data->instance; // scorm ID + $scormid = $data->instance; // scorm ID $validation = new stdClass(); @@ -947,12 +947,12 @@ function scorm_check_package($data) { $reference = $CFG->dataroot.'/'.$courseid.'/'.$reference; } - if (!empty($scormid)) { + if (!empty($scormid)) { // // SCORM Update // if ((!empty($validation)) && (is_file($reference) || $externalpackage)){ - + if (!$externalpackage) { $mdcheck = md5_file($reference); } else if ($externalpackage){ @@ -964,7 +964,7 @@ function scorm_check_package($data) { } } } - + if ($scorm = get_record('scorm','id',$scormid)) { if ($scorm->reference[0] == '#') { if (isset($CFG->repositoryactivate) && $CFG->repositoryactivate) { @@ -1050,7 +1050,7 @@ function scorm_check_package($data) { $validation = null; } break; - default: + default: $validation = null; break; } @@ -1076,23 +1076,23 @@ function scorm_check_package($data) { function scorm_get_count_users($scormid, $groupingid=null) { - + global $CFG; - + if (!empty($CFG->enablegroupings) && !empty($groupingid)) { $sql = "SELECT COUNT(DISTINCT st.userid) FROM {$CFG->prefix}scorm_scoes_track st INNER JOIN {$CFG->prefix}groups_members gm ON st.userid = gm.userid - INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid + INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid WHERE st.scormid = $scormid AND gg.groupingid = $groupingid "; } else { $sql = "SELECT COUNT(DISTINCT st.userid) - FROM {$CFG->prefix}scorm_scoes_track st + FROM {$CFG->prefix}scorm_scoes_track st WHERE st.scormid = $scormid "; } - + return(count_records_sql($sql)); } @@ -1104,7 +1104,7 @@ function scorm_get_count_users($scormid, $groupingid=null) { * @param string $element_name Name of array element to get values for * @param array $children list of sub elements of this array element that also need instantiating * @return None -*/ +*/ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $children) { // reconstitute comments_from_learner and comments_from_lms $current = ''; @@ -1112,7 +1112,7 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $ $current_sub = ''; $count = 0; $count_sub = 0; - + // filter out the ones we want $element_list = array(); foreach($userdata as $element => $value){ @@ -1120,10 +1120,10 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $ $element_list[$element] = $value; } } - + // sort elements in .n array order uksort($element_list, "scorm_element_cmp"); - + // generate JavaScript foreach($element_list as $element => $value){ if ($sversion == 'scorm_13') { @@ -1137,7 +1137,7 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $ if ($count_sub > 0) { echo ' '.$element_name.'_'.$current.'.'.$current_subelement.'._count = '.$count_sub.";\n"; } - $current = $matches[1]; + $current = $matches[1]; $count++; $current_subelement = ''; $current_sub = ''; @@ -1151,7 +1151,7 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $ echo ' '.$subelement.".".$child."._children = ".$child."_children;\n"; } } - + // now - flesh out the second level elements if there are any if ($sversion == 'scorm_13') { $element = preg_replace('/(.*?\.N\d+\..*?)\.(\d+)\./', "\$1.N\$2.", $element); @@ -1160,7 +1160,7 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $ $element = preg_replace('/(.*?\_\d+\..*?)\.(\d+)\./', "\$1_\$2.", $element); preg_match('/.*?\_\d+\.(.*?)\_(\d+)\./', $element, $matches); } - + // check the sub element type if (count($matches) > 0 && $current_subelement != $matches[1]) { if ($count_sub > 0) { @@ -1173,16 +1173,16 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $ $subelement = substr($element,0,$end); echo ' '.$subelement." = new Object();\n"; } - + // now check the subelement subscript if (count($matches) > 0 && $current_sub != $matches[2]) { - $current_sub = $matches[2]; + $current_sub = $matches[2]; $count_sub++; $end = strrpos($element,$matches[2])+strlen($matches[2]); $subelement = substr($element,0,$end); echo ' '.$subelement." = new Object();\n"; } - + echo ' '.$element.' = \''.$value."';\n"; } if ($count_sub > 0) { @@ -1199,7 +1199,7 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $ * @param string $a left array element * @param string $b right array element * @return comparator - 0,1,-1 -*/ +*/ function scorm_element_cmp($a, $b) { preg_match('/.*?(\d+)\./', $a, $matches); $left = intval($matches[1]); @@ -1235,4 +1235,51 @@ function scorm_element_cmp($a, $b) { } } +/** +* Delete Scorm tracks for selected users +* +* @param array $attemptids list of attempts that need to be deleted +* @param int $scormid ID of Scorm +* +* return bool true deleted all responses, false failed deleting an attempt - stopped here +*/ +function scorm_delete_responses($attemptids, $scormid) { + if(!is_array($attemptids) || empty($attemptids)) { + return false; + } + + foreach($attemptids as $num => $attemptid) { + if(empty($attemptid)) { + unset($attemptids[$num]); + } + } + + foreach($attemptids as $attempt) { + $keys = explode(':', $attempt); + if (count($keys) == 2) { + $userid = clean_param($keys[0], PARAM_INT); + $attemptid = clean_param($keys[1], PARAM_INT); + if (!$userid || !$attemptid || !scorm_delete_attempt($userid, $scormid, $attemptid)) { + return false; + } + } else { + return false; + } + } + return true; +} + +/** +* Delete Scorm tracks for selected users +* +* @param int $userid ID of User +* @param int $scormid ID of Scorm +* @param int $attemptid user attempt that need to be deleted +* +* return bool true suceeded +*/ +function scorm_delete_attempt($userid, $scormid, $attemptid) { + delete_records('scorm_scoes_track', 'userid', $userid, 'scormid', $scormid, 'attempt', $attemptid); + return true; +} ?> \ No newline at end of file diff --git a/mod/scorm/report.php b/mod/scorm/report.php index 2372d8288a2..f797f7942d9 100755 --- a/mod/scorm/report.php +++ b/mod/scorm/report.php @@ -10,6 +10,8 @@ $b = optional_param('b', '', PARAM_INT); // SCO ID $user = optional_param('user', '', PARAM_INT); // User ID $attempt = optional_param('attempt', '1', PARAM_INT); // attempt number + $action = optional_param('action', '', PARAM_ALPHA); + $attemptids = optional_param('attemptid', array(), PARAM_RAW); //get array of responses to delete. if (!empty($id)) { if (! $cm = get_coursemodule_from_id('scorm', $id)) { @@ -43,9 +45,9 @@ require_login($course->id, false, $cm); - if (!has_capability('mod/scorm:viewreport', get_context_instance(CONTEXT_MODULE,$cm->id))) { - error('You are not allowed to use this script'); - } + $contextmodule = get_context_instance(CONTEXT_MODULE,$cm->id); + + require_capability('mod/scorm:viewreport', $contextmodule); add_to_log($course->id, 'scorm', 'report', 'report.php?id='.$cm->id, $scorm->id, $cm->id); @@ -63,65 +65,84 @@ $strreport = get_string('report', 'scorm'); $strattempt = get_string('attempt', 'scorm'); $strname = get_string('name'); - + if (empty($b)) { if (empty($a)) { $navigation = build_navigation('', $cm); print_header("$course->shortname: ".format_string($scorm->name), $course->fullname,$navigation, '', '', true); } else { - + $navlinks = array(); - $navlinks[] = array('name' => $strreport, 'link' => "report.php?id=$cm->id", 'type' => 'title'); + $navlinks[] = array('name' => $strreport, 'link' => "report.php?id=$cm->id", 'type' => 'title'); $navlinks[] = array('name' => "$strattempt $attempt - ".fullname($userdata), 'link' => '', 'type' => 'title'); $navigation = build_navigation($navlinks, $cm); - + print_header("$course->shortname: ".format_string($scorm->name), $course->fullname, $navigation, '', '', true); } } else { $navlinks = array(); - $navlinks[] = array('name' => $strreport, 'link' => "report.php?id=$cm->id", 'type' => 'title'); + $navlinks[] = array('name' => $strreport, 'link' => "report.php?id=$cm->id", 'type' => 'title'); $navlinks[] = array('name' => "$strattempt $attempt - ".fullname($userdata), 'link' => "report.php?a=$a&user=$user&attempt=$attempt", 'type' => 'title'); $navlinks[] = array('name' => $sco->title, 'link' => '', 'type' => 'title'); $navigation = build_navigation($navlinks, $cm); - + print_header("$course->shortname: ".format_string($scorm->name), $course->fullname, $navigation, '', '', true); } print_heading(format_string($scorm->name)); } + if ($action == 'delete' && has_capability('mod/scorm:deleteresponses',$contextmodule)) { + if (scorm_delete_responses($attemptids, $scorm->id)) { //delete responses. + notify(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess'); + } + } + $scormpixdir = $CFG->modpixpath.'/scorm/pix'; if (empty($b)) { if (empty($a)) { // No options, show the global scorm report - + if (!empty($CFG->enablegroupings) && !empty($cm->groupingid)) { $sql = "SELECT st.userid, st.scormid FROM {$CFG->prefix}scorm_scoes_track st INNER JOIN {$CFG->prefix}groups_members gm ON st.userid = gm.userid - INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid + INNER JOIN {$CFG->prefix}groupings_groups gg ON gm.groupid = gg.groupid WHERE st.scormid = {$scorm->id} AND gg.groupingid = {$cm->groupingid} GROUP BY st.userid,st.scormid "; } else { $sql = "SELECT st.userid, st.scormid - FROM {$CFG->prefix}scorm_scoes_track st + FROM {$CFG->prefix}scorm_scoes_track st WHERE st.scormid = {$scorm->id} GROUP BY st.userid,st.scormid "; } - + if ($scousers=get_records_sql($sql)) { $table = new stdClass(); - $table->head = array(' ', get_string('name')); - $table->align = array('center', 'left'); - $table->wrap = array('nowrap', 'nowrap'); + $table->head = array(); $table->width = '100%'; - $table->size = array(10, '*'); + if (has_capability('mod/scorm:deleteresponses',$contextmodule)) { + $table->head[] = ' '; + $table->align[] = 'center'; + $table->wrap[] = 'nowrap'; + $table->size[] = '10'; + } + + $table->head[] = ' '; + $table->align[] = 'center'; + $table->wrap[] = 'nowrap'; + $table->size[] = '10'; + + $table->head[] = get_string('name'); + $table->align[] = 'left'; + $table->wrap[] = 'nowrap'; + $table->size[] = '*'; $table->head[]= get_string('attempt','scorm'); $table->align[] = 'center'; @@ -145,24 +166,51 @@ foreach($scousers as $scouser){ $userdata = scorm_get_user_data($scouser->userid); - $attempt = scorm_get_last_attempt($scorm->id,$scouser->userid); + $attempt = scorm_get_last_attempt($scorm->id,$scouser->userid); for ($a = 1; $a<=$attempt; $a++) { $row = array(); + if (has_capability('mod/scorm:deleteresponses',$contextmodule)) { + $row[] = ''; + } $row[] = print_user_picture($scouser->userid, $course->id, $userdata->picture, false, true); $row[] = ''. fullname($userdata).''; $row[] = ''.$a.''; $select = 'scormid = '.$scorm->id.' and userid = '.$scouser->userid.' and attempt = '.$a; - $timetracks = get_record_select('scorm_scoes_track', $select,'min(timemodified) as started, max(timemodified) as last'); + $timetracks = get_record_select('scorm_scoes_track', $select,'min(timemodified) as started, max(timemodified) as last'); + // jump out here if this attempt doesnt exist + if (!$timetracks->started) { + continue; + } $row[] = userdate($timetracks->started, get_string('strftimedaydatetime')); $row[] = userdate($timetracks->last, get_string('strftimedaydatetime')); - + $row[] = scorm_grade_user_attempt($scorm, $scouser->userid, $a); $table->data[] = $row; } } + echo '
'; + if (has_capability('mod/scorm:deleteresponses',$contextmodule)) { + echo '
'; + echo ''; + print_table($table); + echo ''.get_string('selectall', 'quiz').' / '; + echo ''.get_string('selectnone', 'quiz').' '; + echo '  '; + $options = array('delete' => get_string('delete')); + echo choose_from_menu($options, 'action', '', get_string('withselected', 'quiz'), 'if(this.selectedIndex > 0) submitFormById(\'attemptsform\');', '', true); + echo ''; + echo ''; + echo '
'; + } else { + print_table($table); + } + echo '
'; + } else { + notify(get_string('noactivity', 'scorm')); } - print_table($table); } else { if (!empty($user)) { // User SCORM report @@ -230,7 +278,7 @@ if (!empty($userdata)) { print_simple_box_start('center'); //print_heading(format_string($sco->title)); - print_heading(''.format_string($sco->title).''); + print_heading(''.format_string($sco->title).''); echo '
'."\n"; print_user_picture($user, $course->id, $userdata->picture, false, false); echo "wwwroot/user/view.php?id=$user&course=$course->id\">". @@ -252,7 +300,7 @@ $strstatus.'" /> '.$trackdata->total_time.'
'.$scoreview.'
'; echo '
'."\n"; echo '

'.get_string('details','scorm').'

'; - + // Print general score data $table = new stdClass(); $table->head = array(get_string('element','scorm'), get_string('value','scorm')); @@ -260,7 +308,7 @@ $table->wrap = array('nowrap', 'nowrap'); $table->width = '100%'; $table->size = array('*', '*'); - + $existelements = false; if ($scorm->version == 'SCORM_1.3') { $elements = array('raw' => 'cmi.score.raw', @@ -289,8 +337,8 @@ if ($existelements) { echo '

'.get_string('general','scorm').'

'; print_table($table); - } - + } + // Print Interactions data $table = new stdClass(); $table->head = array(get_string('identifier','scorm'), @@ -301,12 +349,12 @@ $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap'); $table->width = '100%'; $table->size = array('*', '*', '*', '*', '*'); - + $existinteraction = false; - + $i = 0; $interactionid = 'cmi.interactions.'.$i.'.id'; - + while (isset($trackdata->$interactionid)) { $existinteraction = true; $printedelements[]=$interactionid; @@ -324,7 +372,7 @@ } } $table->data[] = $row; - + $i++; $interactionid = 'cmi.interactions.'.$i.'.id'; } @@ -333,7 +381,7 @@ echo '

'.get_string('interactions','scorm').'

'; print_table($table); } - + // Print Objectives data $table = new stdClass(); $table->head = array(get_string('identifier','scorm'), @@ -345,12 +393,12 @@ $table->wrap = array('nowrap', 'nowrap', 'nowrap', 'nowrap', 'nowrap'); $table->width = '100%'; $table->size = array('*', '*', '*', '*', '*'); - + $existobjective = false; - + $i = 0; $objectiveid = 'cmi.objectives.'.$i.'.id'; - + while (isset($trackdata->$objectiveid)) { $existobjective = true; $printedelements[]=$objectiveid; @@ -369,7 +417,7 @@ } } $table->data[] = $row; - + $i++; $objectiveid = 'cmi.objectives.'.$i.'.id'; } @@ -383,11 +431,11 @@ $table->wrap = array('nowrap', 'wrap'); $table->width = '100%'; $table->size = array('*', '*'); - + $existelements = false; - + foreach($trackdata as $element => $value) { - if (substr($element,0,3) == 'cmi') { + if (substr($element,0,3) == 'cmi') { if (!(in_array ($element, $printedelements))) { $existelements = true; $row = array(); @@ -400,7 +448,7 @@ if ($existelements) { echo '

'.get_string('othertracks','scorm').'

'; 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