3 require_once '../../../config.php';
4 require_once $CFG->dirroot
.'/grade/lib.php';
6 $courseid = required_param('id', PARAM_INT
);
7 $action = required_param('action', PARAM_ALPHA
);
8 $eid = required_param('eid', PARAM_ALPHANUM
);
10 /// Make sure they can even access this course
11 if (!$course = get_record('course', 'id', $courseid)) {
12 print_error('nocourseid');
14 require_login($course);
15 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
18 $gpr = new grade_plugin_return();
19 $returnurl = $gpr->get_return_url($CFG->wwwroot
.'/grade/edit/tree/index.php?id='.$course->id
);
21 // get the grading tree object
22 $gtree = new grade_tree($courseid, false, false);
24 // what are we working with?
25 if (!$element = $gtree->locate_element($eid)) {
26 error('Incorrect element id!', $returnurl);
28 $object = $element['object'];
33 if ($eid and confirm_sesskey()) {
34 if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:hide', $context)) {
35 error('No permission to hide!', $returnurl);
37 $object->set_hidden(1);
42 if ($eid and confirm_sesskey()) {
43 if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:hide', $context)) {
44 error('No permission to show!', $returnurl);
46 $object->set_hidden(0);
51 if ($eid and confirm_sesskey()) {
52 if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:lock', $context)) {
53 error('No permission to lock!', $returnurl);
55 $object->set_locked(1);
60 if ($eid and confirm_sesskey()) {
61 if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:unlock', $context)) {
62 error('No permission to unlock!', $returnurl);
64 $object->set_locked(0);
70 //redirect($returnurl, 'debug delay', 5);