ROLES AND PERMISSIONS - FIRST CHECK-IN

=======================================

WARNING:  DEV IS CURRENTLY VERY UNSTABLE.

This is a mega-checkin of the new Roles system.   A lot of changes have
been made in core and modules.

Currently there are a lot of rough edges and known problems.  We are
working hard on these .. .the reason for getting this into HEAD at this
stage is enable us to move faster (our branch was diverging from HEAD
too much).

Please keep an eye on http://docs.moodle.org/en/Roles for current status
and information for developers on how to use the new Roles system.
This commit is contained in:
moodler 2006-08-08 05:13:06 +00:00
parent 394577c3e4
commit bbbf2d4015
139 changed files with 40452 additions and 2001 deletions

View file

@ -55,6 +55,8 @@
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$strexercises = get_string("modulenameplural", "exercise");
$strexercise = get_string("modulename", "exercise");
$strassessments = get_string("assessments", "exercise");
@ -71,7 +73,7 @@
/******************* admin amend Grading Grade ************************************/
if ($action == 'adminamendgradinggrade' ) {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}
if (empty($aid)) {
@ -109,7 +111,7 @@
/******************* admin confirm delete ************************************/
elseif ($action == 'adminconfirmdelete' ) {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}
if (empty($aid)) {
@ -125,7 +127,7 @@
/******************* admin delete ************************************/
elseif ($action == 'admindelete' ) {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}
if (empty($aid)) {
@ -145,7 +147,7 @@
/*********************** admin list of asssessments (of a submission) (by teachers)**************/
elseif ($action == 'adminlist') {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}
@ -161,7 +163,7 @@
/****************** admin list of asssessments by a student (used by teachers only )******************/
elseif ($action == 'adminlistbystudent') {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}
@ -258,7 +260,7 @@
/****************** edit assessment elements (for teachers) ***********************/
elseif ($action == 'editelements') {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}
@ -455,7 +457,7 @@
/****************** insert/update assignment elements (for teachers)***********************/
elseif ($action == 'insertelements') {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}
@ -572,7 +574,7 @@
/****************** list assessments for grading (Student submissions)(by teachers)*********************/
elseif ($action == 'listungradedstudentsubmissions') {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}
exercise_list_ungraded_assessments($exercise, "student");
@ -584,7 +586,7 @@
******************Teacher's submissions) (by teachers)****/
elseif ($action == 'listungradedstudentassessments') {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}
exercise_list_ungraded_assessments($exercise, "teacher");
@ -603,7 +605,7 @@
/******************* regrade student assessments ************************************/
elseif ($action == 'regradestudentassessments' ) {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}
// get all the student assessments
@ -636,7 +638,7 @@
/****************** teacher assessment : grading of assessment and submission (from student) ************/
elseif ($action == 'teacherassessment') {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}
@ -659,7 +661,7 @@
/****************** teacher table : show assessments by exercise and teacher ************/
elseif ($action == 'teachertable') {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}
@ -850,7 +852,7 @@
}
// is user allowed to resubmit?
if (isteacher($course->id)) {
if (has_capability('mod/exercise:assess', $context->id)) {
if (!$submission = get_record("exercise_submissions", "id", $assessment->submissionid)) {
error ("Updateassessment: submission record not found");
}
@ -885,7 +887,7 @@
/****************** update teacher assessment (by teacher only) ***************************/
elseif ($action == 'updateteacherassessment') {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}
@ -1098,7 +1100,7 @@
/****************** update grading grade(by teacher) ***************************/
elseif ($action == 'updategradinggrade') {
if (!isteacher($course->id)) {
if (!has_capability('mod/exercise:assess', $context->id)) {
error("Only teachers can look at this page");
}

View file

@ -0,0 +1,52 @@
<?php
//
// Capability definitions for the exercise module.
//
// The capabilities are loaded into the database table when the module is
// installed or updated. Whenever the capability definitions are updated,
// the module version number should be bumped up.
//
// The system has four possible values for a capability:
// CAP_ALLOW, CAP_PREVENT, CAP_PROHIBIT, and inherit (not set).
//
//
// CAPABILITY NAMING CONVENTION
//
// It is important that capability names are unique. The naming convention
// for capabilities that are specific to modules and blocks is as follows:
// [mod/block]/<component_name>:<capabilityname>
//
// component_name should be the same as the directory name of the mod or block.
//
// Core moodle capabilities are defined thus:
// moodle/<capabilityclass>:<capabilityname>
//
// Examples: mod/forum:viewpost
// block/recent_activity:view
// moodle/site:deleteuser
//
// The variable name for the capability definitions array follows the format
// $<componenttype>_<component_name>_capabilities
//
// For the core capabilities, the variable is $moodle_capabilities.
$mod_exercise_capabilities = array(
'mod/exercise:assess' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_MODULE,
'legacy' => array(
'guest' => CAP_PREVENT,
'student' => CAP_PREVENT,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'coursecreator' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
)
);
?>

View file

@ -5,7 +5,7 @@
// This fragment is called by /admin/index.php
////////////////////////////////////////////////////////////////////////////////
$module->version = 2005031000;
$module->version = 2006080800;
$module->requires = 2005031000; // Requires this Moodle version
$module->cron = 60;

View file

@ -38,6 +38,8 @@
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
// ...log activity...
add_to_log($course->id, "exercise", "view", "view.php?id=$cm->id", $exercise->id, $cm->id);
@ -308,8 +310,8 @@
/****************** submission of assignment by teacher only***********************/
elseif ($action == 'submitassignment') {
if (!isteacheredit($course->id)) {
error("Only teachers with editing permissions can do this.");
if (!has_capability('mod/exercise:assess', $context->id)) {
//error("Only teachers with editing permissions can do this.");
}
exercise_print_assignment_info($exercise);