Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-34466 mod_assignment Replace all instances of get_context_instanc…

…e() with respective context_XXXX class in mod/assignment
  • Loading branch information...
commit 01a67102e698c629685f1b1c4b6eb7ac9b2d8810 1 parent 55a568f
@dmonllao dmonllao authored
View
2  mod/assignment/grade.php
@@ -46,7 +46,7 @@
require_login($course, false, $cm);
-if (has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
+if (has_capability('mod/assignment:grade', context_module::instance($cm->id))) {
if ($userid) {
redirect('submissions.php?id='.$cm->id.'&userid='.$userid.'&mode=single&filter=0&offset=0');
} else {
View
34 mod/assignment/lib.php
@@ -112,7 +112,7 @@ function assignment_base($cmid='staticonly', $assignment=NULL, $cm=NULL, $course
print_error('invalidcoursemodule');
}
- $this->context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+ $this->context = context_module::instance($this->cm->id);
if ($course) {
$this->course = $course;
@@ -121,7 +121,7 @@ function assignment_base($cmid='staticonly', $assignment=NULL, $cm=NULL, $course
} else if (! $this->course = $DB->get_record('course', array('id'=>$this->cm->course))) {
print_error('invalidid', 'assignment');
}
- $this->coursecontext = get_context_instance(CONTEXT_COURSE, $this->course->id);
+ $this->coursecontext = context_course::instance($this->course->id);
$courseshortname = format_text($this->course->shortname, true, array('context' => $this->coursecontext));
if ($assignment) {
@@ -153,7 +153,7 @@ function assignment_base($cmid='staticonly', $assignment=NULL, $cm=NULL, $course
*/
function view() {
- $context = get_context_instance(CONTEXT_MODULE,$this->cm->id);
+ $context = context_module::instance($this->cm->id);
require_capability('mod/assignment:view', $context);
add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}",
@@ -197,7 +197,7 @@ function view_header($subpage='') {
echo '<div class="reportlink">'.$this->submittedlink().'</div>';
echo '<div class="clearer"></div>';
- if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
+ if (has_capability('moodle/site:config', context_system::instance())) {
echo $OUTPUT->notification(get_string('upgradenotification', 'assignment'));
$adminurl = new moodle_url('/admin/tool/assignmentupgrade/listnotupgraded.php');
echo $OUTPUT->single_button($adminurl, get_string('viewassignmentupgradetool', 'assignment'));
@@ -385,7 +385,7 @@ function submittedlink($allgroups=false) {
$submitted = '';
$urlbase = "{$CFG->wwwroot}/mod/assignment/";
- $context = get_context_instance(CONTEXT_MODULE,$this->cm->id);
+ $context = context_module::instance($this->cm->id);
if (has_capability('mod/assignment:grade', $context)) {
if ($allgroups and has_capability('moodle/site:accessallgroups', $context)) {
$group = 0;
@@ -523,7 +523,7 @@ function delete_instance($assignment) {
// now get rid of all files
$fs = get_file_storage();
if ($cm = get_coursemodule_from_instance('assignment', $assignment->id)) {
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
$fs->delete_area_files($context->id);
}
@@ -1004,7 +1004,7 @@ function display_submission($offset=-1,$userid =-1, $display=true) {
$course = $this->course;
$assignment = $this->assignment;
$cm = $this->cm;
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
//reset filter to all for offline assignment
if ($assignment->assignmenttype == 'offline' && $filter == self::FILTER_SUBMITTED) {
@@ -1239,7 +1239,7 @@ function display_submissions($message='') {
//hook to allow plagiarism plugins to update status/print links.
echo plagiarism_update_status($this->course, $this->cm);
- $course_context = get_context_instance(CONTEXT_COURSE, $course->id);
+ $course_context = context_course::instance($course->id);
if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
echo '<div class="allcoursegrades"><a href="' . $CFG->wwwroot . '/grade/report/grader/index.php?id=' . $course->id . '">'
. get_string('seeallcoursegrades', 'grades') . '</a></div>';
@@ -1249,7 +1249,7 @@ function display_submissions($message='') {
echo $message; // display messages here if any
}
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
/// Check to see if groups are being used in this assignment
@@ -1911,7 +1911,7 @@ function count_real_submissions($groupid=0) {
global $DB;
// Grab the context assocated with our course module
- $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+ $context = context_module::instance($this->cm->id);
// Get ids of users enrolled in the given course.
list($enroledsql, $params) = get_enrolled_sql($context, 'mod/assignment:view', $groupid);
@@ -2329,7 +2329,7 @@ function reset_userdata($data) {
if (!$cm = get_coursemodule_from_instance('assignment', $assignmentid)) {
continue;
}
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
$fs->delete_area_files($context->id, 'mod_assignment', 'submission');
$fs->delete_area_files($context->id, 'mod_assignment', 'response');
}
@@ -2540,7 +2540,7 @@ function add_grades_section() {
}
}
}
- $course_context = get_context_instance(CONTEXT_MODULE , $this->_customdata->cm->id);
+ $course_context = context_module::instance($this->_customdata->cm->id);
if (has_capability('gradereport/grader:view', $course_context) && has_capability('moodle/grade:viewall', $course_context)) {
$grade = '<a href="'.$CFG->wwwroot.'/grade/report/grader/index.php?id='. $this->_customdata->courseid .'" >'.
$this->_customdata->grading_info->items[0]->grades[$this->_customdata->userid]->str_grade . '</a>';
@@ -2845,7 +2845,7 @@ function assignment_cron () {
/// mail is customised for the receiver.
cron_setup_user($user, $course);
- $coursecontext = get_context_instance(CONTEXT_COURSE, $submission->course);
+ $coursecontext = context_course::instance($submission->course);
$courseshortname = format_string($course->shortname, true, array('context' => $coursecontext));
if (!is_enrolled($coursecontext, $user->id)) {
echo fullname($user)." not an active participant in " . $courseshortname . "\n";
@@ -3228,7 +3228,7 @@ function assignment_print_recent_activity($course, $viewfullnames, $timestart) {
// the act of sumbitting of assignment may be considered private - only graders will see it if specified
if (empty($CFG->assignment_showrecentsubmissions)) {
if (!array_key_exists($cm->id, $grader)) {
- $grader[$cm->id] = has_capability('moodle/grade:viewall', get_context_instance(CONTEXT_MODULE, $cm->id));
+ $grader[$cm->id] = has_capability('moodle/grade:viewall', context_module::instance($cm->id));
}
if (!$grader[$cm->id]) {
continue;
@@ -3237,7 +3237,7 @@ function assignment_print_recent_activity($course, $viewfullnames, $timestart) {
$groupmode = groups_get_activity_groupmode($cm, $course);
- if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
+ if ($groupmode == SEPARATEGROUPS and !has_capability('moodle/site:accessallgroups', context_module::instance($cm->id))) {
if (isguestuser()) {
// shortcut - guest user does not belong into any group
continue;
@@ -3330,7 +3330,7 @@ function assignment_get_recent_mod_activity(&$activities, &$index, $timestart, $
}
$groupmode = groups_get_activity_groupmode($cm, $course);
- $cm_context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $cm_context = context_module::instance($cm->id);
$grader = has_capability('moodle/grade:viewall', $cm_context);
$accessallgroups = has_capability('moodle/site:accessallgroups', $cm_context);
$viewfullnames = has_capability('moodle/site:viewfullnames', $cm_context);
@@ -3705,7 +3705,7 @@ function assignment_print_overview($courses, &$htmlarray) {
} else {
$str .= '<div class="info">'.$strduedateno.'</div>';
}
- $context = get_context_instance(CONTEXT_MODULE, $assignment->coursemodule);
+ $context = context_module::instance($assignment->coursemodule);
if (has_capability('mod/assignment:grade', $context)) {
// count how many people can submit
View
2  mod/assignment/locallib.php
@@ -156,7 +156,7 @@ public function expected_time() {
}
public function check_permissions() {
- $context = get_context_instance(CONTEXT_MODULE, $this->assignment->cm->id);
+ $context = context_module::instance($this->assignment->cm->id);
return has_capability('mod/assignment:exportownsubmission', $context);
}
View
2  mod/assignment/submissions.php
@@ -42,7 +42,7 @@
$PAGE->set_url($url);
require_login($course, false, $cm);
-require_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id));
+require_capability('mod/assignment:grade', context_module::instance($cm->id));
$PAGE->requires->js('/mod/assignment/assignment.js');
View
4 mod/assignment/type/online/all.php
@@ -27,7 +27,7 @@
require_course_login($course);
// check for view capability at course level
-$context = get_context_instance(CONTEXT_COURSE,$course->id);
+$context = context_course::instance($course->id);
require_capability('mod/assignment:view',$context);
// various strings
@@ -60,7 +60,7 @@
}
// check we are allowed to view this
- $context = get_context_instance(CONTEXT_MODULE, $assignment->coursemodule);
+ $context = context_module::instance($assignment->coursemodule);
if (!has_capability('mod/assignment:view',$context)) {
continue;
}
View
2  mod/assignment/type/online/assignment.class.php
@@ -23,7 +23,7 @@ function view() {
$edit = optional_param('edit', 0, PARAM_BOOL);
$saved = optional_param('saved', 0, PARAM_BOOL);
- $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+ $context = context_module::instance($this->cm->id);
require_capability('mod/assignment:view', $context);
$submission = $this->get_submission($USER->id, false);
View
2  mod/assignment/type/online/file.php
@@ -27,7 +27,7 @@
require_login($course, false, $cm);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
if (($USER->id != $user->id) && !has_capability('mod/assignment:grade', $context)) {
print_error('cannotviewassignment', 'assignment');
}
View
4 mod/assignment/type/upload/assignment.class.php
@@ -405,7 +405,7 @@ function count_real_submissions($groupid=0) {
global $DB;
// Grab the context assocated with our course module
- $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+ $context = context_module::instance($this->cm->id);
// Get ids of users enrolled in the given course.
list($enroledsql, $params) = get_enrolled_sql($context, 'mod/assignment:view', $groupid);
@@ -1081,7 +1081,7 @@ function setup_elements(&$mform) {
$mform->addHelpButton('var4', 'trackdrafts', 'assignment');
$mform->setDefault('var4', 1);
- $course_context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
+ $course_context = context_course::instance($COURSE->id);
plagiarism_get_form_elements_module($mform, $course_context);
}
View
2  mod/assignment/type/upload/notes.php
@@ -36,7 +36,7 @@
require_login($course, false, $cm);
-if (!has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
+if (!has_capability('mod/assignment:grade', context_module::instance($cm->id))) {
print_error('cannotviewassignment', 'assignment');
}
View
2  mod/assignment/type/upload/upload.php
@@ -50,7 +50,7 @@
print_error('invalidid', 'assignment');
}
-$fullname = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
+$fullname = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
$PAGE->set_url($url);
$PAGE->set_context($context);
View
6 mod/assignment/type/uploadsingle/assignment.class.php
@@ -62,7 +62,7 @@ function view() {
global $USER, $OUTPUT;
- $context = get_context_instance(CONTEXT_MODULE,$this->cm->id);
+ $context = context_module::instance($this->cm->id);
require_capability('mod/assignment:view', $context);
add_to_log($this->course->id, "assignment", "view", "view.php?id={$this->cm->id}", $this->assignment->id, $this->cm->id);
@@ -114,7 +114,7 @@ function count_real_submissions($groupid=0) {
global $DB;
// Grab the context assocated with our course module
- $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+ $context = context_module::instance($this->cm->id);
// Get ids of users enrolled in the given course.
list($enroledsql, $params) = get_enrolled_sql($context, 'mod/assignment:view', $groupid);
@@ -293,7 +293,7 @@ function setup_elements(&$mform) {
$mform->addElement('select', 'maxbytes', get_string('maximumsize', 'assignment'), $choices);
$mform->setDefault('maxbytes', $CFG->assignment_maxbytes);
- $course_context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
+ $course_context = context_course::instance($COURSE->id);
plagiarism_get_form_elements_module($mform, $course_context);
}
View
2  mod/assignment/type/uploadsingle/upload.php
@@ -51,7 +51,7 @@
}
$instance = new assignment_uploadsingle($cm->id, $assignment, $cm, $course);
-$fullname = format_string($course->fullname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
+$fullname = format_string($course->fullname, true, array('context' => context_course::instance($course->id)));
$PAGE->set_url($url);
$PAGE->set_context($context);
Please sign in to comment.
Something went wrong with that request. Please try again.