Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-33212 Course page: Eye icon should override other conditions

  • Loading branch information...
commit 540f89d7d4bdc76ca4f64f0709a3dc706222a3e5 1 parent 4631e39
sam marshall sammarshallou authored
2  course/lib.php
View
@@ -1728,7 +1728,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
// see the activity itself, or for staff)
if (!$mod->uservisible) {
echo '<div class="availabilityinfo">'.$mod->availableinfo.'</div>';
- } else if ($canviewhidden && !empty($CFG->enableavailability)) {
+ } else if ($canviewhidden && !empty($CFG->enableavailability) && $mod->visible) {
$ci = new condition_info($mod);
$fullinfo = $ci->get_full_information();
if($fullinfo) {
16 lib/conditionlib.php
View
@@ -69,7 +69,8 @@ class condition_info extends condition_info_base {
* @param object $cm Moodle course-module object. May have extra fields
* ->conditionsgrade, ->conditionscompletion which should come from
* get_fast_modinfo. Should have ->availablefrom, ->availableuntil,
- * and ->showavailability, ->course; but the only required thing is ->id.
+ * and ->showavailability, ->course, ->visible; but the only required
+ * thing is ->id.
* @param int $expectingmissing Used to control whether or not a developer
* debugging message (performance warning) will be displayed if some of
* the above data is missing and needs to be retrieved; a
@@ -426,7 +427,8 @@ public function __construct($item, $tableprefix, $idfield, $expectingmissing, $l
* @return array Array of field names
*/
protected function get_main_table_fields() {
- return array('id', 'course', 'availablefrom', 'availableuntil', 'showavailability');
+ return array('id', 'course', 'visible',
+ 'availablefrom', 'availableuntil', 'showavailability');
}
/**
@@ -846,6 +848,16 @@ public function is_available(&$information, $grabthelot=false, $userid=0, $modin
}
}
+ // If the item is marked as 'not visible' then we don't change the available
+ // flag (visible/available are treated distinctly), but we remove any
+ // availability info. If the item is hidden with the eye icon, it doesn't
+ // make sense to show 'Available from <date>' or similar, because even
+ // when that date arrives it will still not be available unless somebody
+ // toggles the eye icon.
+ if (!$this->item->visible) {
+ $information = '';
+ }
+
$information = trim($information);
return $available;
}
14 lib/tests/conditionlib_test.php
View
@@ -70,7 +70,8 @@ function test_constructor() {
$this->assertEquals(
(object)array('id'=>$id,'showavailability'=>1,
'availablefrom'=>17,'availableuntil'=>398,'course'=>64,
- 'conditionsgrade'=>array(), 'conditionscompletion'=>array()),
+ 'conditionsgrade'=>array(), 'conditionscompletion'=>array(),
+ 'visible' => 1),
$test->get_full_course_module());
// just the course_modules stuff; check it doesn't request that from db
@@ -78,11 +79,13 @@ function test_constructor() {
$cm->availablefrom=2;
$cm->availableuntil=74;
$cm->course=38;
+ $cm->visible = 1;
$test=new condition_info($cm,CONDITION_MISSING_EXTRATABLE);
$this->assertEquals(
(object)array('id'=>$id,'showavailability'=>0,
'availablefrom'=>2,'availableuntil'=>74,'course'=>38,
- 'conditionsgrade'=>array(), 'conditionscompletion'=>array()),
+ 'conditionsgrade' => array(), 'conditionscompletion' => array(),
+ 'visible' => 1),
$test->get_full_course_module());
// Now let's add some actual grade/completion conditions
@@ -136,7 +139,8 @@ public function test_section_constructor() {
$this->assertEquals(
(object)array('id' => $id, 'showavailability' => 1, 'groupingid' => 13,
'availablefrom' => 17, 'availableuntil' => 398, 'course' => 64,
- 'conditionsgrade' => array(), 'conditionscompletion' => array()),
+ 'conditionsgrade' => array(), 'conditionscompletion' => array(),
+ 'visible' => 1),
$test->get_full_section());
// Just the course_sections stuff; check it doesn't request that from db
@@ -146,11 +150,13 @@ public function test_section_constructor() {
$section->availableuntil = 74;
$section->course = 38;
$section->groupingid = 99;
+ $section->visible = 1;
$test = new condition_info_section($section, CONDITION_MISSING_EXTRATABLE);
$this->assertEquals(
(object)array('id' => $id, 'showavailability' => 0, 'groupingid' => 99,
'availablefrom' => 2, 'availableuntil' => 74, 'course' => 38,
- 'conditionsgrade' => array(), 'conditionscompletion' => array()),
+ 'conditionsgrade' => array(), 'conditionscompletion' => array(),
+ 'visible' => 1),
$test->get_full_section());
// Now let's add some actual grade/completion conditions
Please sign in to comment.
Something went wrong with that request. Please try again.