Merge branch 'm20_MDL-26176_cleanup' of github.com:danmarsden/moodle

This commit is contained in:
Sam Hemelryk 2011-01-31 17:16:56 +08:00
commit 1f5a33439e
5 changed files with 5 additions and 97 deletions

View file

@ -333,14 +333,12 @@ function scorm_parse_aicc($scorm) {
function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
global $CFG, $DB, $PAGE, $OUTPUT;
$strexpand = get_string('expcoll','scorm');
$modestr = '';
if ($mode == 'browse') {
$modestr = '&mode='.$mode;
}
$result = new stdClass();
//$result->toc = "<ul id='s0' class='$liststyle'>\n";
if ($tocheader) {
$result->toc = '<div id="scorm_layout">';
$result->toc .= '<div id="scorm_toc">';
@ -418,11 +416,6 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
$i--;
}
if (($i == 0) && ($sco->parent != $currentorg)) {
$style = '';
if (isset($_COOKIE['hide:SCORMitem'.$sco->id])) {
$style = ' style="display: none;"';
}
//$result->toc .= "\t\t<li><ul id='s$sublist' class='$liststyle'$style>\n";
$result->toc .= "\t\t<ul>\n";
$level++;
} else {
@ -446,21 +439,12 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
}
if ($nextisvisible && ($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
$sublist++;
$icon = 'minus';
if (isset($_COOKIE['hide:SCORMitem'.$nextsco->id])) {
$icon = 'plus';
}
//$result->toc .= '<a href="javascript:expandCollide(\'img'.$sublist.'\',\'s'.$sublist.'\','.$nextsco->id.');"><img id="img'.$sublist.'" src="'.$OUTPUT->pix_url($icon, 'scorm').'" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
} else if ($isvisible) {
//$result->toc .= '<img src="'.$OUTPUT->pix_url('spacer', 'scorm').'" alt="" />';
}
if (empty($sco->title)) {
$sco->title = $sco->identifier;
}
if (!empty($sco->launch)) {
if ($isvisible) {
$startbold = '';
$endbold = '';
$score = '';
if (empty($scoid) && ($mode != 'normal')) {
$scoid = $sco->id;
@ -499,11 +483,7 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
}
}
if ($sco->id == $scoid) {
$startbold = '<b>';
$endbold = '</b>';
$findnext = true;
$shownext = isset($sco->next) ? $sco->next : 0;
$showprev = isset($sco->previous) ? $sco->previous : 0;
}
if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
@ -537,8 +517,7 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
if ($play) {
// should be disabled
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
}
else {
} else {
$result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n";
}
}
@ -591,5 +570,3 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
return $result;
}

View file

@ -109,14 +109,12 @@ function scorm_eval_prerequisites($prerequisites, $usertracks) {
function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
global $CFG, $DB, $PAGE, $OUTPUT;
$strexpand = get_string('expcoll','scorm');
$modestr = '';
if ($mode == 'browse') {
$modestr = '&amp;mode='.$mode;
}
$result = new stdClass();
//$result->toc = "<ul id='s0' class='$liststyle'>\n";
if ($tocheader) {
$result->toc = '<div id="scorm_layout">';
$result->toc .= '<div id="scorm_toc">';
@ -193,15 +191,7 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
$i--;
}
if (($i == 0) && ($sco->parent != $currentorg)) {
$style = '';
if (isset($_COOKIE['hide:SCORMitem'.$sco->id])) {
$style = ' style="display: none;"';
}
//$result->toc .= "\t\t<li><ul id='s$sublist' class='$liststyle'$style>\n";
$result->toc .= "\t\t<ul>\n";
$level++;
} else {
$result->toc .= $closelist;
@ -224,21 +214,12 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
}
if ($nextisvisible && ($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
$sublist++;
$icon = 'minus';
if (isset($_COOKIE['hide:SCORMitem'.$nextsco->id])) {
$icon = 'plus';
}
//$result->toc .= '<a href="javascript:expandCollide(\'img'.$sublist.'\',\'s'.$sublist.'\','.$nextsco->id.');"><img id="img'.$sublist.'" src="'.$OUTPUT->pix_url($icon, 'scorm').'" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
} else if ($isvisible) {
//$result->toc .= '<img src="'.$OUTPUT->pix_url('spacer', 'scorm').'" alt="" />';
}
if (empty($sco->title)) {
$sco->title = $sco->identifier;
}
if (!empty($sco->launch)) {
if ($isvisible) {
$startbold = '';
$endbold = '';
$score = '';
if (empty($scoid) && ($mode != 'normal')) {
$scoid = $sco->id;
@ -277,11 +258,7 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
}
}
if ($sco->id == $scoid) {
$startbold = '<b>';
$endbold = '</b>';
$findnext = true;
$shownext = isset($sco->next) ? $sco->next : 0;
$showprev = isset($sco->previous) ? $sco->previous : 0;
}
if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
@ -314,8 +291,7 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
if ($play) {
// should be disabled
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
}
else {
} else {
$result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n";
}
}
@ -358,7 +334,6 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
}
if ($scorm->hidetoc == 0) {
$PAGE->requires->data_for_js('scormdata', array(
'plusicon' => $OUTPUT->pix_url('plus', 'scorm'),
@ -372,5 +347,3 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
return $result;
}

View file

@ -3,7 +3,6 @@
function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
global $CFG, $DB, $PAGE, $OUTPUT;
$strexpand = get_string('expcoll','scorm');
$modestr = '';
if ($mode == 'browse') {
$modestr = '&amp;mode='.$mode;
@ -84,11 +83,6 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
$i--;
}
if (($i == 0) && ($sco->parent != $currentorg)) {
$style = '';
if (isset($_COOKIE['hide:SCORMitem'.$sco->id])) {
$style = ' style="display: none;"';
}
//$result->toc .= "\t\t<li><ul id='s$sublist' class='$liststyle'$style>\n";
$result->toc .= "\t\t><ul>\n";
$level++;
} else {
@ -113,22 +107,12 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
if ($nextisvisible && ($nextsco !== false) && ($sco->parent != $nextsco->parent) &&
(($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
$sublist++;
$icon = 'minus';
if (isset($_COOKIE['hide:SCORMitem'.$nextsco->id])) {
$icon = 'plus';
}
// $result->toc .= "\t\t".'<li><a href="javascript:expandCollide(\'img'.$sublist.'\',\'s'.$sublist.'\','.$nextsco->id.');">'.
// '<img id="img'.$sublist.'" src="'.$OUTPUT->pix_url($icon, 'scorm').'" alt="'.$strexpand.'" title="'.$strexpand.'"/></a>';
} else if ($isvisible) {
// $result->toc .= "\t\t".'<li><img src="'.$OUTPUT->pix_url('spacer', 'scorm').'" alt="" />';
}
if (empty($sco->title)) {
$sco->title = $sco->identifier;
}
if (!empty($sco->launch)) {
if ($isvisible) {
$startbold = '';
$endbold = '';
$score = '';
if (empty($scoid) && ($mode != 'normal')) {
$scoid = $sco->id;
@ -168,11 +152,7 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
}
if ($sco->id == $scoid) {
$startbold = '<b>';
$endbold = '</b>';
$findnext = true;
$shownext = isset($sco->next) ? $sco->next : 0;
$showprev = isset($sco->prev) ? $sco->prev : 0;
}
if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
@ -202,12 +182,10 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
if ($sco->id == $scoid) {
$result->prerequisites = false;
}
//$result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n";
if ($play) {
// should be disabled
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
}
else {
} else {
$result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n";
}
}
@ -261,5 +239,3 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
return $result;
}

View file

@ -84,7 +84,6 @@ $string['everytime'] = 'Every time it\'s used';
$string['exceededmaxattempts'] = 'You have reached the maximum number of attempts.';
$string['exit'] = 'Exit course';
$string['exitactivity'] = 'Exit activity';
$string['expcoll'] = 'Expand/Collide';
$string['expired'] = 'Sorry, this activity closed on {$a} and is no longer available';
$string['external'] = 'Update external packages timing';
$string['failed'] = 'Failed';

View file

@ -588,7 +588,6 @@ function scorm_grade_user($scorm, $userid) {
break;
case HIGHESTATTEMPT:
$maxscore = 0;
$attempttime = 0;
for ($attempt = 1; $attempt <= $lastattempt; $attempt++) {
$attemptscore = scorm_grade_user_attempt($scorm, $userid, $attempt);
$maxscore = $attemptscore > $maxscore ? $attemptscore: $maxscore;
@ -661,7 +660,6 @@ function scorm_course_format_display($user,$course) {
global $CFG, $DB, $PAGE, $OUTPUT;
$strupdate = get_string('update');
$strmodule = get_string('modulename','scorm');
$context = get_context_instance(CONTEXT_COURSE,$course->id);
echo '<div class="mod-scorm">';
@ -693,10 +691,9 @@ function scorm_course_format_display($user,$course) {
}
$colspan = ' colspan="2"';
}
$options = (object)array('noclean'=>true);
$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');
scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm, '100%');
scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm);
} else {
if (has_capability('moodle/course:update', $context)) {
// Create a new activity
@ -708,7 +705,7 @@ function scorm_course_format_display($user,$course) {
echo '</div>';
}
function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') {
function scorm_view_display ($user, $scorm, $action, $cm) {
global $CFG, $DB, $PAGE, $OUTPUT;
if ($scorm->updatefreq == UPDATE_EVERYTIME) {
@ -746,16 +743,6 @@ function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') {
}
}
/*
$orgidentifier = '';
if ($org = $DB->get_record('scorm_scoes', array('id'=>$organization))) {
if (($org->organization == '') && ($org->launch == '')) {
$orgidentifier = $org->identifier;
} else {
$orgidentifier = $org->organization;
}
}*/
$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';
@ -1028,8 +1015,6 @@ function scorm_get_attempt_status($user, $scorm) {
}
$result .= get_string('noattemptsmade', 'scorm').': ' . $attemptcount . '<BR>';
$gradereported = 0;
$gradesum = 0;
if ($scorm->maxattempt == 1) {
switch ($scorm->grademethod) {
case GRADEHIGHEST:
@ -1219,8 +1204,6 @@ function scorm_format_duration($duration) {
// then convert in the same way as SCORM 2004
$pattern = array( '#T0+H#', '#([A-Z])0+M#', '#([A-Z])[0.]+S#', '#\.0+S#', '#0*(\d+)H#', '#0*(\d+)M#', '#0+\.(\d+)S#', '#0*([\d.]+)S#', '#T#' );
$replace = array( 'T', '$1', '$1', 'S', '$1 '.$strhours.' ', '$1 '.$strminutes.' ', '0.$1 '.$strseconds, '$1 '.$strseconds, '' );
//$pattern = '##';
//$replace = '';
}
$result = preg_replace($pattern, $replace, $duration);