Browse files

Merge branch 'MDL-33212-m21' of git://github.com/sammarshallou/moodle…

… into MOODLE_21_STABLE
  • Loading branch information...
2 parents ae3f09e + 054d245 commit 573a933e42ad6a40db03d4a7b7dc371b8ab355e8 @danpoltawski danpoltawski committed May 29, 2012
Showing with 19 additions and 6 deletions.
  1. +1 −1 course/lib.php
  2. +13 −3 lib/conditionlib.php
  3. +5 −2 lib/simpletest/testconditionlib.php
View
2 course/lib.php
@@ -1763,7 +1763,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) {
View
16 lib/conditionlib.php
@@ -101,16 +101,16 @@ public function __construct($cm, $expectingmissing=CONDITION_MISSING_NOTHING,
// Missing basic data from course_modules
if (!isset($cm->availablefrom) || !isset($cm->availableuntil) ||
- !isset($cm->showavailability) || !isset($cm->course)) {
+ !isset($cm->showavailability) || !isset($cm->course) || !isset($cm->visible)) {
if ($expectingmissing<CONDITION_MISSING_EVERYTHING) {
debugging('Performance warning: condition_info constructor is
faster if you pass in $cm with at least basic fields
- (availablefrom,availableuntil,showavailability,course).
+ (availablefrom,availableuntil,showavailability,course,visible).
[This warning can be disabled, see phpdoc.]',
DEBUG_DEVELOPER);
}
$cm = $DB->get_record('course_modules',array('id'=>$cm->id),
- 'id,course,availablefrom,availableuntil,showavailability');
+ 'id, course, availablefrom, availableuntil, showavailability, visible');
}
$this->cm = clone($cm);
@@ -486,6 +486,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->cm->visible) {
+ $information = '';
+ }
+
$information=trim($information);
return $available;
}
View
7 lib/simpletest/testconditionlib.php
@@ -79,19 +79,22 @@ function test_constructor() {
$this->assertEqual(
(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
$cm->showavailability=0;
$cm->availablefrom=2;
$cm->availableuntil=74;
$cm->course=38;
+ $cm->visible = 1;
$test=new condition_info($cm,CONDITION_MISSING_EXTRATABLE);
$this->assertEqual(
(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

0 comments on commit 573a933

Please sign in to comment.