Skip to content

Commit

Permalink
MDL-26176 - cleanup garbage/pointless code
Browse files Browse the repository at this point in the history
  • Loading branch information
danmarsden committed Jan 29, 2011
1 parent 7cc7cf5 commit 3934035
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 99 deletions.
25 changes: 1 addition & 24 deletions mod/scorm/datamodels/aicclib.php
Expand Up @@ -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) { function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
global $CFG, $DB, $PAGE, $OUTPUT; global $CFG, $DB, $PAGE, $OUTPUT;


$strexpand = get_string('expcoll','scorm');
$modestr = ''; $modestr = '';
if ($mode == 'browse') { if ($mode == 'browse') {
$modestr = '&mode='.$mode; $modestr = '&mode='.$mode;
} }


$result = new stdClass(); $result = new stdClass();
//$result->toc = "<ul id='s0' class='$liststyle'>\n";
if ($tocheader) { if ($tocheader) {
$result->toc = '<div id="scorm_layout">'; $result->toc = '<div id="scorm_layout">';
$result->toc .= '<div id="scorm_toc">'; $result->toc .= '<div id="scorm_toc">';
Expand Down Expand Up @@ -418,11 +416,6 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
$i--; $i--;
} }
if (($i == 0) && ($sco->parent != $currentorg)) { 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"; $result->toc .= "\t\t<ul>\n";
$level++; $level++;
} else { } else {
Expand All @@ -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)))) { if ($nextisvisible && ($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
$sublist++; $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)) { if (empty($sco->title)) {
$sco->title = $sco->identifier; $sco->title = $sco->identifier;
} }
if (!empty($sco->launch)) { if (!empty($sco->launch)) {
if ($isvisible) { if ($isvisible) {
$startbold = '';
$endbold = '';
$score = ''; $score = '';
if (empty($scoid) && ($mode != 'normal')) { if (empty($scoid) && ($mode != 'normal')) {
$scoid = $sco->id; $scoid = $sco->id;
Expand Down Expand Up @@ -499,11 +483,7 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
} }
} }
if ($sco->id == $scoid) { if ($sco->id == $scoid) {
$startbold = '<b>';
$endbold = '</b>';
$findnext = true; $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)) { if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
Expand Down Expand Up @@ -537,8 +517,7 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
if ($play) { if ($play) {
// should be disabled // should be disabled
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>'; $result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
} } else {
else {
$result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n"; $result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n";
} }
} }
Expand Down Expand Up @@ -591,5 +570,3 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',


return $result; return $result;
} }


31 changes: 2 additions & 29 deletions mod/scorm/datamodels/scorm_12lib.php
Expand Up @@ -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) { function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
global $CFG, $DB, $PAGE, $OUTPUT; global $CFG, $DB, $PAGE, $OUTPUT;


$strexpand = get_string('expcoll','scorm');
$modestr = ''; $modestr = '';
if ($mode == 'browse') { if ($mode == 'browse') {
$modestr = '&amp;mode='.$mode; $modestr = '&amp;mode='.$mode;
} }


$result = new stdClass(); $result = new stdClass();
//$result->toc = "<ul id='s0' class='$liststyle'>\n";
if ($tocheader) { if ($tocheader) {
$result->toc = '<div id="scorm_layout">'; $result->toc = '<div id="scorm_layout">';
$result->toc .= '<div id="scorm_toc">'; $result->toc .= '<div id="scorm_toc">';
Expand Down Expand Up @@ -193,15 +191,7 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
$i--; $i--;
} }
if (($i == 0) && ($sco->parent != $currentorg)) { 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"; $result->toc .= "\t\t<ul>\n";



$level++; $level++;
} else { } else {
$result->toc .= $closelist; $result->toc .= $closelist;
Expand All @@ -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)))) { if ($nextisvisible && ($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
$sublist++; $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)) { if (empty($sco->title)) {
$sco->title = $sco->identifier; $sco->title = $sco->identifier;
} }
if (!empty($sco->launch)) { if (!empty($sco->launch)) {
if ($isvisible) { if ($isvisible) {
$startbold = '';
$endbold = '';
$score = ''; $score = '';
if (empty($scoid) && ($mode != 'normal')) { if (empty($scoid) && ($mode != 'normal')) {
$scoid = $sco->id; $scoid = $sco->id;
Expand Down Expand Up @@ -277,11 +258,7 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
} }
} }
if ($sco->id == $scoid) { if ($sco->id == $scoid) {
$startbold = '<b>';
$endbold = '</b>';
$findnext = true; $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)) { if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
Expand Down Expand Up @@ -314,8 +291,7 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
if ($play) { if ($play) {
// should be disabled // should be disabled
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>'; $result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
} } else {
else {
$result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n"; $result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n";
} }
} }
Expand Down Expand Up @@ -358,7 +334,6 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
} }





if ($scorm->hidetoc == 0) { if ($scorm->hidetoc == 0) {
$PAGE->requires->data_for_js('scormdata', array( $PAGE->requires->data_for_js('scormdata', array(
'plusicon' => $OUTPUT->pix_url('plus', 'scorm'), 'plusicon' => $OUTPUT->pix_url('plus', 'scorm'),
Expand All @@ -371,6 +346,4 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
$result->tocmenu = $OUTPUT->single_select($url, 'scoid', $tocmenus, $sco->id, null, "tocmenu"); $result->tocmenu = $OUTPUT->single_select($url, 'scoid', $tocmenus, $sco->id, null, "tocmenu");


return $result; return $result;
} }


28 changes: 2 additions & 26 deletions mod/scorm/datamodels/scorm_13lib.php
Expand Up @@ -3,7 +3,6 @@
function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) { function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false, $tocheader=false) {
global $CFG, $DB, $PAGE, $OUTPUT; global $CFG, $DB, $PAGE, $OUTPUT;


$strexpand = get_string('expcoll','scorm');
$modestr = ''; $modestr = '';
if ($mode == 'browse') { if ($mode == 'browse') {
$modestr = '&amp;mode='.$mode; $modestr = '&amp;mode='.$mode;
Expand Down Expand Up @@ -84,11 +83,6 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
$i--; $i--;
} }
if (($i == 0) && ($sco->parent != $currentorg)) { 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"; $result->toc .= "\t\t><ul>\n";
$level++; $level++;
} else { } else {
Expand All @@ -113,22 +107,12 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
if ($nextisvisible && ($nextsco !== false) && ($sco->parent != $nextsco->parent) && if ($nextisvisible && ($nextsco !== false) && ($sco->parent != $nextsco->parent) &&
(($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) { (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
$sublist++; $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)) { if (empty($sco->title)) {
$sco->title = $sco->identifier; $sco->title = $sco->identifier;
} }
if (!empty($sco->launch)) { if (!empty($sco->launch)) {
if ($isvisible) { if ($isvisible) {
$startbold = '';
$endbold = '';
$score = ''; $score = '';
if (empty($scoid) && ($mode != 'normal')) { if (empty($scoid) && ($mode != 'normal')) {
$scoid = $sco->id; $scoid = $sco->id;
Expand Down Expand Up @@ -168,11 +152,7 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
} }


if ($sco->id == $scoid) { if ($sco->id == $scoid) {
$startbold = '<b>';
$endbold = '</b>';
$findnext = true; $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)) { if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
Expand Down Expand Up @@ -202,12 +182,10 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
if ($sco->id == $scoid) { if ($sco->id == $scoid) {
$result->prerequisites = false; $result->prerequisites = false;
} }
//$result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n";
if ($play) { if ($play) {
// should be disabled // should be disabled
$result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>'; $result->toc .= '<span>'.$statusicon.'&nbsp;'.format_string($sco->title).'</span>';
} } else {
else {
$result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n"; $result->toc .= $statusicon.'&nbsp;'.format_string($sco->title)."\n";
} }
} }
Expand Down Expand Up @@ -260,6 +238,4 @@ function scorm_get_toc($user,$scorm,$toclink=TOCJSLINK,$currentorg='',$scoid='',
$result->tocmenu = $OUTPUT->single_select($url, 'scoid', $tocmenus, $sco->id, null, "tocmenu"); $result->tocmenu = $OUTPUT->single_select($url, 'scoid', $tocmenus, $sco->id, null, "tocmenu");


return $result; return $result;
} }


1 change: 0 additions & 1 deletion mod/scorm/lang/en/scorm.php
Expand Up @@ -84,7 +84,6 @@
$string['exceededmaxattempts'] = 'You have reached the maximum number of attempts.'; $string['exceededmaxattempts'] = 'You have reached the maximum number of attempts.';
$string['exit'] = 'Exit course'; $string['exit'] = 'Exit course';
$string['exitactivity'] = 'Exit activity'; $string['exitactivity'] = 'Exit activity';
$string['expcoll'] = 'Expand/Collide';
$string['expired'] = 'Sorry, this activity closed on {$a} and is no longer available'; $string['expired'] = 'Sorry, this activity closed on {$a} and is no longer available';
$string['external'] = 'Update external packages timing'; $string['external'] = 'Update external packages timing';
$string['failed'] = 'Failed'; $string['failed'] = 'Failed';
Expand Down
21 changes: 2 additions & 19 deletions mod/scorm/locallib.php
Expand Up @@ -588,7 +588,6 @@ function scorm_grade_user($scorm, $userid) {
break; break;
case HIGHESTATTEMPT: case HIGHESTATTEMPT:
$maxscore = 0; $maxscore = 0;
$attempttime = 0;
for ($attempt = 1; $attempt <= $lastattempt; $attempt++) { for ($attempt = 1; $attempt <= $lastattempt; $attempt++) {
$attemptscore = scorm_grade_user_attempt($scorm, $userid, $attempt); $attemptscore = scorm_grade_user_attempt($scorm, $userid, $attempt);
$maxscore = $attemptscore > $maxscore ? $attemptscore: $maxscore; $maxscore = $attemptscore > $maxscore ? $attemptscore: $maxscore;
Expand Down Expand Up @@ -661,7 +660,6 @@ function scorm_course_format_display($user,$course) {
global $CFG, $DB, $PAGE, $OUTPUT; global $CFG, $DB, $PAGE, $OUTPUT;


$strupdate = get_string('update'); $strupdate = get_string('update');
$strmodule = get_string('modulename','scorm');
$context = get_context_instance(CONTEXT_COURSE,$course->id); $context = get_context_instance(CONTEXT_COURSE,$course->id);


echo '<div class="mod-scorm">'; echo '<div class="mod-scorm">';
Expand Down Expand Up @@ -693,10 +691,9 @@ function scorm_course_format_display($user,$course) {
} }
$colspan = ' colspan="2"'; $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>'; $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, '100%'); scorm_view_display($user, $scorm, 'view.php?id='.$course->id, $cm);
} else { } else {
if (has_capability('moodle/course:update', $context)) { if (has_capability('moodle/course:update', $context)) {
// Create a new activity // Create a new activity
Expand All @@ -708,7 +705,7 @@ function scorm_course_format_display($user,$course) {
echo '</div>'; echo '</div>';
} }


function scorm_view_display ($user, $scorm, $action, $cm, $boxwidth='') { function scorm_view_display ($user, $scorm, $action, $cm) {
global $CFG, $DB, $PAGE, $OUTPUT; global $CFG, $DB, $PAGE, $OUTPUT;


if ($scorm->updatefreq == UPDATE_EVERYTIME) { if ($scorm->updatefreq == UPDATE_EVERYTIME) {
Expand Down Expand Up @@ -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 $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')) { if (!file_exists($CFG->dirroot.'/mod/scorm/datamodels/'.$scorm->version.'lib.php')) {
$scorm->version = 'scorm_12'; $scorm->version = 'scorm_12';
Expand Down Expand Up @@ -1028,8 +1015,6 @@ function scorm_get_attempt_status($user, $scorm) {
} }
$result .= get_string('noattemptsmade', 'scorm').': ' . $attemptcount . '<BR>'; $result .= get_string('noattemptsmade', 'scorm').': ' . $attemptcount . '<BR>';


$gradereported = 0;
$gradesum = 0;
if ($scorm->maxattempt == 1) { if ($scorm->maxattempt == 1) {
switch ($scorm->grademethod) { switch ($scorm->grademethod) {
case GRADEHIGHEST: case GRADEHIGHEST:
Expand Down Expand Up @@ -1219,8 +1204,6 @@ function scorm_format_duration($duration) {
// then convert in the same way as SCORM 2004 // 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#' ); $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, '' ); $replace = array( 'T', '$1', '$1', 'S', '$1 '.$strhours.' ', '$1 '.$strminutes.' ', '0.$1 '.$strseconds, '$1 '.$strseconds, '' );
//$pattern = '##';
//$replace = '';
} }


$result = preg_replace($pattern, $replace, $duration); $result = preg_replace($pattern, $replace, $duration);
Expand Down

0 comments on commit 3934035

Please sign in to comment.