Permalink
Browse files

MDL-34468 scorm: Replace all instances of get_context_instance() with…

… respective context_XXXX in mod/scorm
  • Loading branch information...
1 parent c492a78 commit a3fc4b3ad62153ff2889569f38743f74b71f365a @ankitagarwal ankitagarwal committed Jul 24, 2012
View
@@ -195,7 +195,7 @@
if (! $cm = get_coursemodule_from_instance("scorm", $scorm->id, $scorm->course)) {
echo "error=1\r\nerror_text=Unknown\r\n"; // No one must see this error message if not hacked
}
- if (!empty($aiccdata) && has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE, $cm->id), $aiccuser->id)) {
+ if (!empty($aiccdata) && has_capability('mod/scorm:savetrack', context_module::instance($cm->id), $aiccuser->id)) {
$initlessonstatus = 'not attempted';
$lessonstatus = 'not attempted';
if (isset($scormsession->scorm_lessonstatus)) {
View
@@ -53,7 +53,7 @@
if (confirm_sesskey() && (!empty($scoid))) {
$result = true;
$request = null;
- if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE, $cm->id))) {
+ if (has_capability('mod/scorm:savetrack', context_module::instance($cm->id))) {
foreach (data_submitted() as $element => $value) {
$element = str_replace('__', '.', $element);
if (substr($element, 0, 3) == 'cmi') {
@@ -117,7 +117,7 @@ function scorm_parse_aicc($scorm) {
$cm = get_coursemodule_from_instance('scorm', $scorm->id);
$scorm->cmid = $cm->id;
}
- $context = get_context_instance(CONTEXT_MODULE, $scorm->cmid);
+ $context = context_module::instance($scorm->cmid);
$fs = get_file_storage();
View
@@ -41,7 +41,7 @@
require_login($course, false, $cm);
-if (has_capability('mod/scorm:viewreport', get_context_instance(CONTEXT_MODULE, $cm->id))) {
+if (has_capability('mod/scorm:viewreport', context_module::instance($cm->id))) {
redirect('report.php?id='.$cm->id);
} else {
redirect('view.php?id='.$cm->id);
View
@@ -74,7 +74,7 @@
}
foreach ($scorms as $scorm) {
- $context = get_context_instance(CONTEXT_MODULE, $scorm->coursemodule);
+ $context = context_module::instance($scorm->coursemodule);
$tt = "";
if ($usesections) {
if ($scorm->section) {
View
@@ -98,7 +98,7 @@ function scorm_add_instance($scorm, $mform=null) {
$cmidnumber = $scorm->cmidnumber;
$courseid = $scorm->course;
- $context = get_context_instance(CONTEXT_MODULE, $cmid);
+ $context = context_module::instance($cmid);
$scorm = scorm_option2text($scorm);
$scorm->width = (int)str_replace('%', '', $scorm->width);
@@ -189,7 +189,7 @@ function scorm_update_instance($scorm, $mform=null) {
$scorm->id = $scorm->instance;
- $context = get_context_instance(CONTEXT_MODULE, $cmid);
+ $context = context_module::instance($cmid);
if ($scorm->scormtype === SCORM_TYPE_LOCAL) {
if ($mform) {
View
@@ -61,7 +61,7 @@
}
}
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
if (!empty($scoid)) {
//
View
@@ -181,7 +181,7 @@ function scorm_parse($scorm, $full) {
$cm = get_coursemodule_from_instance('scorm', $scorm->id);
$scorm->cmid = $cm->id;
}
- $context = get_context_instance(CONTEXT_MODULE, $scorm->cmid);
+ $context = context_module::instance($scorm->cmid);
$newhash = $scorm->sha1hash;
if ($scorm->scormtype === SCORM_TYPE_LOCAL or $scorm->scormtype === SCORM_TYPE_LOCALSYNC) {
@@ -697,7 +697,7 @@ function scorm_course_format_display($user, $course) {
global $CFG, $DB, $PAGE, $OUTPUT;
$strupdate = get_string('update');
- $context = get_context_instance(CONTEXT_COURSE, $course->id);
+ $context = context_course::instance($course->id);
echo '<div class="mod-scorm">';
if ($scorms = get_all_instances_in_course('scorm', $course)) {
@@ -706,7 +706,7 @@ function scorm_course_format_display($user, $course) {
if (! $cm = get_coursemodule_from_instance('scorm', $scorm->id, $course->id)) {
print_error('invalidcoursemodule');
}
- $contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $contextmodule = context_module::instance($cm->id);
if ((has_capability('mod/scorm:skipview', $contextmodule))) {
scorm_simple_play($scorm, $user, $contextmodule, $cm->id);
}
@@ -1426,7 +1426,7 @@ function scorm_get_toc($user,$scorm,$cmid,$toclink=TOCJSLINK,$currentorg='',$sco
$scoid = $sco->id;
}
}
- if ($usertrack->score_raw != '' && has_capability('mod/scorm:viewscores', get_context_instance(CONTEXT_MODULE,$cmid))) {
+ if ($usertrack->score_raw != '' && has_capability('mod/scorm:viewscores', context_module::instance($cmid))) {
$score = '('.get_string('score','scorm').':&nbsp;'.$usertrack->score_raw.')';
}
$strsuspended = get_string('suspended','scorm');
View
@@ -87,7 +87,7 @@
$strpopup = get_string('popup', 'scorm');
$strexit = get_string('exitactivity', 'scorm');
-$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+$coursecontext = context_course::instance($course->id);
if ($displaymode == 'popup') {
$PAGE->set_pagelayout('popup');
View
@@ -64,7 +64,7 @@
if (confirm_sesskey() && (!empty($scoid))) {
$result = true;
$request = null;
- if (has_capability('mod/scorm:savetrack', get_context_instance(CONTEXT_MODULE, $cm->id))) {
+ if (has_capability('mod/scorm:savetrack', context_module::instance($cm->id))) {
$result = scorm_get_toc($USER, $scorm, $cm->id, TOCJSLINK, $currentorg, $scoid, $mode, $attempt, true, false);
echo $result->toc;
}
View
@@ -36,7 +36,7 @@
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
$scorm = $DB->get_record('scorm', array('id'=>$cm->instance), '*', MUST_EXIST);
-$contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
+$contextmodule = context_module::instance($cm->id);
$reportlist = scorm_report_list($contextmodule);
$url = new moodle_url('/mod/scorm/report.php');
@@ -33,7 +33,7 @@ class scorm_basic_report extends scorm_default_report {
*/
function display($scorm, $cm, $course, $download) {
global $CFG, $DB, $OUTPUT, $PAGE;
- $contextmodule= get_context_instance(CONTEXT_MODULE, $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);
@@ -35,7 +35,7 @@ class scorm_interactions_report extends scorm_default_report {
*/
function display($scorm, $cm, $course, $download) {
global $CFG, $DB, $OUTPUT, $PAGE;
- $contextmodule = get_context_instance(CONTEXT_MODULE, $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);
@@ -84,7 +84,7 @@ function display($scorm, $cm, $course, $download) {
groups_print_activity_menu($cm, new moodle_url($PAGE->url, $displayoptions));
}
}
- $formattextoptions = array('context' => get_context_instance(CONTEXT_COURSE, $course->id));
+ $formattextoptions = array('context' => context_course::instance($course->id));
// We only want to show the checkbox to delete attempts
// if the user has permissions and if the report mode is showing attempts.
View
@@ -32,7 +32,7 @@
$cm = get_coursemodule_from_instance('scorm', $scorm->id);
}
-$contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
+$contextmodule = context_module::instance($cm->id);
$tabs = array();
$row = array();
View
@@ -64,7 +64,7 @@
// checking login +logging +getting context
require_login($course, false, $cm);
-$contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
+$contextmodule = context_module::instance($cm->id);
require_capability('mod/scorm:viewreport', $contextmodule);
add_to_log($course->id, 'scorm', 'userreport', 'userreport.php?id='.$cm->id, $scorm->id, $cm->id);
View
@@ -65,8 +65,8 @@
$PAGE->requires->js('/mod/scorm/view.js', true);
}
-$context = get_context_instance(CONTEXT_COURSE, $course->id);
-$contextmodule = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_course::instance($course->id);
+$contextmodule = context_module::instance($cm->id);
if (isset($SESSION->scorm)) {
unset($SESSION->scorm);

0 comments on commit a3fc4b3

Please sign in to comment.