Skip to content

Commit

Permalink
MDL-36131 AJAX: Conditional activities will behave same as in non-aja…
Browse files Browse the repository at this point in the history
…x mode
  • Loading branch information
Rajesh Taneja committed Oct 19, 2012
1 parent 7e8ae12 commit 57bda78
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
12 changes: 8 additions & 4 deletions course/lib.php
Expand Up @@ -1474,8 +1474,8 @@ function print_section($course, $section, $mods, $modnamesused, $absolute=false,
$linkclasses = '';
$textclasses = '';
if ($accessiblebutdim) {
$linkclasses .= ' dimmed';
$textclasses .= ' dimmed_text';
$linkclasses .= ' dimmed conditionalhidden';
$textclasses .= ' dimmed_text conditionalhidden';
$accesstext = '<span class="accesshide">'.
get_string('hiddenfromstudents').': </span>';
} else {
Expand Down Expand Up @@ -1657,11 +1657,15 @@ 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) && $mod->visible) {
} else if ($canviewhidden && !empty($CFG->enableavailability)) {
$visibilityclass = '';
if (!$mod->visible) {
$visibilityclass = 'accesshide';
}
$ci = new condition_info($mod);
$fullinfo = $ci->get_full_information();
if($fullinfo) {
echo '<div class="availabilityinfo">'.get_string($mod->showavailability
echo '<div class="availabilityinfo '.$visibilityclass.'">'.get_string($mod->showavailability
? 'userrestriction_visible'
: 'userrestriction_hidden','condition',
$fullinfo).'</div>';
Expand Down
27 changes: 20 additions & 7 deletions course/yui/toolboxes/toolboxes.js
Expand Up @@ -33,7 +33,11 @@ YUI.add('moodle-course-toolboxes', function(Y) {
SECTIONIDPREFIX : 'section-',
SECTIONLI : 'li.section',
SHOW : 'a.editing_show',
SHOWHIDE : 'a.editing_showhide'
SHOWHIDE : 'a.editing_showhide',
CONDITIONALHIDDEN : 'conditionalhidden',
AVAILABILITYINFODIV : 'div.availabilityinfo',
SHOWCLASS : 'editing_show',
ACCESSHIDECLASS : 'accesshide'
};

/**
Expand Down Expand Up @@ -68,18 +72,14 @@ YUI.add('moodle-course-toolboxes', function(Y) {

var status = '';
var value;
if (dimarea.hasClass(toggle_class)) {
if (button.hasClass(CSS.SHOWCLASS)) {
status = 'hide';
value = 1;
} else {
status = 'show';
value = 0;
}

// Change the UI
dimarea.toggleClass(toggle_class);
// We need to toggle dimming on the description too
element.all(CSS.CONTENTAFTERLINK).toggleClass(CSS.DIMMEDTEXT);
// Update button info.
var newstring = M.util.get_string(status, 'moodle');
hideicon.setAttrs({
'alt' : newstring,
Expand All @@ -88,6 +88,19 @@ YUI.add('moodle-course-toolboxes', function(Y) {
button.set('title', newstring);
button.set('className', 'editing_'+status);

// If activity is conditionally hidden, then don't toggle.
if (!dimarea.hasClass(CSS.CONDITIONALHIDDEN)) {
// Change the UI.
dimarea.toggleClass(toggle_class);
// We need to toggle dimming on the description too.
element.all(CSS.CONTENTAFTERLINK).toggleClass(CSS.DIMMEDTEXT);
}
// Toggle availablity info for conditional activities.
var availabilityinfo = element.one(CSS.AVAILABILITYINFODIV);

if (availabilityinfo) {
availabilityinfo.toggleClass(CSS.ACCESSHIDECLASS);
}
return value;
},
/**
Expand Down

0 comments on commit 57bda78

Please sign in to comment.