Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 054d245a2c8ee1485632296e0711535f1ec3a7fa 1 parent 2ddb941
sam marshall sammarshallou authored
2  course/lib.php
@@ -1763,7 +1763,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
1763 1763 // see the activity itself, or for staff)
1764 1764 if (!$mod->uservisible) {
1765 1765 echo '<div class="availabilityinfo">'.$mod->availableinfo.'</div>';
1766   - } else if ($canviewhidden && !empty($CFG->enableavailability)) {
  1766 + } else if ($canviewhidden && !empty($CFG->enableavailability) && $mod->visible) {
1767 1767 $ci = new condition_info($mod);
1768 1768 $fullinfo = $ci->get_full_information();
1769 1769 if($fullinfo) {
16 lib/conditionlib.php
@@ -101,16 +101,16 @@ public function __construct($cm, $expectingmissing=CONDITION_MISSING_NOTHING,
101 101
102 102 // Missing basic data from course_modules
103 103 if (!isset($cm->availablefrom) || !isset($cm->availableuntil) ||
104   - !isset($cm->showavailability) || !isset($cm->course)) {
  104 + !isset($cm->showavailability) || !isset($cm->course) || !isset($cm->visible)) {
105 105 if ($expectingmissing<CONDITION_MISSING_EVERYTHING) {
106 106 debugging('Performance warning: condition_info constructor is
107 107 faster if you pass in $cm with at least basic fields
108   - (availablefrom,availableuntil,showavailability,course).
  108 + (availablefrom,availableuntil,showavailability,course,visible).
109 109 [This warning can be disabled, see phpdoc.]',
110 110 DEBUG_DEVELOPER);
111 111 }
112 112 $cm = $DB->get_record('course_modules',array('id'=>$cm->id),
113   - 'id,course,availablefrom,availableuntil,showavailability');
  113 + 'id, course, availablefrom, availableuntil, showavailability, visible');
114 114 }
115 115
116 116 $this->cm = clone($cm);
@@ -486,6 +486,16 @@ public function is_available(&$information, $grabthelot=false, $userid=0, $modin
486 486 }
487 487 }
488 488
  489 + // If the item is marked as 'not visible' then we don't change the available
  490 + // flag (visible/available are treated distinctly), but we remove any
  491 + // availability info. If the item is hidden with the eye icon, it doesn't
  492 + // make sense to show 'Available from <date>' or similar, because even
  493 + // when that date arrives it will still not be available unless somebody
  494 + // toggles the eye icon.
  495 + if (!$this->cm->visible) {
  496 + $information = '';
  497 + }
  498 +
489 499 $information=trim($information);
490 500 return $available;
491 501 }
7 lib/simpletest/testconditionlib.php
@@ -79,7 +79,8 @@ function test_constructor() {
79 79 $this->assertEqual(
80 80 (object)array('id'=>$id,'showavailability'=>1,
81 81 'availablefrom'=>17,'availableuntil'=>398,'course'=>64,
82   - 'conditionsgrade'=>array(), 'conditionscompletion'=>array()),
  82 + 'conditionsgrade' => array(), 'conditionscompletion' => array(),
  83 + 'visible' => 1),
83 84 $test->get_full_course_module());
84 85
85 86 // just the course_modules stuff; check it doesn't request that from db
@@ -87,11 +88,13 @@ function test_constructor() {
87 88 $cm->availablefrom=2;
88 89 $cm->availableuntil=74;
89 90 $cm->course=38;
  91 + $cm->visible = 1;
90 92 $test=new condition_info($cm,CONDITION_MISSING_EXTRATABLE);
91 93 $this->assertEqual(
92 94 (object)array('id'=>$id,'showavailability'=>0,
93 95 'availablefrom'=>2,'availableuntil'=>74,'course'=>38,
94   - 'conditionsgrade'=>array(), 'conditionscompletion'=>array()),
  96 + 'conditionsgrade' => array(), 'conditionscompletion' => array(),
  97 + 'visible' => 1),
95 98 $test->get_full_course_module());
96 99
97 100 // Now let's add some actual grade/completion conditions

0 comments on commit 054d245

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