From 7b8732344eca9d24a6a091d9552c02d891c37f25 Mon Sep 17 00:00:00 2001 From: bobopinna Date: Fri, 8 Jul 2005 06:56:49 +0000 Subject: [PATCH] changed all the POST with option/required_param functions --- mod/scorm/aicc.php | 9 ++- mod/scorm/api.php | 17 +++-- mod/scorm/datamodel.php | 38 +++++----- mod/scorm/index.php | 10 ++- mod/scorm/loadSCO.php | 17 +++-- mod/scorm/mod.html | 2 +- mod/scorm/playscorm.php | 150 ++++++++++++++++++++-------------------- mod/scorm/report.php | 16 +++-- mod/scorm/styles.php | 14 +++- mod/scorm/validate.php | 25 ++++--- mod/scorm/view.php | 22 +++--- 11 files changed, 175 insertions(+), 145 deletions(-) diff --git a/mod/scorm/aicc.php b/mod/scorm/aicc.php index 813b29192da..5caa6312251 100755 --- a/mod/scorm/aicc.php +++ b/mod/scorm/aicc.php @@ -2,10 +2,13 @@ require_once('../../config.php'); require_once('lib.php'); - //require_login($course->id, false, $cm); + $command = required_param('command', '', PARAM_ALPHA); + $sessionid = required_param('session_id', '', PARAM_ALPHA); + + require_login($course->id, false, $cm); - if (isset($_POST['command']) && confirm_sesskey($_POST['session_id'])) { - $command = strtolower($_POST['command']); + if (!empty($command) && confirm_sesskey($sessionid)) { + $command = strtolower($command); if (isset($SESSION->scorm_scoid)) { $scoid = $SESSION->scorm_scoid; diff --git a/mod/scorm/api.php b/mod/scorm/api.php index 020f077d8ad..44965404fd1 100644 --- a/mod/scorm/api.php +++ b/mod/scorm/api.php @@ -3,25 +3,22 @@ require_once("../../config.php"); require_once("lib.php"); - optional_variable($id); // Course Module ID, or - optional_variable($a); // scorm ID - require_variable($scoid); // sco ID - optional_variable($mode); // navigation mode + $id = optional_param('id', '', PARAM_INT); // Course Module ID, or + $a = optional_param('a', '', PARAM_INT); // scorm ID + $scoid = required_param('scoid', '', PARAM_INT); // sco ID + $mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode - if ($id) { + if (!empty($id)) { if (! $cm = get_record("course_modules", "id", $id)) { error("Course Module ID was incorrect"); } - if (! $course = get_record("course", "id", $cm->course)) { error("Course is misconfigured"); } - if (! $scorm = get_record("scorm", "id", $cm->instance)) { error("Course module is incorrect"); } - - } else { + } else if (!empty($a)) { if (! $scorm = get_record("scorm", "id", $a)) { error("Course module is incorrect"); } @@ -31,6 +28,8 @@ if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { error("Course Module ID was incorrect"); } + } else { + error('A required parameter is missing'); } require_login($course->id, false, $cm); diff --git a/mod/scorm/datamodel.php b/mod/scorm/datamodel.php index 8a1f70b2e9f..f7bbe1be002 100755 --- a/mod/scorm/datamodel.php +++ b/mod/scorm/datamodel.php @@ -2,35 +2,37 @@ require_once('../../config.php'); require_once('lib.php'); - optional_variable($id); // Course Module ID, or - optional_variable($a); // scorm IDa + $id = optional_param('id', '', PARAM_INT); // Course Module ID, or + $a = optional_param('a', '', PARAM_INT); // scorm ID + $scoid = required_param('scoid', '', PARAM_INT); // sco ID - if ($id) { - if (! $cm = get_record('course_modules', 'id', $id)) { - error('Course Module ID was incorrect'); + if (!empty($id)) { + if (! $cm = get_record("course_modules", "id", $id)) { + error("Course Module ID was incorrect"); } - if (! $course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + if (! $course = get_record("course", "id", $cm->course)) { + error("Course is misconfigured"); } - if (! $scorm = get_record('scorm', 'id', $cm->instance)) { - error('Course module is incorrect'); + if (! $scorm = get_record("scorm", "id", $cm->instance)) { + error("Course module is incorrect"); } - } else { - if (! $scorm = get_record('scorm', 'id', $a)) { - error('Course module is incorrect'); + } else if (!empty($a)) { + if (! $scorm = get_record("scorm", "id", $a)) { + error("Course module is incorrect"); } - if (! $course = get_record('course', 'id', $scorm->course)) { - error('Course is misconfigured'); + if (! $course = get_record("course", "id", $scorm->course)) { + error("Course is misconfigured"); } - if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) { - error('Course Module ID was incorrect'); + if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { + error("Course Module ID was incorrect"); } + } else { + error('A required parameter is missing'); } require_login($course->id, false, $cm); - if (confirm_sesskey() && (isset($_POST['scoid']))) { - $scoid = $_POST['scoid']; + if (confirm_sesskey() && (!empty($scoid))) { $result = true; foreach ($_POST as $element => $value) { if (substr($element,0,3) == 'cmi') { diff --git a/mod/scorm/index.php b/mod/scorm/index.php index 2fbb3816519..415ede123f2 100755 --- a/mod/scorm/index.php +++ b/mod/scorm/index.php @@ -2,10 +2,14 @@ require_once("../../config.php"); - require_variable($id); // course + $id = required_param('id', '', PARAM_INT); // course id - if (! $course = get_record("course", "id", $id)) { - error("Course ID is incorrect"); + if (!empty($id)) { + if (! $course = get_record("course", "id", $id)) { + error("Course ID is incorrect"); + } + } else { + error('A required parameter is missing'); } require_course_login($course); diff --git a/mod/scorm/loadSCO.php b/mod/scorm/loadSCO.php index a8166b5fc97..89afbc0a66a 100755 --- a/mod/scorm/loadSCO.php +++ b/mod/scorm/loadSCO.php @@ -2,25 +2,22 @@ require_once("../../config.php"); require_once("lib.php"); - optional_variable($id); // Course Module ID, or - optional_variable($a); // scorm ID - optional_variable($scoid); // sco ID - optional_variable($mode); // lesson mode + $id = optional_param('id', '', PARAM_INT); // Course Module ID, or + $a = optional_param('a', '', PARAM_INT); // scorm ID + $scoid = optional_param('scoid', '', PARAM_INT); // sco ID + $mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode - if ($id) { + if (!empty($id)) { if (! $cm = get_record("course_modules", "id", $id)) { error("Course Module ID was incorrect"); } - if (! $course = get_record("course", "id", $cm->course)) { error("Course is misconfigured"); } - if (! $scorm = get_record("scorm", "id", $cm->instance)) { error("Course module is incorrect"); } - - } else { + } else if (!empty($a)) { if (! $scorm = get_record("scorm", "id", $a)) { error("Course module is incorrect"); } @@ -30,6 +27,8 @@ if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { error("Course Module ID was incorrect"); } + } else { + error('A required parameter is missing'); } require_login($course->id, false, $cm); diff --git a/mod/scorm/mod.html b/mod/scorm/mod.html index 1046ea74240..4ce777ec3d5 100755 --- a/mod/scorm/mod.html +++ b/mod/scorm/mod.html @@ -15,7 +15,7 @@ if (empty($form->auto)) { $form->auto = ""; } - if (empty($form->auto)) { + if (empty($form->popup)) { $form->popup = "0"; } if (empty($form->datadir)) { diff --git a/mod/scorm/playscorm.php b/mod/scorm/playscorm.php index 074321bda2b..1b074ac110a 100755 --- a/mod/scorm/playscorm.php +++ b/mod/scorm/playscorm.php @@ -5,38 +5,58 @@ require_once('../../config.php'); require_once('lib.php'); - optional_variable($id); // Course Module ID, or - optional_variable($a); // scorm ID + $id = optional_param('id', '', PARAM_INT); // Course Module ID, or + $a = optional_param('a', '', PARAM_INT); // scorm ID + $scoid = required_param('scoid', '', PARAM_INT); // sco ID + $mode = optional_param('mode', '', PARAM_ALPHA); // navigation mode + $currentorg = optional_param('currentorg', '', PARAM_); // selected organization + + // + // Checkin script parameters + // + $modestring = ''; + $scoidstring = ''; + $currentorgstring = ''; + if (!empty($mode)) { + $modestring = '&mode='.$mode; + } + if (!empty($scoid)) { + $scoidstring = '&scoid='.$scoid; + } + if (!empty($currentorg)) { + $currentorgstring = '¤torg='.$currentorg; + } - if ($id) { - if (! $cm = get_record('course_modules', 'id', $id)) { - error('Course Module ID was incorrect'); + if (!empty($id)) { + if (! $cm = get_record("course_modules", "id", $id)) { + error("Course Module ID was incorrect"); } - - if (! $course = get_record('course', 'id', $cm->course)) { - error('Course is misconfigured'); + if (! $course = get_record("course", "id", $cm->course)) { + error("Course is misconfigured"); } - - if (! $scorm = get_record('scorm', 'id', $cm->instance)) { - error('Course module is incorrect'); + if (! $scorm = get_record("scorm", "id", $cm->instance)) { + error("Course module is incorrect"); } - - } else { - if (! $scorm = get_record('scorm', 'id', $a)) { - error('Course module is incorrect'); + } else if (!empty($a)) { + if (! $scorm = get_record("scorm", "id", $a)) { + error("Course module is incorrect"); } - if (! $course = get_record('course', 'id', $scorm->course)) { - error('Course is misconfigured'); + if (! $course = get_record("course", "id", $scorm->course)) { + error("Course is misconfigured"); } - if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) { - error('Course Module ID was incorrect'); + if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { + error("Course Module ID was incorrect"); } + } else { + error('A required parameter is missing'); } require_login($course->id, false, $cm); $strscorms = get_string('modulenameplural', 'scorm'); $strscorm = get_string('modulename', 'scorm'); + $strexpand = get_string('expcoll','scorm'); + $strpopup = get_string('popup','scorm'); if ($course->category) { $navigation = "framename}\" href=\"../../course/view.php?id=$course->id\">$course->shortname -> @@ -53,31 +73,6 @@ notice(get_string("activityiscurrentlyhidden")); } - // - // Checkin script parameters - // - $mode = ''; - $scoid=''; - $currentorg=''; - $modestring = ''; - $scoidstring = ''; - $currentorgstring = ''; - if (!empty($_POST['mode'])) { - $mode = $_POST['mode']; - $modestring = '&mode='.$mode; - } - if (!empty($_POST['scoid'])) { - $scoid = $_POST['scoid']; - $scoidstring = '&scoid='.$scoid; - } - if (!empty($_POST['currentorg'])) { - $currentorg = $_POST['currentorg']; - $currentorgstring = '¤torg='.$currentorg; - } - - $strexpand = get_string('expcoll','scorm'); - $strpopup = get_string('popup','scorm'); - // // TOC processing // @@ -110,51 +105,58 @@ ?> + -
- '.get_string('browsemode','scorm').'

' : ''; ?> - + hidetoc == 0) { ?> - - - - - - + popup == 0) { + $browseclass = 'class="left"'; + } ?> - + + + + + + + + + popup == 0) { ?> - + +
-
-
- toc; - ?> -
+ + + + + + + +
toc; ?>
+
+ + + + '.get_string('browsemode','scorm').'' : ''; ?> + -
- - - - - - -
-
-
- -
+ +
+
+ - + \ No newline at end of file diff --git a/mod/scorm/report.php b/mod/scorm/report.php index c4d90e6cbad..63c1582b83a 100755 --- a/mod/scorm/report.php +++ b/mod/scorm/report.php @@ -5,11 +5,11 @@ require_once("../../config.php"); require_once("lib.php"); - optional_variable($id); // Course Module ID, or - optional_variable($b); // SCO ID - optional_variable($user); // User ID + $id = optional_param('id', '', PARAM_INT); // Course Module ID, or + $b = optional_param('b', '', PARAM_INT); // sco ID + $user = optional_param('user', '', PARAM_INT); // user ID - if ($id) { + if (!empty($id)) { if (! $cm = get_record("course_modules", "id", $id)) { error("Course Module ID was incorrect"); } @@ -19,12 +19,12 @@ if (! $scorm = get_record("scorm", "id", $cm->instance)) { error("Course module is incorrect"); } - } else if (isset($b)) { + } else if (!empty($b)) { if (! $sco = get_record("scorm_scoes", "id", $b)) { - error("Scorm activity is incorrect"); + error("Course module is incorrect"); } if (! $scorm = get_record("scorm", "id", $sco->scorm)) { - error("Course module is incorrect"); + error("Scorm activity is incorrect"); } if (! $course = get_record("course", "id", $scorm->course)) { error("Course is misconfigured"); @@ -32,6 +32,8 @@ if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { error("Course Module ID was incorrect"); } + } else { + error('A required parameter is missing'); } require_login($course->id, false, $cm); diff --git a/mod/scorm/styles.php b/mod/scorm/styles.php index e4435fe1b9d..4a21da440e5 100644 --- a/mod/scorm/styles.php +++ b/mod/scorm/styles.php @@ -1,9 +1,20 @@ .top { vertical-align: top; } +.left { + float: left; +} .center { text-align: center; } +.right { + float: right; +} + +.scoframe { + +} + .fullscreen { width: 100%; } @@ -25,9 +36,6 @@ text-indent:-4ex; font-size: small; } -#mod-scorm-playscorm .popupbutton { - float: right; -} #mod-scorm-view .structurehead { font-weight: bold; diff --git a/mod/scorm/validate.php b/mod/scorm/validate.php index 6ba14a2e10a..c1941654f55 100755 --- a/mod/scorm/validate.php +++ b/mod/scorm/validate.php @@ -1,16 +1,25 @@ id, false, $cm); + +if (confirm_sesskey() && !empty($courseid)) { $launch = 0; - if (isset($_POST["instance"])) { - $scormid = $_POST["instance"]; + $validation = new stdClass(); + if (empty($reference)) { + $launch = -1; + $validation->result = "packagefile"; + } + if (!empty($scormid)) { + // + // SCORM Update + // if (is_file($CFG->dataroot.'/'.$courseid.'/'.$reference)) { $fp = fopen($CFG->dataroot.'/'.$courseid.'/'.$reference,"r"); $fstat = fstat($fp); diff --git a/mod/scorm/view.php b/mod/scorm/view.php index fc93177b474..e05957e7928 100755 --- a/mod/scorm/view.php +++ b/mod/scorm/view.php @@ -6,10 +6,11 @@ require_once("../../config.php"); require_once("lib.php"); - optional_variable($id); // Course Module ID, or - optional_variable($a); // scorm ID + $id = optional_param('id', '', PARAM_INT); // Course Module ID, or + $a = optional_param('a', '', PARAM_INT); // scorm ID + $organization = optional_param('organization', '', PARAM_INT); // organization ID - if ($id) { + if (!empty($id)) { if (! $cm = get_record("course_modules", "id", $id)) { error("Course Module ID was incorrect"); } @@ -19,7 +20,7 @@ if (! $scorm = get_record("scorm", "id", $cm->instance)) { error("Course module is incorrect"); } - } else { + } else if (!empty($a)) { if (! $scorm = get_record("scorm", "id", $a)) { error("Course module is incorrect"); } @@ -29,6 +30,8 @@ if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $course->id)) { error("Course Module ID was incorrect"); } + } else { + error('A required parameter is missing'); } require_login($course->id, false, $cm); @@ -86,15 +89,14 @@ ?>
launch; + if (empty($organization)) { + $organization = $scorm->launch; + } if ($orgs = get_records_select_menu('scorm_scoes',"scorm='$scorm->id' AND organization='' AND launch=''",'id','id,title')) { - if (count($orgs) > 1) { - if (isset($_POST['organization'])) { - $organization = $_POST['organization']; - } + if (count($orgs) > 1) { ?>
- +
-- 2.43.0