Filter bar option "Show buttons based on course outcomes" throws a warning.

Issue #152 resolved
daniel.cifuentes created an issue

When creating a course, in the Course Format settings, if the user sets the Filter bar config to Show buttons based on course outcomes, after saving changes and going back to the course main page, a warning will be displayed.

Steps to replicate:

  • Login as admin
  • Create a course and add outcomes to it.
  • Go to the course settings and select format Tiles and then set “Filter bar” config to Show buttons based on course outcomes.
  • Go to the course main page and check the outcomes buttons. Those are not working.

After reviewing the code, I found that in tiles/classes/output/course_output.php, where the $data['has_filter_buttons'] is defined, the conditional that its executed when the filter is set to FORMAT_TILES_FILTERBAR_OUTCOMES`, the variable $data['fiternumberedbuttons'] is not defined. That code is here: https://bitbucket.org/dw8/moodle-format_tiles/src/master/classes/output/course_output.php#lines-626. It should be replaced with $data['fiteroutcomebuttons'].

Also, in the tiles/format.php file, the 'displayFilterBar' param that belong to $jsparams (https://bitbucket.org/dw8/moodle-format_tiles/src/master/format.php#lines-106) stores the following values:

  • 0 if the filter is set to "Hide"
  • 1 if the filter is set to "Show buttons based on tile numbers"
  • 2 if the filter is set to "Show buttons based on course outcomes"
  • 3 if the filter is set to "Show buttons based on tile numbers and course outcomes"

That value is used in tiles/amd/src/course.js here https://bitbucket.org/dw8/moodle-format_tiles/src/master/amd/src/course.js#lines-610 and here. https://bitbucket.org/dw8/moodle-format_tiles/src/master/amd/src/course.js#lines-820. So that code will only be executed when the value is 1, not when the value is set to 2 or 3. We could use something like the following code in the tiles/format.php file:

if ($course->displayfilterbar > 0) {
$displayfilterbar = 1;
} else {
$displayfilterbar = 0;
}

And then pass $displayfilterbar as the parameter in $jsparams.

Thanks!

Comments (1)

  1. Log in to comment