Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'MDL-18301-23' of git://github.com/FMCorz/moodle into MO…

…ODLE_23_STABLE
  • Loading branch information...
commit 0dd189d59d7c1257e3275ae8157ffc8e58ae0e47 2 parents d6cf442 + 2dd2bd7
Dan Poltawski danpoltawski authored
1  grade/edit/tree/item.php
@@ -97,6 +97,7 @@
97 97 } else {
98 98 $item->aggregationcoef = format_float($item->aggregationcoef, 4);
99 99 }
  100 +$item->cancontrolvisibility = $grade_item->can_control_visibility();
100 101
101 102 $mform = new edit_item_form(null, array('current'=>$item, 'gpr'=>$gpr));
102 103
15 grade/edit/tree/item_form.php
@@ -143,11 +143,18 @@ function definition() {
143 143 }
144 144
145 145 /// hiding
146   - // advcheckbox is not compatible with disabledIf!
147   - $mform->addElement('checkbox', 'hidden', get_string('hidden', 'grades'));
  146 + if ($item->cancontrolvisibility) {
  147 + // advcheckbox is not compatible with disabledIf!
  148 + $mform->addElement('checkbox', 'hidden', get_string('hidden', 'grades'));
  149 + $mform->addElement('date_time_selector', 'hiddenuntil', get_string('hiddenuntil', 'grades'), array('optional'=>true));
  150 + $mform->disabledIf('hidden', 'hiddenuntil[off]', 'notchecked');
  151 + } else {
  152 + $mform->addElement('static', 'hidden', get_string('hidden', 'grades'),
  153 + get_string('componentcontrolsvisibility', 'grades'));
  154 + // Unset hidden to avoid data override.
  155 + unset($item->hidden);
  156 + }
148 157 $mform->addHelpButton('hidden', 'hidden', 'grades');
149   - $mform->addElement('date_time_selector', 'hiddenuntil', get_string('hiddenuntil', 'grades'), array('optional'=>true));
150   - $mform->disabledIf('hidden', 'hiddenuntil[off]', 'notchecked');
151 158
152 159 /// locking
153 160 $mform->addElement('advcheckbox', 'locked', get_string('locked', 'grades'));
1  lang/en/grades.php
@@ -117,6 +117,7 @@
117 117 $string['categorytotalfull'] = '{$a->category} total';
118 118 $string['combo'] = 'Tabs and Dropdown menu';
119 119 $string['compact'] = 'Compact';
  120 +$string['componentcontrolsvisibility'] = 'Whether this grade item is hidden is controlled by the activity settings.';
120 121 $string['contract'] = 'Contract category';
121 122 $string['controls'] = 'Controls';
122 123 $string['courseavg'] = 'Course average';
12 lib/grade/grade_item.php
@@ -2067,4 +2067,16 @@ public function get_coefstring() {
2067 2067 return false;
2068 2068 }
2069 2069 }
  2070 +
  2071 + /**
  2072 + * Returns whether the grade item can control the visibility of the grades
  2073 + *
  2074 + * @return bool
  2075 + */
  2076 + public function can_control_visibility() {
  2077 + if (get_plugin_directory($this->itemtype, $this->itemmodule)) {
  2078 + return !plugin_supports($this->itemtype, $this->itemmodule, FEATURE_CONTROLS_GRADE_VISIBILITY, false);
  2079 + }
  2080 + return true;
  2081 + }
2070 2082 }
2  lib/moodlelib.php
@@ -385,6 +385,8 @@
385 385 define('FEATURE_GRADE_OUTCOMES', 'outcomes');
386 386 /** True if module supports advanced grading methods */
387 387 define('FEATURE_ADVANCED_GRADING', 'grade_advanced_grading');
  388 +/** True if module controls the grade visibility over the gradebook */
  389 +define('FEATURE_CONTROLS_GRADE_VISIBILITY', 'controlsgradevisbility');
388 390
389 391 /** True if module has code to track whether somebody viewed it */
390 392 define('FEATURE_COMPLETION_TRACKS_VIEWS', 'completion_tracks_views');
19 mod/quiz/lib.php
@@ -1550,15 +1550,16 @@ function quiz_attempt_summary_link_to_reports($quiz, $cm, $context, $returnzero
1550 1550 */
1551 1551 function quiz_supports($feature) {
1552 1552 switch($feature) {
1553   - case FEATURE_GROUPS: return true;
1554   - case FEATURE_GROUPINGS: return true;
1555   - case FEATURE_GROUPMEMBERSONLY: return true;
1556   - case FEATURE_MOD_INTRO: return true;
1557   - case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
1558   - case FEATURE_GRADE_HAS_GRADE: return true;
1559   - case FEATURE_GRADE_OUTCOMES: return false;
1560   - case FEATURE_BACKUP_MOODLE2: return true;
1561   - case FEATURE_SHOW_DESCRIPTION: return true;
  1553 + case FEATURE_GROUPS: return true;
  1554 + case FEATURE_GROUPINGS: return true;
  1555 + case FEATURE_GROUPMEMBERSONLY: return true;
  1556 + case FEATURE_MOD_INTRO: return true;
  1557 + case FEATURE_COMPLETION_TRACKS_VIEWS: return true;
  1558 + case FEATURE_GRADE_HAS_GRADE: return true;
  1559 + case FEATURE_GRADE_OUTCOMES: return false;
  1560 + case FEATURE_BACKUP_MOODLE2: return true;
  1561 + case FEATURE_SHOW_DESCRIPTION: return true;
  1562 + case FEATURE_CONTROLS_GRADE_VISIBILITY: return true;
1562 1563
1563 1564 default: return null;
1564 1565 }

0 comments on commit 0dd189d

Please sign in to comment.
Something went wrong with that request. Please try again.