Skip to content

Commit

Permalink
MDL-17816: Changes to the way availability conditions are displayed w…
Browse files Browse the repository at this point in the history
…hen viewing course
  • Loading branch information
sam_marshall committed Apr 17, 2009
1 parent 3982f0f commit e8e5098
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
29 changes: 25 additions & 4 deletions course/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,27 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
}
}

// In some cases the activity is visible to user, but it is
// dimmed. This is done if viewhiddenactivities is true and if:
// 1. the activity is not visible, or
// 2. the activity has dates set which do not include current, or
// 3. the activity has any other conditions set (regardless of whether
// current user meets them)
$canviewhidden = has_capability(
'moodle/course:viewhiddenactivities',
get_context_instance(CONTEXT_MODULE, $mod->id));
$accessiblebutdim = false;
if ($canviewhidden) {
$accessiblebutdim = !$mod->visible;
if (!empty($CFG->enableavailability)) {
$accessiblebutdim = $accessiblebutdim ||
$mod->availablefrom > time() ||
($mod->availableuntil && $mod->availableuntil < time()) ||
count($mod->conditionsgrade) > 0 ||
count($mod->conditionscompletion) > 0;
}
}

echo '<li class="activity '.$mod->modname.'" id="module-'.$modnumber.'">'; // Unique ID
if ($ismoving) {
echo '<a title="'.$strmovefull.'"'.
Expand All @@ -1473,12 +1494,12 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
}

if ($mod->modname == "label") {
if (!$mod->visible || !$mod->uservisible) {
if ($accessiblebutdim || !$mod->uservisible) {
echo '<div class="dimmed_text"><span class="accesshide">'.
get_string('hiddenfromstudents').'</span>';
}
echo format_text($extra, FORMAT_HTML, $labelformatoptions);
if (!$mod->visible || !$mod->uservisible) {
if ($accessiblebutdim || !$mod->uservisible) {
echo "</div>";
}
if (!empty($CFG->enablegroupings) && !empty($mod->groupingid) && has_capability('moodle/course:managegroups', get_context_instance(CONTEXT_COURSE, $course->id))) {
Expand Down Expand Up @@ -1529,7 +1550,7 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
// about visibility, without the actual link
if ($mod->uservisible) {
// Display normal module link
if ($mod->visible) {
if (!$accessiblebutdim) {
$linkcss = '';
$accesstext ='';
} else {
Expand Down Expand Up @@ -1668,7 +1689,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 ($isediting && !empty($CFG->enableavailability)) {
} else if ($canviewhidden && !empty($CFG->enableavailability)) {
$ci = new condition_info($mod);
$fullinfo = $ci->get_full_information();
if($fullinfo) {
Expand Down
4 changes: 2 additions & 2 deletions lang/en_utf8/condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
$string['showavailability']='Before activity is available';
$string['showavailability_show']='Show activity greyed-out, with restriction information';
$string['showavailability_hide']='Hide activity entirely';
$string['userrestriction_visible']='Activity conditionally restricted: &lsquo;$a&rsquo;';
$string['userrestriction_hidden']='Activity conditionally restricted (completely hidden, no message): &lsquo;$a&rsquo;';
$string['userrestriction_visible']='Restricted: &lsquo;$a&rsquo;';
$string['userrestriction_hidden']='Restricted (completely hidden, no message): &lsquo;$a&rsquo;';
?>

0 comments on commit e8e5098

Please sign in to comment.