mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-18301 Gradebook: Added feature for components to control grade visibility
This commit is contained in:
parent
d71b79a406
commit
455dc0de61
@ -97,6 +97,7 @@ if ($parent_category->aggregation == GRADE_AGGREGATE_SUM or $parent_category->ag
|
||||
} 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));
|
||||
|
||||
|
@ -143,11 +143,18 @@ class edit_item_form extends moodleform {
|
||||
}
|
||||
|
||||
/// 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'));
|
||||
|
@ -117,6 +117,7 @@ $string['categorytotalname'] = 'Category total name';
|
||||
$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';
|
||||
|
@ -2067,4 +2067,16 @@ class grade_item extends grade_object {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -385,6 +385,8 @@ define('FEATURE_GRADE_HAS_GRADE', 'grade_has_grade');
|
||||
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');
|
||||
|
@ -1550,15 +1550,16 @@ function quiz_attempt_summary_link_to_reports($quiz, $cm, $context, $returnzero
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user