Merge branch 'MDL-20250_grade_settings2' of https://github.com/andyjdavis/moodle

This commit is contained in:
Sam Hemelryk 2014-09-29 14:00:42 +13:00
commit a93039706c
14 changed files with 164 additions and 24 deletions

View File

@ -68,6 +68,10 @@ if (has_capability('moodle/grade:manage', $systemcontext)
$temp->add(new admin_setting_special_gradelimiting());
$temp->add(new admin_setting_configcheckbox('grade_report_showmin',
get_string('minimum_show', 'grades'),
get_string('minimum_show_help', 'grades'), '1'));
$temp->add(new admin_setting_special_gradepointmax());
$temp->add(new admin_setting_special_gradepointdefault());
@ -125,6 +129,9 @@ if (has_capability('moodle/grade:manage', $systemcontext)
$defaults['forced'] = false;
$temp->add(new admin_setting_gradecat_combo('grade_droplow', new lang_string('droplow', 'grades'),
new lang_string('droplow_help', 'grades'), $defaults, $options));
$temp->add(new admin_setting_configcheckbox('grade_overridecat', new lang_string('overridecat', 'grades'),
new lang_string('overridecat_help', 'grades'), 1));
}
$ADMIN->add('grades', $temp);

View File

@ -162,11 +162,13 @@ class edit_category_form extends moodleform {
$mform->disabledIf('grade_item_grademax', 'grade_item_gradetype', 'noteq', GRADE_TYPE_VALUE);
$mform->disabledIf('grade_item_grademax', 'aggregation', 'eq', GRADE_AGGREGATE_SUM);
$mform->addElement('text', 'grade_item_grademin', get_string('grademin', 'grades'));
$mform->setType('grade_item_grademin', PARAM_RAW);
$mform->addHelpButton('grade_item_grademin', 'grademin', 'grades');
$mform->disabledIf('grade_item_grademin', 'grade_item_gradetype', 'noteq', GRADE_TYPE_VALUE);
$mform->disabledIf('grade_item_grademin', 'aggregation', 'eq', GRADE_AGGREGATE_SUM);
if ((bool) get_config('moodle', 'grade_report_showmin')) {
$mform->addElement('text', 'grade_item_grademin', get_string('grademin', 'grades'));
$mform->setType('grade_item_grademin', PARAM_RAW);
$mform->addHelpButton('grade_item_grademin', 'grademin', 'grades');
$mform->disabledIf('grade_item_grademin', 'grade_item_gradetype', 'noteq', GRADE_TYPE_VALUE);
$mform->disabledIf('grade_item_grademin', 'aggregation', 'eq', GRADE_AGGREGATE_SUM);
}
$mform->addElement('text', 'grade_item_gradepass', get_string('gradepass', 'grades'));
$mform->setType('grade_item_gradepass', PARAM_RAW);
@ -413,7 +415,9 @@ class edit_category_form extends moodleform {
if ($grade_item->is_outcome_item()) {
// we have to prevent incompatible modifications of outcomes if outcomes disabled
$mform->removeElement('grade_item_grademax');
$mform->removeElement('grade_item_grademin');
if ($mform->elementExists('grade_item_grademin')) {
$mform->removeElement('grade_item_grademin');
}
$mform->removeElement('grade_item_gradetype');
$mform->removeElement('grade_item_display');
$mform->removeElement('grade_item_decimals');

View File

@ -90,10 +90,12 @@ class edit_item_form extends moodleform {
$mform->disabledIf('grademax', 'gradetype', 'noteq', GRADE_TYPE_VALUE);
$mform->setType('grademax', PARAM_RAW);
$mform->addElement('text', 'grademin', get_string('grademin', 'grades'));
$mform->addHelpButton('grademin', 'grademin', 'grades');
$mform->disabledIf('grademin', 'gradetype', 'noteq', GRADE_TYPE_VALUE);
$mform->setType('grademin', PARAM_RAW);
if ((bool) get_config('moodle', 'grade_report_showmin')) {
$mform->addElement('text', 'grademin', get_string('grademin', 'grades'));
$mform->addHelpButton('grademin', 'grademin', 'grades');
$mform->disabledIf('grademin', 'gradetype', 'noteq', GRADE_TYPE_VALUE);
$mform->setType('grademin', PARAM_RAW);
}
$mform->addElement('text', 'gradepass', get_string('gradepass', 'grades'));
$mform->addHelpButton('gradepass', 'gradepass', 'grades');
@ -235,7 +237,9 @@ class edit_item_form extends moodleform {
if ($grade_item->is_outcome_item()) {
// we have to prevent incompatible modifications of outcomes if outcomes disabled
$mform->removeElement('grademax');
$mform->removeElement('grademin');
if ($mform->elementExists('grademin')) {
$mform->removeElement('grademin');
}
$mform->removeElement('gradetype');
$mform->removeElement('display');
$mform->removeElement('decimals');
@ -244,7 +248,11 @@ class edit_item_form extends moodleform {
} else {
if ($grade_item->is_external_item()) {
// following items are set up from modules and should not be overrided by user
$mform->hardFreeze('itemname,gradetype,grademax,grademin,scaleid');
if ($mform->elementExists('grademin')) {
// The site setting grade_report_showmin may have prevented grademin being added to the form.
$mform->hardFreeze('grademin');
}
$mform->hardFreeze('itemname,gradetype,grademax,scaleid');
if ($grade_item->itemnumber == 0) {
// the idnumber of grade itemnumber 0 is synced with course_modules
$mform->hardFreeze('idnumber');
@ -316,7 +324,6 @@ class edit_item_form extends moodleform {
}
}
/// perform extra validation before submission
function validation($data, $files) {
global $COURSE;

View File

@ -49,12 +49,22 @@ class grade_edit_tree {
public $table;
public $categories = array();
/**
* Show calculator icons next to manual grade items
* @var bool $show_calculations
*/
private $show_calculations;
/**
* Constructor
*/
public function __construct($gtree, $moving=false, $gpr) {
global $USER, $OUTPUT, $COURSE;
$systemdefault = get_config('moodle', 'grade_report_showcalculations');
$this->show_calculations = get_user_preferences('grade_report_showcalculations', $systemdefault);
$this->gtree = $gtree;
$this->moving = $moving;
$this->gpr = $gpr;
@ -138,7 +148,9 @@ class grade_edit_tree {
$actions .= $this->gtree->get_edit_icon($element, $this->gpr);
}
$actions .= $this->gtree->get_calculation_icon($element, $this->gpr);
if ($this->show_calculations) {
$actions .= $this->gtree->get_calculation_icon($element, $this->gpr);
}
if ($element['type'] == 'item' or ($element['type'] == 'category' and $element['depth'] > 1)) {
if ($this->element_deletable($element)) {

View File

@ -95,6 +95,12 @@ class grade_report_grader extends grade_report {
*/
protected $feedback_trunc_length = 50;
/**
* Allow category grade overriding
* @var bool $overridecat
*/
protected $overridecat;
/**
* Constructor. Sets local copies of user preferences and initialises grade_tree.
* @param int $courseid
@ -143,6 +149,8 @@ class grade_report_grader extends grade_report {
$this->setup_groups();
$this->setup_users();
$this->setup_sortitemid();
$this->overridecat = (bool)get_config('moodle', 'grade_overridecat');
}
/**
@ -1029,7 +1037,13 @@ class grade_report_grader extends grade_report {
}
if ($enableajax) {
$itemcell->attributes['class'] .= ' clickable';
$canoverride = true;
if ($item->is_category_item() || $item->is_course_item()) {
$canoverride = (bool) get_config('moodle', 'grade_overridecat');
}
if ($canoverride) {
$itemcell->attributes['class'] .= ' clickable';
}
}
if ($item->needsupdate) {
@ -1485,7 +1499,16 @@ class grade_report_grader extends grade_report {
// Init all icons
$editicon = '';
if ($element['type'] != 'categoryitem' && $element['type'] != 'courseitem') {
$editable = true;
if ($element['type'] == 'grade') {
$item = $element['object']->grade_item;
if ($item->is_course_item() or $item->is_category_item()) {
$editable = $this->overridecat;
}
}
if ($element['type'] != 'categoryitem' && $element['type'] != 'courseitem' && $editable) {
$editicon = $this->gtree->get_edit_icon($element, $this->gpr);
}

View File

@ -314,7 +314,7 @@ M.gradereport_grader.classes.ajax = function(report, cfg) {
this.existingfields = [];
if (!report.isediting) {
report.table.all('.cell.grade').on('makeditable|click', this.make_editable, this);
report.table.all('.clickable').on('click', this.make_editable, this);
} else {
for (var userid in report.users) {
if (!this.existingfields[userid]) {
@ -1043,7 +1043,7 @@ M.gradereport_grader.classes.textfield.prototype.revert = function() {
}
}
this.keyevents = [];
this.node.on('makeditable|click', this.report.ajax.make_editable, this.report.ajax);
this.node.on('click', this.report.ajax.make_editable, this.report.ajax);
};
/**
* Gets the grade for current cell

View File

@ -55,7 +55,9 @@ class grader_report_preferences_form extends moodleform {
if (has_capability('moodle/grade:manage', $context)) {
$preferences['prefshow'] = array();
$preferences['prefshow']['showcalculations'] = $checkbox_default;
$preferences['prefshow']['showcalculations'] = $checkbox_default;
$preferences['prefshow']['showeyecons'] = $checkbox_default;
if ($canviewhidden) {
$preferences['prefshow']['showaverages'] = $checkbox_default;

View File

@ -55,8 +55,9 @@ if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configcheckbox('grade_report_enableajax', get_string('enableajax', 'grades'),
get_string('enableajax_help', 'grades'), 0));
$settings->add(new admin_setting_configcheckbox('grade_report_showcalculations', get_string('showcalculations', 'grades'),
get_string('showcalculations_help', 'grades'), 0));
$settings->add(new admin_setting_configcheckbox('grade_report_showcalculations',
get_string('showcalculations', 'grades'),
get_string('showcalculations_help', 'grades'), 1));
$settings->add(new admin_setting_configcheckbox('grade_report_showeyecons', get_string('showeyecons', 'grades'),
get_string('showeyecons_help', 'grades'), 0));

View File

@ -0,0 +1,58 @@
@core @core_grades
Feature: Site settings can be used to hide parts of the gradebook UI
In order to hide UI elements
As an admin
I need to modify gradebook related system settings
Background:
Given the following "courses" exist:
| fullname | shortname | category | format |
| Course 1 | C1 | 0 | topics |
And the following "users" exist:
| username | firstname | lastname | email | idnumber |
| student1 | Student | 1 | student1@asd.com | s1 |
And the following "course enrolments" exist:
| user | course | role |
| student1 | C1 | student |
And the following "activities" exist:
| activity | course | idnumber | name | intro |
| assign | C1 | assign1 | Assignment1 | Assignment 1 intro |
And I log in as "admin"
And I follow "Course 1"
And I follow "Grades"
And I turn editing mode on
@javascript
Scenario: Hide minimum grade
When I click on "Edit assign Assignment1" "link"
And I should see "Minimum grade"
Then I navigate to "General settings" node in "Site administration > Grades"
And I click on "Show minimum grade" "checkbox"
And I press "Save changes"
And I follow "Home"
And I follow "Course 1"
And I follow "Grades"
And I click on "Edit assign Assignment1" "link"
And I should not see "Minimum grade"
@javascript
Scenario: Hide calculation icons
And "Edit calculation for Course total" "link" should exist
When I navigate to "Grader report" node in "Site administration > Grades > Report settings"
And I click on "Show calculations" "checkbox"
And I press "Save changes"
And I follow "Home"
And I follow "Course 1"
And I follow "Grades"
Then "Edit calculation for Course total" "link" should not exist
@javascript
Scenario: Disable category overriding
And ".r0 .course input[type='text']" "css_element" should exist
Then I navigate to "Grade category settings" node in "Site administration > Grades"
And I click on "Allow category grades to be manually overridden" "checkbox"
And I press "Save changes"
And I follow "Home"
And I follow "Course 1"
And I follow "Grades"
And ".r0 .course input[type='text']" "css_element" should not exist

View File

@ -420,6 +420,8 @@ $string['meanselection'] = 'Grades selected for column averages';
$string['meanselection_help'] = 'This setting determines whether cells with no grade should be included when calculating the average (mean) for each category or grade item.';
$string['median'] = 'Median';
$string['min'] = 'Lowest';
$string['minimum_show'] = 'Show minimum grade';
$string['minimum_show_help'] = 'Minimum grade is used in calculating grades and weights. If not shown, minimum grade will default to zero and cannot be edited.';
$string['missingscale'] = 'Scale must be selected';
$string['mode'] = 'Mode';
$string['modgradeerrorbadpoint'] = 'Invalid Grade Value. This must be an integer between 0 and {$a}';
@ -496,6 +498,8 @@ $string['outcomesstandardavailable'] = 'Available standard outcomes';
$string['outcomestandard'] = 'Standard outcome';
$string['outcomestandard_help'] = 'A standard outcome is available site-wide, for all courses.';
$string['overallaverage'] = 'Overall average';
$string['overridecat'] = 'Allow category grades to be manually overridden';
$string['overridecat_help'] = 'Disabling this setting makes it impossible for users to override category grades.';
$string['overridden'] = 'Overridden';
$string['overridden_help'] = 'If ticked, the grade can no longer be changed from within the related activity.
@ -603,7 +607,7 @@ $string['showallstudents'] = 'Show all Students';
$string['showaverages'] = 'Show column averages';
$string['showaverages_help'] = 'If enabled, the grader report will contain an additional row displaying the average (mean) for each category and grade item.';
$string['showcalculations'] = 'Show calculations';
$string['showcalculations_help'] = 'If enabled, when editing is turned on, a calculator icon is shown for each grade item and category, with tool tips over calculated items and a visual indicator that a column is calculated.';
$string['showcalculations_help'] = 'If enabled, when editing, a calculator icon is shown for each grade item and category with a visual indicator that a grade item is calculated.';
$string['showeyecons'] = 'Show show/hide icons';
$string['showeyecons_help'] = 'If enabled, when editing is turned on, a show/hide icon is shown for each grade for controlling its visibility to the student.';
$string['showgroups'] = 'Show groups';
@ -683,6 +687,8 @@ $string['usenooutcome'] = 'Use no outcome';
$string['usenoscale'] = 'Use no scale';
$string['usepercent'] = 'Use percent';
$string['user'] = 'User';
$string['userfields_show'] = 'Show user fields';
$string['userfields_show_help'] = 'Show additional user fields like email address on the grader report. The specific fields displayed are controlled by the site setting showuseridentity';
$string['usergrade'] = 'User {$a->fullname} ({$a->useridnumber}) on item {$a->gradeidnumber}';
$string['userid'] = 'User ID';
$string['useridnumberwarning'] = 'Users without an ID number are excluded from the export as they cannot be imported';

View File

@ -569,6 +569,8 @@ class grade_category extends grade_object {
return;
}
$minvisible = (bool) get_config('moodle', 'grade_report_showmin');
// normalize the grades first - all will have value 0...1
// ungraded items are not used in aggregation
foreach ($grade_values as $itemid=>$v) {
@ -582,6 +584,10 @@ class grade_category extends grade_object {
unset($grade_values[$itemid]);
continue;
}
// If grademin is hidden, set it to 0.
if (!$minvisible and $items[$itemid]->gradetype != GRADE_TYPE_SCALE) {
$items[$itemid]->grademin = 0;
}
$grade_values[$itemid] = grade_grade::standardise_score($v, $items[$itemid]->grademin, $items[$itemid]->grademax, 0, 1);
}
@ -615,6 +621,10 @@ class grade_category extends grade_object {
$result = $this->aggregate_values_and_adjust_bounds($grade_values, $items);
$agg_grade = $result['grade'];
if (!$minvisible and $this->grade_item->gradetype != GRADE_TYPE_SCALE) {
$this->grade_item->grademin = 0;
}
// recalculate the grade back to requested range
$finalgrade = grade_grade::standardise_score($agg_grade, 0, 1, $result['grademin'], $result['grademax']);

View File

@ -243,6 +243,10 @@ class grade_grade extends grade_object {
return false;
}
if ($grade_item->is_course_item() or $grade_item->is_category_item()) {
return (bool)get_config('moodle', 'grade_overridecat');
}
return true;
}

View File

@ -949,7 +949,13 @@ class grade_item extends grade_object {
* @return bool
*/
public function is_overridable_item() {
return !$this->is_outcome_item() and ($this->is_external_item() or $this->is_calculated() or $this->is_course_item() or $this->is_category_item());
if ($this->is_course_item() or $this->is_category_item()) {
$overridable = (bool) get_config('moodle', 'grade_overridecat');
} else {
$overridable = false;
}
return !$this->is_outcome_item() and ($this->is_external_item() or $this->is_calculated() or $overridable);
}
/**

View File

@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
$version = 2014092500.00; // YYYYMMDD = weekly release date of this DEV branch.
$version = 2014092900.00; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.