MDL-36736 course: Availability information should not be visible for hidden modules
authorRajesh Taneja <rajesh@moodle.com>
Wed, 21 Nov 2012 02:49:05 +0000 (10:49 +0800)
committerRajesh Taneja <rajesh@moodle.com>
Thu, 22 Nov 2012 07:13:26 +0000 (15:13 +0800)
If user is viewing hidden module, availability information should only be visible to
user when editing and module is visible. If editing and module is hidden, then hide
availablilty information as it's invalid.
When user is not editing and activity is hidden then don't add availability information.

course/lib.php

index c3aa869..f1cf07a 100644 (file)
@@ -1732,17 +1732,20 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
             if (!$mod->uservisible) {
                 echo '<div class="availabilityinfo">'.$mod->availableinfo.'</div>';
             } else if ($canviewhidden && !empty($CFG->enableavailability)) {
-                $visibilityclass = '';
-                if (!$mod->visible) {
-                    $visibilityclass = 'hide';
-                }
-                $ci = new condition_info($mod);
-                $fullinfo = $ci->get_full_information();
-                if($fullinfo) {
-                    echo '<div class="availabilityinfo '.$visibilityclass.'">'.get_string($mod->showavailability
-                        ? 'userrestriction_visible'
-                        : 'userrestriction_hidden','condition',
-                        $fullinfo).'</div>';
+                // Don't add availability information if user is not editing and activity is hidden.
+                if ($mod->visible || $PAGE->user_is_editing()) {
+                    $hidinfoclass = '';
+                    if (!$mod->visible) {
+                        $hidinfoclass = 'hide';
+                    }
+                    $ci = new condition_info($mod);
+                    $fullinfo = $ci->get_full_information();
+                    if($fullinfo) {
+                        echo '<div class="availabilityinfo '.$hidinfoclass.'">'.get_string($mod->showavailability
+                            ? 'userrestriction_visible'
+                            : 'userrestriction_hidden','condition',
+                            $fullinfo).'</div>';
+                    }
                 }
             }