SCORM MDL-28111 tidy up formatting of code
This commit is contained in:
+176
-181
@@ -67,7 +67,7 @@ class scorm_package_file_info extends file_info_stored {
|
||||
*
|
||||
* @return array an array of popup options as the key and their defaults as the value
|
||||
*/
|
||||
function scorm_get_popup_options_array(){
|
||||
function scorm_get_popup_options_array() {
|
||||
global $CFG;
|
||||
$cfg_scorm = get_config('scorm');
|
||||
|
||||
@@ -85,7 +85,7 @@ function scorm_get_popup_options_array(){
|
||||
*
|
||||
* @return array an array of what grade options
|
||||
*/
|
||||
function scorm_get_grade_method_array(){
|
||||
function scorm_get_grade_method_array() {
|
||||
return array (GRADESCOES => get_string('gradescoes', 'scorm'),
|
||||
GRADEHIGHEST => get_string('gradehighest', 'scorm'),
|
||||
GRADEAVERAGE => get_string('gradeaverage', 'scorm'),
|
||||
@@ -97,7 +97,7 @@ function scorm_get_grade_method_array(){
|
||||
*
|
||||
* @return array an array of what grade options
|
||||
*/
|
||||
function scorm_get_what_grade_array(){
|
||||
function scorm_get_what_grade_array() {
|
||||
return array (HIGHESTATTEMPT => get_string('highestattempt', 'scorm'),
|
||||
AVERAGEATTEMPT => get_string('averageattempt', 'scorm'),
|
||||
FIRSTATTEMPT => get_string('firstattempt', 'scorm'),
|
||||
@@ -109,9 +109,9 @@ function scorm_get_what_grade_array(){
|
||||
*
|
||||
* @return array an array of skip view options
|
||||
*/
|
||||
function scorm_get_skip_view_array(){
|
||||
return array(0 => get_string('never'),
|
||||
1 => get_string('firstaccess','scorm'),
|
||||
function scorm_get_skip_view_array() {
|
||||
return array(0 => get_string('never'),
|
||||
1 => get_string('firstaccess', 'scorm'),
|
||||
2 => get_string('always'));
|
||||
}
|
||||
|
||||
@@ -120,10 +120,10 @@ function scorm_get_skip_view_array(){
|
||||
*
|
||||
* @return array an array of hide table of contents options
|
||||
*/
|
||||
function scorm_get_hidetoc_array(){
|
||||
return array(0 =>get_string('sided','scorm'),
|
||||
1 => get_string('hidden','scorm'),
|
||||
2 => get_string('popupmenu','scorm'));
|
||||
function scorm_get_hidetoc_array() {
|
||||
return array(0 =>get_string('sided', 'scorm'),
|
||||
1 => get_string('hidden', 'scorm'),
|
||||
2 => get_string('popupmenu', 'scorm'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,11 +131,11 @@ function scorm_get_hidetoc_array(){
|
||||
*
|
||||
* @return array an array of update frequency options
|
||||
*/
|
||||
function scorm_get_updatefreq_array(){
|
||||
function scorm_get_updatefreq_array() {
|
||||
return array(0 => get_string('never'),
|
||||
1 => get_string('onchanges','scorm'),
|
||||
2 => get_string('everyday','scorm'),
|
||||
3 => get_string('everytime','scorm'));
|
||||
1 => get_string('onchanges', 'scorm'),
|
||||
2 => get_string('everyday', 'scorm'),
|
||||
3 => get_string('everytime', 'scorm'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +143,7 @@ function scorm_get_updatefreq_array(){
|
||||
*
|
||||
* @return array an array of popup display options
|
||||
*/
|
||||
function scorm_get_popup_display_array(){
|
||||
function scorm_get_popup_display_array() {
|
||||
return array(0 => get_string('currentwindow', 'scorm'),
|
||||
1 => get_string('popup', 'scorm'));
|
||||
}
|
||||
@@ -153,12 +153,12 @@ function scorm_get_popup_display_array(){
|
||||
*
|
||||
* @return array an array of attempt options
|
||||
*/
|
||||
function scorm_get_attempts_array(){
|
||||
$attempts = array(0 => get_string('nolimit','scorm'),
|
||||
1 => get_string('attempt1','scorm'));
|
||||
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);
|
||||
$attempts[$i] = get_string('attemptsx', 'scorm', $i);
|
||||
}
|
||||
|
||||
return $attempts;
|
||||
@@ -231,7 +231,6 @@ function scorm_parse($scorm, $full) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ($manifest = $fs->get_file($context->id, 'mod_scorm', 'content', 0, '/', 'imsmanifest.xml')) {
|
||||
require_once("$CFG->dirroot/mod/scorm/datamodels/scormlib.php");
|
||||
// SCORM
|
||||
@@ -262,7 +261,7 @@ function scorm_parse($scorm, $full) {
|
||||
return;
|
||||
}
|
||||
require_once("$CFG->dirroot/mod/scorm/datamodels/scormlib.php");
|
||||
if (!scorm_parse_scorm($scorm, $CFG->repository.substr($scorm->reference,1).'/imsmanifest.xml')) {
|
||||
if (!scorm_parse_scorm($scorm, $CFG->repository.substr($scorm->reference, 1).'/imsmanifest.xml')) {
|
||||
$scorm->version = 'ERROR';
|
||||
}
|
||||
$newhash = sha1($scorm->reference);
|
||||
@@ -300,34 +299,33 @@ function scorm_repeater($what, $times) {
|
||||
return null;
|
||||
}
|
||||
$return = '';
|
||||
for ($i=0; $i<$times;$i++) {
|
||||
for ($i=0; $i<$times; $i++) {
|
||||
$return .= $what;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
function scorm_external_link($link) {
|
||||
// check if a link is external
|
||||
// check if a link is external
|
||||
$result = false;
|
||||
$link = strtolower($link);
|
||||
if (substr($link,0,7) == 'http://') {
|
||||
if (substr($link, 0, 7) == 'http://') {
|
||||
$result = true;
|
||||
} else if (substr($link,0,8) == 'https://') {
|
||||
} else if (substr($link, 0, 8) == 'https://') {
|
||||
$result = true;
|
||||
} else if (substr($link,0,4) == 'www.') {
|
||||
} else if (substr($link, 0, 4) == 'www.') {
|
||||
$result = true;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object containing all datas relative to the given sco ID
|
||||
*
|
||||
* @param integer $id The sco ID
|
||||
* @return mixed (false if sco id does not exists)
|
||||
*/
|
||||
|
||||
function scorm_get_sco($id,$what=SCO_ALL) {
|
||||
* Returns an object containing all datas relative to the given sco ID
|
||||
*
|
||||
* @param integer $id The sco ID
|
||||
* @return mixed (false if sco id does not exists)
|
||||
*/
|
||||
function scorm_get_sco($id, $what=SCO_ALL) {
|
||||
global $DB;
|
||||
|
||||
if ($sco = $DB->get_record('scorm_scoes', array('id'=>$id))) {
|
||||
@@ -346,14 +344,13 @@ function scorm_get_sco($id,$what=SCO_ALL) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an object (array) containing all the scoes data related to the given sco ID
|
||||
*
|
||||
* @param integer $id The sco ID
|
||||
* @param integer $organisation an organisation ID - defaults to false if not required
|
||||
* @return mixed (false if there are no scoes or an array)
|
||||
*/
|
||||
|
||||
function scorm_get_scoes($id,$organisation=false) {
|
||||
* Returns an object (array) containing all the scoes data related to the given sco ID
|
||||
*
|
||||
* @param integer $id The sco ID
|
||||
* @param integer $organisation an organisation ID - defaults to false if not required
|
||||
* @return mixed (false if there are no scoes or an array)
|
||||
*/
|
||||
function scorm_get_scoes($id, $organisation=false) {
|
||||
global $DB;
|
||||
|
||||
$organizationsql = '';
|
||||
@@ -365,7 +362,7 @@ function scorm_get_scoes($id,$organisation=false) {
|
||||
// drop keys so that it is a simple array as expected
|
||||
$scoes = array_values($scoes);
|
||||
foreach ($scoes as $sco) {
|
||||
if ($scodatas = $DB->get_records('scorm_scoes_data',array('scoid'=>$sco->id))) {
|
||||
if ($scodatas = $DB->get_records('scorm_scoes_data', array('scoid'=>$sco->id))) {
|
||||
foreach ($scodatas as $scodata) {
|
||||
$sco->{$scodata->name} = $scodata->value;
|
||||
}
|
||||
@@ -377,7 +374,7 @@ function scorm_get_scoes($id,$organisation=false) {
|
||||
}
|
||||
}
|
||||
|
||||
function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value,$forcecompleted=false) {
|
||||
function scorm_insert_track($userid, $scormid, $scoid, $attempt, $element, $value, $forcecompleted=false) {
|
||||
global $DB, $CFG;
|
||||
|
||||
$id = null;
|
||||
@@ -385,25 +382,25 @@ function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value,$fo
|
||||
if ($forcecompleted) {
|
||||
//TODO - this could be broadened to encompass SCORM 2004 in future
|
||||
if (($element == 'cmi.core.lesson_status') && ($value == 'incomplete')) {
|
||||
if ($track = $DB->get_record_select('scorm_scoes_track','userid=? AND scormid=? AND scoid=? AND attempt=? AND element=\'cmi.core.score.raw\'', array($userid, $scormid, $scoid, $attempt))) {
|
||||
if ($track = $DB->get_record_select('scorm_scoes_track', 'userid=? AND scormid=? AND scoid=? AND attempt=? AND element=\'cmi.core.score.raw\'', array($userid, $scormid, $scoid, $attempt))) {
|
||||
$value = 'completed';
|
||||
}
|
||||
}
|
||||
if ($element == 'cmi.core.score.raw') {
|
||||
if ($tracktest = $DB->get_record_select('scorm_scoes_track','userid=? AND scormid=? AND scoid=? AND attempt=? AND element=\'cmi.core.lesson_status\'', array($userid, $scormid, $scoid, $attempt))) {
|
||||
if ($tracktest = $DB->get_record_select('scorm_scoes_track', 'userid=? AND scormid=? AND scoid=? AND attempt=? AND element=\'cmi.core.lesson_status\'', array($userid, $scormid, $scoid, $attempt))) {
|
||||
if ($tracktest->value == "incomplete") {
|
||||
$tracktest->value = "completed";
|
||||
$DB->update_record('scorm_scoes_track',$tracktest);
|
||||
$DB->update_record('scorm_scoes_track', $tracktest);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($track = $DB->get_record('scorm_scoes_track',array('userid'=>$userid, 'scormid'=>$scormid, 'scoid'=>$scoid, 'attempt'=>$attempt, 'element'=>$element))) {
|
||||
if ($track = $DB->get_record('scorm_scoes_track', array('userid'=>$userid, 'scormid'=>$scormid, 'scoid'=>$scoid, 'attempt'=>$attempt, 'element'=>$element))) {
|
||||
if ($element != 'x.start.time' ) { //don't update x.start.time - keep the original value.
|
||||
$track->value = $value;
|
||||
$track->timemodified = time();
|
||||
$DB->update_record('scorm_scoes_track',$track);
|
||||
$DB->update_record('scorm_scoes_track', $track);
|
||||
$id = $track->id;
|
||||
}
|
||||
} else {
|
||||
@@ -414,7 +411,7 @@ function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value,$fo
|
||||
$track->element = $element;
|
||||
$track->value = $value;
|
||||
$track->timemodified = time();
|
||||
$id = $DB->insert_record('scorm_scoes_track',$track);
|
||||
$id = $DB->insert_record('scorm_scoes_track', $track);
|
||||
}
|
||||
|
||||
if (strstr($element, '.score.raw') ||
|
||||
@@ -427,18 +424,18 @@ function scorm_insert_track($userid,$scormid,$scoid,$attempt,$element,$value,$fo
|
||||
return $id;
|
||||
}
|
||||
|
||||
function scorm_get_tracks($scoid,$userid,$attempt='') {
|
||||
/// Gets all tracks of specified sco and user
|
||||
function scorm_get_tracks($scoid, $userid, $attempt='') {
|
||||
/// Gets all tracks of specified sco and user
|
||||
global $CFG, $DB;
|
||||
|
||||
if (empty($attempt)) {
|
||||
if ($scormid = $DB->get_field('scorm_scoes','scorm', array('id'=>$scoid))) {
|
||||
$attempt = scorm_get_last_attempt($scormid,$userid);
|
||||
if ($scormid = $DB->get_field('scorm_scoes', 'scorm', array('id'=>$scoid))) {
|
||||
$attempt = scorm_get_last_attempt($scormid, $userid);
|
||||
} else {
|
||||
$attempt = 1;
|
||||
}
|
||||
}
|
||||
if ($tracks = $DB->get_records('scorm_scoes_track', array('userid'=>$userid, 'scoid'=>$scoid, 'attempt'=>$attempt),'element ASC')) {
|
||||
if ($tracks = $DB->get_records('scorm_scoes_track', array('userid'=>$userid, 'scoid'=>$scoid, 'attempt'=>$attempt), 'element ASC')) {
|
||||
$usertrack = new stdClass();
|
||||
$usertrack->userid = $userid;
|
||||
$usertrack->scoid = $scoid;
|
||||
@@ -501,21 +498,19 @@ function scorm_get_sco_runtime($scormid, $scoid, $userid, $attempt=1) {
|
||||
|
||||
$timedata = new stdClass();
|
||||
$sql = !empty($scoid) ? "userid=$userid AND scormid=$scormid AND scoid=$scoid AND attempt=$attempt" : "userid=$userid AND scormid=$scormid AND attempt=$attempt";
|
||||
$tracks = $DB->get_records_select('scorm_scoes_track',"$sql ORDER BY timemodified ASC");
|
||||
$tracks = $DB->get_records_select('scorm_scoes_track', "$sql ORDER BY timemodified ASC");
|
||||
if ($tracks) {
|
||||
$tracks = array_values($tracks);
|
||||
}
|
||||
|
||||
if ($tracks) {
|
||||
$timedata->start = $tracks[0]->timemodified;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$timedata->start = false;
|
||||
}
|
||||
if ($tracks && $track = array_pop($tracks)) {
|
||||
$timedata->finish = $track->timemodified;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$timedata->finish = $timedata->start;
|
||||
}
|
||||
return $timedata;
|
||||
@@ -524,15 +519,15 @@ function scorm_get_sco_runtime($scormid, $scoid, $userid, $attempt=1) {
|
||||
|
||||
function scorm_get_user_data($userid) {
|
||||
global $DB;
|
||||
/// Gets user info required to display the table of scorm results
|
||||
/// for report.php
|
||||
/// Gets user info required to display the table of scorm results
|
||||
/// for report.php
|
||||
|
||||
return $DB->get_record('user', array('id'=>$userid), user_picture::fields());
|
||||
}
|
||||
|
||||
function scorm_grade_user_attempt($scorm, $userid, $attempt=1) {
|
||||
global $DB;
|
||||
$attemptscore = NULL;
|
||||
$attemptscore = null;
|
||||
$attemptscore->scoes = 0;
|
||||
$attemptscore->values = 0;
|
||||
$attemptscore->max = 0;
|
||||
@@ -540,11 +535,11 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1) {
|
||||
$attemptscore->lastmodify = 0;
|
||||
|
||||
if (!$scoes = $DB->get_records('scorm_scoes', array('scorm'=>$scorm->id))) {
|
||||
return NULL;
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach ($scoes as $sco) {
|
||||
if ($userdata=scorm_get_tracks($sco->id, $userid,$attempt)) {
|
||||
if ($userdata=scorm_get_tracks($sco->id, $userid, $attempt)) {
|
||||
if (($userdata->status == 'completed') || ($userdata->status == 'passed')) {
|
||||
$attemptscore->scoes++;
|
||||
}
|
||||
@@ -588,7 +583,7 @@ function scorm_grade_user($scorm, $userid) {
|
||||
|
||||
// ensure we dont grade user beyond $scorm->maxattempt settings
|
||||
$lastattempt = scorm_get_last_attempt($scorm->id, $userid);
|
||||
if($scorm->maxattempt != 0 && $lastattempt >= $scorm->maxattempt){
|
||||
if ($scorm->maxattempt != 0 && $lastattempt >= $scorm->maxattempt) {
|
||||
$lastattempt = $scorm->maxattempt;
|
||||
}
|
||||
|
||||
@@ -627,7 +622,7 @@ function scorm_grade_user($scorm, $userid) {
|
||||
}
|
||||
}
|
||||
|
||||
function scorm_count_launchable($scormid,$organization='') {
|
||||
function scorm_count_launchable($scormid, $organization='') {
|
||||
global $DB;
|
||||
|
||||
$sqlorganization = '';
|
||||
@@ -636,13 +631,13 @@ function scorm_count_launchable($scormid,$organization='') {
|
||||
$sqlorganization = " AND organization=?";
|
||||
$params[] = $organization;
|
||||
}
|
||||
return $DB->count_records_select('scorm_scoes',"scorm = ? $sqlorganization AND ".$DB->sql_isnotempty('scorm_scoes', 'launch', false, true), $params);
|
||||
return $DB->count_records_select('scorm_scoes', "scorm = ? $sqlorganization AND ".$DB->sql_isnotempty('scorm_scoes', 'launch', false, true), $params);
|
||||
}
|
||||
|
||||
function scorm_get_last_attempt($scormid, $userid) {
|
||||
global $DB;
|
||||
|
||||
/// Find the last attempt number for the given user id and scorm id
|
||||
/// Find the last attempt number for the given user id and scorm id
|
||||
if ($lastattempt = $DB->get_record('scorm_scoes_track', array('userid'=>$userid, 'scormid'=>$scormid), 'max(attempt) as a')) {
|
||||
if (empty($lastattempt->a)) {
|
||||
return '1';
|
||||
@@ -657,7 +652,7 @@ function scorm_get_last_attempt($scormid, $userid) {
|
||||
function scorm_get_last_completed_attempt($scormid, $userid) {
|
||||
global $DB;
|
||||
|
||||
/// Find the last attempt number for the given user id and scorm id
|
||||
/// Find the last attempt number for the given user id and scorm id
|
||||
if ($lastattempt = $DB->get_record_select('scorm_scoes_track', "userid = ? AND scormid = ? AND (value='completed' OR value='passed')", array($userid, $scormid), 'max(attempt) as a')) {
|
||||
if (empty($lastattempt->a)) {
|
||||
return '1';
|
||||
@@ -669,11 +664,11 @@ function scorm_get_last_completed_attempt($scormid, $userid) {
|
||||
}
|
||||
}
|
||||
|
||||
function scorm_course_format_display($user,$course) {
|
||||
function scorm_course_format_display($user, $course) {
|
||||
global $CFG, $DB, $PAGE, $OUTPUT;
|
||||
|
||||
$strupdate = get_string('update');
|
||||
$context = get_context_instance(CONTEXT_COURSE,$course->id);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
|
||||
echo '<div class="mod-scorm">';
|
||||
if ($scorms = get_all_instances_in_course('scorm', $course)) {
|
||||
@@ -698,14 +693,14 @@ function scorm_course_format_display($user,$course) {
|
||||
if ($trackedusers->c > 0) {
|
||||
$headertext .= '<td class="reportlink">'.
|
||||
'<a href="'.$CFG->wwwroot.'/mod/scorm/report.php?id='.$cm->id.'">'.
|
||||
get_string('viewallreports','scorm',$trackedusers->c).'</a>';
|
||||
get_string('viewallreports', 'scorm', $trackedusers->c).'</a>';
|
||||
} else {
|
||||
$headertext .= '<td class="reportlink">'.get_string('noreports','scorm');
|
||||
$headertext .= '<td class="reportlink">'.get_string('noreports', 'scorm');
|
||||
}
|
||||
$colspan = ' colspan="2"';
|
||||
}
|
||||
$headertext .= '</td></tr><tr><td'.$colspan.'>'.get_string('summary').':<br />'.format_module_intro('scorm', $scorm, $scorm->coursemodule).'</td></tr></table>';
|
||||
echo $OUTPUT->box($headertext,'generalbox boxwidthwide');
|
||||
echo $OUTPUT->box($headertext, 'generalbox boxwidthwide');
|
||||
scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm);
|
||||
} else {
|
||||
if (has_capability('moodle/course:update', $context)) {
|
||||
@@ -728,11 +723,11 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
|
||||
|
||||
$organization = optional_param('organization', '', PARAM_INT);
|
||||
|
||||
if($scorm->displaycoursestructure == 1) {
|
||||
if ($scorm->displaycoursestructure == 1) {
|
||||
echo $OUTPUT->box_start('generalbox boxaligncenter toc');
|
||||
?>
|
||||
<div class="structurehead"><?php print_string('contents','scorm') ?></div>
|
||||
<?php
|
||||
?>
|
||||
<div class="structurehead"><?php print_string('contents', 'scorm') ?></div>
|
||||
<?php
|
||||
}
|
||||
if (empty($organization)) {
|
||||
$organization = $scorm->launch;
|
||||
@@ -740,10 +735,10 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
|
||||
if ($orgs = $DB->get_records_select_menu('scorm_scoes', 'scorm = ? AND '.
|
||||
$DB->sql_isempty('scorm_scoes', 'launch', false, true).' AND '.
|
||||
$DB->sql_isempty('scorm_scoes', 'organization', false, false),
|
||||
array($scorm->id),'id','id,title')) {
|
||||
array($scorm->id), 'id', 'id,title')) {
|
||||
if (count($orgs) > 1) {
|
||||
$select = new single_select(new moodle_url($action), 'organization', $orgs, $organization, null);
|
||||
$select->label = get_string('organizations','scorm');
|
||||
$select->label = get_string('organizations', 'scorm');
|
||||
$select->class = 'scorm-center';
|
||||
echo $OUTPUT->render($select);
|
||||
}
|
||||
@@ -763,11 +758,11 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
|
||||
}
|
||||
require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
|
||||
|
||||
$result = scorm_get_toc($user,$scorm,$cm->id,TOCFULLURL,$orgidentifier);
|
||||
$result = scorm_get_toc($user, $scorm, $cm->id, TOCFULLURL, $orgidentifier);
|
||||
$incomplete = $result->incomplete;
|
||||
|
||||
// do we want the TOC to be displayed?
|
||||
if($scorm->displaycoursestructure == 1) {
|
||||
if ($scorm->displaycoursestructure == 1) {
|
||||
echo $result->toc;
|
||||
echo $OUTPUT->box_end();
|
||||
}
|
||||
@@ -777,41 +772,41 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
|
||||
|
||||
// do not give the player launch FORM if the SCORM object is locked after the final attempt
|
||||
if ($scorm->lastattemptlock == 0 || $result->attemptleft > 0) {
|
||||
?>
|
||||
?>
|
||||
<div class="scorm-center">
|
||||
<form id="theform" method="post" action="<?php echo $CFG->wwwroot ?>/mod/scorm/player.php">
|
||||
<?php
|
||||
if ($scorm->hidebrowse == 0) {
|
||||
print_string('mode','scorm');
|
||||
echo ': <input type="radio" id="b" name="mode" value="browse" /><label for="b">'.get_string('browse','scorm').'</label>'."\n";
|
||||
echo '<input type="radio" id="n" name="mode" value="normal" checked="checked" /><label for="n">'.get_string('normal','scorm')."</label>\n";
|
||||
} else {
|
||||
echo '<input type="hidden" name="mode" value="normal" />'."\n";
|
||||
}
|
||||
if ($scorm->forcenewattempt == 1) {
|
||||
if ($incomplete === false) {
|
||||
echo '<input type="hidden" name="newattempt" value="on" />'."\n";
|
||||
}
|
||||
} elseif (!empty($attemptcount) && ($incomplete === false) && (($result->attemptleft > 0)||($scorm->maxattempt == 0))) {
|
||||
?>
|
||||
<?php
|
||||
if ($scorm->hidebrowse == 0) {
|
||||
print_string('mode', 'scorm');
|
||||
echo ': <input type="radio" id="b" name="mode" value="browse" /><label for="b">'.get_string('browse', 'scorm').'</label>'."\n";
|
||||
echo '<input type="radio" id="n" name="mode" value="normal" checked="checked" /><label for="n">'.get_string('normal', 'scorm')."</label>\n";
|
||||
} else {
|
||||
echo '<input type="hidden" name="mode" value="normal" />'."\n";
|
||||
}
|
||||
if ($scorm->forcenewattempt == 1) {
|
||||
if ($incomplete === false) {
|
||||
echo '<input type="hidden" name="newattempt" value="on" />'."\n";
|
||||
}
|
||||
} else if (!empty($attemptcount) && ($incomplete === false) && (($result->attemptleft > 0)||($scorm->maxattempt == 0))) {
|
||||
?>
|
||||
<br />
|
||||
<input type="checkbox" id="a" name="newattempt" />
|
||||
<label for="a"><?php print_string('newattempt','scorm') ?></label>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<label for="a"><?php print_string('newattempt', 'scorm') ?></label>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<br />
|
||||
<input type="hidden" name="scoid"/>
|
||||
<input type="hidden" name="cm" value="<?php echo $cm->id ?>"/>
|
||||
<input type="hidden" name="currentorg" value="<?php echo $orgidentifier ?>" />
|
||||
<input type="submit" value="<?php print_string('enter','scorm') ?>" />
|
||||
<input type="submit" value="<?php print_string('enter', 'scorm') ?>" />
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
function scorm_simple_play($scorm,$user, $context) {
|
||||
function scorm_simple_play($scorm, $user, $context) {
|
||||
global $DB;
|
||||
|
||||
$result = false;
|
||||
@@ -828,7 +823,7 @@ function scorm_simple_play($scorm,$user, $context) {
|
||||
if ($scoes) {
|
||||
if ($scorm->skipview >= 1) {
|
||||
$sco = current($scoes);
|
||||
if (scorm_get_tracks($sco->id,$user->id) === false) {
|
||||
if (scorm_get_tracks($sco->id, $user->id) === false) {
|
||||
header('Location: player.php?a='.$scorm->id.'&scoid='.$sco->id);
|
||||
$result = true;
|
||||
} else if ($scorm->skipview == 2) {
|
||||
@@ -863,14 +858,14 @@ function scorm_get_count_users($scormid, $groupingid=null) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Build up the JavaScript representation of an array element
|
||||
*
|
||||
* @param string $sversion SCORM API version
|
||||
* @param array $userdata User track data
|
||||
* @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
|
||||
*/
|
||||
* Build up the JavaScript representation of an array element
|
||||
*
|
||||
* @param string $sversion SCORM API version
|
||||
* @param array $userdata User track data
|
||||
* @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 = '';
|
||||
@@ -880,12 +875,12 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
|
||||
$count_sub = 0;
|
||||
$scormseperator = '_';
|
||||
if ($sversion == 'scorm_13') { //scorm 1.3 elements use a . instead of an _
|
||||
$scormseperator = '.';
|
||||
$scormseperator = '.';
|
||||
}
|
||||
// filter out the ones we want
|
||||
$element_list = array();
|
||||
foreach($userdata as $element => $value){
|
||||
if (substr($element,0,strlen($element_name)) == $element_name) {
|
||||
foreach ($userdata as $element => $value) {
|
||||
if (substr($element, 0, strlen($element_name)) == $element_name) {
|
||||
$element_list[$element] = $value;
|
||||
}
|
||||
}
|
||||
@@ -894,7 +889,7 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
|
||||
uksort($element_list, "scorm_element_cmp");
|
||||
|
||||
// generate JavaScript
|
||||
foreach($element_list as $element => $value){
|
||||
foreach ($element_list as $element => $value) {
|
||||
if ($sversion == 'scorm_13') {
|
||||
$element = preg_replace('/\.(\d+)\./', ".N\$1.", $element);
|
||||
preg_match('/\.(N\d+)\./', $element, $matches);
|
||||
@@ -911,8 +906,8 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
|
||||
$current_subelement = '';
|
||||
$current_sub = '';
|
||||
$count_sub = 0;
|
||||
$end = strpos($element,$matches[1])+strlen($matches[1]);
|
||||
$subelement = substr($element,0,$end);
|
||||
$end = strpos($element, $matches[1])+strlen($matches[1]);
|
||||
$subelement = substr($element, 0, $end);
|
||||
echo ' '.$subelement." = new Object();\n";
|
||||
// now add the children
|
||||
foreach ($children as $child) {
|
||||
@@ -938,8 +933,8 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
|
||||
$current_subelement = $matches[1];
|
||||
$current_sub = '';
|
||||
$count_sub = 0;
|
||||
$end = strpos($element,$matches[1])+strlen($matches[1]);
|
||||
$subelement = substr($element,0,$end);
|
||||
$end = strpos($element, $matches[1])+strlen($matches[1]);
|
||||
$subelement = substr($element, 0, $end);
|
||||
echo ' '.$subelement." = new Object();\n";
|
||||
}
|
||||
|
||||
@@ -947,8 +942,8 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
|
||||
if (count($matches) > 0 && $current_sub != $matches[2]) {
|
||||
$current_sub = $matches[2];
|
||||
$count_sub++;
|
||||
$end = strrpos($element,$matches[2])+strlen($matches[2]);
|
||||
$subelement = substr($element,0,$end);
|
||||
$end = strrpos($element, $matches[2])+strlen($matches[2]);
|
||||
$subelement = substr($element, 0, $end);
|
||||
echo ' '.$subelement." = new Object();\n";
|
||||
}
|
||||
|
||||
@@ -963,12 +958,12 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
|
||||
}
|
||||
|
||||
/**
|
||||
* Build up the JavaScript representation of an array element
|
||||
*
|
||||
* @param string $a left array element
|
||||
* @param string $b right array element
|
||||
* @return comparator - 0,1,-1
|
||||
*/
|
||||
* Build up the JavaScript representation of an array element
|
||||
*
|
||||
* @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]);
|
||||
@@ -976,7 +971,7 @@ function scorm_element_cmp($a, $b) {
|
||||
$right = intval($matches[1]);
|
||||
if ($left < $right) {
|
||||
return -1; // smaller
|
||||
} elseif ($left > $right) {
|
||||
} else if ($left > $right) {
|
||||
return 1; // bigger
|
||||
} else {
|
||||
// look for a second level qualifier eg cmi.interactions_0.correct_responses_0.pattern
|
||||
@@ -988,12 +983,12 @@ function scorm_element_cmp($a, $b) {
|
||||
$right = intval($matches[3]);
|
||||
if ($leftterm < $rightterm) {
|
||||
return -1; // smaller
|
||||
} elseif ($leftterm > $rightterm) {
|
||||
} else if ($leftterm > $rightterm) {
|
||||
return 1; // bigger
|
||||
} else {
|
||||
if ($left < $right) {
|
||||
return -1; // smaller
|
||||
} elseif ($left > $right) {
|
||||
} else if ($left > $right) {
|
||||
return 1; // bigger
|
||||
}
|
||||
}
|
||||
@@ -1005,17 +1000,17 @@ function scorm_element_cmp($a, $b) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the user attempt status string
|
||||
*
|
||||
* @param object $user Current context user
|
||||
* @param object $scorm a moodle scrom object - mdl_scorm
|
||||
* @return string - Attempt status string
|
||||
*/
|
||||
* Generate the user attempt status string
|
||||
*
|
||||
* @param object $user Current context user
|
||||
* @param object $scorm a moodle scrom object - mdl_scorm
|
||||
* @return string - Attempt status string
|
||||
*/
|
||||
function scorm_get_attempt_status($user, $scorm) {
|
||||
global $DB;
|
||||
|
||||
$attempts = scorm_get_attempt_count($user->id, $scorm, true);
|
||||
if(empty($attempts)) {
|
||||
if (empty($attempts)) {
|
||||
$attemptcount = 0;
|
||||
} else {
|
||||
$attemptcount = count($attempts);
|
||||
@@ -1044,8 +1039,8 @@ function scorm_get_attempt_status($user, $scorm) {
|
||||
$grademethod = get_string('gradescoes', 'scorm');
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch ($scorm->whatgrade) {
|
||||
} else {
|
||||
switch ($scorm->whatgrade) {
|
||||
case HIGHESTATTEMPT:
|
||||
$grademethod = get_string('highestattempt', 'scorm');
|
||||
break;
|
||||
@@ -1059,11 +1054,11 @@ function scorm_get_attempt_status($user, $scorm) {
|
||||
$grademethod = get_string('lastattempt', 'scorm');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($attempts)) {
|
||||
if (!empty($attempts)) {
|
||||
$i = 1;
|
||||
foreach($attempts as $attempt) {
|
||||
foreach ($attempts as $attempt) {
|
||||
$gradereported = scorm_grade_user_attempt($scorm, $user->id, $attempt->attemptnumber);
|
||||
if ($scorm->grademethod !== GRADESCOES && !empty($scorm->maxgrade)) {
|
||||
$gradereported = $gradereported/$scorm->maxgrade;
|
||||
@@ -1079,26 +1074,26 @@ function scorm_get_attempt_status($user, $scorm) {
|
||||
$calculatedgrade = number_format($calculatedgrade*100, 0) .'%';
|
||||
}
|
||||
$result .= get_string('grademethod', 'scorm'). ': ' . $grademethod;
|
||||
if(empty($attempts)) {
|
||||
$result .= '<br />' . get_string('gradereported','scorm') . ': ' . get_string('none') . '<br />';
|
||||
if (empty($attempts)) {
|
||||
$result .= '<br />' . get_string('gradereported', 'scorm') . ': ' . get_string('none') . '<br />';
|
||||
} else {
|
||||
$result .= '<br />' . get_string('gradereported','scorm') . ': ' . $calculatedgrade . '<br />';
|
||||
$result .= '<br />' . get_string('gradereported', 'scorm') . ': ' . $calculatedgrade . '<br />';
|
||||
}
|
||||
$result .= '</p>';
|
||||
if ($attemptcount >= $scorm->maxattempt and $scorm->maxattempt > 0) {
|
||||
$result .= '<p><font color="#cc0000">'.get_string('exceededmaxattempts','scorm').'</font></p>';
|
||||
$result .= '<p><font color="#cc0000">'.get_string('exceededmaxattempts', 'scorm').'</font></p>';
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get SCORM attempt count
|
||||
*
|
||||
* @param object $user Current context user
|
||||
* @param object $scorm a moodle scrom object - mdl_scorm
|
||||
* @param bool $attempts return the list of attempts
|
||||
* @return int - no. of attempts so far
|
||||
*/
|
||||
* Get SCORM attempt count
|
||||
*
|
||||
* @param object $user Current context user
|
||||
* @param object $scorm a moodle scrom object - mdl_scorm
|
||||
* @param bool $attempts return the list of attempts
|
||||
* @return int - no. of attempts so far
|
||||
*/
|
||||
function scorm_get_attempt_count($userid, $scorm, $attempts_only=false) {
|
||||
global $DB;
|
||||
$attemptcount = 0;
|
||||
@@ -1109,22 +1104,22 @@ function scorm_get_attempt_count($userid, $scorm, $attempts_only=false) {
|
||||
if ($scorm->version == 'scorm1_3') {
|
||||
$element = 'cmi.score.raw';
|
||||
}
|
||||
$attempts = $DB->get_records_select('scorm_scoes_track',"element=? AND userid=? AND scormid=?", array($element, $userid, $scorm->id),'attempt','DISTINCT attempt AS attemptnumber');
|
||||
$attempts = $DB->get_records_select('scorm_scoes_track', "element=? AND userid=? AND scormid=?", array($element, $userid, $scorm->id), 'attempt', 'DISTINCT attempt AS attemptnumber');
|
||||
if ($attempts_only) {
|
||||
return $attempts;
|
||||
}
|
||||
if(!empty($attempts)) {
|
||||
if (!empty($attempts)) {
|
||||
$attemptcount = count($attempts);
|
||||
}
|
||||
return $attemptcount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Figure out with this is a debug situation
|
||||
*
|
||||
* @param object $scorm a moodle scrom object - mdl_scorm
|
||||
* @return boolean - debugging true/false
|
||||
*/
|
||||
* Figure out with this is a debug situation
|
||||
*
|
||||
* @param object $scorm a moodle scrom object - mdl_scorm
|
||||
* @return boolean - debugging true/false
|
||||
*/
|
||||
function scorm_debugging($scorm) {
|
||||
global $CFG, $USER;
|
||||
$cfg_scorm = get_config('scorm');
|
||||
@@ -1144,25 +1139,25 @@ function scorm_debugging($scorm) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Scorm tracks for selected users
|
||||
*
|
||||
* @param array $attemptids list of attempts that need to be deleted
|
||||
* @param int $scorm instance
|
||||
*
|
||||
* return bool true deleted all responses, false failed deleting an attempt - stopped here
|
||||
*/
|
||||
* Delete Scorm tracks for selected users
|
||||
*
|
||||
* @param array $attemptids list of attempts that need to be deleted
|
||||
* @param int $scorm instance
|
||||
*
|
||||
* return bool true deleted all responses, false failed deleting an attempt - stopped here
|
||||
*/
|
||||
function scorm_delete_responses($attemptids, $scorm) {
|
||||
if(!is_array($attemptids) || empty($attemptids)) {
|
||||
if (!is_array($attemptids) || empty($attemptids)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach($attemptids as $num => $attemptid) {
|
||||
if(empty($attemptid)) {
|
||||
foreach ($attemptids as $num => $attemptid) {
|
||||
if (empty($attemptid)) {
|
||||
unset($attemptids[$num]);
|
||||
}
|
||||
}
|
||||
|
||||
foreach($attemptids as $attempt) {
|
||||
foreach ($attemptids as $attempt) {
|
||||
$keys = explode(':', $attempt);
|
||||
if (count($keys) == 2) {
|
||||
$userid = clean_param($keys[0], PARAM_INT);
|
||||
@@ -1178,14 +1173,14 @@ function scorm_delete_responses($attemptids, $scorm) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
* 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, $scorm, $attemptid) {
|
||||
global $DB;
|
||||
|
||||
|
||||
+55
-58
@@ -18,7 +18,7 @@ if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
|
||||
require_once ($CFG->dirroot.'/course/moodleform_mod.php');
|
||||
require_once($CFG->dirroot.'/course/moodleform_mod.php');
|
||||
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
|
||||
|
||||
class mod_scorm_mod_form extends moodleform_mod {
|
||||
@@ -30,16 +30,16 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
$mform = $this->_form;
|
||||
|
||||
if (!$CFG->slasharguments) {
|
||||
$mform->addElement('static', '', '',$OUTPUT->notification(get_string('slashargs', 'scorm'), 'notifyproblem'));
|
||||
$mform->addElement('static', '', '', $OUTPUT->notification(get_string('slashargs', 'scorm'), 'notifyproblem'));
|
||||
}
|
||||
$zlib = ini_get('zlib.output_compression'); //check for zlib compression - if used, throw error because of IE bug. - SEE MDL-16185
|
||||
if (isset($zlib) && $zlib) {
|
||||
$mform->addElement('static', '', '',$OUTPUT->notification(get_string('zlibwarning', 'scorm'), 'notifyproblem'));
|
||||
$mform->addElement('static', '', '', $OUTPUT->notification(get_string('zlibwarning', 'scorm'), 'notifyproblem'));
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------
|
||||
$mform->addElement('header', 'general', get_string('general', 'form'));
|
||||
|
||||
// Name
|
||||
// Name
|
||||
$mform->addElement('text', 'name', get_string('name'));
|
||||
if (!empty($CFG->formatstringstriptags)) {
|
||||
$mform->setType('name', PARAM_TEXT);
|
||||
@@ -48,10 +48,10 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
}
|
||||
$mform->addRule('name', null, 'required', null, 'client');
|
||||
|
||||
// Summary
|
||||
// Summary
|
||||
$this->add_intro_editor(true);
|
||||
|
||||
// Scorm types
|
||||
// Scorm types
|
||||
$options = array(SCORM_TYPE_LOCAL => get_string('typelocal', 'scorm'));
|
||||
|
||||
if ($cfg_scorm->allowtypeexternal) {
|
||||
@@ -66,7 +66,7 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
$options[SCORM_TYPE_IMSREPOSITORY] = get_string('typeimsrepository', 'scorm');
|
||||
}
|
||||
|
||||
// Reference
|
||||
// Reference
|
||||
if (count($options) > 1) {
|
||||
$mform->addElement('select', 'scormtype', get_string('scormtype', 'scorm'), $options);
|
||||
$mform->addHelpButton('scormtype', 'scormtype', 'scorm');
|
||||
@@ -78,75 +78,75 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
$mform->addElement('hidden', 'scormtype', SCORM_TYPE_LOCAL);
|
||||
}
|
||||
|
||||
// New local package upload
|
||||
// New local package upload
|
||||
$maxbytes = get_max_upload_file_size($CFG->maxbytes, $COURSE->maxbytes);
|
||||
$mform->setMaxFileSize($maxbytes);
|
||||
$mform->addElement('filepicker', 'packagefile', get_string('package','scorm'));
|
||||
$mform->addElement('filepicker', 'packagefile', get_string('package', 'scorm'));
|
||||
$mform->addHelpButton('packagefile', 'package', 'scorm');
|
||||
$mform->disabledIf('packagefile', 'scormtype', 'noteq', SCORM_TYPE_LOCAL);
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Time restrictions
|
||||
//-------------------------------------------------------------------------------
|
||||
// Time restrictions
|
||||
$mform->addElement('header', 'timerestricthdr', get_string('timerestrict', 'scorm'));
|
||||
|
||||
$mform->addElement('date_time_selector', 'timeopen', get_string("scormopen", "scorm"),array('optional' => true));
|
||||
$mform->addElement('date_time_selector', 'timeclose', get_string("scormclose", "scorm"),array('optional' => true));
|
||||
//-------------------------------------------------------------------------------
|
||||
// Other Settings
|
||||
$mform->addElement('date_time_selector', 'timeopen', get_string("scormopen", "scorm"), array('optional' => true));
|
||||
$mform->addElement('date_time_selector', 'timeclose', get_string("scormclose", "scorm"), array('optional' => true));
|
||||
//-------------------------------------------------------------------------------
|
||||
// Other Settings
|
||||
$mform->addElement('header', 'advanced', get_string('othersettings', 'form'));
|
||||
|
||||
// Grade Method
|
||||
// Grade Method
|
||||
$mform->addElement('select', 'grademethod', get_string('grademethod', 'scorm'), scorm_get_grade_method_array());
|
||||
$mform->addHelpButton('grademethod', 'grademethod', 'scorm');
|
||||
$mform->setDefault('grademethod', $cfg_scorm->grademethod);
|
||||
|
||||
// Maximum Grade
|
||||
// Maximum Grade
|
||||
for ($i=0; $i<=100; $i++) {
|
||||
$grades[$i] = "$i";
|
||||
$grades[$i] = "$i";
|
||||
}
|
||||
$mform->addElement('select', 'maxgrade', get_string('maximumgrade'), $grades);
|
||||
$mform->setDefault('maxgrade', $cfg_scorm->maxgrade);
|
||||
$mform->disabledIf('maxgrade', 'grademethod','eq', GRADESCOES);
|
||||
$mform->disabledIf('maxgrade', 'grademethod', 'eq', GRADESCOES);
|
||||
|
||||
// Attempts
|
||||
$mform->addElement('static', '', '' ,'<hr />');
|
||||
// Attempts
|
||||
$mform->addElement('static', '', '' , '<hr />');
|
||||
|
||||
// Max Attempts
|
||||
// Max Attempts
|
||||
$mform->addElement('select', 'maxattempt', get_string('maximumattempts', 'scorm'), scorm_get_attempts_array());
|
||||
$mform->addHelpButton('maxattempt', 'maximumattempts', 'scorm');
|
||||
$mform->setDefault('maxattempt', $cfg_scorm->maxattempts);
|
||||
|
||||
// What Grade
|
||||
// What Grade
|
||||
$mform->addElement('select', 'whatgrade', get_string('whatgrade', 'scorm'), scorm_get_what_grade_array());
|
||||
$mform->disabledIf('whatgrade', 'maxattempt','eq',1);
|
||||
$mform->disabledIf('whatgrade', 'maxattempt', 'eq', 1);
|
||||
$mform->addHelpButton('whatgrade', 'whatgrade', 'scorm');
|
||||
$mform->setDefault('whatgrade', $cfg_scorm->whatgrade);
|
||||
$mform->setAdvanced('whatgrade');
|
||||
|
||||
// Display attempt status
|
||||
// Display attempt status
|
||||
$mform->addElement('selectyesno', 'displayattemptstatus', get_string('displayattemptstatus', 'scorm'));
|
||||
$mform->addHelpButton('displayattemptstatus', 'displayattemptstatus', 'scorm');
|
||||
$mform->setDefault('displayattemptstatus', $cfg_scorm->displayattemptstatus);
|
||||
|
||||
// Force completed
|
||||
// Force completed
|
||||
$mform->addElement('selectyesno', 'forcecompleted', get_string('forcecompleted', 'scorm'));
|
||||
$mform->addHelpButton('forcecompleted', 'forcecompleted', 'scorm');
|
||||
$mform->setDefault('forcecompleted', $cfg_scorm->forcecompleted);
|
||||
$mform->setAdvanced('forcecompleted');
|
||||
|
||||
// Force new attempt
|
||||
// Force new attempt
|
||||
$mform->addElement('selectyesno', 'forcenewattempt', get_string('forcenewattempt', 'scorm'));
|
||||
$mform->addHelpButton('forcenewattempt', 'forcenewattempt', 'scorm');
|
||||
$mform->setDefault('forcenewattempt', $cfg_scorm->forcenewattempt);
|
||||
$mform->setAdvanced('forcenewattempt');
|
||||
|
||||
// Last attempt lock - lock the enter button after the last available attempt has been made
|
||||
// Last attempt lock - lock the enter button after the last available attempt has been made
|
||||
$mform->addElement('selectyesno', 'lastattemptlock', get_string('lastattemptlock', 'scorm'));
|
||||
$mform->addHelpButton('lastattemptlock', 'lastattemptlock', 'scorm');
|
||||
$mform->setDefault('lastattemptlock', $cfg_scorm->lastattemptlock);
|
||||
$mform->setAdvanced('lastattemptlock');
|
||||
|
||||
// Activation period
|
||||
// Activation period
|
||||
/* $mform->addElement('static', '', '' ,'<hr />');
|
||||
$mform->addElement('static', 'activation', get_string('activation','scorm'));
|
||||
$datestartgrp = array();
|
||||
@@ -166,77 +166,77 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
$mform->disabledIf('dateendgrp', 'enddisabled', 'checked');
|
||||
*/
|
||||
|
||||
// Framed / Popup Window
|
||||
// Framed / Popup Window
|
||||
$mform->addElement('select', 'popup', get_string('display', 'scorm'), scorm_get_popup_display_array());
|
||||
$mform->setDefault('popup', $cfg_scorm->popup);
|
||||
$mform->setAdvanced('popup');
|
||||
|
||||
// Width
|
||||
$mform->addElement('text', 'width', get_string('width','scorm'), 'maxlength="5" size="5"');
|
||||
// Width
|
||||
$mform->addElement('text', 'width', get_string('width', 'scorm'), 'maxlength="5" size="5"');
|
||||
$mform->setDefault('width', $cfg_scorm->framewidth);
|
||||
$mform->setType('width', PARAM_INT);
|
||||
$mform->setAdvanced('width');
|
||||
$mform->disabledIf('width', 'popup', 'eq', 0);
|
||||
|
||||
// Height
|
||||
$mform->addElement('text', 'height', get_string('height','scorm'), 'maxlength="5" size="5"');
|
||||
// Height
|
||||
$mform->addElement('text', 'height', get_string('height', 'scorm'), 'maxlength="5" size="5"');
|
||||
$mform->setDefault('height', $cfg_scorm->frameheight);
|
||||
$mform->setType('height', PARAM_INT);
|
||||
$mform->setAdvanced('height');
|
||||
$mform->disabledIf('height', 'popup', 'eq', 0);
|
||||
|
||||
// Window Options
|
||||
// Window Options
|
||||
$winoptgrp = array();
|
||||
foreach(scorm_get_popup_options_array() as $key => $value){
|
||||
foreach (scorm_get_popup_options_array() as $key => $value) {
|
||||
$winoptgrp[] = &$mform->createElement('checkbox', $key, '', get_string($key, 'scorm'));
|
||||
$mform->setDefault($key, $value);
|
||||
}
|
||||
$mform->addGroup($winoptgrp, 'winoptgrp', get_string('options','scorm'), '<br />', false);
|
||||
$mform->addGroup($winoptgrp, 'winoptgrp', get_string('options', 'scorm'), '<br />', false);
|
||||
$mform->setAdvanced('winoptgrp');
|
||||
$mform->disabledIf('winoptgrp', 'popup', 'eq', 0);
|
||||
|
||||
// Skip view page
|
||||
$mform->addElement('select', 'skipview', get_string('skipview', 'scorm'),scorm_get_skip_view_array());
|
||||
// Skip view page
|
||||
$mform->addElement('select', 'skipview', get_string('skipview', 'scorm'), scorm_get_skip_view_array());
|
||||
$mform->addHelpButton('skipview', 'skipview', 'scorm');
|
||||
$mform->setDefault('skipview', $cfg_scorm->skipview);
|
||||
$mform->setAdvanced('skipview');
|
||||
|
||||
// Hide Browse
|
||||
// Hide Browse
|
||||
$mform->addElement('selectyesno', 'hidebrowse', get_string('hidebrowse', 'scorm'));
|
||||
$mform->addHelpButton('hidebrowse', 'hidebrowse', 'scorm');
|
||||
$mform->setDefault('hidebrowse', $cfg_scorm->hidebrowse);
|
||||
$mform->setAdvanced('hidebrowse');
|
||||
|
||||
// Display course structure
|
||||
// Display course structure
|
||||
$mform->addElement('selectyesno', 'displaycoursestructure', get_string('displaycoursestructure', 'scorm'));
|
||||
$mform->addHelpButton('displaycoursestructure', 'displaycoursestructure', 'scorm');
|
||||
$mform->setDefault('displaycoursestructure', $cfg_scorm->displaycoursestructure);
|
||||
$mform->setAdvanced('displaycoursestructure');
|
||||
|
||||
// Toc display
|
||||
// Toc display
|
||||
$mform->addElement('select', 'hidetoc', get_string('hidetoc', 'scorm'), scorm_get_hidetoc_array());
|
||||
$mform->addHelpButton('hidetoc', 'hidetoc', 'scorm');
|
||||
$mform->setDefault('hidetoc', $cfg_scorm->hidetoc);
|
||||
$mform->setAdvanced('hidetoc');
|
||||
|
||||
// Hide Navigation panel
|
||||
// Hide Navigation panel
|
||||
$mform->addElement('selectyesno', 'hidenav', get_string('hidenav', 'scorm'));
|
||||
$mform->setDefault('hidenav', $cfg_scorm->hidenav);
|
||||
$mform->setAdvanced('hidenav');
|
||||
|
||||
// Autocontinue
|
||||
// Autocontinue
|
||||
$mform->addElement('selectyesno', 'auto', get_string('autocontinue', 'scorm'));
|
||||
$mform->addHelpButton('auto', 'autocontinue', 'scorm');
|
||||
$mform->setDefault('auto', $cfg_scorm->auto);
|
||||
$mform->setAdvanced('auto');
|
||||
|
||||
// Update packages timing
|
||||
// Update packages timing
|
||||
$mform->addElement('select', 'updatefreq', get_string('updatefreq', 'scorm'), scorm_get_updatefreq_array());
|
||||
$mform->setDefault('updatefreq', $cfg_scorm->updatefreq);
|
||||
$mform->setAdvanced('updatefreq');
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
// Hidden Settings
|
||||
//-------------------------------------------------------------------------------
|
||||
// Hidden Settings
|
||||
$mform->addElement('hidden', 'datadir', null);
|
||||
$mform->setType('datadir', PARAM_RAW);
|
||||
$mform->addElement('hidden', 'pkgtype', null);
|
||||
@@ -248,13 +248,11 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
$mform->addElement('hidden', 'redirecturl', null);
|
||||
$mform->setType('redirecturl', PARAM_RAW);
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------
|
||||
$this->standard_coursemodule_elements();
|
||||
//-------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------
|
||||
// buttons
|
||||
$this->add_action_buttons();
|
||||
|
||||
}
|
||||
|
||||
function data_preprocessing(&$default_values) {
|
||||
@@ -262,9 +260,9 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
|
||||
if (isset($default_values['popup']) && ($default_values['popup'] == 1) && isset($default_values['options'])) {
|
||||
if (!empty($default_values['options'])) {
|
||||
$options = explode(',',$default_values['options']);
|
||||
$options = explode(',', $default_values['options']);
|
||||
foreach ($options as $option) {
|
||||
list($element,$value) = explode('=',$option);
|
||||
list($element, $value) = explode('=', $option);
|
||||
$element = trim($element);
|
||||
$default_values[$element] = trim($value);
|
||||
}
|
||||
@@ -273,10 +271,10 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
if (isset($default_values['grademethod'])) {
|
||||
$default_values['grademethod'] = intval($default_values['grademethod']);
|
||||
}
|
||||
if (isset($default_values['width']) && (strpos($default_values['width'],'%') === false) && ($default_values['width'] <= 100)) {
|
||||
if (isset($default_values['width']) && (strpos($default_values['width'], '%') === false) && ($default_values['width'] <= 100)) {
|
||||
$default_values['width'] .= '%';
|
||||
}
|
||||
if (isset($default_values['width']) && (strpos($default_values['height'],'%') === false) && ($default_values['height'] <= 100)) {
|
||||
if (isset($default_values['width']) && (strpos($default_values['height'], '%') === false) && ($default_values['height'] <= 100)) {
|
||||
$default_values['height'] .= '%';
|
||||
}
|
||||
$scorms = get_all_instances_in_course('scorm', $COURSE);
|
||||
@@ -294,7 +292,7 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
$default_values['redirecturl'] = '../mod/scorm/view.php?id='.$default_values['coursemodule'];
|
||||
}
|
||||
if (isset($default_values['version'])) {
|
||||
$default_values['pkgtype'] = (substr($default_values['version'],0,5) == 'SCORM') ? 'scorm':'aicc';
|
||||
$default_values['pkgtype'] = (substr($default_values['version'], 0, 5) == 'SCORM') ? 'scorm':'aicc';
|
||||
}
|
||||
if (isset($default_values['instance'])) {
|
||||
$default_values['datadir'] = $default_values['instance'];
|
||||
@@ -406,4 +404,3 @@ class mod_scorm_mod_form extends moodleform_mod {
|
||||
parent::set_data($default_values);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-8
@@ -48,10 +48,8 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launc
|
||||
var scorm_bloody_labelclick = false;
|
||||
var scorm_nav_panel;
|
||||
|
||||
|
||||
Y.use('yui2-resize', 'yui2-dragdrop', 'yui2-container', 'yui2-button', 'yui2-layout', 'yui2-treeview', 'yui2-json', 'yui2-event', function(Y) {
|
||||
|
||||
|
||||
var scorm_activate_item = function(node) {
|
||||
if (!node) {
|
||||
return;
|
||||
@@ -122,14 +120,13 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launc
|
||||
}
|
||||
var old = YAHOO.util.Dom.get('scorm_object');
|
||||
if (old) {
|
||||
if(window_name) {
|
||||
if(window_name) {
|
||||
var cwidth = scormplayerdata.cwidth;
|
||||
var cheight = scormplayerdata.cheight;
|
||||
var poptions = scormplayerdata.popupoptions;
|
||||
scorm_openpopup("loadSCO.php?" + node.title, window_name, poptions, cwidth, cheight);
|
||||
}
|
||||
else {
|
||||
content.replaceChild(obj, old);
|
||||
} else {
|
||||
content.replaceChild(obj, old);
|
||||
}
|
||||
} else {
|
||||
content.appendChild(obj);
|
||||
@@ -230,7 +227,6 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launc
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var scorm_up = function(node) {
|
||||
var node = scorm_tree_node.getHighlightedNode();
|
||||
if (node.depth > 0) {
|
||||
@@ -285,7 +281,6 @@ M.mod_scorm.init = function(Y, hide_nav, hide_toc, toc_title, window_name, launc
|
||||
mod_scorm_next = scorm_next;
|
||||
mod_scorm_prev = scorm_prev;
|
||||
|
||||
|
||||
// layout
|
||||
YAHOO.widget.LayoutUnit.prototype.STR_COLLAPSE = M.str.moodle.hide;
|
||||
YAHOO.widget.LayoutUnit.prototype.STR_EXPAND = M.str.moodle.show;
|
||||
|
||||
+168
-173
@@ -16,184 +16,177 @@
|
||||
|
||||
/// This page prints a particular instance of aicc/scorm package
|
||||
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
|
||||
require_once($CFG->libdir . '/completionlib.php');
|
||||
require_once('../../config.php');
|
||||
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
|
||||
require_once($CFG->libdir . '/completionlib.php');
|
||||
|
||||
//
|
||||
// Checkin' script parameters
|
||||
//
|
||||
$id = optional_param('cm', '', 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', 'normal', PARAM_ALPHA); // navigation mode
|
||||
$currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
|
||||
$newattempt = optional_param('newattempt', 'off', PARAM_ALPHA); // the user request to start a new attempt
|
||||
$id = optional_param('cm', '', 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', 'normal', PARAM_ALPHA); // navigation mode
|
||||
$currentorg = optional_param('currentorg', '', PARAM_RAW); // selected organization
|
||||
$newattempt = optional_param('newattempt', 'off', PARAM_ALPHA); // the user request to start a new attempt
|
||||
|
||||
//IE 6 Bug workaround
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) {
|
||||
@ini_set('zlib.output_compression', 'Off');
|
||||
@apache_setenv('no-gzip', 1);
|
||||
//IE 6 Bug workaround
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 6') !== false) {
|
||||
@ini_set('zlib.output_compression', 'Off');
|
||||
@apache_setenv('no-gzip', 1);
|
||||
}
|
||||
|
||||
if (!empty($id)) {
|
||||
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (!empty($id)) {
|
||||
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
} else if (!empty($a)) {
|
||||
if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
} else {
|
||||
print_error('missingparameter');
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
$url = new moodle_url('/mod/scorm/player.php', array('scoid'=>$scoid, 'cm'=>$cm->id));
|
||||
if ($mode !== 'normal') {
|
||||
$url->param('mode', $mode);
|
||||
if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if ($currentorg !== '') {
|
||||
$url->param('currentorg', $currentorg);
|
||||
} else if (!empty($a)) {
|
||||
if (! $scorm = $DB->get_record("scorm", array("id"=>$a))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if ($newattempt !== 'off') {
|
||||
$url->param('newattempt', $newattempt);
|
||||
if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
$forcejs = get_config('scorm','forcejavascript');
|
||||
if (!empty($forcejs)) {
|
||||
$PAGE->add_body_class('forcejavascript');
|
||||
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
} else {
|
||||
print_error('missingparameter');
|
||||
}
|
||||
|
||||
require_login($course->id, false, $cm);
|
||||
$url = new moodle_url('/mod/scorm/player.php', array('scoid'=>$scoid, 'cm'=>$cm->id));
|
||||
if ($mode !== 'normal') {
|
||||
$url->param('mode', $mode);
|
||||
}
|
||||
if ($currentorg !== '') {
|
||||
$url->param('currentorg', $currentorg);
|
||||
}
|
||||
if ($newattempt !== 'off') {
|
||||
$url->param('newattempt', $newattempt);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
$forcejs = get_config('scorm', 'forcejavascript');
|
||||
if (!empty($forcejs)) {
|
||||
$PAGE->add_body_class('forcejavascript');
|
||||
}
|
||||
|
||||
$strscorms = get_string('modulenameplural', 'scorm');
|
||||
$strscorm = get_string('modulename', 'scorm');
|
||||
$strpopup = get_string('popup','scorm');
|
||||
$strexit = get_string('exitactivity','scorm');
|
||||
require_login($course->id, false, $cm);
|
||||
|
||||
$pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
|
||||
$PAGE->set_title($pagetitle);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$strscorms = get_string('modulenameplural', 'scorm');
|
||||
$strscorm = get_string('modulename', 'scorm');
|
||||
$strpopup = get_string('popup', 'scorm');
|
||||
$strexit = get_string('exitactivity', 'scorm');
|
||||
|
||||
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE,$course->id))) {
|
||||
$pagetitle = strip_tags("$course->shortname: ".format_string($scorm->name));
|
||||
$PAGE->set_title($pagetitle);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
|
||||
if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_COURSE, $course->id))) {
|
||||
echo $OUTPUT->header();
|
||||
notice(get_string("activityiscurrentlyhidden"));
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
||||
//check if scorm closed
|
||||
$timenow = time();
|
||||
if ($scorm->timeclose !=0) {
|
||||
if ($scorm->timeopen > $timenow) {
|
||||
echo $OUTPUT->header();
|
||||
notice(get_string("activityiscurrentlyhidden"));
|
||||
echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter");
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
} else if ($timenow > $scorm->timeclose) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter");
|
||||
echo $OUTPUT->footer();
|
||||
|
||||
//check if scorm closed
|
||||
$timenow = time();
|
||||
if ($scorm->timeclose !=0) {
|
||||
if ($scorm->timeopen > $timenow) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter");
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
} elseif ($timenow > $scorm->timeclose) {
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->box(get_string("expired", "scorm", userdate($scorm->timeclose)), "generalbox boxaligncenter");
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
die;
|
||||
}
|
||||
}
|
||||
// TOC processing
|
||||
$scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe
|
||||
if (!file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php')) {
|
||||
$scorm->version = 'scorm_12';
|
||||
}
|
||||
require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
|
||||
$attempt = scorm_get_last_attempt($scorm->id, $USER->id);
|
||||
if (($newattempt=='on') && (($attempt < $scorm->maxattempt) || ($scorm->maxattempt == 0))) {
|
||||
$attempt++;
|
||||
$mode = 'normal';
|
||||
}
|
||||
$attemptstr = '&attempt=' . $attempt;
|
||||
|
||||
//
|
||||
// TOC processing
|
||||
//
|
||||
$scorm->version = strtolower(clean_param($scorm->version, PARAM_SAFEDIR)); // Just to be safe
|
||||
if (!file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php')) {
|
||||
$scorm->version = 'scorm_12';
|
||||
}
|
||||
require_once($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php');
|
||||
$attempt = scorm_get_last_attempt($scorm->id, $USER->id);
|
||||
if (($newattempt=='on') && (($attempt < $scorm->maxattempt) || ($scorm->maxattempt == 0))) {
|
||||
$attempt++;
|
||||
$mode = 'normal';
|
||||
}
|
||||
$attemptstr = '&attempt=' . $attempt;
|
||||
$result = scorm_get_toc($USER, $scorm, $cm->id, TOCJSLINK, $currentorg, $scoid, $mode, $attempt, true, true);
|
||||
$sco = $result->sco;
|
||||
|
||||
$result = scorm_get_toc($USER, $scorm, $cm->id, TOCJSLINK, $currentorg, $scoid, $mode, $attempt, true, true);
|
||||
$sco = $result->sco;
|
||||
|
||||
if (($mode == 'browse') && ($scorm->hidebrowse == 1)) {
|
||||
$mode = 'normal';
|
||||
}
|
||||
if ($mode != 'browse') {
|
||||
if ($trackdata = scorm_get_tracks($sco->id,$USER->id,$attempt)) {
|
||||
if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) {
|
||||
$mode = 'review';
|
||||
} else {
|
||||
$mode = 'normal';
|
||||
}
|
||||
if (($mode == 'browse') && ($scorm->hidebrowse == 1)) {
|
||||
$mode = 'normal';
|
||||
}
|
||||
if ($mode != 'browse') {
|
||||
if ($trackdata = scorm_get_tracks($sco->id, $USER->id, $attempt)) {
|
||||
if (($trackdata->status == 'completed') || ($trackdata->status == 'passed') || ($trackdata->status == 'failed')) {
|
||||
$mode = 'review';
|
||||
} else {
|
||||
$mode = 'normal';
|
||||
}
|
||||
}
|
||||
|
||||
add_to_log($course->id, 'scorm', 'view', "player.php?cm=$cm->id&scoid=$sco->id", "$scorm->id", $cm->id);
|
||||
|
||||
|
||||
$scoidstr = '&scoid='.$sco->id;
|
||||
$scoidpop = '&scoid='.$sco->id;
|
||||
$modestr = '&mode='.$mode;
|
||||
if ($mode == 'browse') {
|
||||
$modepop = '&mode='.$mode;
|
||||
} else {
|
||||
$modepop = '';
|
||||
$mode = 'normal';
|
||||
}
|
||||
$orgstr = '¤torg='.$currentorg;
|
||||
}
|
||||
|
||||
$SESSION->scorm_scoid = $sco->id;
|
||||
$SESSION->scorm_status = 'Not Initialized';
|
||||
$SESSION->scorm_mode = $mode;
|
||||
$SESSION->scorm_attempt = $attempt;
|
||||
add_to_log($course->id, 'scorm', 'view', "player.php?cm=$cm->id&scoid=$sco->id", "$scorm->id", $cm->id);
|
||||
|
||||
// Mark module viewed
|
||||
$completion = new completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
//
|
||||
// Print the page header
|
||||
//
|
||||
$bodyscript = '';
|
||||
if ($scorm->popup == 1) {
|
||||
$bodyscript = 'onunload="main.close();"';
|
||||
}
|
||||
$scoidstr = '&scoid='.$sco->id;
|
||||
$scoidpop = '&scoid='.$sco->id;
|
||||
$modestr = '&mode='.$mode;
|
||||
if ($mode == 'browse') {
|
||||
$modepop = '&mode='.$mode;
|
||||
} else {
|
||||
$modepop = '';
|
||||
}
|
||||
$orgstr = '¤torg='.$currentorg;
|
||||
|
||||
$exitlink = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$scorm->course.'" title="'.$strexit.'">'.$strexit.'</a> ';
|
||||
$SESSION->scorm_scoid = $sco->id;
|
||||
$SESSION->scorm_status = 'Not Initialized';
|
||||
$SESSION->scorm_mode = $mode;
|
||||
$SESSION->scorm_attempt = $attempt;
|
||||
|
||||
$PAGE->set_button($exitlink);
|
||||
// Mark module viewed
|
||||
$completion = new completion_info($course);
|
||||
$completion->set_module_viewed($cm);
|
||||
|
||||
$PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,'cheight'=>$scorm->height,
|
||||
'popupoptions' => $scorm->options), true);
|
||||
$PAGE->requires->js('/mod/scorm/request.js', true);
|
||||
$PAGE->requires->js('/lib/cookies.js', true);
|
||||
//$PAGE->requires->js('/mod/scorm/loaddatamodel.php?id='.$cm->id.$scoidstr.$modestr.$attemptstr, true);
|
||||
$PAGE->requires->css('/mod/scorm/styles.css');
|
||||
// Print the page header
|
||||
$bodyscript = '';
|
||||
if ($scorm->popup == 1) {
|
||||
$bodyscript = 'onunload="main.close();"';
|
||||
}
|
||||
|
||||
echo $OUTPUT->header();
|
||||
$exitlink = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$scorm->course.'" title="'.$strexit.'">'.$strexit.'</a> ';
|
||||
|
||||
// NEW IMS TOC
|
||||
$PAGE->requires->string_for_js('navigation', 'scorm');
|
||||
$PAGE->requires->string_for_js('toc', 'scorm');
|
||||
$PAGE->requires->string_for_js('hide', 'moodle');
|
||||
$PAGE->requires->string_for_js('show', 'moodle');
|
||||
$PAGE->requires->string_for_js('popupsblocked', 'scorm');
|
||||
$PAGE->set_button($exitlink);
|
||||
|
||||
$name = false;
|
||||
$PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,
|
||||
'cheight'=>$scorm->height,
|
||||
'popupoptions' => $scorm->options), true);
|
||||
$PAGE->requires->js('/mod/scorm/request.js', true);
|
||||
$PAGE->requires->js('/lib/cookies.js', true);
|
||||
$PAGE->requires->css('/mod/scorm/styles.css');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
|
||||
// NEW IMS TOC
|
||||
$PAGE->requires->string_for_js('navigation', 'scorm');
|
||||
$PAGE->requires->string_for_js('toc', 'scorm');
|
||||
$PAGE->requires->string_for_js('hide', 'moodle');
|
||||
$PAGE->requires->string_for_js('show', 'moodle');
|
||||
$PAGE->requires->string_for_js('popupsblocked', 'scorm');
|
||||
|
||||
$name = false;
|
||||
|
||||
?>
|
||||
<div id="scormpage">
|
||||
@@ -204,21 +197,21 @@
|
||||
</div>
|
||||
<div id="scormtop">
|
||||
<?php
|
||||
if ($result->prerequisites) {
|
||||
if ($scorm->popup != 0) {
|
||||
//Added incase javascript popups are blocked we don't provide a direct link to the pop-up as JS communication can fail - the user must disable their pop-up blocker.
|
||||
$linkcourse = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$scorm->course.'">' . get_string('finishscormlinkname','scorm') . '</a>';
|
||||
echo $OUTPUT->box(get_string('finishscorm','scorm',$linkcourse), 'generalbox', 'altfinishlink');
|
||||
}
|
||||
if ($result->prerequisites) {
|
||||
if ($scorm->popup != 0) {
|
||||
//Added incase javascript popups are blocked we don't provide a direct link to the pop-up as JS communication can fail - the user must disable their pop-up blocker.
|
||||
$linkcourse = '<a href="'.$CFG->wwwroot.'/course/view.php?id='.$scorm->course.'">' . get_string('finishscormlinkname', 'scorm') . '</a>';
|
||||
echo $OUTPUT->box(get_string('finishscorm', 'scorm', $linkcourse), 'generalbox', 'altfinishlink');
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php echo $mode == 'browse' ? '<div id="scormmode" class="scorm-left">'.get_string('browsemode','scorm')."</div>\n" : ''; ?>
|
||||
<?php echo $mode == 'review' ? '<div id="scormmode" class="scorm-left">'.get_string('reviewmode','scorm')."</div>\n" : ''; ?>
|
||||
<?php echo $mode == 'browse' ? '<div id="scormmode" class="scorm-left">'.get_string('browsemode', 'scorm')."</div>\n" : ''; ?>
|
||||
<?php echo $mode == 'review' ? '<div id="scormmode" class="scorm-left">'.get_string('reviewmode', 'scorm')."</div>\n" : ''; ?>
|
||||
<div id="scormnav" class="scorm-right">
|
||||
<?php
|
||||
if ($scorm->hidetoc == 2) {
|
||||
echo $result->tocmenu;
|
||||
}
|
||||
if ($scorm->hidetoc == 2) {
|
||||
echo $result->tocmenu;
|
||||
}
|
||||
?>
|
||||
</div> <!-- Scormnav -->
|
||||
</div> <!-- Scormtop -->
|
||||
@@ -228,23 +221,25 @@
|
||||
</div> <!-- tocbox -->
|
||||
<noscript>
|
||||
<div id="noscript">
|
||||
<?php print_string('noscriptnoscorm','scorm'); // No Martin(i), No Party ;-) ?>
|
||||
<?php print_string('noscriptnoscorm', 'scorm'); // No Martin(i), No Party ;-) ?>
|
||||
|
||||
</div>
|
||||
</noscript>
|
||||
<?php
|
||||
if ($result->prerequisites) {
|
||||
if ($scorm->popup != 0) {
|
||||
// Clean the name for the window as IE is fussy
|
||||
$name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name);
|
||||
if (!$name) {
|
||||
$name = 'DefaultPlayerWindow';
|
||||
}
|
||||
$name = 'scorm_'.$name;
|
||||
|
||||
echo html_writer::script('', $CFG->wwwroot.'/mod/scorm/player.js');
|
||||
echo html_writer::script(js_writer::function_call('scorm_openpopup', Array("loadSCO.php?id=".$cm->id.$scoidpop, $name, $scorm->options, $scorm->width, $scorm->height)));
|
||||
?>
|
||||
if ($result->prerequisites) {
|
||||
if ($scorm->popup != 0) {
|
||||
// Clean the name for the window as IE is fussy
|
||||
$name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name);
|
||||
if (!$name) {
|
||||
$name = 'DefaultPlayerWindow';
|
||||
}
|
||||
$name = 'scorm_'.$name;
|
||||
echo html_writer::script('', $CFG->wwwroot.'/mod/scorm/player.js');
|
||||
echo html_writer::script(
|
||||
js_writer::function_call('scorm_openpopup', Array("loadSCO.php?id=".$cm->id.$scoidpop,
|
||||
$name, $scorm->options,
|
||||
$scorm->width, $scorm->height)));
|
||||
?>
|
||||
<noscript>
|
||||
<!--[if IE]>
|
||||
<iframe id="main" class="scoframe" name="main" src="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr; ?>"></iframe>
|
||||
@@ -253,11 +248,11 @@
|
||||
<object id="main" class="scoframe" type="text/html" data="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr; ?>"></object>
|
||||
<![endif]-->
|
||||
</noscript>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
echo $OUTPUT->box(get_string('noprerequisites','scorm'));
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
echo $OUTPUT->box(get_string('noprerequisites', 'scorm'));
|
||||
}
|
||||
?>
|
||||
</div> <!-- SCORM page -->
|
||||
<?php
|
||||
|
||||
Reference in New Issue
Block a user