Permalink
Browse files

MDL-34466 mod_choice Replace all instances of get_context_instance() …

…with respective context_XXXX class in mod/choice
  • Loading branch information...
1 parent c068b41 commit 327c67a9714e8e19a7ee74c7d9facfb8fed40dfd @dmonllao dmonllao committed Jul 26, 2012
Showing with 8 additions and 12 deletions.
  1. +4 −6 mod/choice/lib.php
  2. +1 −1 mod/choice/report.php
  3. +3 −5 mod/choice/view.php
View
@@ -200,7 +200,7 @@ function choice_prepare_options($choice, $user, $coursemodule, $allresponses) {
$cdisplay = array('options'=>array());
$cdisplay['limitanswers'] = true;
- $context = get_context_instance(CONTEXT_MODULE, $coursemodule->id);
+ $context = context_module::instance($coursemodule->id);
foreach ($choice->option as $optionid => $text) {
if (isset($text)) { //make sure there are no dud entries in the db with blank text values.
@@ -248,7 +248,7 @@ function choice_user_submit_response($formanswer, $choice, $userid, $course, $cm
require_once($CFG->libdir.'/completionlib.php');
$current = $DB->get_record('choice_answers', array('choiceid' => $choice->id, 'userid' => $userid));
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
$countanswers=0;
if($choice->limitanswers) {
@@ -368,7 +368,7 @@ function prepare_choice_show_results($choice, $course, $cm, $allresponses, $forc
unset($display->maxanswers);
$display->numberofuser = $totaluser;
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
$display->viewresponsecapability = has_capability('mod/choice:readresponses', $context);
$display->deleterepsonsecapability = has_capability('mod/choice:deleteresponses',$context);
$display->fullnamecapability = has_capability('moodle/site:viewfullnames', $context);
@@ -386,8 +386,6 @@ function prepare_choice_show_results($choice, $course, $cm, $allresponses, $forc
}
}
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
$hascapfullnames = has_capability('moodle/site:viewfullnames', $context);
$viewresponses = has_capability('mod/choice:readresponses', $context);
@@ -708,7 +706,7 @@ function choice_reset_userdata($data) {
function choice_get_response_data($choice, $cm, $groupmode) {
global $CFG, $USER, $DB;
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
/// Get the current group
if ($groupmode > 0) {
@@ -31,7 +31,7 @@
require_login($course, false, $cm);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
require_capability('mod/choice:readresponses', $context);
View
@@ -31,9 +31,7 @@
$strchoice = get_string('modulename', 'choice');
$strchoices = get_string('modulenameplural', 'choice');
- if (!$context = get_context_instance(CONTEXT_MODULE, $cm->id)) {
- print_error('badcontext');
- }
+ $context = context_module::instance($cm->id);
if ($action == 'delchoice' and confirm_sesskey() and is_enrolled($context, NULL, 'mod/choice:choose') and $choice->allowupdate) {
if ($answer = $DB->get_record('choice_answers', array('choiceid' => $choice->id, 'userid' => $USER->id))) {
@@ -133,7 +131,7 @@
}
if (!$choiceformshown) {
- $sitecontext = get_context_instance(CONTEXT_SYSTEM);
+ $sitecontext = context_system::instance();
if (isguestuser()) {
// Guest account
@@ -144,7 +142,7 @@
$SESSION->wantsurl = qualified_me();
$SESSION->enrolcancel = (!empty($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : '';
- $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
+ $coursecontext = context_course::instance($course->id);
$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
echo $OUTPUT->box_start('generalbox', 'notice');

0 comments on commit 327c67a

Please sign in to comment.