mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
Merge branch 'wip-MDL-34463-master' of git://github.com/abgreeve/moodle
This commit is contained in:
commit
4ea5885e87
@ -34,7 +34,7 @@ $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
|
||||
|
||||
/// Make sure they can even access this course
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/course:update', $context);
|
||||
|
||||
/// return tracking object
|
||||
|
@ -40,7 +40,7 @@ if ($id !== 0) {
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_pagelayout('admin');
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$systemcontext = context_system::instance();
|
||||
$heading = null;
|
||||
|
||||
// a bit complex access control :-O
|
||||
@ -57,7 +57,7 @@ if ($id) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
$courseid = $course->id;
|
||||
} else {
|
||||
@ -77,7 +77,7 @@ if ($id) {
|
||||
/// adding new outcome from course
|
||||
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
navigation_node::override_active_url(new moodle_url('/grade/edit/outcome/course.php', array('id'=>$courseid)));
|
||||
|
||||
|
@ -121,7 +121,7 @@ class edit_outcome_form extends moodleform {
|
||||
if (empty($courseid)) {
|
||||
$mform->hardFreeze('standard');
|
||||
|
||||
} else if (empty($outcome->courseid) and !has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
} else if (empty($outcome->courseid) and !has_capability('moodle/grade:manage', context_system::instance())) {
|
||||
$mform->hardFreeze('standard');
|
||||
|
||||
} else if ($coursecount and empty($outcome->courseid)) {
|
||||
@ -130,7 +130,7 @@ class edit_outcome_form extends moodleform {
|
||||
|
||||
|
||||
} else {
|
||||
if (empty($courseid) or !has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (empty($courseid) or !has_capability('moodle/grade:manage', context_system::instance())) {
|
||||
$mform->hardFreeze('standard');
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ if ($courseid) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
if (empty($CFG->enableoutcomes)) {
|
||||
@ -49,10 +49,6 @@ if ($courseid) {
|
||||
|
||||
require_sesskey();
|
||||
|
||||
// $outcome = grade_outcome::fetch(array('id'=>$outcomeid));
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
|
||||
header("Content-Type: text/csv; charset=utf-8");
|
||||
// TODO: make the filename more useful, include a date, a specific name, something...
|
||||
header('Content-Disposition: attachment; filename=outcomes.csv');
|
||||
|
@ -40,7 +40,7 @@ if ($courseid) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
if (empty($CFG->enableoutcomes)) {
|
||||
redirect('../../index.php?id='.$courseid);
|
||||
@ -49,7 +49,7 @@ if ($courseid) {
|
||||
} else {
|
||||
require_once $CFG->libdir.'/adminlib.php';
|
||||
admin_externalpage_setup('outcomes');
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$context = context_system::instance();
|
||||
}
|
||||
|
||||
require_capability('moodle/grade:manageoutcomes', $context);
|
||||
@ -79,7 +79,7 @@ if (!$upload_form->save_file('userfile', $imported_file, true)) {
|
||||
if (isset($courseid) && ($scope == 'custom')) {
|
||||
// custom scale
|
||||
$local_scope = true;
|
||||
} elseif (($scope == 'global') && has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
} elseif (($scope == 'global') && has_capability('moodle/grade:manage', context_system::instance())) {
|
||||
// global scale
|
||||
$local_scope = false;
|
||||
} else {
|
||||
|
@ -41,7 +41,7 @@ class import_outcomes_form extends moodleform {
|
||||
$mform->setType('id', PARAM_INT);
|
||||
|
||||
$scope = array();
|
||||
if (($PAGE->course->id > 1) && has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (($PAGE->course->id > 1) && has_capability('moodle/grade:manage', context_system::instance())) {
|
||||
$mform->addElement('radio', 'scope', get_string('importcustom', 'grades'), null, 'custom');
|
||||
$mform->addElement('radio', 'scope', get_string('importstandard', 'grades'), null, 'global');
|
||||
$mform->setDefault('scope', 'custom');
|
||||
|
@ -36,7 +36,7 @@ $PAGE->set_pagelayout('admin');
|
||||
if ($courseid) {
|
||||
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manageoutcomes', $context);
|
||||
|
||||
if (empty($CFG->enableoutcomes)) {
|
||||
@ -76,7 +76,7 @@ switch ($action) {
|
||||
}
|
||||
|
||||
if (empty($outcome->courseid)) {
|
||||
require_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_capability('moodle/grade:manage', context_system::instance());
|
||||
} else if ($outcome->courseid != $courseid) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
@ -105,7 +105,7 @@ switch ($action) {
|
||||
break;
|
||||
}
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$systemcontext = context_system::instance();
|
||||
$caneditsystemscales = has_capability('moodle/course:managescales', $systemcontext);
|
||||
|
||||
if ($courseid) {
|
||||
@ -138,7 +138,7 @@ if ($courseid and $outcomes = grade_outcome::fetch_all_local($courseid)) {
|
||||
} else if ($scale->courseid == $courseid) {
|
||||
$caneditthisscale = $caneditcoursescales;
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $scale->courseid);
|
||||
$context = context_course::instance($scale->courseid);
|
||||
$caneditthisscale = has_capability('moodle/course:managescales', $context);
|
||||
}
|
||||
if ($caneditthisscale) {
|
||||
@ -187,7 +187,7 @@ if ($outcomes = grade_outcome::fetch_all_global()) {
|
||||
} else if ($scale->courseid == $courseid) {
|
||||
$caneditthisscale = $caneditcoursescales;
|
||||
} else {
|
||||
$context = get_context_instance(CONTEXT_COURSE, $scale->courseid);
|
||||
$context = context_course::instance($scale->courseid);
|
||||
$caneditthisscale = has_capability('moodle/course:managescales', $context);
|
||||
}
|
||||
if ($caneditthisscale) {
|
||||
@ -201,10 +201,10 @@ if ($outcomes = grade_outcome::fetch_all_global()) {
|
||||
$line[] = $outcome->get_item_uses_count();
|
||||
|
||||
$buttons = "";
|
||||
if (has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_capability('moodle/grade:manage', context_system::instance())) {
|
||||
$buttons .= grade_button('edit', $courseid, $outcome);
|
||||
}
|
||||
if (has_capability('moodle/grade:manage', get_context_instance(CONTEXT_SYSTEM)) and $outcome->can_delete()) {
|
||||
if (has_capability('moodle/grade:manage', context_system::instance()) and $outcome->can_delete()) {
|
||||
$buttons .= grade_button('delete', $courseid, $outcome);
|
||||
}
|
||||
$line[] = $buttons;
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
$row = $tabs = array();
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
|
||||
$row[] = new tabobject('courseoutcomes',
|
||||
$CFG->wwwroot.'/grade/edit/outcome/course.php?id='.$courseid,
|
||||
|
@ -33,7 +33,7 @@ $id = optional_param('id', 0, PARAM_INT);
|
||||
$PAGE->set_url('/grade/edit/scale/edit.php', array('id' => $id, 'courseid' => $courseid));
|
||||
$PAGE->set_pagelayout('admin');
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$systemcontext = context_system::instance();
|
||||
$heading = '';
|
||||
|
||||
// a bit complex access control :-O
|
||||
@ -50,7 +50,7 @@ if ($id) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/course:managescales', $context);
|
||||
$courseid = $course->id;
|
||||
} else {
|
||||
@ -75,7 +75,7 @@ if ($id) {
|
||||
$scale_rec->standard = 0;
|
||||
$scale_rec->courseid = $courseid;
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/course:managescales', $context);
|
||||
|
||||
} else {
|
||||
|
@ -88,7 +88,7 @@ class edit_scale_form extends moodleform {
|
||||
if (empty($courseid)) {
|
||||
$mform->hardFreeze('standard');
|
||||
|
||||
} else if (!has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
} else if (!has_capability('moodle/course:managescales', context_system::instance())) {
|
||||
//if they dont have managescales at system level the shouldnt be allowed to make scales standard (or not standard)
|
||||
$mform->hardFreeze('standard');
|
||||
|
||||
@ -102,7 +102,7 @@ class edit_scale_form extends moodleform {
|
||||
|
||||
} else {
|
||||
$mform->removeElement('used');
|
||||
if (empty($courseid) or !has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (empty($courseid) or !has_capability('moodle/course:managescales', context_system::instance())) {
|
||||
$mform->hardFreeze('standard');
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ if ($courseid) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/course:managescales', $context);
|
||||
$PAGE->set_pagelayout('admin');
|
||||
} else {
|
||||
@ -69,7 +69,7 @@ switch ($action) {
|
||||
}
|
||||
|
||||
if (empty($scale->courseid)) {
|
||||
require_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM));
|
||||
require_capability('moodle/course:managescales', context_system::instance());
|
||||
} else if ($scale->courseid != $courseid) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
@ -147,10 +147,10 @@ if ($scales = grade_scale::fetch_all_global()) {
|
||||
$line[] = $used ? get_string('yes') : get_string('no');
|
||||
|
||||
$buttons = "";
|
||||
if (has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (has_capability('moodle/course:managescales', context_system::instance())) {
|
||||
$buttons .= grade_button('edit', $courseid, $scale);
|
||||
}
|
||||
if (!$used and has_capability('moodle/course:managescales', get_context_instance(CONTEXT_SYSTEM))) {
|
||||
if (!$used and has_capability('moodle/course:managescales', context_system::instance())) {
|
||||
$buttons .= grade_button('delete', $courseid, $scale);
|
||||
}
|
||||
$line[] = $buttons;
|
||||
|
@ -39,7 +39,7 @@ class course_settings_form extends moodleform {
|
||||
|
||||
$mform =& $this->_form;
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$systemcontext = context_system::instance();
|
||||
$can_view_admin_links = false;
|
||||
if (has_capability('moodle/grade:manage', $systemcontext)) {
|
||||
$can_view_admin_links = true;
|
||||
|
@ -36,7 +36,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
|
@ -36,7 +36,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
// default return url
|
||||
$gpr = new grade_plugin_return();
|
||||
|
@ -43,7 +43,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// default return url
|
||||
|
@ -42,7 +42,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// default return url
|
||||
|
@ -50,7 +50,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
|
||||
$PAGE->set_pagelayout('incourse');
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
if (!has_capability('moodle/grade:manage', $context)) {
|
||||
require_capability('moodle/grade:edit', $context);
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ class edit_grade_form extends moodleform {
|
||||
function definition_after_data() {
|
||||
global $CFG, $COURSE, $DB;
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $COURSE->id);
|
||||
$context = context_course::instance($COURSE->id);
|
||||
|
||||
$mform =& $this->_form;
|
||||
$grade_item = $this->_customdata['grade_item'];
|
||||
|
@ -47,7 +47,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// todo $PAGE->requires->js_module() should be used here instead
|
||||
|
@ -43,7 +43,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
// default return url
|
||||
|
@ -41,7 +41,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:manage', $context);
|
||||
|
||||
|
||||
|
@ -119,7 +119,7 @@ class grade_export_form extends moodleform {
|
||||
|
||||
if ($grade_items = $gseq->items) {
|
||||
$needs_multiselect = false;
|
||||
$canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $COURSE->id));
|
||||
$canviewhidden = has_capability('moodle/grade:viewhidden', context_course::instance($COURSE->id));
|
||||
|
||||
foreach ($grade_items as $grade_item) {
|
||||
// Is the grade_item hidden? If so, can the user see hidden grade_items?
|
||||
|
@ -59,7 +59,7 @@ if ($id) {
|
||||
$key->courseid = $course->id;
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:export', $context);
|
||||
|
||||
// extra security check
|
||||
|
@ -35,7 +35,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
|
||||
require_capability('moodle/grade:export', $context);
|
||||
|
||||
|
@ -29,7 +29,7 @@ if (empty($CFG->gradepublishing)) {
|
||||
print_error('gradepubdisable');
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
require_capability('gradeexport/ods:publish', $context);
|
||||
|
||||
// use the same page parameters as export.php and append &key=sdhakjsahdksahdkjsahksadjksahdkjsadhksa
|
||||
|
@ -33,7 +33,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/ods:view', $context);
|
||||
|
@ -32,7 +32,7 @@ class grade_export_ods extends grade_export {
|
||||
|
||||
$strgrades = get_string('grades');
|
||||
|
||||
$shortname = format_string($this->course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $this->course->id)));
|
||||
$shortname = format_string($this->course->shortname, true, array('context' => context_course::instance($this->course->id)));
|
||||
|
||||
// Calculate file name
|
||||
$downloadfilename = clean_filename("$shortname $strgrades.ods");
|
||||
|
@ -28,7 +28,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/ods:view', $context);
|
||||
|
@ -29,7 +29,7 @@ if (empty($CFG->gradepublishing)) {
|
||||
print_error('gradepubdisable');
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
require_capability('gradeexport/txt:publish', $context);
|
||||
|
||||
// use the same page parameters as export.php and append &key=sdhakjsahdksahdkjsahksadjksahdkjsadhksa
|
||||
|
@ -34,7 +34,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/txt:view', $context);
|
||||
|
@ -74,7 +74,7 @@ class grade_export_txt extends grade_export {
|
||||
@header('Pragma: no-cache');
|
||||
}
|
||||
header("Content-Type: application/download\n");
|
||||
$shortname = format_string($this->course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $this->course->id)));
|
||||
$shortname = format_string($this->course->shortname, true, array('context' => context_course::instance($this->course->id)));
|
||||
$downloadfilename = clean_filename("$shortname $strgrades");
|
||||
header("Content-Disposition: attachment; filename=\"$downloadfilename.txt\"");
|
||||
|
||||
|
@ -28,7 +28,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/txt:view', $context);
|
||||
|
@ -29,7 +29,7 @@ if (empty($CFG->gradepublishing)) {
|
||||
print_error('gradepubdisable');
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
require_capability('gradeexport/xls:publish', $context);
|
||||
|
||||
// use the same page parameters as export.php and append &key=sdhakjsahdksahdkjsahksadjksahdkjsadhksa
|
||||
|
@ -33,7 +33,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/xls:view', $context);
|
||||
|
@ -33,7 +33,7 @@ class grade_export_xls extends grade_export {
|
||||
$strgrades = get_string('grades');
|
||||
|
||||
// Calculate file name
|
||||
$shortname = format_string($this->course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $this->course->id)));
|
||||
$shortname = format_string($this->course->shortname, true, array('context' => context_course::instance($this->course->id)));
|
||||
$downloadfilename = clean_filename("$shortname $strgrades.xls");
|
||||
// Creating a workbook
|
||||
$workbook = new MoodleExcelWorkbook("-");
|
||||
|
@ -28,7 +28,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/xls:view', $context);
|
||||
|
@ -29,7 +29,7 @@ if (empty($CFG->gradepublishing)) {
|
||||
print_error('gradepubdisable');
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
require_capability('gradeexport/xml:publish', $context);
|
||||
|
||||
// use the same page parameters as export.php and append &key=sdhakjsahdksahdkjsahksadjksahdkjsadhksa
|
||||
|
@ -33,7 +33,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/xml:view', $context);
|
||||
|
@ -38,7 +38,7 @@ class grade_export_xml extends grade_export {
|
||||
$strgrades = get_string('grades');
|
||||
|
||||
/// Calculate file name
|
||||
$shortname = format_string($this->course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $this->course->id)));
|
||||
$shortname = format_string($this->course->shortname, true, array('context' => context_course::instance($this->course->id)));
|
||||
$downloadfilename = clean_filename("$shortname $strgrades.xml");
|
||||
|
||||
make_temp_directory('gradeexport');
|
||||
|
@ -28,7 +28,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
|
||||
require_capability('moodle/grade:export', $context);
|
||||
require_capability('gradeexport/xml:view', $context);
|
||||
|
@ -41,7 +41,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
require_capability('moodle/grade:import', $context);
|
||||
require_capability('gradeimport/csv:view', $context);
|
||||
|
||||
|
@ -59,7 +59,7 @@ if ($id) {
|
||||
$key->courseid = $course->id;
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('moodle/grade:import', $context);
|
||||
|
||||
// extra security check
|
||||
|
@ -35,7 +35,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
|
||||
require_capability('moodle/grade:import', $context);
|
||||
|
||||
|
@ -161,13 +161,13 @@ function grade_import_commit($courseid, $importcode, $importfeedback=true, $verb
|
||||
*/
|
||||
function get_unenrolled_users_in_import($importcode, $courseid) {
|
||||
global $CFG, $DB;
|
||||
$relatedctxcondition = get_related_contexts_string(get_context_instance(CONTEXT_COURSE, $courseid));
|
||||
$relatedctxcondition = get_related_contexts_string(context_course::instance($courseid));
|
||||
|
||||
//users with a gradeable role
|
||||
list($gradebookrolessql, $gradebookrolesparams) = $DB->get_in_or_equal(explode(',', $CFG->gradebookroles), SQL_PARAMS_NAMED, 'grbr');
|
||||
|
||||
//enrolled users
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
list($enrolledsql, $enrolledparams) = get_enrolled_sql($context);
|
||||
|
||||
$sql = "SELECT giv.id, u.firstname, u.lastname, u.idnumber AS useridnumber,
|
||||
|
@ -29,7 +29,7 @@ if (empty($CFG->gradepublishing)) {
|
||||
print_error('gradepubdisable');
|
||||
}
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
require_capability('gradeimport/xml:publish', $context);
|
||||
|
||||
// use the same page parameters as import.php and append &key=sdhakjsahdksahdkjsahksadjksahdkjsadhksa
|
||||
|
@ -34,7 +34,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
|
||||
require_capability('moodle/grade:import', $context);
|
||||
require_capability('gradeimport/xml:view', $context);
|
||||
|
@ -29,7 +29,7 @@ if (!$course = $DB->get_record('course', array('id'=>$id))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $id);
|
||||
$context = context_course::instance($id);
|
||||
require_capability('moodle/grade:import', $context);
|
||||
require_capability('gradeimport/xml:view', $context);
|
||||
|
||||
|
@ -135,7 +135,7 @@ class graded_users_iterator {
|
||||
return false;
|
||||
}
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $this->course->id);
|
||||
$coursecontext = context_course::instance($this->course->id);
|
||||
$relatedcontexts = get_related_contexts_string($coursecontext);
|
||||
|
||||
list($gradebookroles_sql, $params) =
|
||||
@ -568,7 +568,7 @@ function grade_print_tabs($active_type, $active_plugin, $plugin_info, $return=fa
|
||||
function grade_get_plugin_info($courseid, $active_type, $active_plugin) {
|
||||
global $CFG, $SITE;
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
|
||||
$plugin_info = array();
|
||||
$count = 0;
|
||||
@ -1674,7 +1674,7 @@ class grade_seq extends grade_structure {
|
||||
global $USER, $CFG;
|
||||
|
||||
$this->courseid = $courseid;
|
||||
$this->context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$this->context = context_course::instance($courseid);
|
||||
|
||||
// get course grade tree
|
||||
$top_element = grade_category::fetch_course_tree($courseid, true);
|
||||
@ -1828,7 +1828,7 @@ class grade_tree extends grade_structure {
|
||||
|
||||
$this->courseid = $courseid;
|
||||
$this->levels = array();
|
||||
$this->context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$this->context = context_course::instance($courseid);
|
||||
|
||||
if (!empty($COURSE->id) && $COURSE->id == $this->courseid) {
|
||||
$course = $COURSE;
|
||||
@ -2459,7 +2459,7 @@ abstract class grade_helper {
|
||||
if (self::$managesetting !== null) {
|
||||
return self::$managesetting;
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
if (has_capability('moodle/course:update', $context)) {
|
||||
self::$managesetting = new grade_plugin_info('coursesettings', new moodle_url('/grade/edit/settings/index.php', array('id'=>$courseid)), get_string('course'));
|
||||
} else {
|
||||
@ -2479,7 +2479,7 @@ abstract class grade_helper {
|
||||
if (self::$gradereports !== null) {
|
||||
return self::$gradereports;
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
$gradereports = array();
|
||||
$gradepreferences = array();
|
||||
foreach (get_plugin_list('gradereport') as $plugin => $plugindir) {
|
||||
@ -2539,7 +2539,7 @@ abstract class grade_helper {
|
||||
if (self::$scaleinfo !== null) {
|
||||
return self::$scaleinfo;
|
||||
}
|
||||
if (has_capability('moodle/course:managescales', get_context_instance(CONTEXT_COURSE, $courseid))) {
|
||||
if (has_capability('moodle/course:managescales', context_course::instance($courseid))) {
|
||||
$url = new moodle_url('/grade/edit/scale/index.php', array('id'=>$courseid));
|
||||
self::$scaleinfo = new grade_plugin_info('scale', $url, get_string('view'));
|
||||
} else {
|
||||
@ -2558,7 +2558,7 @@ abstract class grade_helper {
|
||||
if (self::$outcomeinfo !== null) {
|
||||
return self::$outcomeinfo;
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
$canmanage = has_capability('moodle/grade:manage', $context);
|
||||
$canupdate = has_capability('moodle/course:update', $context);
|
||||
if (!empty($CFG->enableoutcomes) && ($canmanage || $canupdate)) {
|
||||
@ -2593,7 +2593,7 @@ abstract class grade_helper {
|
||||
if (self::$edittree !== null) {
|
||||
return self::$edittree;
|
||||
}
|
||||
if (has_capability('moodle/grade:manage', get_context_instance(CONTEXT_COURSE, $courseid))) {
|
||||
if (has_capability('moodle/grade:manage', context_course::instance($courseid))) {
|
||||
$url = new moodle_url('/grade/edit/tree/index.php', array('sesskey'=>sesskey(), 'showadvanced'=>'0', 'id'=>$courseid));
|
||||
self::$edittree = array(
|
||||
'simpleview' => new grade_plugin_info('simpleview', $url, get_string('simpleview', 'grades')),
|
||||
@ -2613,7 +2613,7 @@ abstract class grade_helper {
|
||||
if (self::$letterinfo !== null) {
|
||||
return self::$letterinfo;
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
$canmanage = has_capability('moodle/grade:manage', $context);
|
||||
$canmanageletters = has_capability('moodle/grade:manageletters', $context);
|
||||
if ($canmanage || $canmanageletters) {
|
||||
@ -2638,7 +2638,7 @@ abstract class grade_helper {
|
||||
return self::$importplugins;
|
||||
}
|
||||
$importplugins = array();
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
|
||||
if (has_capability('moodle/grade:import', $context)) {
|
||||
foreach (get_plugin_list('gradeimport') as $plugin => $plugindir) {
|
||||
@ -2676,7 +2676,7 @@ abstract class grade_helper {
|
||||
if (self::$exportplugins !== null) {
|
||||
return self::$exportplugins;
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_COURSE, $courseid);
|
||||
$context = context_course::instance($courseid);
|
||||
$exportplugins = array();
|
||||
if (has_capability('moodle/grade:export', $context)) {
|
||||
foreach (get_plugin_list('gradeexport') as $plugin => $plugindir) {
|
||||
|
@ -39,7 +39,7 @@ $newvalue = optional_param('newvalue', false, PARAM_TEXT);
|
||||
if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_login($course);
|
||||
|
||||
switch ($action) {
|
||||
|
@ -46,7 +46,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
require_capability('gradereport/grader:view', $context);
|
||||
require_capability('moodle/grade:viewall', $context);
|
||||
|
@ -107,7 +107,7 @@ class grade_report_grader extends grade_report {
|
||||
global $CFG;
|
||||
parent::__construct($courseid, $gpr, $context, $page);
|
||||
|
||||
$this->canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->course->id));
|
||||
$this->canviewhidden = has_capability('moodle/grade:viewhidden', context_course::instance($this->course->id));
|
||||
|
||||
// load collapsed settings for this report
|
||||
if ($collapsed = get_user_preferences('grade_report_grader_collapsed_categories')) {
|
||||
|
@ -40,8 +40,8 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
|
||||
require_login($course);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$context = context_course::instance($course->id);
|
||||
$systemcontext = context_system::instance();
|
||||
require_capability('gradereport/grader:view', $context);
|
||||
|
||||
require('preferences_form.php');
|
||||
|
@ -40,8 +40,7 @@ class grader_report_preferences_form extends moodleform {
|
||||
$mform =& $this->_form;
|
||||
$course = $this->_customdata['course'];
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
$canviewhidden = has_capability('moodle/grade:viewhidden', $context);
|
||||
|
||||
|
@ -52,7 +52,7 @@ if (!$item = $DB->get_record('grade_items', array('id' => $itemid))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
require_capability('gradereport/grader:view', $context);
|
||||
require_capability('moodle/grade:viewall', $context);
|
||||
|
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
$row = $tabs = array();
|
||||
$tabcontext = get_context_instance(CONTEXT_COURSE, $COURSE->id);
|
||||
$tabcontext = context_course::instance($COURSE->id);
|
||||
$row[] = new tabobject('graderreport',
|
||||
$CFG->wwwroot.'/grade/report/grader/index.php?id='.$courseid,
|
||||
get_string('pluginname', 'gradereport_grader'));
|
||||
|
@ -33,7 +33,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
print_error('nocourseid');
|
||||
}
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
/// find all accessible reports
|
||||
$reports = get_plugin_list('gradereport'); // Get all installed reports
|
||||
|
@ -35,7 +35,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
}
|
||||
|
||||
require_login($course);
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
require_capability('gradereport/outcomes:view', $context);
|
||||
|
||||
|
@ -38,8 +38,8 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
}
|
||||
require_login($course);
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$context = context_course::instance($course->id);
|
||||
$systemcontext = context_system::instance();
|
||||
require_capability('gradereport/overview:view', $context);
|
||||
|
||||
if (empty($userid)) {
|
||||
@ -64,7 +64,7 @@ if (has_capability('moodle/grade:viewall', $systemcontext)) {
|
||||
//ok - can view own course grades
|
||||
$access = true;
|
||||
|
||||
} else if (has_capability('moodle/grade:viewall', get_context_instance(CONTEXT_USER, $userid)) and $course->showgrades) {
|
||||
} else if (has_capability('moodle/grade:viewall', context_user::instance($userid)) and $course->showgrades) {
|
||||
// ok - can view grades of this user- parent most probably
|
||||
$access = true;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ class grade_report_overview extends grade_report {
|
||||
continue;
|
||||
}
|
||||
|
||||
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$coursecontext = context_course::instance($course->id);
|
||||
|
||||
if (!$course->visible && !has_capability('moodle/course:viewhiddencourses', $coursecontext)) {
|
||||
// The course is hidden and the user isn't allowed to see it
|
||||
|
@ -39,7 +39,7 @@ if (!$course = $DB->get_record('course', array('id' => $courseid))) {
|
||||
require_login($course);
|
||||
$PAGE->set_pagelayout('report');
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
require_capability('gradereport/user:view', $context);
|
||||
|
||||
if (empty($userid)) {
|
||||
@ -60,7 +60,7 @@ if (has_capability('moodle/grade:viewall', $context)) {
|
||||
//ok - can view own grades
|
||||
$access = true;
|
||||
|
||||
} else if (has_capability('moodle/grade:viewall', get_context_instance(CONTEXT_USER, $userid)) and $course->showgrades) {
|
||||
} else if (has_capability('moodle/grade:viewall', context_user::instance($userid)) and $course->showgrades) {
|
||||
// ok - can view grades of this user- parent most probably
|
||||
$access = true;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ class grade_report_user extends grade_report {
|
||||
|
||||
$this->tabledata = array();
|
||||
|
||||
$this->canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->courseid));
|
||||
$this->canviewhidden = has_capability('moodle/grade:viewhidden', context_course::instance($this->courseid));
|
||||
|
||||
// get the user (for full name)
|
||||
$this->user = $DB->get_record('user', array('id' => $userid));
|
||||
@ -870,7 +870,7 @@ function grade_report_user_profilereport($course, $user) {
|
||||
global $OUTPUT;
|
||||
if (!empty($course->showgrades)) {
|
||||
|
||||
$context = get_context_instance(CONTEXT_COURSE, $course->id);
|
||||
$context = context_course::instance($course->id);
|
||||
|
||||
//first make sure we have proper final grades - this must be done before constructing of the grade tree
|
||||
grade_regrade_final_grades($course->id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user