diff --git a/mod/scorm/datamodel.php b/mod/scorm/datamodel.php
index e176308cb9b..6107422e6c5 100644
--- a/mod/scorm/datamodel.php
+++ b/mod/scorm/datamodel.php
@@ -26,17 +26,17 @@ if (!empty($id)) {
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
print_error('invalidcoursemodule');
}
- if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
+ if (! $course = $DB->get_record("course", array("id" => $cm->course))) {
print_error('coursemisconf');
}
- if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
+ 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))) {
+ if (! $scorm = $DB->get_record("scorm", array("id" => $a))) {
print_error('invalidcoursemodule');
}
- if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
+ if (! $course = $DB->get_record("course", array("id" => $scorm->course))) {
print_error('coursemisconf');
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
@@ -46,7 +46,7 @@ if (!empty($id)) {
print_error('missingparameter');
}
-$PAGE->set_url('/mod/scorm/datamodel.php', array('scoid'=>$scoid, 'attempt'=>$attempt, 'id'=>$cm->id));
+$PAGE->set_url('/mod/scorm/datamodel.php', array('scoid' => $scoid, 'attempt' => $attempt, 'id' => $cm->id));
require_login($course, false, $cm);
diff --git a/mod/scorm/grade.php b/mod/scorm/grade.php
index 631b214ba97..e9a94e9c689 100644
--- a/mod/scorm/grade.php
+++ b/mod/scorm/grade.php
@@ -31,11 +31,11 @@ if (! $cm = get_coursemodule_from_id('scorm', $id)) {
print_error('invalidcoursemodule');
}
-if (! $scorm = $DB->get_record('scorm', array('id'=>$cm->instance))) {
+if (! $scorm = $DB->get_record('scorm', array('id' => $cm->instance))) {
print_error('invalidcoursemodule');
}
-if (! $course = $DB->get_record('course', array('id'=> $scorm->course))) {
+if (! $course = $DB->get_record('course', array('id' => $scorm->course))) {
print_error('coursemisconf');
}
diff --git a/mod/scorm/index.php b/mod/scorm/index.php
index 95a65d7b858..506ef5dd2fb 100644
--- a/mod/scorm/index.php
+++ b/mod/scorm/index.php
@@ -19,10 +19,10 @@ require_once($CFG->dirroot.'/mod/scorm/locallib.php');
$id = required_param('id', PARAM_INT); // course id
-$PAGE->set_url('/mod/scorm/index.php', array('id'=>$id));
+$PAGE->set_url('/mod/scorm/index.php', array('id' => $id));
if (!empty($id)) {
- if (!$course = $DB->get_record('course', array('id'=>$id))) {
+ if (!$course = $DB->get_record('course', array('id' => $id))) {
print_error('invalidcourseid');
}
} else {
@@ -89,7 +89,7 @@ foreach ($scorms as $scorm) {
if (has_capability('mod/scorm:viewreport', $context)) {
$trackedusers = scorm_get_count_users($scorm->id, $scorm->groupingid);
if ($trackedusers > 0) {
- $reportshow = ''.get_string('viewallreports', 'scorm', $trackedusers).' ';
+ $reportshow = html_writer::link('report.php?id='.$scorm->coursemodule, get_string('viewallreports', 'scorm', $trackedusers)).html_writer::end_div();
} else {
$reportshow = get_string('noreports', 'scorm');
}
@@ -98,19 +98,19 @@ foreach ($scorms as $scorm) {
$report = scorm_grade_user($scorm, $USER->id);
$reportshow = get_string('score', 'scorm').": ".$report;
}
- $options = (object)array('noclean'=>true);
+ $options = (object)array('noclean' => true);
if (!$scorm->visible) {
- //Show dimmed if the mod is hidden
- $table->data[] = array ($tt, "coursemodule\">".format_string($scorm->name)." ",
+ // Show dimmed if the mod is hidden
+ $table->data[] = array ($tt, html_writer::link('view.php?id='.$scorm->coursemodule, format_string($scorm->name), array('class' => 'dimmed')),
format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
} else {
- //Show normal if the mod is visible
- $table->data[] = array ($tt, "coursemodule\">".format_string($scorm->name)." ",
+ // Show normal if the mod is visible
+ $table->data[] = array ($tt, html_writer::link('view.php?id='.$scorm->coursemodule, format_string($scorm->name)),
format_module_intro('scorm', $scorm, $scorm->coursemodule), $reportshow);
}
}
-echo " ";
+echo html_writer::empty_tag('br');
echo html_writer::table($table);
diff --git a/mod/scorm/lib.php b/mod/scorm/lib.php
index 7b13f0b2b3c..a2332e48b13 100644
--- a/mod/scorm/lib.php
+++ b/mod/scorm/lib.php
@@ -39,7 +39,7 @@ define('SCORM_NAV_DISABLED', 0);
define('SCORM_NAV_UNDER_CONTENT', 1);
define('SCORM_NAV_FLOATING', 2);
-//used to check what SCORM version is being used.
+// Used to check what SCORM version is being used.
define('SCORM_12', 1);
define('SCORM_13', 2);
define('SCORM_AICC', 3);
@@ -58,14 +58,14 @@ define('SCORM_DISPLAY_ATTEMPTSTATUS_ENTRY', 3);
* @param bool $with_strings (optional)
* @return array
*/
-function scorm_status_options($with_strings = false) {
- // Id's are important as they are bits
+function scorm_status_options($withstrings = false) {
+ // Id's are important as they are bits.
$options = array(
2 => 'passed',
4 => 'completed'
);
- if ($with_strings) {
+ if ($withstrings) {
foreach ($options as $key => $value) {
$options[$key] = get_string('completionstatus_'.$value, 'scorm');
}
@@ -119,10 +119,10 @@ function scorm_add_instance($scorm, $mform=null) {
$id = $DB->insert_record('scorm', $scorm);
// Update course module record - from now on this instance properly exists and all function may be used.
- $DB->set_field('course_modules', 'instance', $id, array('id'=>$cmid));
+ $DB->set_field('course_modules', 'instance', $id, array('id' => $cmid));
// Reload scorm instance.
- $record = $DB->get_record('scorm', array('id'=>$id));
+ $record = $DB->get_record('scorm', array('id' => $id));
// Store the package and verify.
if ($record->scormtype === SCORM_TYPE_LOCAL) {
@@ -238,9 +238,9 @@ function scorm_update_instance($scorm, $mform=null) {
$DB->update_record('scorm', $scorm);
- $scorm = $DB->get_record('scorm', array('id'=>$scorm->id));
+ $scorm = $DB->get_record('scorm', array('id' => $scorm->id));
- /// extra fields required in grade related functions
+ // Extra fields required in grade related functions.
$scorm->course = $courseid;
$scorm->idnumber = $cmidnumber;
$scorm->cmid = $cmid;
@@ -266,25 +266,25 @@ function scorm_update_instance($scorm, $mform=null) {
function scorm_delete_instance($id) {
global $CFG, $DB;
- if (! $scorm = $DB->get_record('scorm', array('id'=>$id))) {
+ if (! $scorm = $DB->get_record('scorm', array('id' => $id))) {
return false;
}
$result = true;
- // Delete any dependent records
- if (! $DB->delete_records('scorm_scoes_track', array('scormid'=>$scorm->id))) {
+ // Delete any dependent records.
+ if (! $DB->delete_records('scorm_scoes_track', array('scormid' => $scorm->id))) {
$result = false;
}
- if ($scoes = $DB->get_records('scorm_scoes', array('scorm'=>$scorm->id))) {
+ if ($scoes = $DB->get_records('scorm_scoes', array('scorm' => $scorm->id))) {
foreach ($scoes as $sco) {
- if (! $DB->delete_records('scorm_scoes_data', array('scoid'=>$sco->id))) {
+ if (! $DB->delete_records('scorm_scoes_data', array('scoid' => $sco->id))) {
$result = false;
}
}
- $DB->delete_records('scorm_scoes', array('scorm'=>$scorm->id));
+ $DB->delete_records('scorm_scoes', array('scorm' => $scorm->id));
}
- if (! $DB->delete_records('scorm', array('id'=>$scorm->id))) {
+ if (! $DB->delete_records('scorm', array('id' => $scorm->id))) {
$result = false;
}
@@ -338,9 +338,9 @@ function scorm_user_outline($course, $user, $mod, $scorm) {
$result = new stdClass();
$result->info = get_string('grade') . ': '. $grade->str_long_grade;
- //datesubmitted == time created. dategraded == time modified or time overridden
- //if grade was last modified by the user themselves use date graded. Otherwise use date submitted
- //TODO: move this copied & pasted code somewhere in the grades API. See MDL-26704
+ // Datesubmitted == time created. dategraded == time modified or time overridden
+ // if grade was last modified by the user themselves use date graded. Otherwise use date submitted.
+ // TODO: move this copied & pasted code somewhere in the grades API. See MDL-26704.
if ($grade->usermodified == $user->id || empty($grade->datesubmitted)) {
$result->time = $grade->dategraded;
} else {
@@ -375,7 +375,7 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
$sometoreport = false;
$report = '';
- // First Access and Last Access dates for SCOs
+ // First Access and Last Access dates for SCOs.
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
$timetracks = scorm_get_sco_runtime($scorm->id, false, $user->id);
$firstmodify = $timetracks->start;
@@ -401,52 +401,52 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
$org->identifier = '';
$orgs[] = $org;
}
- $report .= '
'."\n";
+ $report .= html_writer::start_div('mod-scorm');
foreach ($orgs as $org) {
$conditions = array();
$currentorg = '';
if (!empty($org->identifier)) {
- $report .= '
'.$org->title.'
';
+ $report .= html_writer::div($org->title, 'orgtitle');
$currentorg = $org->identifier;
$conditions['organization'] = $currentorg;
}
- $report .= "
";
+ $report .= html_writer::start_tag('ul', array('id' => '0', 'class' => $liststyle));
$conditions['scorm'] = $scorm->id;
if ($scoes = $DB->get_records('scorm_scoes', $conditions, "sortorder, id")) {
- // drop keys so that we can access array sequentially
+ // Drop keys so that we can access array sequentially.
$scoes = array_values($scoes);
- $level=0;
- $sublist=1;
- $parents[$level]='/';
+ $level = 0;
+ $sublist = 1;
+ $parents[$level] = '/';
foreach ($scoes as $pos => $sco) {
- if ($parents[$level]!=$sco->parent) {
- if ($level>0 && $parents[$level-1]==$sco->parent) {
- $report .= "\t\t \n";
+ if ($parents[$level] != $sco->parent) {
+ if ($level > 0 && $parents[$level - 1] == $sco->parent) {
+ $report .= html_writer::end_tag('ul').html_writer::end_tag('li');
$level--;
} else {
$i = $level;
$closelist = '';
while (($i > 0) && ($parents[$level] != $sco->parent)) {
- $closelist .= "\t\t\n";
+ $closelist .= html_writer::end_tag('ul').html_writer::end_tag('li');
$i--;
}
if (($i == 0) && ($sco->parent != $currentorg)) {
- $report .= "\t\t
\n";
+ $report .= html_writer::start_tag('li').html_writer::start_tag('ul', array('id' => $sublist, 'class' => $liststyle));
$level++;
} else {
$report .= $closelist;
$level = $i;
}
- $parents[$level]=$sco->parent;
+ $parents[$level] = $sco->parent;
}
}
- $report .= "\t\t";
- if (isset($scoes[$pos+1])) {
- $nextsco = $scoes[$pos+1];
+ $report .= html_writer::start_tag('li');
+ if (isset($scoes[$pos + 1])) {
+ $nextsco = $scoes[$pos + 1];
} else {
$nextsco = false;
}
- if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level==0) || (($level>0) && ($nextsco->parent == $sco->identifier)))) {
+ if (($nextsco !== false) && ($sco->parent != $nextsco->parent) && (($level == 0) || (($level > 0) && ($nextsco->parent == $sco->identifier)))) {
$sublist++;
} else {
$report .= $OUTPUT->spacer(array("height" => "12", "width" => "13"));
@@ -455,52 +455,53 @@ function scorm_user_complete($course, $user, $mod, $scorm) {
if ($sco->launch) {
$score = '';
$totaltime = '';
- if ($usertrack=scorm_get_tracks($sco->id, $user->id)) {
+ if ($usertrack = scorm_get_tracks($sco->id, $user->id)) {
if ($usertrack->status == '') {
$usertrack->status = 'notattempted';
}
$strstatus = get_string($usertrack->status, 'scorm');
- $report .= " ";
+ $report .= html_writer::img($OUTPUT->pix_url($usertrack->status, 'scorm'), $strstatus, array('title' => $strstatus));
} else {
if ($sco->scormtype == 'sco') {
- $report .= ' ';
+ $report .= html_writer::img($OUTPUT->pix_url('notattempted', 'scorm'), get_string('notattempted', 'scorm'),
+ array('title' => get_string('notattempted', 'scorm')));
} else {
- $report .= ' ';
+ $report .= html_writer::img($OUTPUT->pix_url('asset', 'scorm'), get_string('asset', 'scorm'), array('title' => get_string('asset', 'scorm')));
}
}
- $report .= " $sco->title $score$totaltime \n";
+ $report .= " $sco->title $score$totaltime".html_writer::end_tag('li');
if ($usertrack !== false) {
$sometoreport = true;
- $report .= "\t\t\t\n";
+ $report .= html_writer::start_tag('li').html_writer::start_tag('ul', array('class' => $liststyle));
foreach ($usertrack as $element => $value) {
if (substr($element, 0, 3) == 'cmi') {
- $report .= ''.$element.' => '.s($value).' ';
+ $report .= html_writer::tag('li', $element.' => '.s($value));
}
}
- $report .= "\t\t\t \n";
+ $report .= html_writer::end_tag('ul').html_writer::end_tag('li');
}
} else {
- $report .= " $sco->title \n";
+ $report .= " $sco->title".html_writer::end_tag('li');
}
}
- for ($i=0; $i<$level; $i++) {
- $report .= "\t\t\n";
+ for ($i = 0; $i < $level; $i++) {
+ $report .= html_writer::end_tag('ul').html_writer::end_tag('li');
}
}
- $report .= "\t
\n";
+ $report .= html_writer::end_tag('ul').html_writer::empty_tag('br');
}
- $report .= "
\n";
+ $report .= html_writer::end_div();
}
if ($sometoreport) {
if ($firstmodify < $now) {
$timeago = format_time($now - $firstmodify);
- echo get_string('firstaccess', 'scorm').': '.userdate($firstmodify).' ('.$timeago.") \n";
+ echo get_string('firstaccess', 'scorm').': '.userdate($firstmodify).' ('.$timeago.")".html_writer::empty_tag('br');
}
if ($lastmodify > 0) {
$timeago = format_time($now - $lastmodify);
- echo get_string('lastaccess', 'scorm').': '.userdate($lastmodify).' ('.$timeago.") \n";
+ echo get_string('lastaccess', 'scorm').': '.userdate($lastmodify).' ('.$timeago.")".html_writer::empty_tag('br');
}
- echo get_string('report', 'scorm').": \n";
+ echo get_string('report', 'scorm').":".html_writer::empty_tag('br');
echo $report;
} else {
print_string('noactivity', 'scorm');
@@ -547,7 +548,7 @@ function scorm_cron () {
// Now clear out AICC session table with old session data.
$cfgscorm = get_config('scorm');
if (!empty($cfgscorm->allowaicchacp)) {
- $expiretime = time() - ($cfgscorm->aicchacpkeepsessiondata*24*60*60);
+ $expiretime = time() - ($cfgscorm->aicchacpkeepsessiondata * 24 * 60 * 60);
$DB->delete_records_select('scorm_aicc_session', 'timemodified < ?', array($expiretime));
}
}
@@ -583,7 +584,7 @@ function scorm_get_user_grades($scorm, $userid=0) {
} else {
if (!$DB->get_records_select('scorm_scoes_track', "scormid=? AND userid=? GROUP BY userid", array($scorm->id, $userid), "", "userid,null")) {
- return false; //no attempt yet
+ return false; // No attempt yet.
}
$grades[$userid] = new stdClass();
$grades[$userid]->id = $userid;
@@ -609,14 +610,14 @@ function scorm_update_grades($scorm, $userid=0, $nullifnone=true) {
if ($grades = scorm_get_user_grades($scorm, $userid)) {
scorm_grade_item_update($scorm, $grades);
- //set complete
+ // Set complete.
scorm_set_completion($scorm, $userid, COMPLETION_COMPLETE, $grades);
} else if ($userid and $nullifnone) {
$grade = new stdClass();
$grade->userid = $userid;
$grade->rawgrade = null;
scorm_grade_item_update($scorm, $grade);
- //set incomplete.
+ // Set incomplete.
scorm_set_completion($scorm, $userid, COMPLETION_INCOMPLETE);
} else {
scorm_grade_item_update($scorm);
@@ -642,10 +643,10 @@ function scorm_upgrade_grades() {
$rs = $DB->get_recordset_sql($sql);
if ($rs->valid()) {
$pbar = new progress_bar('scormupgradegrades', 500, true);
- $i=0;
+ $i = 0;
foreach ($rs as $scorm) {
$i++;
- upgrade_set_timeout(60*5); // set up timeout, may also abort execution
+ upgrade_set_timeout(60 * 5); // Set up timeout, may also abort execution.
scorm_update_grades($scorm, 0, false);
$pbar->update($i, $count, "Updating Scorm grades ($i/$count).");
}
@@ -666,11 +667,11 @@ function scorm_upgrade_grades() {
function scorm_grade_item_update($scorm, $grades=null) {
global $CFG, $DB;
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
- if (!function_exists('grade_update')) { //workaround for buggy PHP versions
+ if (!function_exists('grade_update')) { // Workaround for buggy PHP versions.
require_once($CFG->libdir.'/gradelib.php');
}
- $params = array('itemname'=>$scorm->name);
+ $params = array('itemname' => $scorm->name);
if (isset($scorm->cmidnumber)) {
$params['idnumber'] = $scorm->cmidnumber;
}
@@ -689,7 +690,7 @@ function scorm_grade_item_update($scorm, $grades=null) {
$params['grademin'] = 0;
}
- if ($grades === 'reset') {
+ if ($grades === 'reset') {
$params['reset'] = true;
$grades = null;
}
@@ -708,7 +709,7 @@ function scorm_grade_item_delete($scorm) {
global $CFG;
require_once($CFG->libdir.'/gradelib.php');
- return grade_update('mod/scorm', $scorm->course, 'mod', 'scorm', $scorm->id, 0, null, array('deleted'=>1));
+ return grade_update('mod/scorm', $scorm->course, 'mod', 'scorm', $scorm->id, 0, null, array('deleted' => 1));
}
/**
@@ -744,12 +745,12 @@ function scorm_get_post_actions() {
* @return object $scorm
*/
function scorm_option2text($scorm) {
- $scorm_popoup_options = scorm_get_popup_options_array();
+ $scormpopoupoptions = scorm_get_popup_options_array();
if (isset($scorm->popup)) {
if ($scorm->popup == 1) {
$optionlist = array();
- foreach ($scorm_popoup_options as $name => $option) {
+ foreach ($scormpopoupoptions as $name => $option) {
if (isset($scorm->$name)) {
$optionlist[] = $name.'='.$scorm->$name;
} else {
@@ -784,7 +785,7 @@ function scorm_reset_course_form_definition(&$mform) {
* @return array
*/
function scorm_reset_course_form_defaults($course) {
- return array('reset_scorm'=>1);
+ return array('reset_scorm' => 1);
}
/**
@@ -831,15 +832,15 @@ function scorm_reset_userdata($data) {
$DB->delete_records_select('scorm_scoes_track', "scormid IN ($scormssql)", array($data->courseid));
- // remove all grades from gradebook
+ // Remove all grades from gradebook.
if (empty($data->reset_gradebook_grades)) {
scorm_reset_gradebook($data->courseid);
}
- $status[] = array('component'=>$componentstr, 'item'=>get_string('deleteallattempts', 'scorm'), 'error'=>false);
+ $status[] = array('component' => $componentstr, 'item' => get_string('deleteallattempts', 'scorm'), 'error' => false);
}
- // no dates to shift here
+ // No dates to shift here.
return $status;
}
@@ -891,7 +892,7 @@ function scorm_get_file_info($browser, $areas, $course, $cm, $context, $filearea
return null;
}
- // no writing for now!
+ // No writing for now!
$fs = get_file_storage();
@@ -905,7 +906,7 @@ function scorm_get_file_info($browser, $areas, $course, $cm, $context, $filearea
if ($filepath === '/' and $filename === '.') {
$storedfile = new virtual_root_file($context->id, 'mod_scorm', 'content', 0);
} else {
- // not found
+ // Not found.
return null;
}
}
@@ -921,7 +922,7 @@ function scorm_get_file_info($browser, $areas, $course, $cm, $context, $filearea
if ($filepath === '/' and $filename === '.') {
$storedfile = new virtual_root_file($context->id, 'mod_scorm', 'package', 0);
} else {
- // not found
+ // Not found.
return null;
}
}
@@ -959,7 +960,7 @@ function scorm_pluginfile($course, $cm, $context, $filearea, $args, $forcedownlo
$lifetime = null;
if ($filearea === 'content') {
- $revision = (int)array_shift($args); // prevents caching problems - ignored here
+ $revision = (int)array_shift($args); // Prevents caching problems - ignored here.
$relativepath = implode('/', $args);
$fullpath = "/$context->id/mod_scorm/content/0/$relativepath";
// TODO: add any other access restrictions here if needed!
@@ -970,7 +971,7 @@ function scorm_pluginfile($course, $cm, $context, $filearea, $args, $forcedownlo
}
$relativepath = implode('/', $args);
$fullpath = "/$context->id/mod_scorm/package/0/$relativepath";
- $lifetime = 0; // no caching here
+ $lifetime = 0; // No caching here.
} else if ($filearea === 'imsmanifest') { // This isn't a real filearea, it's a url parameter for this type of package.
$revision = (int)array_shift($args); // Prevents caching problems - ignored here.
@@ -994,14 +995,14 @@ function scorm_pluginfile($course, $cm, $context, $filearea, $args, $forcedownlo
$fs = get_file_storage();
if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
- if ($filearea === 'content') { //return file not found straight away to improve performance.
+ if ($filearea === 'content') { // Return file not found straight away to improve performance.
send_header_404();
die;
}
return false;
}
- // finally send the file
+ // Finally send the file.
send_stored_file($file, $lifetime, 0, false, $options);
}
@@ -1120,19 +1121,18 @@ function scorm_print_overview($courses, &$htmlarray) {
$showattemptstatus = true;
}
if ($showattemptstatus || !empty($isopen) || !empty($scorm->timeclose)) {
- $str = '';
+ $str = html_writer::start_div('scorm overview').
+ html_writer::div($strscorm. ': '.
+ html_writer::link($CFG->wwwroot.'/mod/scorm/view.php?id='.$scorm->coursemodule, $scorm->name,
+ array('title' => $strscorm, 'class' => $scorm->visible ? '' : 'dimmed')), 'name');
if ($scorm->timeclose) {
- $str .= '
'.$strduedate.': '.userdate($scorm->timeclose).'
';
+ $str .= html_writer::div($strduedate.': '.userdate($scorm->timeclose), 'info');
}
if ($showattemptstatus) {
require_once($CFG->dirroot.'/mod/scorm/locallib.php');
- $str .= '
'.scorm_get_attempt_status($USER, $scorm).'
';
+ $str .= html_writer::div(scorm_get_attempt_status($USER, $scorm), 'details');
}
- $str .= '
';
+ $str .= html_writer::end_div();
if (empty($htmlarray[$scorm->course]['scorm'])) {
$htmlarray[$scorm->course]['scorm'] = $str;
} else {
@@ -1149,8 +1149,8 @@ function scorm_print_overview($courses, &$htmlarray) {
* @param stdClass $currentcontext Current context of block
*/
function scorm_page_type_list($pagetype, $parentcontext, $currentcontext) {
- $module_pagetype = array('mod-scorm-*'=>get_string('page-mod-scorm-x', 'scorm'));
- return $module_pagetype;
+ $modulepagetype = array('mod-scorm-*' => get_string('page-mod-scorm-x', 'scorm'));
+ return $modulepagetype;
}
/**
@@ -1161,7 +1161,7 @@ function scorm_page_type_list($pagetype, $parentcontext, $currentcontext) {
*/
function scorm_version_check($scormversion, $version='') {
$scormversion = trim(strtolower($scormversion));
- if (empty($version) || $version==SCORM_12) {
+ if (empty($version) || $version == SCORM_12) {
if ($scormversion == 'scorm_12' || $scormversion == 'scorm_1.2') {
return SCORM_12;
}
@@ -1204,7 +1204,7 @@ function scorm_get_completion_state($course, $cm, $userid, $type) {
$result = $type;
- // Get scorm
+ // Get scorm.
if (!$scorm = $DB->get_record('scorm', array('id' => $cm->instance))) {
print_error('cannotfindscorm');
}
@@ -1241,10 +1241,10 @@ function scorm_get_completion_state($course, $cm, $userid, $type) {
}
}
- // Check for status
+ // Check for status.
if ($scorm->completionstatusrequired !== null) {
- // Get status
+ // Get status.
$statuses = array_flip(scorm_status_options());
$nstatus = 0;
@@ -1266,7 +1266,7 @@ function scorm_get_completion_state($course, $cm, $userid, $type) {
}
- // Check for score
+ // Check for score.
if ($scorm->completionscorerequired !== null) {
$maxscore = -1;
@@ -1346,7 +1346,7 @@ function scorm_set_completion($scorm, $userid, $completionstate = COMPLETION_COM
$course->id = $scorm->course;
$completion = new completion_info($course);
- // Check if completion is enabled site-wide, or for the course
+ // Check if completion is enabled site-wide, or for the course.
if (!$completion->is_enabled()) {
return;
}
@@ -1356,7 +1356,7 @@ function scorm_set_completion($scorm, $userid, $completionstate = COMPLETION_COM
return;
}
- if (empty($userid)) { //we need to get all the relevant users from $grades param.
+ if (empty($userid)) { // We need to get all the relevant users from $grades param.
foreach ($grades as $grade) {
$completion->update_state($cm, $completionstate, $grade->userid);
}
diff --git a/mod/scorm/loadSCO.php b/mod/scorm/loadSCO.php
index 41466a147b0..39eaa3b2d8b 100644
--- a/mod/scorm/loadSCO.php
+++ b/mod/scorm/loadSCO.php
@@ -27,17 +27,17 @@ if (!empty($id)) {
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
print_error('invalidcoursemodule');
}
- if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
+ if (! $course = $DB->get_record('course', array('id' => $cm->course))) {
print_error('coursemisconf');
}
- if (! $scorm = $DB->get_record('scorm', array('id'=>$cm->instance))) {
+ 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))) {
+ if (! $scorm = $DB->get_record('scorm', array('id' => $a))) {
print_error('coursemisconf');
}
- if (! $course = $DB->get_record('course', array('id'=>$scorm->course))) {
+ if (! $course = $DB->get_record('course', array('id' => $scorm->course))) {
print_error('coursemisconf');
}
if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
@@ -47,7 +47,7 @@ if (!empty($id)) {
print_error('missingparameter');
}
-$PAGE->set_url('/mod/scorm/loadSCO.php', array('scoid'=>$scoid, 'id'=>$cm->id));
+$PAGE->set_url('/mod/scorm/loadSCO.php', array('scoid' => $scoid, 'id' => $cm->id));
if (!isloggedin()) { // Prevent login page from being shown in iframe.
// Using simple html instead of exceptions here as shown inside iframe/object.
@@ -60,9 +60,9 @@ if (!isloggedin()) { // Prevent login page from being shown in iframe.
require_login($course, false, $cm, false); // Call require_login anyway to set up globals correctly.
-//check if scorm closed
+// check if scorm closed
$timenow = time();
-if ($scorm->timeclose !=0) {
+if ($scorm->timeclose != 0) {
if ($scorm->timeopen > $timenow) {
print_error('notopenyet', 'scorm', null, userdate($scorm->timeopen));
} else if ($timenow > $scorm->timeclose) {
@@ -104,7 +104,7 @@ if (!isset($sco)) {
if ($sco->scormtype == 'asset') {
$attempt = scorm_get_last_attempt($scorm->id, $USER->id);
- $element = (scorm_version_check($scorm->version, SCORM_13)) ? 'cmi.completion_status':'cmi.core.lesson_status';
+ $element = (scorm_version_check($scorm->version, SCORM_13)) ? 'cmi.completion_status' : 'cmi.core.lesson_status';
$value = 'completed';
$result = scorm_insert_track($USER->id, $scorm->id, $sco->id, $attempt, $element, $value);
}
@@ -127,15 +127,15 @@ if ((isset($sco->parameters) && (!empty($sco->parameters))) || ($version == 'AIC
if ($version == 'AICC') {
require_once("$CFG->dirroot/mod/scorm/datamodels/aicclib.php");
- $aicc_sid = scorm_aicc_get_hacp_session($scorm->id);
- if (empty($aicc_sid)) {
- $aicc_sid = sesskey();
+ $aiccsid = scorm_aicc_get_hacp_session($scorm->id);
+ if (empty($aiccsid)) {
+ $aiccsid = sesskey();
}
- $sco_params = '';
+ $scoparams = '';
if (isset($sco->parameters) && (!empty($sco->parameters))) {
- $sco_params = '&'. $sco->parameters;
+ $scoparams = '&'. $sco->parameters;
}
- $launcher = $sco->launch.$connector.'aicc_sid='.$aicc_sid.'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$sco_params;
+ $launcher = $sco->launch.$connector.'aicc_sid='.$aiccsid.'&aicc_url='.$CFG->wwwroot.'/mod/scorm/aicc.php'.$scoparams;
} else {
if (isset($sco->parameters) && (!empty($sco->parameters))) {
$launcher = $sco->launch.$connector.$sco->parameters;
@@ -145,7 +145,7 @@ if ($version == 'AICC') {
}
if (scorm_external_link($sco->launch)) {
- //TODO: does this happen?
+ // TODO: does this happen?
$result = $launcher;
} else if ($scorm->scormtype === SCORM_TYPE_EXTERNAL) {
// Remote learning activity.
@@ -176,80 +176,81 @@ if ($sco->scormtype == 'asset') {
// HTTP 302 Found => Moved Temporarily.
header('Location: ' . $result);
// Provide a short feedback in case of slow network connection.
- echo '' . get_string('activitypleasewait', 'scorm'). '
';
+ echo html_writer::start_tag('html');
+ echo html_writer::tag('body', html_writer::tag('p', get_string('activitypleasewait', 'scorm')));
+ echo html_writer::end_tag('html');
exit;
}
// We expect a SCO: select which API are we looking for.
-$LMS_api = (scorm_version_check($scorm->version, SCORM_12) || empty($scorm->version)) ? 'API' : 'API_1484_11';
+$LMSapi = (scorm_version_check($scorm->version, SCORM_12) || empty($scorm->version)) ? 'API' : 'API_1484_11';
+echo html_writer::start_tag('html');
+echo html_writer::start_tag('head');
+echo html_writer::tag('title', 'LoadSCO');
?>
-
-
- LoadSCO
-
-
-
-
-
-
-
-
-
+ else {
+ document.body.innerHTML = " . '>
";
+ var e = document.getElementById("countdown");
+ var cSeconds = parseInt(e.innerHTML);
+ var timer = setInterval(function() {
+ if( cSeconds && myGetAPIHandle() == null ) {
+ e.innerHTML = --cSeconds;
+ } else {
+ clearInterval(timer);
+ document.body.innerHTML = "
";
+ location = "";
+ }
+ }, 1000);
+ }
+ }
+ //]]>
+
+
+
+
+ "doredirect();"));
+echo html_writer::end_tag('html');
diff --git a/mod/scorm/loaddatamodel.php b/mod/scorm/loaddatamodel.php
index f9d6ba1bff6..dea95f686da 100644
--- a/mod/scorm/loaddatamodel.php
+++ b/mod/scorm/loaddatamodel.php
@@ -34,17 +34,17 @@ $attempt = required_param('attempt', PARAM_INT); // new attempt.
if (!empty($id)) {
$cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST);
- $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
- $scorm = $DB->get_record('scorm', array('id'=>$cm->instance), '*', MUST_EXIST);
+ $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+ $scorm = $DB->get_record('scorm', array('id' => $cm->instance), '*', MUST_EXIST);
} else if (!empty($a)) {
- $scorm = $DB->get_record('scorm', array('id'=>$a), '*', MUST_EXIST);
- $course = $DB->get_record('course', array('id'=>$scorm->course), '*', MUST_EXIST);
+ $scorm = $DB->get_record('scorm', array('id' => $a), '*', MUST_EXIST);
+ $course = $DB->get_record('course', array('id' => $scorm->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id, false, MUST_EXIST);
} else {
print_error('missingparameter');
}
-$PAGE->set_url('/mod/scorm/loaddatamodel.php', array('scoid'=>$scoid, 'id'=>$cm->id));
+$PAGE->set_url('/mod/scorm/loaddatamodel.php', array('scoid' => $scoid, 'id' => $cm->id));
require_login($course, false, $cm);
diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php
index 20f81301364..5eba60a94a4 100644
--- a/mod/scorm/locallib.php
+++ b/mod/scorm/locallib.php
@@ -25,7 +25,7 @@
require_once("$CFG->dirroot/mod/scorm/lib.php");
require_once("$CFG->libdir/filelib.php");
-/// Constants and settings for module scorm
+// Constants and settings for module scorm.
define('SCORM_UPDATE_NEVER', '0');
define('SCORM_UPDATE_EVERYDAY', '2');
define('SCORM_UPDATE_EVERYTIME', '3');
@@ -51,7 +51,7 @@ define('LASTATTEMPT', '3');
define('TOCJSLINK', 1);
define('TOCFULLURL', 2);
-/// Local Library of functions for module scorm
+// Local Library of functions for module scorm.
/**
* @package mod_scorm
@@ -81,12 +81,12 @@ class scorm_package_file_info extends file_info_stored {
function scorm_get_popup_options_array() {
$cfgscorm = get_config('scorm');
- return array('scrollbars'=> isset($cfgscorm->scrollbars) ? $cfgscorm->scrollbars : 0,
- 'directories'=> isset($cfgscorm->directories) ? $cfgscorm->directories : 0,
- 'location'=> isset($cfgscorm->location) ? $cfgscorm->location : 0,
- 'menubar'=> isset($cfgscorm->menubar) ? $cfgscorm->menubar : 0,
- 'toolbar'=> isset($cfgscorm->toolbar) ? $cfgscorm->toolbar : 0,
- 'status'=> isset($cfgscorm->status) ? $cfgscorm->status : 0);
+ return array('scrollbars' => isset($cfgscorm->scrollbars) ? $cfgscorm->scrollbars : 0,
+ 'directories' => isset($cfgscorm->directories) ? $cfgscorm->directories : 0,
+ 'location' => isset($cfgscorm->location) ? $cfgscorm->location : 0,
+ 'menubar' => isset($cfgscorm->menubar) ? $cfgscorm->menubar : 0,
+ 'toolbar' => isset($cfgscorm->toolbar) ? $cfgscorm->toolbar : 0,
+ 'status' => isset($cfgscorm->status) ? $cfgscorm->status : 0);
}
/**
@@ -177,7 +177,7 @@ function scorm_get_attempts_array() {
$attempts = array(0 => get_string('nolimit', 'scorm'),
1 => get_string('attempt1', 'scorm'));
- for ($i=2; $i<=6; $i++) {
+ for ($i = 2; $i <= 6; $i++) {
$attempts[$i] = get_string('attemptsx', 'scorm', $i);
}
@@ -205,7 +205,7 @@ function scorm_get_attemptstatus_array() {
*/
function scorm_parse($scorm, $full) {
global $CFG, $DB;
- $cfg_scorm = get_config('scorm');
+ $cfgscorm = get_config('scorm');
if (!isset($scorm->cmid)) {
$cm = get_coursemodule_from_instance('scorm', $scorm->id);
@@ -233,14 +233,15 @@ function scorm_parse($scorm, $full) {
$newhash = null;
}
} else {
- if (!$cfg_scorm->allowtypelocalsync) {
- // sorry - localsync disabled
+ if (!$cfgscorm->allowtypelocalsync) {
+ // Sorry - localsync disabled.
return;
}
if ($scorm->reference !== '' and (!$full or $scorm->sha1hash !== sha1($scorm->reference))) {
$fs->delete_area_files($context->id, 'mod_scorm', 'package');
- $file_record = array('contextid'=>$context->id, 'component'=>'mod_scorm', 'filearea'=>'package', 'itemid'=>0, 'filepath'=>'/');
- if ($packagefile = $fs->create_file_from_url($file_record, $scorm->reference, array('calctimeout' => true))) {
+ $filerecord = array('contextid' => $context->id, 'component' => 'mod_scorm', 'filearea' => 'package',
+ 'itemid' => 0, 'filepath' => '/');
+ if ($packagefile = $fs->create_file_from_url($filerecord, $scorm->reference, array('calctimeout' => true))) {
$newhash = sha1($scorm->reference);
} else {
$newhash = null;
@@ -256,7 +257,7 @@ function scorm_parse($scorm, $full) {
return;
}
} else if (strpos($scorm->version, 'AICC') !== false) {
- // TODO: add more sanity checks - something really exists in scorm_content area
+ // TODO: add more sanity checks - something really exists in scorm_content area.
return;
}
}
@@ -280,36 +281,36 @@ function scorm_parse($scorm, $full) {
} else if ($manifest = $fs->get_file($context->id, 'mod_scorm', 'content', 0, '/', 'imsmanifest.xml')) {
require_once("$CFG->dirroot/mod/scorm/datamodels/scormlib.php");
- // SCORM
+ // SCORM.
if (!scorm_parse_scorm($scorm, $manifest)) {
$scorm->version = 'ERROR';
}
} else {
require_once("$CFG->dirroot/mod/scorm/datamodels/aicclib.php");
- // AICC
+ // AICC.
if (!scorm_parse_aicc($scorm)) {
$scorm->version = 'ERROR';
}
$scorm->version = 'AICC';
}
- } else if ($scorm->scormtype === SCORM_TYPE_EXTERNAL and $cfg_scorm->allowtypeexternal) {
+ } else if ($scorm->scormtype === SCORM_TYPE_EXTERNAL and $cfgscorm->allowtypeexternal) {
require_once("$CFG->dirroot/mod/scorm/datamodels/scormlib.php");
- // SCORM only, AICC can not be external
+ // SCORM only, AICC can not be external.
if (!scorm_parse_scorm($scorm, $scorm->reference)) {
$scorm->version = 'ERROR';
}
$newhash = sha1($scorm->reference);
- } else if ($scorm->scormtype === SCORM_TYPE_AICCURL and $cfg_scorm->allowtypeexternalaicc) {
+ } else if ($scorm->scormtype === SCORM_TYPE_AICCURL and $cfgscorm->allowtypeexternalaicc) {
require_once("$CFG->dirroot/mod/scorm/datamodels/aicclib.php");
- // AICC
+ // AICC.
if (!scorm_parse_aicc($scorm)) {
$scorm->version = 'ERROR';
}
$scorm->version = 'AICC';
} else {
- // sorry, disabled type
+ // Sorry, disabled type.
return;
}
@@ -341,14 +342,14 @@ 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://') {
@@ -370,13 +371,13 @@ function scorm_external_link($link) {
function scorm_get_sco($id, $what=SCO_ALL) {
global $DB;
- if ($sco = $DB->get_record('scorm_scoes', array('id'=>$id))) {
+ if ($sco = $DB->get_record('scorm_scoes', array('id' => $id))) {
$sco = ($what == SCO_DATA) ? new stdClass() : $sco;
- if (($what != SCO_ONLY) && ($scodatas = $DB->get_records('scorm_scoes_data', array('scoid'=>$id)))) {
+ if (($what != SCO_ONLY) && ($scodatas = $DB->get_records('scorm_scoes_data', array('scoid' => $id)))) {
foreach ($scodatas as $scodata) {
$sco->{$scodata->name} = $scodata->value;
}
- } else if (($what != SCO_ONLY) && (!($scodatas = $DB->get_records('scorm_scoes_data', array('scoid'=>$id))))) {
+ } else if (($what != SCO_ONLY) && (!($scodatas = $DB->get_records('scorm_scoes_data', array('scoid' => $id))))) {
$sco->parameters = '';
}
return $sco;
@@ -395,7 +396,7 @@ function scorm_get_sco($id, $what=SCO_ALL) {
function scorm_get_scoes($id, $organisation=false) {
global $DB;
- $queryarray = array('scorm'=>$id);
+ $queryarray = array('scorm' => $id);
if (!empty($organisation)) {
$queryarray['organization'] = $organisation;
}
@@ -403,7 +404,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;
}
@@ -421,14 +422,18 @@ function scorm_insert_track($userid, $scormid, $scoid, $attempt, $element, $valu
$id = null;
if ($forcecompleted) {
- //TODO - this could be broadened to encompass SCORM 2004 in future
+ // 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);
@@ -558,14 +563,14 @@ function scorm_get_tracks($scoid, $userid, $attempt='') {
global $DB;
if (empty($attempt)) {
- if ($scormid = $DB->get_field('scorm_scoes', 'scorm', array('id'=>$scoid))) {
+ 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 = scorm_format_interactions($tracks);
$usertrack->userid = $userid;
$usertrack->scoid = $scoid;
@@ -669,14 +674,14 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1) {
}
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++;
}
- if (!empty($userdata->score_raw) || (isset($scorm->type) && $scorm->type=='sco' && isset($userdata->score_raw))) {
+ if (!empty($userdata->score_raw) || (isset($scorm->type) && $scorm->type == 'sco' && isset($userdata->score_raw))) {
$attemptscore->values++;
$attemptscore->sum += $userdata->score_raw;
- $attemptscore->max = ($userdata->score_raw > $attemptscore->max)?$userdata->score_raw:$attemptscore->max;
+ $attemptscore->max = ($userdata->score_raw > $attemptscore->max) ? $userdata->score_raw : $attemptscore->max;
if (isset($userdata->timemodified) && ($userdata->timemodified > $attemptscore->lastmodify)) {
$attemptscore->lastmodify = $userdata->timemodified;
} else {
@@ -691,7 +696,7 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1) {
break;
case GRADEAVERAGE:
if ($attemptscore->values > 0) {
- $score = $attemptscore->sum/$attemptscore->values;
+ $score = $attemptscore->sum / $attemptscore->values;
} else {
$score = 0;
}
@@ -703,7 +708,7 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1) {
$score = $attemptscore->scoes;
break;
default:
- $score = $attemptscore->max; // Remote Learner GRADEHIGHEST is default
+ $score = $attemptscore->max; // Remote Learner GRADEHIGHEST is default.
}
return $score;
@@ -711,7 +716,7 @@ function scorm_grade_user_attempt($scorm, $userid, $attempt=1) {
function scorm_grade_user($scorm, $userid) {
- // ensure we dont grade user beyond $scorm->maxattempt settings
+ // Ensure we dont grade user beyond $scorm->maxattempt settings.
$lastattempt = scorm_get_last_attempt($scorm->id, $userid);
if ($scorm->maxattempt != 0 && $lastattempt >= $scorm->maxattempt) {
$lastattempt = $scorm->maxattempt;
@@ -728,7 +733,7 @@ function scorm_grade_user($scorm, $userid) {
$maxscore = 0;
for ($attempt = 1; $attempt <= $lastattempt; $attempt++) {
$attemptscore = scorm_grade_user_attempt($scorm, $userid, $attempt);
- $maxscore = $attemptscore > $maxscore ? $attemptscore: $maxscore;
+ $maxscore = $attemptscore > $maxscore ? $attemptscore : $maxscore;
}
return $maxscore;
@@ -775,7 +780,7 @@ function scorm_count_launchable($scormid, $organization='') {
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.
$sql = "SELECT MAX(attempt)
FROM {scorm_scoes_track}
WHERE userid = ? AND scormid = ?";
@@ -798,7 +803,7 @@ function scorm_get_last_attempt($scormid, $userid) {
function scorm_get_last_completed_attempt($scormid, $userid) {
global $DB;
- /// Find the last completed attempt number for the given user id and scorm id
+ // Find the last completed attempt number for the given user id and scorm id.
$sql = "SELECT MAX(attempt)
FROM {scorm_scoes_track}
WHERE userid = ? AND scormid = ?
@@ -841,9 +846,7 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
if ($scorm->displaycoursestructure == 1) {
echo $OUTPUT->box_start('generalbox boxaligncenter toc', 'toc');
- ?>
-
- launch;
@@ -868,7 +871,7 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
}
}
- $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')) {
$scorm->version = 'scorm_12';
}
@@ -877,51 +880,49 @@ function scorm_view_display ($user, $scorm, $action, $cm) {
$result = scorm_get_toc($user, $scorm, $cm->id, TOCFULLURL, $orgidentifier);
$incomplete = $result->incomplete;
- // do we want the TOC to be displayed?
+ // Do we want the TOC to be displayed?
if ($scorm->displaycoursestructure == 1) {
echo $result->toc;
echo $OUTPUT->box_end();
}
- // is this the first attempt ?
+ // Is this the first attempt ?
$attemptcount = scorm_get_attempt_count($user->id, $scorm);
- // do not give the player launch FORM if the SCORM object is locked after the final attempt
+ // Do not give the player launch FORM if the SCORM object is locked after the final attempt.
if ($scorm->lastattemptlock == 0 || $result->attemptleft > 0) {
- ?>
-
-
-
- 'hidden', 'name' => 'scoid', 'value' => $scorm->launch));
+ echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'cm', 'value' => $cm->id));
+ echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'currentorg', 'value' => $orgidentifier));
+ echo html_writer::empty_tag('input', array('type' => 'submit', 'value' => get_string('enter', 'scorm')));
+ echo html_writer::end_tag('form');
+ echo html_writer::end_div();
}
}
@@ -930,7 +931,7 @@ function scorm_simple_play($scorm, $user, $context, $cmid) {
$result = false;
- if (has_capability('mod/scorm:viewreport', $context)) { //if this user can view reports, don't skipview so they can see links to reports.
+ if (has_capability('mod/scorm:viewreport', $context)) { // If this user can view reports, don't skipview so they can see links to reports.
return $result;
}
@@ -952,13 +953,13 @@ function scorm_simple_play($scorm, $user, $context, $cmid) {
if ($scorm->skipview >= SCORM_SKIPVIEW_FIRST) {
$sco = current($scoes);
$url = new moodle_url('/mod/scorm/player.php', array('a' => $scorm->id,
- 'currentorg'=>$orgidentifier,
- 'scoid'=>$sco->id));
+ 'currentorg' => $orgidentifier,
+ 'scoid' => $sco->id));
if ($scorm->skipview == SCORM_SKIPVIEW_ALWAYS || !scorm_has_tracks($scorm->id, $user->id)) {
if (!empty($scorm->forcenewattempt)) {
$result = scorm_get_toc($user, $scorm, $cmid, TOCFULLURL, $orgidentifier);
if ($result->incomplete === false) {
- $url->param('newattempt','on');
+ $url->param('newattempt', 'on');
}
}
redirect($url);
@@ -995,34 +996,34 @@ function scorm_get_count_users($scormid, $groupingid=null) {
*
* @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 string $elementname 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
+function scorm_reconstitute_array_element($sversion, $userdata, $elementname, $children) {
+ // Reconstitute comments_from_learner and comments_from_lms.
$current = '';
- $current_subelement = '';
- $current_sub = '';
+ $currentsubelement = '';
+ $currentsub = '';
$count = 0;
- $count_sub = 0;
+ $countsub = 0;
$scormseperator = '_';
- if (scorm_version_check($sversion, SCORM_13)) { //scorm 1.3 elements use a . instead of an _
+ if (scorm_version_check($sversion, SCORM_13)) { // Scorm 1.3 elements use a . instead of an _ .
$scormseperator = '.';
}
- // filter out the ones we want
- $element_list = array();
+ // Filter out the ones we want.
+ $elementlist = array();
foreach ($userdata as $element => $value) {
- if (substr($element, 0, strlen($element_name)) == $element_name) {
- $element_list[$element] = $value;
+ if (substr($element, 0, strlen($elementname)) == $elementname) {
+ $elementlist[$element] = $value;
}
}
- // sort elements in .n array order
- uksort($element_list, "scorm_element_cmp");
+ // Sort elements in .n array order.
+ uksort($elementlist, "scorm_element_cmp");
- // generate JavaScript
- foreach ($element_list as $element => $value) {
+ // Generate JavaScript.
+ foreach ($elementlist as $element => $value) {
if (scorm_version_check($sversion, SCORM_13)) {
$element = preg_replace('/\.(\d+)\./', ".N\$1.", $element);
preg_match('/\.(N\d+)\./', $element, $matches);
@@ -1031,15 +1032,15 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
preg_match('/\_(\d+)\./', $element, $matches);
}
if (count($matches) > 0 && $current != $matches[1]) {
- if ($count_sub > 0) {
- echo ' '.$element_name.$scormseperator.$current.'.'.$current_subelement.'._count = '.$count_sub.";\n";
+ if ($countsub > 0) {
+ echo ' '.$elementname.$scormseperator.$current.'.'.$currentsubelement.'._count = '.$countsub.";\n";
}
$current = $matches[1];
$count++;
- $current_subelement = '';
- $current_sub = '';
- $count_sub = 0;
- $end = strpos($element, $matches[1])+strlen($matches[1]);
+ $currentsubelement = '';
+ $currentsub = '';
+ $countsub = 0;
+ $end = strpos($element, $matches[1]) + strlen($matches[1]);
$subelement = substr($element, 0, $end);
echo ' '.$subelement." = new Object();\n";
// now add the children
@@ -1049,7 +1050,7 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
}
}
- // now - flesh out the second level elements if there are any
+ // Now - flesh out the second level elements if there are any.
if (scorm_version_check($sversion, SCORM_13)) {
$element = preg_replace('/(.*?\.N\d+\..*?)\.(\d+)\./', "\$1.N\$2.", $element);
preg_match('/.*?\.N\d+\.(.*?)\.(N\d+)\./', $element, $matches);
@@ -1058,35 +1059,35 @@ function scorm_reconstitute_array_element($sversion, $userdata, $element_name, $
preg_match('/.*?\_\d+\.(.*?)\_(\d+)\./', $element, $matches);
}
- // check the sub element type
- if (count($matches) > 0 && $current_subelement != $matches[1]) {
- if ($count_sub > 0) {
- echo ' '.$element_name.$scormseperator.$current.'.'.$current_subelement.'._count = '.$count_sub.";\n";
+ // Check the sub element type.
+ if (count($matches) > 0 && $currentsubelement != $matches[1]) {
+ if ($countsub > 0) {
+ echo ' '.$elementname.$scormseperator.$current.'.'.$currentsubelement.'._count = '.$countsub.";\n";
}
- $current_subelement = $matches[1];
- $current_sub = '';
- $count_sub = 0;
- $end = strpos($element, $matches[1])+strlen($matches[1]);
+ $currentsubelement = $matches[1];
+ $currentsub = '';
+ $countsub = 0;
+ $end = strpos($element, $matches[1]) + strlen($matches[1]);
$subelement = substr($element, 0, $end);
echo ' '.$subelement." = new Object();\n";
}
- // now check the subelement subscript
- if (count($matches) > 0 && $current_sub != $matches[2]) {
- $current_sub = $matches[2];
- $count_sub++;
- $end = strrpos($element, $matches[2])+strlen($matches[2]);
+ // Now check the subelement subscript.
+ if (count($matches) > 0 && $currentsub != $matches[2]) {
+ $currentsub = $matches[2];
+ $countsub++;
+ $end = strrpos($element, $matches[2]) + strlen($matches[2]);
$subelement = substr($element, 0, $end);
echo ' '.$subelement." = new Object();\n";
}
echo ' '.$element.' = \''.$value."';\n";
}
- if ($count_sub > 0) {
- echo ' '.$element_name.$scormseperator.$current.'.'.$current_subelement.'._count = '.$count_sub.";\n";
+ if ($countsub > 0) {
+ echo ' '.$elementname.$scormseperator.$current.'.'.$currentsubelement.'._count = '.$countsub.";\n";
}
if ($count > 0) {
- echo ' '.$element_name.'._count = '.$count.";\n";
+ echo ' '.$elementname.'._count = '.$count.";\n";
}
}
@@ -1103,11 +1104,11 @@ function scorm_element_cmp($a, $b) {
preg_match('/.?(\d+)\./', $b, $matches);
$right = intval($matches[1]);
if ($left < $right) {
- return -1; // smaller
+ return -1; // Smaller.
} else if ($left > $right) {
- return 1; // bigger
+ return 1; // Bigger.
} else {
- // look for a second level qualifier eg cmi.interactions_0.correct_responses_0.pattern
+ // Look for a second level qualifier eg cmi.interactions_0.correct_responses_0.pattern.
if (preg_match('/.*?(\d+)\.(.*?)\.(\d+)\./', $a, $matches)) {
$leftterm = intval($matches[2]);
$left = intval($matches[3]);
@@ -1115,20 +1116,20 @@ function scorm_element_cmp($a, $b) {
$rightterm = intval($matches[2]);
$right = intval($matches[3]);
if ($leftterm < $rightterm) {
- return -1; // smaller
+ return -1; // Smaller.
} else if ($leftterm > $rightterm) {
- return 1; // bigger
+ return 1; // Bigger.
} else {
if ($left < $right) {
- return -1; // smaller
+ return -1; // Smaller.
} else if ($left > $right) {
- return 1; // bigger
+ return 1; // Bigger.
}
}
}
}
- // fall back for no second level matches or second level matches are equal
- return 0; // equal to
+ // Fall back for no second level matches or second level matches are equal.
+ return 0; // Equal to.
}
}
@@ -1149,13 +1150,13 @@ function scorm_get_attempt_status($user, $scorm, $cm='') {
$attemptcount = count($attempts);
}
- $result = ''.get_string('noattemptsallowed', 'scorm').': ';
+ $result = html_writer::start_tag('p').get_string('noattemptsallowed', 'scorm').': ';
if ($scorm->maxattempt > 0) {
- $result .= $scorm->maxattempt . ' ';
+ $result .= $scorm->maxattempt . html_writer::empty_tag('br');
} else {
- $result .= get_string('unlimited').' ';
+ $result .= get_string('unlimited').html_writer::empty_tag('br');
}
- $result .= get_string('noattemptsmade', 'scorm').': ' . $attemptcount . ' ';
+ $result .= get_string('noattemptsmade', 'scorm').': ' . $attemptcount . html_writer::empty_tag('br');
if ($scorm->maxattempt == 1) {
switch ($scorm->grademethod) {
@@ -1194,39 +1195,38 @@ function scorm_get_attempt_status($user, $scorm, $cm='') {
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;
- $gradereported = number_format($gradereported*100, 0) .'%';
+ $gradereported = $gradereported / $scorm->maxgrade;
+ $gradereported = number_format($gradereported * 100, 0) .'%';
}
- $result .= get_string('gradeforattempt', 'scorm').' ' . $i . ': ' . $gradereported .' ';
+ $result .= get_string('gradeforattempt', 'scorm').' ' . $i . ': ' . $gradereported .html_writer::empty_tag('br');
$i++;
}
}
$calculatedgrade = scorm_grade_user($scorm, $user->id);
if ($scorm->grademethod !== GRADESCOES && !empty($scorm->maxgrade)) {
- $calculatedgrade = $calculatedgrade/$scorm->maxgrade;
- $calculatedgrade = number_format($calculatedgrade*100, 0) .'%';
+ $calculatedgrade = $calculatedgrade / $scorm->maxgrade;
+ $calculatedgrade = number_format($calculatedgrade * 100, 0) .'%';
}
$result .= get_string('grademethod', 'scorm'). ': ' . $grademethod;
if (empty($attempts)) {
- $result .= ' ' . get_string('gradereported', 'scorm') . ': ' . get_string('none') . ' ';
+ $result .= html_writer::empty_tag('br') . get_string('gradereported', 'scorm') . ': ' . get_string('none') . html_writer::empty_tag('br');
} else {
- $result .= ' ' . get_string('gradereported', 'scorm') . ': ' . $calculatedgrade . ' ';
+ $result .= html_writer::empty_tag('br') . get_string('gradereported', 'scorm') . ': ' . $calculatedgrade . html_writer::empty_tag('br');
}
- $result .= '
';
+ $result .= html_writer::end_tag('p');
if ($attemptcount >= $scorm->maxattempt and $scorm->maxattempt > 0) {
- $result .= ''.get_string('exceededmaxattempts', 'scorm').'
';
+ $result .= html_writer::tag('p', get_string('exceededmaxattempts', 'scorm'), array('class' => 'exceededmaxattempts'));
}
if (!empty($cm)) {
$context = context_module::instance($cm->id);
if (has_capability('mod/scorm:deleteownresponses', $context) &&
$DB->record_exists('scorm_scoes_track', array('userid' => $user->id, 'scormid' => $scorm->id))) {
- //check to see if any data is stored for this user:
- $deleteurl = new moodle_url($PAGE->url, array('action'=>'delete', 'sesskey' => sesskey()));
+ // Check to see if any data is stored for this user.
+ $deleteurl = new moodle_url($PAGE->url, array('action' => 'delete', 'sesskey' => sesskey()));
$result .= $OUTPUT->single_button($deleteurl, get_string('deleteallattempts', 'scorm'));
}
}
-
return $result;
}
@@ -1243,7 +1243,7 @@ function scorm_get_attempt_count($userid, $scorm, $returnobjects = false, $ignor
global $DB;
// Historically attempts that don't report these elements haven't been included in the average attempts grading method
- // we may want to change this in future, but to avoid unexpected grade decreases we're leaving this in. MDL-43222
+ // we may want to change this in future, but to avoid unexpected grade decreases we're leaving this in. MDL-43222 .
if (scorm_version_check($scorm->version, SCORM_13)) {
$element = 'cmi.score.raw';
} else if ($scorm->grademethod == GRADESCOES) {
@@ -1282,14 +1282,14 @@ function scorm_get_attempt_count($userid, $scorm, $returnobjects = false, $ignor
*/
function scorm_debugging($scorm) {
global $CFG, $USER;
- $cfg_scorm = get_config('scorm');
+ $cfgscorm = get_config('scorm');
- if (!$cfg_scorm->allowapidebug) {
+ if (!$cfgscorm->allowapidebug) {
return false;
}
$identifier = $USER->username.':'.$scorm->name;
- $test = $cfg_scorm->apidebugmask;
- // check the regex is only a short list of safe characters
+ $test = $cfgscorm->apidebugmask;
+ // Check the regex is only a short list of safe characters.
if (!preg_match('/^[\w\s\*\.\?\+\:\_\\\]+$/', $test)) {
return false;
}
@@ -1369,7 +1369,7 @@ function scorm_delete_attempt($userid, $scorm, $attemptid) {
* @return string human-readable date/time
*/
function scorm_format_duration($duration) {
- // fetch date/time strings
+ // Fetch date/time strings.
$stryears = get_string('years');
$strmonths = get_string('nummonths');
$strdays = get_string('days');
@@ -1378,19 +1378,19 @@ function scorm_format_duration($duration) {
$strseconds = get_string('seconds');
if ($duration[0] == 'P') {
- // if timestamp starts with 'P' - it's a SCORM 2004 format
+ // If timestamp starts with 'P' - it's a SCORM 2004 format
// this regexp discards empty sections, takes Month/Minute ambiguity into consideration,
// and outputs filled sections, discarding leading zeroes and any format literals
- // also saves the only zero before seconds decimals (if there are any) and discards decimals if they are zero
+ // also saves the only zero before seconds decimals (if there are any) and discards decimals if they are zero.
$pattern = array( '#([A-Z])0+Y#', '#([A-Z])0+M#', '#([A-Z])0+D#', '#P(|\d+Y)0*(\d+)M#', '#0*(\d+)Y#', '#0*(\d+)D#', '#P#',
'#([A-Z])0+H#', '#([A-Z])[0.]+S#', '#\.0+S#', '#T(|\d+H)0*(\d+)M#', '#0*(\d+)H#', '#0+\.(\d+)S#', '#0*([\d.]+)S#', '#T#' );
$replace = array( '$1', '$1', '$1', '$1$2 '.$strmonths.' ', '$1 '.$stryears.' ', '$1 '.$strdays.' ', '',
'$1', '$1', 'S', '$1$2 '.$strminutes.' ', '$1 '.$strhours.' ', '0.$1 '.$strseconds, '$1 '.$strseconds, '');
} else {
- // else we have SCORM 1.2 format there
- // first convert the timestamp to some SCORM 2004-like format for conveniency
+ // Else we have SCORM 1.2 format there
+ // first convert the timestamp to some SCORM 2004-like format for conveniency.
$duration = preg_replace('#^(\d+):(\d+):([\d.]+)$#', 'T$1H$2M$3S', $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#' );
$replace = array( 'T', '$1', '$1', 'S', '$1 '.$strhours.' ', '$1 '.$strminutes.' ', '0.$1 '.$strseconds, '$1 '.$strseconds, '' );
}
@@ -1418,7 +1418,7 @@ function scorm_get_toc_object($user, $scorm, $currentorg='', $scoid='', $mode='n
$result[0]->url = '';
}
- if ($scoes = scorm_get_scoes($scorm->id, $currentorg)){
+ if ($scoes = scorm_get_scoes($scorm->id, $currentorg)) {
// Retrieve user tracking data for each learning object.
$usertracks = array();
foreach ($scoes as $sco) {
@@ -1454,12 +1454,13 @@ function scorm_get_toc_object($user, $scorm, $currentorg='', $scoid='', $mode='n
if (isset($usertracks[$sco->identifier])) {
$usertrack = $usertracks[$sco->identifier];
- $strstatus = get_string($usertrack->status,'scorm');
+ $strstatus = get_string($usertrack->status, 'scorm');
if ($sco->scormtype == 'sco') {
- $statusicon = ' ';
+ $statusicon = html_writer::img($OUTPUT->pix_url($usertrack->status, 'scorm'), $strstatus, array('title' => $strstatus));
} else {
- $statusicon = ' ';
+ $statusicon = html_writer::img($OUTPUT->pix_url('asset', 'scorm'), get_string('assetlaunched', 'scorm'),
+ array('title' => get_string('assetlaunched', 'scorm')));
}
if (($usertrack->status == 'notattempted') || ($usertrack->status == 'incomplete') || ($usertrack->status == 'browsed')) {
@@ -1478,7 +1479,7 @@ function scorm_get_toc_object($user, $scorm, $currentorg='', $scoid='', $mode='n
}
if ($incomplete && isset($usertrack->{$exitvar}) && ($usertrack->{$exitvar} == 'suspend')) {
- $statusicon = ' ';
+ $statusicon = html_writer::img($OUTPUT->pix_url('suspend', 'scorm'), $strstatus.' - '.$strsuspended, array('title' => $strstatus.' - '.$strsuspended));
}
} else {
@@ -1489,16 +1490,18 @@ function scorm_get_toc_object($user, $scorm, $currentorg='', $scoid='', $mode='n
$incomplete = true;
if ($sco->scormtype == 'sco') {
- $statusicon = ' ';
+ $statusicon = html_writer::img($OUTPUT->pix_url('notattempted', 'scorm'), get_string('notattempted', 'scorm'),
+ array('title' => get_string('notattempted', 'scorm')));
} else {
- $statusicon = ' ';
+ $statusicon = html_writer::img($OUTPUT->pix_url('asset', 'scorm'), get_string('asset', 'scorm'), array('title' => get_string('asset', 'scorm')));
}
}
}
}
if (empty($statusicon)) {
- $sco->statusicon = ' ';
+ $sco->statusicon = html_writer::img($OUTPUT->pix_url('notattempted', 'scorm'), get_string('notattempted', 'scorm'),
+ array('title' => get_string('notattempted', 'scorm')));
} else {
$sco->statusicon = $statusicon;
}
@@ -1515,7 +1518,7 @@ function scorm_get_toc_object($user, $scorm, $currentorg='', $scoid='', $mode='n
// Get the parent scoes!
$result = scorm_get_toc_get_parent_child($result, $currentorg);
- // Be safe, prevent warnings from showing up while returning array
+ // Be safe, prevent warnings from showing up while returning array.
if (!isset($scoid)) {
$scoid = '';
}
@@ -1602,7 +1605,8 @@ function scorm_get_toc_get_parent_child(&$result, $currentorg) {
return $results;
}
-function scorm_format_toc_for_treeview($user, $scorm, $scoes, $usertracks, $cmid, $toclink=TOCJSLINK, $currentorg='', $attempt='', $play=false, $organizationsco=null, $children=false) {
+function scorm_format_toc_for_treeview($user, $scorm, $scoes, $usertracks, $cmid, $toclink=TOCJSLINK, $currentorg='',
+ $attempt='', $play=false, $organizationsco=null, $children=false) {
global $CFG;
$result = new stdClass();
@@ -1616,17 +1620,17 @@ function scorm_format_toc_for_treeview($user, $scorm, $scoes, $usertracks, $cmid
}
if (!$children) {
- $result->toc = "\n";
+ $result->toc = html_writer::start_tag('ul');
- if (!$play && !empty($organizationsco)) {
- $result->toc .= "\t".$organizationsco->title." \n";
+ if (!$play && !empty($organizationsco)) {
+ $result->toc .= html_writer::start_tag('li').$organizationsco->title.html_writer::end_tag('li');
}
}
$prevsco = '';
if (!empty($scoes)) {
foreach ($scoes as $sco) {
- $result->toc .= "\t\n";
+ $result->toc .= html_writer::start_tag('li');
$scoid = $sco->id;
$sco->isvisible = true;
@@ -1638,7 +1642,7 @@ function scorm_format_toc_for_treeview($user, $scorm, $scoes, $usertracks, $cmid
$viewscore = has_capability('mod/scorm:viewscores', context_module::instance($cmid));
if (isset($usertracks[$sco->identifier]->score_raw) && $viewscore) {
if ($usertracks[$sco->identifier]->score_raw != '') {
- $score = '('.get_string('score','scorm').': '.$usertracks[$sco->identifier]->score_raw.')';
+ $score = '('.get_string('score', 'scorm').': '.$usertracks[$sco->identifier]->score_raw.')';
}
}
}
@@ -1650,37 +1654,38 @@ function scorm_format_toc_for_treeview($user, $scorm, $scoes, $usertracks, $cmid
if (!empty($prevsco) && scorm_version_check($scorm->version, SCORM_13) && !empty($prevsco->hidecontinue)) {
if ($sco->scormtype == 'sco') {
- $result->toc .= ''.$sco->statusicon.' '.format_string($sco->title).' ';
+ $result->toc .= html_writer::span($sco->statusicon.' '.format_string($sco->title));
} else {
- $result->toc .= ' '.format_string($sco->title).' ';
+ $result->toc .= html_writer::span(' '.format_string($sco->title));
}
} else if ($toclink == TOCFULLURL) {
$url = $CFG->wwwroot.'/mod/scorm/player.php?'.$sco->url;
if (!empty($sco->launch)) {
if ($sco->scormtype == 'sco') {
- $result->toc .= $sco->statusicon.' '.format_string($sco->title).' '.$score."\n";
+ $result->toc .= $sco->statusicon.' '.html_writer::link($url, format_string($sco->title)).$score;
} else {
- $result->toc .= ' '.format_string($sco->title).' '.$score."\n";
+ $result->toc .= ' '.html_writer::link($url, format_string($sco->title), array('data-scoid' => $sco->id)).$score;
}
} else {
if ($sco->scormtype == 'sco') {
- $result->toc .= $sco->statusicon.' '.format_string($sco->title).$score."\n";
+ $result->toc .= $sco->statusicon.' '.format_string($sco->title).$score;
} else {
- $result->toc .= ' '.format_string($sco->title).$score."\n";
+ $result->toc .= ' '.format_string($sco->title).$score;
}
}
} else {
if (!empty($sco->launch)) {
if ($sco->scormtype == 'sco') {
- $result->toc .= ''.$sco->statusicon.' '.format_string($sco->title).' '.$score.' ';
+ $result->toc .= html_writer::tag('a', $sco->statusicon.' '.format_string($sco->title).' '.$score,
+ array('data-scoid' => $sco->id, 'title' => $sco->url));
} else {
- $result->toc .= ' '.format_string($sco->title).' '.$score.' ';
+ $result->toc .= html_writer::tag('a', ' '.format_string($sco->title).' '.$score, array('data-scoid' => $sco->id, 'title' => $sco->url));
}
} else {
if ($sco->scormtype == 'sco') {
- $result->toc .= ''.$sco->statusicon.' '.format_string($sco->title).' ';
+ $result->toc .= html_writer::span($sco->statusicon.' '.format_string($sco->title));
} else {
- $result->toc .= ' '.format_string($sco->title).' ';
+ $result->toc .= html_writer::span(' '.format_string($sco->title));
}
}
}
@@ -1688,31 +1693,31 @@ function scorm_format_toc_for_treeview($user, $scorm, $scoes, $usertracks, $cmid
} else {
if ($play) {
if ($sco->scormtype == 'sco') {
- $result->toc .= ''.$sco->statusicon.' '.format_string($sco->title).' ';
+ $result->toc .= html_writer::span($sco->statusicon.' '.format_string($sco->title));
} else {
- $result->toc .= ' '.format_string($sco->title).'';
+ $result->toc .= ' '.format_string($sco->title).html_writer::end_span();
}
} else {
if ($sco->scormtype == 'sco') {
- $result->toc .= $sco->statusicon.' '.format_string($sco->title)."\n";
+ $result->toc .= $sco->statusicon.' '.format_string($sco->title);
} else {
- $result->toc .= ' '.format_string($sco->title)."\n";
+ $result->toc .= ' '.format_string($sco->title);
}
}
}
} else {
- $result->toc .= "\t\t ".format_string($sco->title)."\n";
+ $result->toc .= " ".format_string($sco->title);
}
if (!empty($sco->children)) {
- $result->toc .= "\n\t\t\n";
+ $result->toc .= html_writer::start_tag('ul');
$childresult = scorm_format_toc_for_treeview($user, $scorm, $sco->children, $usertracks, $cmid, $toclink, $currentorg, $attempt, $play, $organizationsco, true);
$result->toc .= $childresult->toc;
- $result->toc .= "\t\t \n";
- $result->toc .= "\t \n";
+ $result->toc .= html_writer::end_tag('ul');
+ $result->toc .= html_writer::end_tag('li');
} else {
- $result->toc .= "\t\n";
+ $result->toc .= html_writer::end_tag('li');
}
$prevsco = $sco;
}
@@ -1720,7 +1725,7 @@ function scorm_format_toc_for_treeview($user, $scorm, $scoes, $usertracks, $cmid
}
if (!$children) {
- $result->toc .= " \n";
+ $result->toc .= html_writer::end_tag('ul');
}
return $result;
@@ -1732,7 +1737,7 @@ function scorm_format_toc_for_droplist($scorm, $scoes, $usertracks, $currentorg=
$tocmenus[$organizationsco->id] = $organizationsco->title;
}
- $parents[$level]='/';
+ $parents[$level] = '/';
foreach ($scoes as $sco) {
if ($parents[$level] != $sco->parent) {
if ($newlevel = array_search($sco->parent, $parents)) {
@@ -1772,7 +1777,8 @@ function scorm_format_toc_for_droplist($scorm, $scoes, $usertracks, $currentorg=
return $tocmenus;
}
-function scorm_get_toc($user, $scorm, $cmid, $toclink=TOCJSLINK, $currentorg='', $scoid='', $mode='normal', $attempt='', $play=false, $tocheader=false) {
+function scorm_get_toc($user, $scorm, $cmid, $toclink=TOCJSLINK, $currentorg='', $scoid='', $mode='normal',
+ $attempt='', $play=false, $tocheader=false) {
global $CFG, $DB, $OUTPUT;
if (empty($attempt)) {
@@ -1783,14 +1789,14 @@ function scorm_get_toc($user, $scorm, $cmid, $toclink=TOCJSLINK, $currentorg='',
$organizationsco = null;
if ($tocheader) {
- $result->toc = "\n";
- $result->toc .= "
\n";
- $result->toc .= "
\n";
- $result->toc .= "
\n";
+ $result->toc = html_writer::start_div('yui3-g-r', array('id' => 'scorm_layout'));
+ $result->toc .= html_writer::start_div('yui3-u-1-5', array('id' => 'scorm_toc'));
+ $result->toc .= html_writer::div('', '', array('id' => 'scorm_toc_title'));
+ $result->toc .= html_writer::start_div('', array('id' => 'scorm_tree'));
}
if (!empty($currentorg)) {
- $organizationsco = $DB->get_record('scorm_scoes', array('scorm'=>$scorm->id, 'identifier'=>$currentorg));
+ $organizationsco = $DB->get_record('scorm_scoes', array('scorm' => $scorm->id, 'identifier' => $currentorg));
if (!empty($organizationsco->title)) {
if ($play) {
$result->toctitle = $organizationsco->title;
@@ -1800,7 +1806,8 @@ function scorm_get_toc($user, $scorm, $cmid, $toclink=TOCJSLINK, $currentorg='',
$scoes = scorm_get_toc_object($user, $scorm, $currentorg, $scoid, $mode, $attempt, $play, $organizationsco);
- $treeview = scorm_format_toc_for_treeview($user, $scorm, $scoes['scoes'][0]->children, $scoes['usertracks'], $cmid, $toclink, $currentorg, $attempt, $play, $organizationsco, false);
+ $treeview = scorm_format_toc_for_treeview($user, $scorm, $scoes['scoes'][0]->children, $scoes['usertracks'], $cmid,
+ $toclink, $currentorg, $attempt, $play, $organizationsco, false);
if ($tocheader) {
$result->toc .= $treeview->toc;
@@ -1835,12 +1842,12 @@ function scorm_get_toc($user, $scorm, $cmid, $toclink=TOCJSLINK, $currentorg='',
$result->attemptleft = $treeview->attemptleft;
if ($tocheader) {
- $result->toc .= "
\n";
- $result->toc .= "
\n";
- $result->toc .= "
\n";
- $result->toc .= "
";
- $result->toc .= "
\n";
- $result->toc .= "
\n";
+ $result->toc .= html_writer::end_div().html_writer::end_div();
+ $result->toc .= html_writer::start_div('', array('id' => 'scorm_toc_toggle'));
+ $result->toc .= html_writer::tag('button', '', array('id' => 'scorm_toc_toggle_btn')).html_writer::end_div();
+ $result->toc .= html_writer::start_div('', array('id' => 'scorm_content'));
+ $result->toc .= html_writer::div('', '', array('id' => 'scorm_navpanel'));
+ $result->toc .= html_writer::end_div().html_writer::end_div();
}
return $result;
diff --git a/mod/scorm/mod_form.php b/mod/scorm/mod_form.php
index d240b3fc206..57f67764bca 100644
--- a/mod/scorm/mod_form.php
+++ b/mod/scorm/mod_form.php
@@ -72,7 +72,7 @@ class mod_scorm_mod_form extends moodleform_mod {
$mform->addElement('select', 'scormtype', get_string('scormtype', 'scorm'), $scormtypes);
$mform->setType('scormtype', PARAM_ALPHA);
$mform->addHelpButton('scormtype', 'scormtype', 'scorm');
- $mform->addElement('text', 'packageurl', get_string('packageurl', 'scorm'), array('size'=>60));
+ $mform->addElement('text', 'packageurl', get_string('packageurl', 'scorm'), array('size' => 60));
$mform->setType('packageurl', PARAM_RAW);
$mform->addHelpButton('packageurl', 'packageurl', 'scorm');
$mform->disabledIf('packageurl', 'scormtype', 'eq', SCORM_TYPE_LOCAL);
@@ -212,7 +212,7 @@ class mod_scorm_mod_form extends moodleform_mod {
$mform->setDefault('grademethod', $cfgscorm->grademethod);
// Maximum Grade.
- for ($i=0; $i<=100; $i++) {
+ for ($i = 0; $i <= 100; $i++) {
$grades[$i] = "$i";
}
$mform->addElement('select', 'maxgrade', get_string('maximumgrade'), $grades);
@@ -314,7 +314,7 @@ class mod_scorm_mod_form extends moodleform_mod {
$defaultvalues['redirecturl'] = '../mod/scorm/view.php?id='.$defaultvalues['coursemodule'];
}
if (isset($defaultvalues['version'])) {
- $defaultvalues['pkgtype'] = (substr($defaultvalues['version'], 0, 5) == 'SCORM') ? 'scorm':'aicc';
+ $defaultvalues['pkgtype'] = (substr($defaultvalues['version'], 0, 5) == 'SCORM') ? 'scorm' : 'aicc';
}
if (isset($defaultvalues['instance'])) {
$defaultvalues['datadir'] = $defaultvalues['instance'];
@@ -365,7 +365,7 @@ class mod_scorm_mod_form extends moodleform_mod {
$fs = get_file_storage();
$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id', false);
- if (count($files)<1) {
+ if (count($files) < 1) {
$errors['packagefile'] = get_string('required');
return $errors;
}
@@ -479,7 +479,6 @@ class mod_scorm_mod_form extends moodleform_mod {
$items[] = 'completionscoregroup';
-
// Require status.
$first = true;
$firstkey = null;
@@ -500,14 +499,14 @@ class mod_scorm_mod_form extends moodleform_mod {
return $items;
}
- function completion_rule_enabled($data) {
+ public function completion_rule_enabled($data) {
$status = !empty($data['completionstatusrequired']);
$score = empty($data['completionscoredisabled']) && strlen($data['completionscorerequired']);
return $status || $score;
}
- function get_data($slashed = true) {
+ public function get_data($slashed = true) {
$data = parent::get_data($slashed);
if (!$data) {
@@ -527,12 +526,11 @@ class mod_scorm_mod_form extends moodleform_mod {
// Turn off completion settings if the checkboxes aren't ticked.
$autocompletion = isset($data->completion) && $data->completion == COMPLETION_TRACKING_AUTOMATIC;
- if (isset($data->completionstatusrequired) && $autocompletion) {
- // Do nothing: completionstatusrequired has been already converted
- // into a correct integer representation.
- } else {
+ if (!(isset($data->completionstatusrequired) && $autocompletion)) {
$data->completionstatusrequired = null;
}
+ // Else do nothing: completionstatusrequired has been already converted
+ // into a correct integer representation.
if (!empty($data->completionscoredisabled) || !$autocompletion) {
$data->completionscorerequired = null;
diff --git a/mod/scorm/player.php b/mod/scorm/player.php
index f9f01297aa5..9c9a8e6f24b 100644
--- a/mod/scorm/player.php
+++ b/mod/scorm/player.php
@@ -32,17 +32,17 @@ if (!empty($id)) {
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
print_error('invalidcoursemodule');
}
- if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
+ if (! $course = $DB->get_record("course", array("id" => $cm->course))) {
print_error('coursemisconf');
}
- if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
+ 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))) {
+ if (! $scorm = $DB->get_record("scorm", array("id" => $a))) {
print_error('invalidcoursemodule');
}
- if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
+ if (! $course = $DB->get_record("course", array("id" => $scorm->course))) {
print_error('coursemisconf');
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
@@ -57,7 +57,7 @@ $attempt = scorm_get_last_attempt($scorm->id, $USER->id);
// Check mode is correct and set/validate mode/attempt/newattempt (uses pass by reference).
scorm_check_mode($scorm, $newattempt, $attempt, $USER->id, $mode);
-$url = new moodle_url('/mod/scorm/player.php', array('scoid'=>$scoid, 'cm'=>$cm->id));
+$url = new moodle_url('/mod/scorm/player.php', array('scoid' => $scoid, 'cm' => $cm->id));
if ($mode !== 'normal') {
$url->param('mode', $mode);
}
@@ -106,7 +106,7 @@ if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $cou
// Check if scorm closed.
$timenow = time();
-if ($scorm->timeclose !=0) {
+if ($scorm->timeclose != 0) {
if ($scorm->timeopen > $timenow) {
echo $OUTPUT->header();
echo $OUTPUT->box(get_string("notopenyet", "scorm", userdate($scorm->timeopen)), "generalbox boxaligncenter");
@@ -150,8 +150,8 @@ $completion = new completion_info($course);
$completion->set_module_viewed($cm);
// Print the page header.
-if (empty($scorm->popup) || $displaymode=='popup') {
- $exitlink = ''.$strexit.' ';
+if (empty($scorm->popup) || $displaymode == 'popup') {
+ $exitlink = html_writer::link($CFG->wwwroot.'/course/view.php?id='.$scorm->course, $strexit, array('title' => $strexit));
$PAGE->set_button($exitlink);
}
@@ -178,44 +178,35 @@ $PAGE->requires->string_for_js('popupsblocked', 'scorm');
$name = false;
-?>
-
+echo html_writer::start_div('', array('id' => 'scormpage'));
+echo html_writer::start_div('', array('id' => 'tocbox'));
+echo html_writer::div(html_writer::tag('script', '', array('id' => 'external-scormapi', 'type' => 'text/JavaScript')), '', array('id' => 'scormapi-parent'));
-
-
-
-
-hidetoc == SCORM_TOC_POPUP or $mode=='browse' or $mode=='review') {
- echo '
';
- echo $mode == 'browse' ? '
'.get_string('browsemode', 'scorm')."
\n" : '';
- echo $mode == 'review' ? '
'.get_string('reviewmode', 'scorm')."
\n" : '';
+if ($scorm->hidetoc == SCORM_TOC_POPUP or $mode == 'browse' or $mode == 'review') {
+ echo html_writer::start_div('', array('id' => 'scormtop'));
+ echo $mode == 'browse' ? html_writer::div(get_string('browsemode', 'scorm'), 'scorm-left', array('id' => 'scormmode')) : '';
+ echo $mode == 'review' ? html_writer::div(get_string('reviewmode', 'scorm'), 'scorm-left', array('id' => 'scormmode')) : '';
if ($scorm->hidetoc == SCORM_TOC_POPUP) {
- echo '
'.$result->tocmenu.'
';
+ echo html_writer::div($result->tocmenu, 'scorm-right', array('id' => 'scormnav'));
}
- echo '
';
+ echo html_writer::end_div();
}
-?>
-
- popup) || $displaymode == 'popup') {
- echo $result->toc;
- } else {
- //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 = '
' . get_string('finishscormlinkname', 'scorm') . ' ';
- echo $OUTPUT->box(get_string('finishscorm', 'scorm', $linkcourse), 'generalbox', 'altfinishlink');
- }?>
-
-
-
-
-
-
-
- 'toctree'));
+
+if (empty($scorm->popup) || $displaymode == 'popup') {
+ echo $result->toc;
+} else {
+ // 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 = html_writer::link($CFG->wwwroot.'/course/view.php?id='.$scorm->course, get_string('finishscormlinkname', 'scorm'));
+ echo $OUTPUT->box(get_string('finishscorm', 'scorm', $linkcourse), 'generalbox', 'altfinishlink');
+}
+echo html_writer::end_div(); //
+echo html_writer::end_div(); //
+echo html_writer::tag('noscript', html_writer::div(get_string('noscriptnoscorm', 'scorm'), '', array('id' => 'noscript')));
+
if ($result->prerequisites) {
- if ($scorm->popup != 0 && $displaymode !=='popup') {
+ if ($scorm->popup != 0 && $displaymode !== 'popup') {
// Clean the name for the window as IE is fussy
$name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name);
if (!$name) {
@@ -228,18 +219,14 @@ if ($result->prerequisites) {
js_writer::function_call('scorm_openpopup', Array($url->out(false),
$name, $scorm->options,
$scorm->width, $scorm->height)));
- ?>
-
-
-
- 'main', 'class' => 'scoframe', 'name' => 'main',
+ 'src' => 'loadSCO.php?id='.$cm->id.$scoidstr.$modestr)));
}
} else {
echo $OUTPUT->box(get_string('noprerequisites', 'scorm'));
}
-?>
-
-
+
$scoes = scorm_get_toc_object($USER, $scorm, $currentorg, $sco->id, $mode, $attempt);
$adlnav = scorm_get_adlnav_json($scoes['scoes']);
diff --git a/mod/scorm/prereqs.php b/mod/scorm/prereqs.php
index a507ef910d1..88050893181 100644
--- a/mod/scorm/prereqs.php
+++ b/mod/scorm/prereqs.php
@@ -30,17 +30,17 @@ if (!empty($id)) {
if (! $cm = get_coursemodule_from_id('scorm', $id)) {
print_error('invalidcoursemodule');
}
- if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
+ if (! $course = $DB->get_record("course", array("id" => $cm->course))) {
print_error('coursemisconf');
}
- if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
+ 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))) {
+ if (! $scorm = $DB->get_record("scorm", array("id" => $a))) {
print_error('invalidcoursemodule');
}
- if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
+ if (! $course = $DB->get_record("course", array("id" => $scorm->course))) {
print_error('coursemisconf');
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) {
@@ -50,7 +50,7 @@ if (!empty($id)) {
print_error('missingparameter');
}
-$PAGE->set_url('/mod/scorm/prereqs.php', array('scoid'=>$scoid, 'attempt'=>$attempt, 'id'=>$cm->id));
+$PAGE->set_url('/mod/scorm/prereqs.php', array('scoid' => $scoid, 'attempt' => $attempt, 'id' => $cm->id));
require_login($course, false, $cm);
diff --git a/mod/scorm/renderer.php b/mod/scorm/renderer.php
index a0cc7ccfa80..4f5a2fa8c75 100644
--- a/mod/scorm/renderer.php
+++ b/mod/scorm/renderer.php
@@ -36,7 +36,7 @@ class mod_scorm_renderer extends plugin_renderer_base {
$output = '';
$output .= $this->box_start('generalbox boxaligncenter');
$output .= html_writer::start_tag('div', array('class' => 'mdl-align'));
- $output .= $this->user_picture($user, array('courseid'=>$course->id, 'link' => true));
+ $output .= $this->user_picture($user, array('courseid' => $course->id, 'link' => true));
$url = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
$output .= html_writer::link($url, fullname($user));
$baseurl->param('attempt', '');
@@ -165,7 +165,7 @@ class mod_scorm_attempt_bar implements renderable {
if (count($this->attemptids) > 1) {
$lastattempt = end($this->attemptids); // Get last attempt.
- $firstattempt = reset($this->attemptids); // get first attempt.
+ $firstattempt = reset($this->attemptids); // get first attempt.
$nextattempt = 0;
$prevattempt = null;
@@ -176,7 +176,7 @@ class mod_scorm_attempt_bar implements renderable {
$prevattempt = $previous;
} else {
$attemptlink = html_writer::link(
- new moodle_url($this->baseurl, array($this->pagevar=>$attemptid)), $attemptid);
+ new moodle_url($this->baseurl, array($this->pagevar => $attemptid)), $attemptid);
$this->attemptlinks[] = $attemptlink;
if (empty($nextattempt) && $prevattempt !== null) {
// Set the nextattempt var as we have set previous attempt earlier.
@@ -188,14 +188,14 @@ class mod_scorm_attempt_bar implements renderable {
if ($this->attempt != $firstattempt) {
$this->previouslink = html_writer::link(
- new moodle_url($this->baseurl, array($this->pagevar=>$prevattempt)),
- get_string('previous'), array('class'=>'previous'));
+ new moodle_url($this->baseurl, array($this->pagevar => $prevattempt)),
+ get_string('previous'), array('class' => 'previous'));
}
if ($this->attempt != $lastattempt) {
$this->nextlink = html_writer::link(
- new moodle_url($this->baseurl, array($this->pagevar=>$nextattempt)),
- get_string('next'), array('class'=>'next'));
+ new moodle_url($this->baseurl, array($this->pagevar => $nextattempt)),
+ get_string('next'), array('class' => 'next'));
}
}
}
diff --git a/mod/scorm/report.php b/mod/scorm/report.php
index bbad079b174..4e4b57e5fc1 100644
--- a/mod/scorm/report.php
+++ b/mod/scorm/report.php
@@ -33,8 +33,8 @@ $download = optional_param('download', '', PARAM_RAW);
$mode = optional_param('mode', '', PARAM_ALPHA); // Report mode
$cm = get_coursemodule_from_id('scorm', $id, 0, false, MUST_EXIST);
-$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
-$scorm = $DB->get_record('scorm', array('id'=>$cm->instance), '*', MUST_EXIST);
+$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+$scorm = $DB->get_record('scorm', array('id' => $cm->instance), '*', MUST_EXIST);
$contextmodule = context_module::instance($cm->id);
$reportlist = scorm_report_list($contextmodule);
@@ -75,14 +75,14 @@ $userdata = null;
if (!empty($download)) {
$noheader = true;
}
-/// Print the page header
+// Print the page header
if (empty($noheader)) {
$strreport = get_string('report', 'scorm');
$strattempt = get_string('attempt', 'scorm');
$PAGE->set_title("$course->shortname: ".format_string($scorm->name));
$PAGE->set_heading($course->fullname);
- $PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id'=>$cm->id)));
+ $PAGE->navbar->add($strreport, new moodle_url('/mod/scorm/report.php', array('id' => $cm->id)));
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($scorm->name));
diff --git a/mod/scorm/report/basic/report.php b/mod/scorm/report/basic/report.php
index 9f7a137fd54..3d001b2f73f 100644
--- a/mod/scorm/report/basic/report.php
+++ b/mod/scorm/report/basic/report.php
@@ -32,24 +32,24 @@ class scorm_basic_report extends scorm_default_report {
* @param stdClass $course - full course object
* @param string $download - type of download being requested
*/
- function display($scorm, $cm, $course, $download) {
+ public function display($scorm, $cm, $course, $download) {
global $CFG, $DB, $OUTPUT, $PAGE;
- $contextmodule= context_module::instance($cm->id);
+ $contextmodule = context_module::instance($cm->id);
$action = optional_param('action', '', PARAM_ALPHA);
$attemptids = optional_param_array('attemptid', array(), PARAM_RAW);
$attemptsmode = optional_param('attemptsmode', SCORM_REPORT_ATTEMPTS_ALL_STUDENTS, PARAM_INT);
$PAGE->set_url(new moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));
if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
- if (scorm_delete_responses($attemptids, $scorm)) { //delete responses.
+ if (scorm_delete_responses($attemptids, $scorm)) { // Delete responses.
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
}
}
- // find out current groups mode
+ // Find out current groups mode.
$currentgroup = groups_get_activity_group($cm, true);
- // detailed report
+ // Detailed report.
$mform = new mod_scorm_report_settings($PAGE->url, compact('currentgroup'));
if ($fromform = $mform->get_data()) {
$detailedrep = $fromform->detailedrep;
@@ -64,10 +64,10 @@ class scorm_basic_report extends scorm_default_report {
$pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE;
}
- // select group menu
+ // Select group menu.
$displayoptions = array();
$displayoptions['attemptsmode'] = $attemptsmode;
- if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
+ if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
if (!$download) {
groups_print_activity_menu($cm, new moodle_url($PAGE->url, $displayoptions));
}
@@ -76,12 +76,12 @@ class scorm_basic_report extends scorm_default_report {
// We only want to show the checkbox to delete attempts
// if the user has permissions and if the report mode is showing attempts.
$candelete = has_capability('mod/scorm:deleteresponses', $contextmodule)
- && ($attemptsmode!= SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO);
- // select the students
+ && ($attemptsmode != SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO);
+ // Select the students.
$nostudents = false;
if (empty($currentgroup)) {
- // all users who can attempt scoes
+ // All users who can attempt scoes.
if (!$students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id', '', '', '', '', '', false)) {
echo $OUTPUT->notification(get_string('nostudentsyet'));
$nostudents = true;
@@ -91,8 +91,9 @@ class scorm_basic_report extends scorm_default_report {
}
unset($students);
} else {
- // all users who can attempt scoes and who are in the currently selected group
- if (!$groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id', '', '', '', $currentgroup, '', false)) {
+ // All users who can attempt scoes and who are in the currently selected group.
+ if (!$groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id', '', '', '',
+ $currentgroup, '', false)) {
echo $OUTPUT->notification(get_string('nostudentsingroup'));
$nostudents = true;
$groupstudents = array();
@@ -102,45 +103,45 @@ class scorm_basic_report extends scorm_default_report {
}
if ( !$nostudents ) {
- // Now check if asked download of data
+ // Now check if asked download of data.
$coursecontext = context_course::instance($course->id);
if ($download) {
$shortname = format_string($course->shortname, true, array('context' => $coursecontext));
$filename = clean_filename("$shortname ".format_string($scorm->name, true));
}
- // Define table columns
+ // Define table columns.
$columns = array();
$headers = array();
if (!$download && $candelete) {
- $columns[]= 'checkbox';
- $headers[]= null;
+ $columns[] = 'checkbox';
+ $headers[] = null;
}
if (!$download && $CFG->grade_report_showuserimage) {
- $columns[]= 'picture';
- $headers[]= '';
+ $columns[] = 'picture';
+ $headers[] = '';
}
- $columns[]= 'fullname';
- $headers[]= get_string('name');
+ $columns[] = 'fullname';
+ $headers[] = get_string('name');
$extrafields = get_extra_user_fields($coursecontext);
foreach ($extrafields as $field) {
$columns[] = $field;
$headers[] = get_user_field_name($field);
}
- $columns[]= 'attempt';
- $headers[]= get_string('attempt', 'scorm');
- $columns[]= 'start';
- $headers[]= get_string('started', 'scorm');
- $columns[]= 'finish';
- $headers[]= get_string('last', 'scorm');
- $columns[]= 'score';
- $headers[]= get_string('score', 'scorm');
- if ($detailedrep && $scoes = $DB->get_records('scorm_scoes', array("scorm"=>$scorm->id), 'sortorder, id')) {
+ $columns[] = 'attempt';
+ $headers[] = get_string('attempt', 'scorm');
+ $columns[] = 'start';
+ $headers[] = get_string('started', 'scorm');
+ $columns[] = 'finish';
+ $headers[] = get_string('last', 'scorm');
+ $columns[] = 'score';
+ $headers[] = get_string('score', 'scorm');
+ if ($detailedrep && $scoes = $DB->get_records('scorm_scoes', array("scorm" => $scorm->id), 'sortorder, id')) {
foreach ($scoes as $sco) {
- if ($sco->launch!='') {
- $columns[]= 'scograde'.$sco->id;
- $headers[]= format_string($sco->title);
+ if ($sco->launch != '') {
+ $columns[] = 'scograde'.$sco->id;
+ $headers[] = format_string($sco->title);
}
}
} else {
@@ -157,7 +158,7 @@ class scorm_basic_report extends scorm_default_report {
$table->sortable(true);
$table->collapsible(true);
- // This is done to prevent redundant data, when a user has multiple attempts
+ // This is done to prevent redundant data, when a user has multiple attempts.
$table->column_suppress('picture');
$table->column_suppress('fullname');
foreach ($extrafields as $field) {
@@ -172,7 +173,7 @@ class scorm_basic_report extends scorm_default_report {
if ( $scoes ) {
foreach ($scoes as $sco) {
- if ($sco->launch!='') {
+ if ($sco->launch != '') {
$table->no_sorting('scograde'.$sco->id);
}
}
@@ -186,20 +187,20 @@ class scorm_basic_report extends scorm_default_report {
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'generaltable generalbox');
- // Start working -- this is necessary as soon as the niceties are over
+ // Start working -- this is necessary as soon as the niceties are over.
$table->setup();
- } else if ($download =='ODS') {
+ } else if ($download == 'ODS') {
require_once("$CFG->libdir/odslib.class.php");
$filename .= ".ods";
- // Creating a workbook
+ // Creating a workbook.
$workbook = new MoodleODSWorkbook("-");
- // Sending HTTP headers
+ // Sending HTTP headers.
$workbook->send($filename);
- // Creating the first worksheet
+ // Creating the first worksheet.
$sheettitle = get_string('report', 'scorm');
$myxls = $workbook->add_worksheet($sheettitle);
- // format types
+ // Format types.
$format = $workbook->add_format();
$format->set_bold(0);
$formatbc = $workbook->add_format();
@@ -219,26 +220,26 @@ class scorm_basic_report extends scorm_default_report {
$formatg->set_bold(1);
$formatg->set_color('green');
$formatg->set_align('center');
- // Here starts workshhet headers
+ // Here starts workshhet headers.
$colnum = 0;
foreach ($headers as $item) {
$myxls->write(0, $colnum, $item, $formatbc);
$colnum++;
}
- $rownum=1;
- } else if ($download =='Excel') {
+ $rownum = 1;
+ } else if ($download == 'Excel') {
require_once("$CFG->libdir/excellib.class.php");
$filename .= ".xls";
- // Creating a workbook
+ // Creating a workbook.
$workbook = new MoodleExcelWorkbook("-");
- // Sending HTTP headers
+ // Sending HTTP headers.
$workbook->send($filename);
- // Creating the first worksheet
+ // Creating the first worksheet.
$sheettitle = get_string('report', 'scorm');
$myxls = $workbook->add_worksheet($sheettitle);
- // format types
+ // Format types.
$format = $workbook->add_format();
$format->set_bold(0);
$formatbc = $workbook->add_format();
@@ -264,34 +265,34 @@ class scorm_basic_report extends scorm_default_report {
$myxls->write(0, $colnum, $item, $formatbc);
$colnum++;
}
- $rownum=1;
- } else if ($download=='CSV') {
+ $rownum = 1;
+ } else if ($download == 'CSV') {
$csvexport = new csv_export_writer("tab");
$csvexport->set_filename($filename, ".txt");
$csvexport->add_data($headers);
}
$params = array();
list($usql, $params) = $DB->get_in_or_equal($allowedlist, SQL_PARAMS_NAMED);
- // Construct the SQL
+ // Construct the SQL.
$select = 'SELECT DISTINCT '.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').' AS uniqueid, ';
$select .= 'st.scormid AS scormid, st.attempt AS attempt, ' .
user_picture::fields('u', array('idnumber'), 'userid') .
get_extra_user_fields_sql($coursecontext, 'u', '', array('email', 'idnumber')) . ' ';
- // This part is the same for all cases - join users and scorm_scoes_track tables
+ // This part is the same for all cases - join users and scorm_scoes_track tables.
$from = 'FROM {user} u ';
$from .= 'LEFT JOIN {scorm_scoes_track} st ON st.userid = u.id AND st.scormid = '.$scorm->id;
switch ($attemptsmode) {
case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH:
- // Show only students with attempts
+ // Show only students with attempts.
$where = ' WHERE u.id ' .$usql. ' AND st.userid IS NOT NULL';
break;
case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO:
- // Show only students without attempts
+ // Show only students without attempts.
$where = ' WHERE u.id ' .$usql. ' AND st.userid IS NULL';
break;
case SCORM_REPORT_ATTEMPTS_ALL_STUDENTS:
- // Show all students with or without attempts
+ // Show all students with or without attempts.
$where = ' WHERE u.id ' .$usql. ' AND (st.userid IS NOT NULL OR st.userid IS NULL)';
break;
}
@@ -306,7 +307,7 @@ class scorm_basic_report extends scorm_default_report {
} else {
$sort = '';
}
- // Fix some wired sorting
+ // Fix some wired sorting.
if (empty($sort)) {
$sort = ' ORDER BY uniqueid';
} else {
@@ -314,10 +315,10 @@ class scorm_basic_report extends scorm_default_report {
}
if (!$download) {
- // Add extra limits due to initials bar
+ // Add extra limits due to initials bar.
list($twhere, $tparams) = $table->get_sql_where();
if ($twhere) {
- $where .= ' AND '.$twhere; //initial bar
+ $where .= ' AND '.$twhere; // Initial bar.
$params = array_merge($params, $tparams);
}
@@ -333,35 +334,36 @@ class scorm_basic_report extends scorm_default_report {
$table->pagesize($pagesize, $total);
- echo '';
+ echo html_writer::start_div('scormattemptcounts');
if ( $count->nbresults == $count->nbattempts ) {
echo get_string('reportcountattempts', 'scorm', $count);
- } else if ( $count->nbattempts>0 ) {
+ } else if ( $count->nbattempts > 0 ) {
echo get_string('reportcountallattempts', 'scorm', $count);
} else {
echo $count->nbusers.' '.get_string('users');
}
- echo '
';
+ echo html_writer::end_div();
}
- // Fetch the attempts
+ // Fetch the attempts.
if (!$download) {
$attempts = $DB->get_records_sql($select.$from.$where.$sort, $params,
$table->get_page_start(), $table->get_page_size());
- echo '';
+ echo html_writer::start_div('', array('id' => 'scormtablecontainer'));
if ($candelete) {
- // Start form
+ // Start form.
$strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm'));
- echo '
';
+ echo html_writer::empty_tag('input', array('type' => 'submit',
+ 'value' => get_string('deleteselected', 'quiz_overview')));
+ echo html_writer::end_tag('td').html_writer::end_tag('tr').html_writer::end_tag('table');
+ // Close form.
+ echo html_writer::end_tag('div');
+ echo html_writer::end_tag('form');
}
- echo '
';
+ echo html_writer::end_div();
if (!empty($attempts)) {
- echo '';
- echo '';
+ echo html_writer::start_tag('table', array('class' => 'boxaligncenter')).html_writer::start_tag('tr');
+ echo html_writer::start_tag('td');
echo $OUTPUT->single_button(new moodle_url($PAGE->url,
- array('download'=>'ODS') + $displayoptions),
+ array('download' => 'ODS') + $displayoptions),
get_string('downloadods'));
- echo " \n";
- echo '';
+ echo html_writer::end_tag('td');
+ echo html_writer::start_tag('td');
echo $OUTPUT->single_button(new moodle_url($PAGE->url,
- array('download'=>'Excel') + $displayoptions),
+ array('download' => 'Excel') + $displayoptions),
get_string('downloadexcel'));
- echo " \n";
- echo '';
+ echo html_writer::end_tag('td');
+ echo html_writer::start_tag('td');
echo $OUTPUT->single_button(new moodle_url($PAGE->url,
- array('download'=>'CSV') + $displayoptions),
+ array('download' => 'CSV') + $displayoptions),
get_string('downloadtext'));
- echo " \n";
- echo "";
- echo " \n";
- echo '
';
+ echo html_writer::end_tag('td');
+ echo html_writer::start_tag('td');
+ echo html_writer::end_tag('td');
+ echo html_writer::end_tag('tr').html_writer::end_tag('table');
}
}
} else {
if ($candelete && !$download) {
- echo '';
- echo '';
+ echo html_writer::end_div();
+ echo html_writer::end_tag('form');
$table->finish_output();
}
- echo '';
+ echo html_writer::end_div();
}
- // Show preferences form irrespective of attempts are there to report or not
+ // Show preferences form irrespective of attempts are there to report or not.
if (!$download) {
$mform->set_data(compact('detailedrep', 'pagesize', 'attemptsmode'));
$mform->display();
@@ -539,5 +548,5 @@ class scorm_basic_report extends scorm_default_report {
} else {
echo $OUTPUT->notification(get_string('noactivity', 'scorm'));
}
- }// function ends
+ }// Function ends.
}
diff --git a/mod/scorm/report/interactions/report.php b/mod/scorm/report/interactions/report.php
index a424d85eadd..f0baa834b4c 100644
--- a/mod/scorm/report/interactions/report.php
+++ b/mod/scorm/report/interactions/report.php
@@ -33,7 +33,7 @@ class scorm_interactions_report extends scorm_default_report {
* @param stdClass $course - full course object
* @param string $download - type of download being requested
*/
- function display($scorm, $cm, $course, $download) {
+ public function display($scorm, $cm, $course, $download) {
global $CFG, $DB, $OUTPUT, $PAGE;
$contextmodule = context_module::instance($cm->id);
@@ -43,14 +43,14 @@ class scorm_interactions_report extends scorm_default_report {
$PAGE->set_url(new moodle_url($PAGE->url, array('attemptsmode' => $attemptsmode)));
if ($action == 'delete' && has_capability('mod/scorm:deleteresponses', $contextmodule) && confirm_sesskey()) {
- if (scorm_delete_responses($attemptids, $scorm)) { //delete responses.
+ if (scorm_delete_responses($attemptids, $scorm)) { // Delete responses.
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');
}
}
- // find out current groups mode
+ // Find out current groups mode.
$currentgroup = groups_get_activity_group($cm, true);
- // detailed report
+ // Detailed report.
$mform = new mod_scorm_report_interactions_settings($PAGE->url, compact('currentgroup'));
if ($fromform = $mform->get_data()) {
$pagesize = $fromform->pagesize;
@@ -71,7 +71,7 @@ class scorm_interactions_report extends scorm_default_report {
$pagesize = SCORM_REPORT_DEFAULT_PAGE_SIZE;
}
- // select group menu
+ // Select group menu.
$displayoptions = array();
$displayoptions['attemptsmode'] = $attemptsmode;
$displayoptions['qtext'] = $includeqtext;
@@ -79,7 +79,7 @@ class scorm_interactions_report extends scorm_default_report {
$displayoptions['right'] = $includeright;
$mform->set_data($displayoptions + array('pagesize' => $pagesize));
- if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used
+ if ($groupmode = groups_get_activity_groupmode($cm)) { // Groups are being used.
if (!$download) {
groups_print_activity_menu($cm, new moodle_url($PAGE->url, $displayoptions));
}
@@ -90,11 +90,11 @@ class scorm_interactions_report extends scorm_default_report {
// if the user has permissions and if the report mode is showing attempts.
$candelete = has_capability('mod/scorm:deleteresponses', $contextmodule)
&& ($attemptsmode != SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO);
- // select the students
+ // Select the students.
$nostudents = false;
if (empty($currentgroup)) {
- // all users who can attempt scoes
+ // All users who can attempt scoes.
if (!$students = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id', '', '', '', '', '', false)) {
echo $OUTPUT->notification(get_string('nostudentsyet'));
$nostudents = true;
@@ -104,8 +104,10 @@ class scorm_interactions_report extends scorm_default_report {
}
unset($students);
} else {
- // all users who can attempt scoes and who are in the currently selected group
- if (!$groupstudents = get_users_by_capability($contextmodule, 'mod/scorm:savetrack', 'u.id', '', '', '', $currentgroup, '', false)) {
+ // All users who can attempt scoes and who are in the currently selected group.
+ if (!$groupstudents = get_users_by_capability($contextmodule,
+ 'mod/scorm:savetrack', 'u.id', '', '', '',
+ $currentgroup, '', false)) {
echo $OUTPUT->notification(get_string('nostudentsingroup'));
$nostudents = true;
$groupstudents = array();
@@ -114,13 +116,13 @@ class scorm_interactions_report extends scorm_default_report {
unset($groupstudents);
}
if ( !$nostudents ) {
- // Now check if asked download of data
+ // Now check if asked download of data.
$coursecontext = context_course::instance($course->id);
if ($download) {
- $filename = clean_filename("$course->shortname ".format_string($scorm->name, true,$formattextoptions));
+ $filename = clean_filename("$course->shortname ".format_string($scorm->name, true, $formattextoptions));
}
- // Define table columns
+ // Define table columns.
$columns = array();
$headers = array();
if (!$download && $candelete) {
@@ -151,32 +153,32 @@ class scorm_interactions_report extends scorm_default_report {
foreach ($scoes as $sco) {
if ($sco->launch != '') {
$columns[] = 'scograde'.$sco->id;
- $headers[] = format_string($sco->title,'',$formattextoptions);
+ $headers[] = format_string($sco->title, '', $formattextoptions);
}
}
$params = array();
list($usql, $params) = $DB->get_in_or_equal($allowedlist, SQL_PARAMS_NAMED);
- // Construct the SQL
+ // Construct the SQL.
$select = 'SELECT DISTINCT '.$DB->sql_concat('u.id', '\'#\'', 'COALESCE(st.attempt, 0)').' AS uniqueid, ';
$select .= 'st.scormid AS scormid, st.attempt AS attempt, ' .
user_picture::fields('u', array('idnumber'), 'userid') .
get_extra_user_fields_sql($coursecontext, 'u', '', array('email', 'idnumber')) . ' ';
- // This part is the same for all cases - join users and scorm_scoes_track tables
+ // This part is the same for all cases - join users and scorm_scoes_track tables.
$from = 'FROM {user} u ';
$from .= 'LEFT JOIN {scorm_scoes_track} st ON st.userid = u.id AND st.scormid = '.$scorm->id;
switch ($attemptsmode) {
case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH:
- // Show only students with attempts
+ // Show only students with attempts.
$where = ' WHERE u.id ' .$usql. ' AND st.userid IS NOT NULL';
break;
case SCORM_REPORT_ATTEMPTS_STUDENTS_WITH_NO:
- // Show only students without attempts
+ // Show only students without attempts.
$where = ' WHERE u.id ' .$usql. ' AND st.userid IS NULL';
break;
case SCORM_REPORT_ATTEMPTS_ALL_STUDENTS:
- // Show all students with or without attempts
+ // Show all students with or without attempts.
$where = ' WHERE u.id ' .$usql. ' AND (st.userid IS NOT NULL OR st.userid IS NULL)';
break;
}
@@ -187,7 +189,7 @@ class scorm_interactions_report extends scorm_default_report {
$countsql .= $from.$where;
$questioncount = get_scorm_question_count($scorm->id);
$nbmaincolumns = count($columns);
- for($id = 0; $id < $questioncount; $id++) {
+ for ($id = 0; $id < $questioncount; $id++) {
if ($displayoptions['qtext']) {
$columns[] = 'question' . $id;
$headers[] = get_string('questionx', 'scormreport_interactions', $id);
@@ -212,7 +214,7 @@ class scorm_interactions_report extends scorm_default_report {
$table->sortable(true);
$table->collapsible(true);
- // This is done to prevent redundant data, when a user has multiple attempts
+ // This is done to prevent redundant data, when a user has multiple attempts.
$table->column_suppress('picture');
$table->column_suppress('fullname');
foreach ($extrafields as $field) {
@@ -225,7 +227,7 @@ class scorm_interactions_report extends scorm_default_report {
$table->no_sorting('checkbox');
$table->no_sorting('picture');
- for($id = 0; $id < $questioncount; $id++) {
+ for ($id = 0; $id < $questioncount; $id++) {
if ($displayoptions['qtext']) {
$table->no_sorting('question'.$id);
}
@@ -251,20 +253,20 @@ class scorm_interactions_report extends scorm_default_report {
$table->set_attribute('id', 'attempts');
$table->set_attribute('class', 'generaltable generalbox');
- // Start working -- this is necessary as soon as the niceties are over
+ // Start working -- this is necessary as soon as the niceties are over.
$table->setup();
} else if ($download == 'ODS') {
require_once("$CFG->libdir/odslib.class.php");
$filename .= ".ods";
- // Creating a workbook
+ // Creating a workbook.
$workbook = new MoodleODSWorkbook("-");
- // Sending HTTP headers
+ // Sending HTTP headers.
$workbook->send($filename);
- // Creating the first worksheet
+ // Creating the first worksheet.
$sheettitle = get_string('report', 'scorm');
$myxls = $workbook->add_worksheet($sheettitle);
- // format types
+ // Format types.
$format = $workbook->add_format();
$format->set_bold(0);
$formatbc = $workbook->add_format();
@@ -284,7 +286,7 @@ class scorm_interactions_report extends scorm_default_report {
$formatg->set_bold(1);
$formatg->set_color('green');
$formatg->set_align('center');
- // Here starts workshhet headers
+ // Here starts workshhet headers.
$colnum = 0;
foreach ($headers as $item) {
@@ -292,18 +294,18 @@ class scorm_interactions_report extends scorm_default_report {
$colnum++;
}
$rownum = 1;
- } else if ($download =='Excel') {
+ } else if ($download == 'Excel') {
require_once("$CFG->libdir/excellib.class.php");
$filename .= ".xls";
- // Creating a workbook
+ // Creating a workbook.
$workbook = new MoodleExcelWorkbook("-");
- // Sending HTTP headers
+ // Sending HTTP headers.
$workbook->send($filename);
- // Creating the first worksheet
+ // Creating the first worksheet.
$sheettitle = get_string('report', 'scorm');
$myxls = $workbook->add_worksheet($sheettitle);
- // format types
+ // Format types.
$format = $workbook->add_format();
$format->set_bold(0);
$formatbc = $workbook->add_format();
@@ -341,7 +343,7 @@ class scorm_interactions_report extends scorm_default_report {
} else {
$sort = '';
}
- // Fix some wired sorting
+ // Fix some wired sorting.
if (empty($sort)) {
$sort = ' ORDER BY uniqueid';
} else {
@@ -349,15 +351,15 @@ class scorm_interactions_report extends scorm_default_report {
}
if (!$download) {
- // Add extra limits due to initials bar
+ // Add extra limits due to initials bar.
list($twhere, $tparams) = $table->get_sql_where();
if ($twhere) {
- $where .= ' AND '.$twhere; //initial bar
+ $where .= ' AND '.$twhere; // Initial bar.
$params = array_merge($params, $tparams);
}
if (!empty($countsql)) {
- $count = $DB->get_record_sql($countsql,$params);
+ $count = $DB->get_record_sql($countsql, $params);
$totalinitials = $count->nbresults;
if ($twhere) {
$countsql .= ' AND '.$twhere;
@@ -368,35 +370,36 @@ class scorm_interactions_report extends scorm_default_report {
$table->pagesize($pagesize, $total);
- echo '';
+ echo html_writer::start_div('scormattemptcounts');
if ( $count->nbresults == $count->nbattempts ) {
echo get_string('reportcountattempts', 'scorm', $count);
- } else if ( $count->nbattempts>0 ) {
+ } else if ( $count->nbattempts > 0 ) {
echo get_string('reportcountallattempts', 'scorm', $count);
} else {
echo $count->nbusers.' '.get_string('users');
}
- echo '
';
+ echo html_writer::end_div();
}
- // Fetch the attempts
+ // Fetch the attempts.
if (!$download) {
$attempts = $DB->get_records_sql($select.$from.$where.$sort, $params,
$table->get_page_start(), $table->get_page_size());
- echo '';
+ echo html_writer::start_div('', array('id' => 'scormtablecontainer'));
if ($candelete) {
- // Start form
+ // Start form.
$strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm'));
- echo '
';
+ echo html_writer::empty_tag('input', array('type' => 'submit',
+ 'value' => get_string('deleteselected', 'quiz_overview')));
+ echo html_writer::end_tag('td').html_writer::end_tag('tr').html_writer::end_tag('table');
+ // Close form.
+ echo html_writer::end_tag('div');
+ echo html_writer::end_tag('form');
}
- echo '
';
+ echo html_writer::end_div();
if (!empty($attempts)) {
- echo '';
- echo '';
+ echo html_writer::start_tag('table', array('class' => 'boxaligncenter')).html_writer::start_tag('tr');
+ echo html_writer::start_tag('td');
echo $OUTPUT->single_button(new moodle_url($PAGE->url,
- array('download'=>'ODS') + $displayoptions),
+ array('download' => 'ODS') + $displayoptions),
get_string('downloadods'));
- echo " \n";
- echo '';
+ echo html_writer::end_tag('td');
+ echo html_writer::start_tag('td');
echo $OUTPUT->single_button(new moodle_url($PAGE->url,
- array('download'=>'Excel') + $displayoptions),
+ array('download' => 'Excel') + $displayoptions),
get_string('downloadexcel'));
- echo " \n";
- echo '';
+ echo html_writer::end_tag('td');
+ echo html_writer::start_tag('td');
echo $OUTPUT->single_button(new moodle_url($PAGE->url,
- array('download'=>'CSV') + $displayoptions),
+ array('download' => 'CSV') + $displayoptions),
get_string('downloadtext'));
- echo " \n";
- echo "";
- echo " \n";
- echo '
';
+ echo html_writer::end_tag('td');
+ echo html_writer::start_tag('td');
+ echo html_writer::end_tag('td');
+ echo html_writer::end_tag('tr').html_writer::end_tag('table');
}
}
} else {
if ($candelete && !$download) {
- echo '';
- echo '';
+ echo html_writer::end_div();
+ echo html_writer::end_tag('form');
$table->finish_output();
}
- echo '';
+ echo html_writer::end_div();
}
- // Show preferences form irrespective of attempts are there to report or not
+ // Show preferences form irrespective of attempts are there to report or not.
if (!$download) {
$mform->set_data(compact('detailedrep', 'pagesize', 'attemptsmode'));
$mform->display();
@@ -609,5 +617,5 @@ class scorm_interactions_report extends scorm_default_report {
} else {
echo $OUTPUT->notification(get_string('noactivity', 'scorm'));
}
- }// function ends
+ }// Function ends.
}
diff --git a/mod/scorm/report/objectives/report.php b/mod/scorm/report/objectives/report.php
index 4a450278319..7cb3666583e 100644
--- a/mod/scorm/report/objectives/report.php
+++ b/mod/scorm/report/objectives/report.php
@@ -295,7 +295,7 @@ class scorm_objectives_report extends scorm_default_report {
$colnum++;
}
$rownum = 1;
- } else if ($download =='Excel') {
+ } else if ($download == 'Excel') {
require_once("$CFG->libdir/excellib.class.php");
$filename .= ".xls";
@@ -371,35 +371,36 @@ class scorm_objectives_report extends scorm_default_report {
$table->pagesize($pagesize, $total);
- echo '';
+ echo html_writer::start_div('scormattemptcounts');
if ( $count->nbresults == $count->nbattempts ) {
echo get_string('reportcountattempts', 'scorm', $count);
- } else if ( $count->nbattempts>0 ) {
+ } else if ( $count->nbattempts > 0 ) {
echo get_string('reportcountallattempts', 'scorm', $count);
} else {
echo $count->nbusers.' '.get_string('users');
}
- echo '
';
+ echo html_writer::end_div();
}
// Fetch the attempts.
if (!$download) {
$attempts = $DB->get_records_sql($select.$from.$where.$sort, $params,
$table->get_page_start(), $table->get_page_size());
- echo '';
+ echo html_writer::start_div('', array('id' => 'scormtablecontainer'));
if ($candelete) {
// Start form.
$strreallydel = addslashes_js(get_string('deleteattemptcheck', 'scorm'));
- echo '
';
+ echo html_writer::end_tag('div');
+ echo html_writer::end_tag('form');
}
- echo '
';
+ echo html_writer::end_div();
if (!empty($attempts)) {
- echo '';
- echo '';
+ echo html_writer::start_tag('table', array('class' => 'boxaligncenter')).html_writer::start_tag('tr');
+ echo html_writer::start_tag('td');
echo $OUTPUT->single_button(new moodle_url($PAGE->url,
- array('download'=>'ODS') + $displayoptions),
+ array('download' => 'ODS') + $displayoptions),
get_string('downloadods'));
- echo " \n";
- echo '';
+ echo html_writer::end_tag('td');
+ echo html_writer::start_tag('td');
echo $OUTPUT->single_button(new moodle_url($PAGE->url,
- array('download'=>'Excel') + $displayoptions),
+ array('download' => 'Excel') + $displayoptions),
get_string('downloadexcel'));
- echo " \n";
- echo '';
+ echo html_writer::end_tag('td');
+ echo html_writer::start_tag('td');
echo $OUTPUT->single_button(new moodle_url($PAGE->url,
- array('download'=>'CSV') + $displayoptions),
+ array('download' => 'CSV') + $displayoptions),
get_string('downloadtext'));
- echo " \n";
- echo "";
- echo " \n";
- echo '
';
+ echo html_writer::end_tag('td');
+ echo html_writer::start_tag('td');
+ echo html_writer::end_tag('td');
+ echo html_writer::end_tag('tr').html_writer::end_tag('table');
}
}
} else {
if ($candelete && !$download) {
- echo '';
- echo '';
+ echo html_writer::end_div();
+ echo html_writer::end_tag('form');
$table->finish_output();
}
- echo '';
+ echo html_writer::end_div();
}
// Show preferences form irrespective of attempts are there to report or not.
if (!$download) {
diff --git a/mod/scorm/reportsettings_form.php b/mod/scorm/reportsettings_form.php
index a34f1214a5a..edef8d64c01 100644
--- a/mod/scorm/reportsettings_form.php
+++ b/mod/scorm/reportsettings_form.php
@@ -15,16 +15,16 @@
// along with Moodle. If not, see .
if (!defined('MOODLE_INTERNAL')) {
- die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
+ die('Direct access to this script is forbidden.'); // It must be included from a Moodle page.
}
require_once("$CFG->libdir/formslib.php");
class mod_scorm_report_settings extends moodleform {
- function definition() {
+ public function definition() {
global $COURSE;
$mform =& $this->_form;
- //-------------------------------------------------------------------------------
+ // -------------------------------------------------------------------------------
$mform->addElement('header', 'preferencespage', get_string('preferencespage', 'scorm'));
$options = array();
@@ -35,7 +35,7 @@ class mod_scorm_report_settings extends moodleform {
}
$mform->addElement('select', 'attemptsmode', get_string('show', 'scorm'), $options);
- //-------------------------------------------------------------------------------
+ // -------------------------------------------------------------------------------
$mform->addElement('header', 'preferencesuser', get_string('preferencesuser', 'scorm'));
$mform->addElement('text', 'pagesize', get_string('pagesize', 'scorm'));
diff --git a/mod/scorm/settings.php b/mod/scorm/settings.php
index 2f7993cb584..ab78be15afc 100644
--- a/mod/scorm/settings.php
+++ b/mod/scorm/settings.php
@@ -21,7 +21,7 @@ if ($ADMIN->fulltree) {
$yesno = array(0 => get_string('no'),
1 => get_string('yes'));
- //default display settings
+ // default display settings
$settings->add(new admin_setting_heading('scorm/displaysettings', get_string('defaultdisplaysettings', 'scorm'), ''));
$settings->add(new admin_setting_configselect_with_advanced('scorm/displaycoursestructure',
@@ -83,13 +83,13 @@ if ($ADMIN->fulltree) {
get_string('displayattemptstatus', 'scorm'), get_string('displayattemptstatusdesc', 'scorm'),
array('value' => 1, 'adv' => false), $yesno));
- //default grade settings
+ // default grade settings
$settings->add(new admin_setting_heading('scorm/gradesettings', get_string('defaultgradesettings', 'scorm'), ''));
$settings->add(new admin_setting_configselect('scorm/grademethod',
get_string('grademethod', 'scorm'), get_string('grademethoddesc', 'scorm'),
GRADEHIGHEST, scorm_get_grade_method_array()));
- for ($i=0; $i<=100; $i++) {
+ for ($i = 0; $i <= 100; $i++) {
$grades[$i] = "$i";
}
@@ -98,7 +98,7 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('scorm/othersettings', get_string('defaultothersettings', 'scorm'), ''));
- //default attempts settings.
+ // default attempts settings.
$settings->add(new admin_setting_configselect('scorm/maxattempt',
get_string('maximumattempts', 'scorm'), '', '0', scorm_get_attempts_array()));
@@ -120,7 +120,7 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configselect('scorm/updatefreq',
get_string('updatefreq', 'scorm'), get_string('updatefreqdesc', 'scorm'), 0, scorm_get_updatefreq_array()));
- //admin level settings.
+ // admin level settings.
$settings->add(new admin_setting_heading('scorm/adminsettings', get_string('adminsettings', 'scorm'), ''));
$settings->add(new admin_setting_configcheckbox('scorm/scorm12standard', get_string('scorm12standard', 'scorm'), get_string('scorm12standarddesc', 'scorm'), 1));
@@ -129,7 +129,8 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configcheckbox('scorm/allowtypelocalsync', get_string('allowtypelocalsync', 'scorm'), '', 0));
- $settings->add(new admin_setting_configcheckbox('scorm/allowtypeexternalaicc', get_string('allowtypeexternalaicc', 'scorm'), get_string('allowtypeexternalaicc_desc', 'scorm'), 0));
+ $settings->add(new admin_setting_configcheckbox('scorm/allowtypeexternalaicc',
+ get_string('allowtypeexternalaicc', 'scorm'), get_string('allowtypeexternalaicc_desc', 'scorm'), 0));
$settings->add(new admin_setting_configcheckbox('scorm/allowaicchacp', get_string('allowtypeaicchacp', 'scorm'), get_string('allowtypeaicchacp_desc', 'scorm'), 0));
diff --git a/mod/scorm/styles.css b/mod/scorm/styles.css
index 362c0b0ca7f..8f82d9f8f52 100644
--- a/mod/scorm/styles.css
+++ b/mod/scorm/styles.css
@@ -159,6 +159,10 @@
white-space: nowrap;
}
+#page-mod-scorm-view .exceededmaxattempts {
+ color: #cc0000;
+}
+
#page-mod-scorm-player #altfinishlink {
font-size: 140%;
border: 0px;
@@ -221,6 +225,13 @@
word-break: break-all;
}
+#page-mod-scorm-report .scormattemptcounts {
+ clear: left;
+ text-align: center;
+ display:inline;
+ margin-left:20%;
+}
+
#page-mod-scorm-player #scormpage span.yui3-treeview-icon {
display: none;
}
diff --git a/mod/scorm/view.php b/mod/scorm/view.php
index fbc1285f510..bd204e0b695 100644
--- a/mod/scorm/view.php
+++ b/mod/scorm/view.php
@@ -28,17 +28,17 @@ if (!empty($id)) {
if (! $cm = get_coursemodule_from_id('scorm', $id, 0, true)) {
print_error('invalidcoursemodule');
}
- if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
+ if (! $course = $DB->get_record("course", array("id" => $cm->course))) {
print_error('coursemisconf');
}
- if (! $scorm = $DB->get_record("scorm", array("id"=>$cm->instance))) {
+ 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))) {
+ if (! $scorm = $DB->get_record("scorm", array("id" => $a))) {
print_error('invalidcoursemodule');
}
- if (! $course = $DB->get_record("course", array("id"=>$scorm->course))) {
+ if (! $course = $DB->get_record("course", array("id" => $scorm->course))) {
print_error('coursemisconf');
}
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id, true)) {
@@ -48,7 +48,7 @@ if (!empty($id)) {
print_error('missingparameter');
}
-$url = new moodle_url('/mod/scorm/view.php', array('id'=>$cm->id));
+$url = new moodle_url('/mod/scorm/view.php', array('id' => $cm->id));
if ($organization !== '') {
$url->param('organization', $organization);
}
@@ -145,12 +145,12 @@ echo $OUTPUT->heading(format_string($scorm->name));
if (!empty($action) && confirm_sesskey() && has_capability('mod/scorm:deleteownresponses', $contextmodule)) {
if ($action == 'delete') {
- $confirmurl = new moodle_url($PAGE->url, array('action'=>'deleteconfirm'));
+ $confirmurl = new moodle_url($PAGE->url, array('action' => 'deleteconfirm'));
echo $OUTPUT->confirm(get_string('deleteuserattemptcheck', 'scorm'), $confirmurl, $PAGE->url);
echo $OUTPUT->footer();
exit;
} else if ($action == 'deleteconfirm') {
- //delete this users attempts.
+ // delete this users attempts.
$DB->delete_records('scorm_scoes_track', array('userid' => $USER->id, 'scormid' => $scorm->id));
scorm_update_grades($scorm, $USER->id, true);
echo $OUTPUT->notification(get_string('scormresponsedeleted', 'scorm'), 'notifysuccess');