Skip to content
Permalink
Browse files

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

  • Loading branch information...
sammarshallou committed May 23, 2012
1 parent 2ddb941 commit 054d245a2c8ee1485632296e0711535f1ec3a7fa
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
@@ -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) {
@@ -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;
}
@@ -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 054d245

Please sign in to comment.
You can’t perform that action at this time.