MDL-11275 added (submissions). Also fixed :

Issue:
    Teachers can edit grader report preferences (including switches for quickgrading and
    quickfeedback), but do not have access to the "Turn editing on/off" button, so they
    can't do quickgrading.
Solutions:
    1.Decouple the quickgrading and quickfeedback modes from the editing mode,
        and turn them on/off through the preferences page. New capability: moodle/grade:edit
        * preferences: don't show quickgrading if no capability grade:edit
        * If quickgrading is switched off as a preference and user doesn't have manage cap, show edit icons around grades when in editing mode
This commit is contained in:
nicolasconnault 2007-09-17 17:31:48 +00:00
parent 07a7d85924
commit a5b8be622c
11 changed files with 132 additions and 103 deletions

View File

@ -17,7 +17,7 @@ if (!$course = get_record('course', 'id', $courseid)) {
require_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
if (!has_capability('moodle/grade:manage', $context)) {
require_capability('moodle/grade:override', $context);
require_capability('moodle/grade:edit', $context);
}
// default return url
@ -191,7 +191,7 @@ if ($mform->is_cancelled()) {
$grade_grade->set_excluded($data->excluded);
}
if (isset($data->overridden) and has_capability('moodle/grade:manage', $context) or has_capability('moodle/grade:override', $context)) {
if (isset($data->overridden) and has_capability('moodle/grade:manage', $context) or has_capability('moodle/grade:edit', $context)) {
// ignore overridden flag when changing final grade
if ($old_grade_grade->finalgrade == $grade_grade->finalgrade) {
$grade_grade->set_overridden($data->overridden);

View File

@ -967,7 +967,7 @@ class grade_tree {
global $CFG;
if (!has_capability('moodle/grade:manage', $this->context)) {
if ($element['type'] == 'grade' and has_capability('moodle/grade:override', $this->context)) {
if ($element['type'] == 'grade' and has_capability('moodle/grade:edit', $this->context)) {
// oki - let them override grade
} else {
return '';

View File

@ -73,7 +73,7 @@ if (!isset($USER->gradeediting)) {
$USER->gradeediting = array();
}
if (has_capability('moodle/grade:override', $context)) {
if (has_capability('moodle/grade:edit', $context)) {
if (!isset($USER->gradeediting[$course->id])) {
$USER->gradeediting[$course->id] = 0;
}

View File

@ -121,7 +121,7 @@ class grade_report_grader extends grade_report {
*/
function process_data($data) {
if (!has_capability('moodle/grade:override', $this->context)) {
if (!has_capability('moodle/grade:edit', $this->context)) {
return false;
}
@ -591,7 +591,7 @@ class grade_report_grader extends grade_report {
$scales_list = substr($scales_list, 0, -1);
$scales_array = get_records_list('scale', 'id', $scales_list);
}
$canviewhidden = has_capability('moodle/grade:viewhidden', get_context_instance(CONTEXT_COURSE, $this->course->id));
foreach ($this->users as $userid => $user) {
@ -629,7 +629,7 @@ class grade_report_grader extends grade_report {
$studentshtml .= '<td class="cell c'.$columncount++.'">'.userdate($grade->timecreated,get_string('strftimedatetimeshort')).'</td>'; } else {
$studentshtml .= '<td class="cell c'.$columncount++.'">-</td>';
}
continue;
continue;
}
$grade->courseid = $this->courseid;
@ -822,6 +822,10 @@ class grade_report_grader extends grade_report {
$groupwheresql = null;
}
if ($shownumberofgrades) {
$straverage .= ' (' . get_string('submissions', 'grades') . ') ';
}
$totalcount = $this->get_numusers($grouponly);
if ($showaverages) {
@ -1024,16 +1028,19 @@ class grade_report_grader extends grade_report {
$show_hide_icon = '';
$lock_unlock_icon = '';
if ($this->get_pref('showcalculations')) {
$edit_calculation_icon = $this->gtree->get_calculation_icon($element, $this->gpr);
}
if (has_capability('moodle/grade:manage', $this->context)) {
if ($this->get_pref('showeyecons')) {
$show_hide_icon = $this->gtree->get_hiding_icon($element, $this->gpr);
}
if ($this->get_pref('showcalculations')) {
$edit_calculation_icon = $this->gtree->get_calculation_icon($element, $this->gpr);
}
if ($this->get_pref('showlocks')) {
$lock_unlock_icon = $this->gtree->get_locking_icon($element, $this->gpr);
if ($this->get_pref('showeyecons')) {
$show_hide_icon = $this->gtree->get_hiding_icon($element, $this->gpr);
}
if ($this->get_pref('showlocks')) {
$lock_unlock_icon = $this->gtree->get_locking_icon($element, $this->gpr);
}
}
return '<div class="grade_icons">'.$edit_icon.$edit_calculation_icon.$show_hide_icon.$lock_unlock_icon.'</div>';

View File

@ -38,7 +38,7 @@ if (!$course = get_record('course', 'id', $courseid)) {
require_login($course->id);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('moodle/grade:manage', $context);
require_capability('gradereport/grader:view', $context);
// If data submitted, then process and store.
if ($data = data_submitted()) {

View File

@ -14,6 +14,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);
$strgradeboundary = get_string('gradeboundary', 'grades');
@ -35,59 +36,75 @@ class grader_report_preferences_form extends moodleform {
/// form definition with preferences defaults
//--------------------------------------------------------------------------------
$preferences = array();
$preferences['prefgeneral'] = array(
'studentsperpage' => 'text',
'quickgrading' => $checkbox_default,
'quickfeedback' => $checkbox_default,
'decimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default', 0, 1, 2, 3, 4, 5),
'aggregationposition' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_AGGREGATION_POSITION_LEFT => get_string('left', 'grades'),
GRADE_REPORT_AGGREGATION_POSITION_RIGHT => get_string('right', 'grades')),
'aggregationview' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_AGGREGATION_VIEW_FULL => get_string('fullmode', 'grades'),
GRADE_REPORT_AGGREGATION_VIEW_AGGREGATES_ONLY => get_string('aggregatesonly', 'grades'),
GRADE_REPORT_AGGREGATION_VIEW_GRADES_ONLY => get_string('gradesonly', 'grades')),
'gradedisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')),
'meanselection' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_MEAN_ALL => get_string('meanall', 'grades'),
GRADE_REPORT_MEAN_GRADED => get_string('meangraded', 'grades')),
'enableajax' => $checkbox_default);
$preferences['prefshow'] = array('showcalculations' => $checkbox_default,
'showeyecons' => $checkbox_default,
'showaverages' => $checkbox_default,
'showgroups' => $checkbox_default,
'showlocks' => $checkbox_default,
'showranges' => $checkbox_default,
'showuserimage' => $checkbox_default,
'showactivityicons' => $checkbox_default);
$preferences['prefrows'] = array(
'shownumberofgrades' => $checkbox_default,
'averagesdisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')),
'rangesdisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')),
'averagesdecimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit, 0, 1, 2, 3, 4, 5),
'rangesdecimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit, 0, 1, 2, 3, 4, 5));
// Initialise the preferences arrays with grade:manage capabilities
if (has_capability('moodle/grade:manage', $context)) {
$preferences['prefgeneral'] = array(
'decimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default', 0, 1, 2, 3, 4, 5),
'aggregationview' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_AGGREGATION_VIEW_FULL => get_string('fullmode', 'grades'),
GRADE_REPORT_AGGREGATION_VIEW_AGGREGATES_ONLY => get_string('aggregatesonly', 'grades'),
GRADE_REPORT_AGGREGATION_VIEW_GRADES_ONLY => get_string('gradesonly', 'grades')),
'gradedisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')),
'meanselection' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_MEAN_ALL => get_string('meanall', 'grades'),
GRADE_REPORT_MEAN_GRADED => get_string('meangraded', 'grades')));
for ($i = 1; $i <= 10; $i++) {
$preferences['prefletters']['gradeletter' . $i] = 'text';
$preferences['prefletters']['gradeboundary' . $i] = $percentages;
$preferences['prefshow'] = array('showcalculations' => $checkbox_default,
'showeyecons' => $checkbox_default,
'showaverages' => $checkbox_default,
'showgroups' => $checkbox_default,
'showlocks' => $checkbox_default);
$preferences['prefrows'] = array(
'averagesdisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')),
'rangesdisplaytype' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit,
GRADE_REPORT_GRADE_DISPLAY_TYPE_REAL => get_string('real', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades'),
GRADE_REPORT_GRADE_DISPLAY_TYPE_LETTER => get_string('letter', 'grades')),
'averagesdecimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit, 0, 1, 2, 3, 4, 5),
'rangesdecimalpoints' => array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_PREFERENCE_INHERIT => $strinherit, 0, 1, 2, 3, 4, 5));
for ($i = 1; $i <= 10; $i++) {
$preferences['prefletters']['gradeletter' . $i] = 'text';
$preferences['prefletters']['gradeboundary' . $i] = $percentages;
}
}
// quickgrading and quickfeedback are conditional on grade:edit capability
if (has_capability('moodle/grade:edit', $context)) {
$preferences['prefgeneral']['quickgrading'] = $checkbox_default;
$preferences['prefgeneral']['quickfeedback'] = $checkbox_default;
}
// View capability is the lowest permission. Users with grade:manage or grade:edit must also have grader:view
if (has_capability('gradereport/grader:view', $context)) {
$preferences['prefgeneral']['studentsperpage'] = 'text';
$preferences['prefgeneral']['aggregationposition'] = array(GRADE_REPORT_PREFERENCE_DEFAULT => 'default',
GRADE_REPORT_AGGREGATION_POSITION_LEFT => get_string('left', 'grades'),
GRADE_REPORT_AGGREGATION_POSITION_RIGHT => get_string('right', 'grades'));
$preferences['prefgeneral']['enableajax'] = $checkbox_default;
$preferences['prefshow']['showuserimage'] = $checkbox_default;
$preferences['prefshow']['showactivityicons'] = $checkbox_default;
$preferences['prefshow']['showranges'] = $checkbox_default;
$preferences['prefrows']['shownumberofgrades'] = $checkbox_default;
}
foreach ($preferences as $group => $prefs) {
$mform->addElement('header', $group, get_string($group, 'grades'));

View File

@ -1,10 +1,12 @@
<?php // $Id$
$row = $tabs = array();
$tabcontext = get_context_instance(CONTEXT_COURSE, $COURSE->id);
$row[] = new tabobject('graderreport',
$CFG->wwwroot.'/grade/report/grader/index.php?id='.$courseid,
get_string('modulename', 'gradereport_grader'));
if (has_capability('moodle/grade:manage', get_context_instance(CONTEXT_COURSE, $COURSE->id))) {
if (has_capability('moodle/grade:manage',$tabcontext ) ||
has_capability('moodle/grade:edit', $tabcontext) ||
has_capability('gradereport/grader:view', $tabcontext)) {
$row[] = new tabobject('preferences',
$CFG->wwwroot.'/grade/report/grader/preferences.php?id='.$courseid,
get_string('preferences'));

View File

@ -1,6 +1,6 @@
<?PHP // $Id$
$plugin->version = 2007091400;
$plugin->requires = 2007091400;
$plugin->version = 2007091700;
$plugin->requires = 2007091700;
?>

View File

@ -44,6 +44,7 @@ $string['course:viewhiddenuserfields'] = 'View hidden user fields';
$string['course:viewparticipants'] = 'View participants';
$string['course:viewscales'] = 'View scales';
$string['course:visibility'] = 'Hide/show courses';
$string['grade:edit'] = 'Edit grades';
$string['grade:export'] = 'Export grades';
$string['grade:hide'] = 'Hide/unhide grades or items';
$string['grade:import'] = 'Import grades';

View File

@ -518,7 +518,7 @@ $moodle_capabilities = array(
'coursecreator' => CAP_ALLOW,
'teacher' => CAP_ALLOW,
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
'admin' => CAP_ALLOW
)
),
@ -740,26 +740,26 @@ $moodle_capabilities = array(
)
),
'moodle/user:editownprofile' => array(
'moodle/user:editownprofile' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'legacy' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'legacy' => array(
'guest' => CAP_PROHIBIT,
'user' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
)
),
'moodle/user:changeownpassword' => array(
'moodle/user:changeownpassword' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'legacy' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'legacy' => array(
'guest' => CAP_PROHIBIT,
'user' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
)
),
// The next 3 might make no sense for some roles, e.g teacher, etc.
@ -807,8 +807,8 @@ $moodle_capabilities = array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
),
),
//new in moodle 1.9
'moodle/question:add' => array(
'riskbitmask' => RISK_SPAM,
@ -828,7 +828,7 @@ $moodle_capabilities = array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/question:manage'
'clonepermissionsfrom' => 'moodle/question:manage'
),
'moodle/question:editall' => array(
'riskbitmask' => RISK_SPAM,
@ -838,7 +838,7 @@ $moodle_capabilities = array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/question:manage'
'clonepermissionsfrom' => 'moodle/question:manage'
),
'moodle/question:viewmine' => array(
'captype' => 'read',
@ -847,7 +847,7 @@ $moodle_capabilities = array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/question:manage'
'clonepermissionsfrom' => 'moodle/question:manage'
),
'moodle/question:viewall' => array(
'captype' => 'read',
@ -856,7 +856,7 @@ $moodle_capabilities = array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/question:manage'
'clonepermissionsfrom' => 'moodle/question:manage'
),
'moodle/question:usemine' => array(
'captype' => 'read',
@ -865,7 +865,7 @@ $moodle_capabilities = array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/question:manage'
'clonepermissionsfrom' => 'moodle/question:manage'
),
'moodle/question:useall' => array(
'captype' => 'read',
@ -874,8 +874,8 @@ $moodle_capabilities = array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/question:manage'
),
'clonepermissionsfrom' => 'moodle/question:manage'
),
'moodle/question:movemine' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
@ -883,7 +883,7 @@ $moodle_capabilities = array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/question:manage'
'clonepermissionsfrom' => 'moodle/question:manage'
),
'moodle/question:moveall' => array(
'captype' => 'write',
@ -892,10 +892,10 @@ $moodle_capabilities = array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/question:manage'
'clonepermissionsfrom' => 'moodle/question:manage'
),
//END new in moodle 1.9
// Configure the installed question types.
'moodle/question:config' => array(
@ -1031,6 +1031,17 @@ $moodle_capabilities = array(
'clonepermissionsfrom' => 'moodle/course:managegrades'
),
'moodle/grade:edit' => array(
'riskbitmask' => RISK_PERSONAL | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'legacy' => array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
),
'clonepermissionsfrom' => 'moodle/course:managegrades'
),
'moodle/grade:manageoutcomes' => array(
'riskbitmask' => RISK_PERSONAL,
'captype' => 'write',
@ -1069,15 +1080,6 @@ $moodle_capabilities = array(
)
),
'moodle/grade:override' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_COURSE,
'legacy' => array(
'editingteacher' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
),
'moodle/my:manageblocks' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
@ -1124,7 +1126,7 @@ $moodle_capabilities = array(
'user' => CAP_ALLOW
)
),
'moodle/tag:edit' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
@ -1133,7 +1135,7 @@ $moodle_capabilities = array(
'user' => CAP_ALLOW
)
),
'moodle/tag:editblocks' => array(
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,

View File

@ -6,7 +6,7 @@
// This is compared against the values stored in the database to determine
// whether upgrades should be performed (see lib/db/*.php)
$version = 2007091401; // YYYYMMDD = date
$version = 2007091702; // YYYYMMDD = date
// XY = increments within a single day
$release = '1.9 Beta +'; // Human-friendly version name