} else {
$item->aggregationcoef = format_float($item->aggregationcoef, 4);
}
+$item->cancontrolvisibility = $grade_item->can_control_visibility();
$mform = new edit_item_form(null, array('current'=>$item, 'gpr'=>$gpr));
}
/// hiding
- // advcheckbox is not compatible with disabledIf!
- $mform->addElement('checkbox', 'hidden', get_string('hidden', 'grades'));
+ if ($item->cancontrolvisibility) {
+ // advcheckbox is not compatible with disabledIf!
+ $mform->addElement('checkbox', 'hidden', get_string('hidden', 'grades'));
+ $mform->addElement('date_time_selector', 'hiddenuntil', get_string('hiddenuntil', 'grades'), array('optional'=>true));
+ $mform->disabledIf('hidden', 'hiddenuntil[off]', 'notchecked');
+ } else {
+ $mform->addElement('static', 'hidden', get_string('hidden', 'grades'),
+ get_string('componentcontrolsvisibility', 'grades'));
+ // Unset hidden to avoid data override.
+ unset($item->hidden);
+ }
$mform->addHelpButton('hidden', 'hidden', 'grades');
- $mform->addElement('date_time_selector', 'hiddenuntil', get_string('hiddenuntil', 'grades'), array('optional'=>true));
- $mform->disabledIf('hidden', 'hiddenuntil[off]', 'notchecked');
/// locking
$mform->addElement('advcheckbox', 'locked', get_string('locked', 'grades'));
$string['categorytotalfull'] = '{$a->category} total';
$string['combo'] = 'Tabs and Dropdown menu';
$string['compact'] = 'Compact';
+$string['componentcontrolsvisibility'] = 'Whether this grade item is hidden is controlled by the activity settings.';
$string['contract'] = 'Contract category';
$string['controls'] = 'Controls';
$string['courseavg'] = 'Course average';
return false;
}
}
+
+ /**
+ * Returns whether the grade item can control the visibility of the grades
+ *
+ * @return bool
+ */
+ public function can_control_visibility() {
+ if (get_plugin_directory($this->itemtype, $this->itemmodule)) {
+ return !plugin_supports($this->itemtype, $this->itemmodule, FEATURE_CONTROLS_GRADE_VISIBILITY, false);
+ }
+ return true;
+ }
}
define('FEATURE_GRADE_OUTCOMES', 'outcomes');
/** True if module supports advanced grading methods */
define('FEATURE_ADVANCED_GRADING', 'grade_advanced_grading');
+/** True if module controls the grade visibility over the gradebook */
+define('FEATURE_CONTROLS_GRADE_VISIBILITY', 'controlsgradevisbility');
/** True if module has code to track whether somebody viewed it */
define('FEATURE_COMPLETION_TRACKS_VIEWS', 'completion_tracks_views');
*/
function quiz_supports($feature) {
switch($feature) {
- case FEATURE_GROUPS: return true;
- case FEATURE_GROUPINGS: return true;
- case FEATURE_GROUPMEMBERSONLY: return true;
- case FEATURE_MOD_INTRO: return true;
- case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
- case FEATURE_GRADE_HAS_GRADE: return true;
- case FEATURE_GRADE_OUTCOMES: return false;
- case FEATURE_BACKUP_MOODLE2: return true;
- case FEATURE_SHOW_DESCRIPTION: return true;
+ case FEATURE_GROUPS: return true;
+ case FEATURE_GROUPINGS: return true;
+ case FEATURE_GROUPMEMBERSONLY: return true;
+ case FEATURE_MOD_INTRO: return true;
+ case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
+ case FEATURE_GRADE_HAS_GRADE: return true;
+ case FEATURE_GRADE_OUTCOMES: return false;
+ case FEATURE_BACKUP_MOODLE2: return true;
+ case FEATURE_SHOW_DESCRIPTION: return true;
+ case FEATURE_CONTROLS_GRADE_VISIBILITY: return true;
default: return null;
}