Moodle
  1. Moodle
  2. MDL-7336

Allow filters to be enabled/disabled per course or activity

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7
    • Fix Version/s: 2.0
    • Component/s: Filters
    • Labels:
      None
    • Affected Branches:
      MOODLE_17_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Rank:
      32965

      Description

      The most popular variant of this request is "Can I disable the glossary auto-linking filter in my quiz?"
      Another example is "Enable the TeX filter only in the Maths course."

      Original description: Currently allowing auto-linking of resources is based on a site-wide option in administration. I would like to see this handled similar to how the max upload file size is handled where it could be allowed or disallowed at the site level (this has the highest priority) such that if it is disabled on the site then regardless of the course or activity settings it would be disabled. On the course level a teacher could determine if he or she wishes to utilize auto-linking; however, still have the option if on a particular label they did not wish to use auto-linking to disable it. I think the course-wide option would be easier to implement. The resource or activity option may be more complicated and significantly less practical (IMO).

      1. bigpatch.txt
        183 kB
        Tim Hunt
      2. bigpatch.txt
        183 kB
        Tim Hunt
      3. Global filter settings.bmml
        6 kB
        Tim Hunt
      4. patch_series.txt
        234 kB
        Tim Hunt
      5. patch_series.txt
        231 kB
        Tim Hunt
      6. patch_series.txt
        180 kB
        Tim Hunt
      7. patch_series.txt
        52 kB
        Tim Hunt
      8. Per-context settings page..bmml
        3 kB
        Tim Hunt
      9. String handling overview.bmml
        9 kB
        Tim Hunt
      1. Global filter settings.png
        46 kB
      2. Per-context settings page..png
        28 kB
      3. String handling overview.png
        115 kB

        Issue Links

          Activity

          Hide
          Matt Campbell added a comment -

          Glossaries are doing this per glossary, and there's a hack to turn this off for quizzes (and maybe even a feature request?) but it would be nice to give teachers control over how linking happens on a course-by-course basis.

          Show
          Matt Campbell added a comment - Glossaries are doing this per glossary, and there's a hack to turn this off for quizzes (and maybe even a feature request?) but it would be nice to give teachers control over how linking happens on a course-by-course basis.
          Hide
          James Williamson added a comment -

          +1 on allowing this feature to be set at different levels

          Show
          James Williamson added a comment - +1 on allowing this feature to be set at different levels
          Hide
          James Williamson added a comment -

          As we explore this issue further, there are multiple causes of "auto-linking:" in the Glossary, in Resource Name Auto-Linking, in Activity Names Auto-linking. While certainly complicating the GUI, one general caveat of interface design is that events should not happen automatically to users without their ability to turn them off. Since auto-linking manifests itself in multiple ways, and since these are controlled globally at the Admin level, providing users with the ability to control their course would be good.

          Show
          James Williamson added a comment - As we explore this issue further, there are multiple causes of "auto-linking:" in the Glossary, in Resource Name Auto-Linking, in Activity Names Auto-linking. While certainly complicating the GUI, one general caveat of interface design is that events should not happen automatically to users without their ability to turn them off. Since auto-linking manifests itself in multiple ways, and since these are controlled globally at the Admin level, providing users with the ability to control their course would be good.
          Hide
          Ray Lawrence added a comment -

          Big +1 on this too. Lack of flexibility is a real pest where different auto-linking state are preferred in different courses.

          Matt's point is slightly off topic I feel as the issue is about where linking is active rather than setting up entries. However, perhaps there are two strands to this:

          1. Does auto-linking apply in this course for the various auto-linking types.
          2. Prevent auto-linking to an activity or resource (glossary and database entries already have an option for this).

          I don't this this would be overly complicated - no more than the autolinking option in Glossary and an addtional switch in course settngs (Perhaps under an "Advanced" area like elsewhere.

          Show
          Ray Lawrence added a comment - Big +1 on this too. Lack of flexibility is a real pest where different auto-linking state are preferred in different courses. Matt's point is slightly off topic I feel as the issue is about where linking is active rather than setting up entries. However, perhaps there are two strands to this: 1. Does auto-linking apply in this course for the various auto-linking types. 2. Prevent auto-linking to an activity or resource (glossary and database entries already have an option for this). I don't this this would be overly complicated - no more than the autolinking option in Glossary and an addtional switch in course settngs (Perhaps under an "Advanced" area like elsewhere.
          Hide
          Anthony Borrow added a comment -

          I think the easiest way to implement this is to create a capability. Ideally, I think it would be more flexible if the capability were something like usesfilters. What I'm uncertain about is how to best handle the various filters. One option (perhaps the easiest) would be to create a capability for each filter. I'm not sure if this helps or not but as I read Ray's comments above my mind started thinking in this direction. This would allow things to be controlled at the activity or user level with roles. Comments, questions?

          Show
          Anthony Borrow added a comment - I think the easiest way to implement this is to create a capability. Ideally, I think it would be more flexible if the capability were something like usesfilters. What I'm uncertain about is how to best handle the various filters. One option (perhaps the easiest) would be to create a capability for each filter. I'm not sure if this helps or not but as I read Ray's comments above my mind started thinking in this direction. This would allow things to be controlled at the activity or user level with roles. Comments, questions?
          Hide
          Ray Lawrence added a comment -

          Seems waaaaay to complicated to me.

          At the moment I can't think of a reason why I'd want (for example) a teacher not to see the auto-linking to a glossary entry and a student to see it.

          What I can see as a beneficial state of affairs is the ability to:

          Enable/disable linking types by course.
          Enable/disable linking within specified module instances - Quiz, Lesson being obvious candidates.
          Set the linking parameters e.g. one per page/block at course level.

          Let's not forget that the ability to assign roles and override permissions is not granted universally.

          This would (in my non-developer head) seem to be workable as far as back up and restore are concerned too, especially between sites where corresponding roles may not have the same permissions.

          Filters link in the Administration block anyone?

          Show
          Ray Lawrence added a comment - Seems waaaaay to complicated to me. At the moment I can't think of a reason why I'd want (for example) a teacher not to see the auto-linking to a glossary entry and a student to see it. What I can see as a beneficial state of affairs is the ability to: Enable/disable linking types by course. Enable/disable linking within specified module instances - Quiz, Lesson being obvious candidates. Set the linking parameters e.g. one per page/block at course level. Let's not forget that the ability to assign roles and override permissions is not granted universally. This would (in my non-developer head) seem to be workable as far as back up and restore are concerned too, especially between sites where corresponding roles may not have the same permissions. Filters link in the Administration block anyone?
          Hide
          Tim Hunt added a comment -

          I would like to do this in Moodle 2.0 as part of the Navigation/blocks/themes changes.

          I am about to do a design at http://docs.moodle.org/en/Development:Filter_enable/disable_by_context.

          Show
          Tim Hunt added a comment - I would like to do this in Moodle 2.0 as part of the Navigation/blocks/themes changes. I am about to do a design at http://docs.moodle.org/en/Development:Filter_enable/disable_by_context .
          Hide
          Anthony Borrow added a comment -

          Tim - Just to follow up here in the tracker, as I mentioned in chat I commented on the docs page at http://docs.moodle.org/en/Development_talk:Filter_enable/disable_by_context. Peace - Anthony

          Show
          Anthony Borrow added a comment - Tim - Just to follow up here in the tracker, as I mentioned in chat I commented on the docs page at http://docs.moodle.org/en/Development_talk:Filter_enable/disable_by_context . Peace - Anthony
          Hide
          Tim Hunt added a comment -

          Added UI Mockup: <String handling overview>

          Show
          Tim Hunt added a comment - Added UI Mockup: <String handling overview>
          Hide
          Tim Hunt added a comment -

          Added UI Mockup: <Per-context settings page.>

          Show
          Tim Hunt added a comment - Added UI Mockup: <Per-context settings page.>
          Hide
          Ray Lawrence added a comment -

          This is getting better all the time. Per context control is great.

          Can we assume:

          Only activated filters will appear in the UI.
          All auto-linking filters will be included

          Show
          Ray Lawrence added a comment - This is getting better all the time. Per context control is great. Can we assume: Only activated filters will appear in the UI. All auto-linking filters will be included
          Hide
          Tim Hunt added a comment -

          Only activated filters, yes.

          I am not proposing to change any of the core filters to take advantage of this (I have too much else to do) just put the necessary framework in place. (Actually changing individual filters is easier anyway.)

          Show
          Tim Hunt added a comment - Only activated filters, yes. I am not proposing to change any of the core filters to take advantage of this (I have too much else to do) just put the necessary framework in place. (Actually changing individual filters is easier anyway.)
          Hide
          Tim Hunt added a comment -

          Note to self - where I have got to.

          Done:

          • create database tables
          • upgrade from $CFG->textfilters
          • library functions for setting the global active state
          • library functions for setting local state overrides
          • library functions for getting and setting local config
          • library function get_active_filters
          • created moodle/filter:manage capability

          To do

          • way to pass local config to filters.
          • change format_text/string to take contextid not courseid and use get_active_filters
          • change admin settings page
          • create local settings page - probably as a tab next to roles for now
          • hook to link to local settings page if filter has one
          • backup
          • restore
          Show
          Tim Hunt added a comment - Note to self - where I have got to. Done: create database tables upgrade from $CFG->textfilters library functions for setting the global active state library functions for setting local state overrides library functions for getting and setting local config library function get_active_filters created moodle/filter:manage capability To do way to pass local config to filters. change format_text/string to take contextid not courseid and use get_active_filters change admin settings page create local settings page - probably as a tab next to roles for now hook to link to local settings page if filter has one backup restore
          Hide
          Tim Hunt added a comment -

          Patch series of the changes so far, exported from git.

          Show
          Tim Hunt added a comment - Patch series of the changes so far, exported from git.
          Hide
          Tim Hunt added a comment -

          Also to do:

          • Try to measure performance implication on a 'typical large site'.
          Show
          Tim Hunt added a comment - Also to do: Try to measure performance implication on a 'typical large site'.
          Hide
          Dan Poltawski added a comment -

          Kudos, Tim. Thats some really nice clean code..!

          Show
          Dan Poltawski added a comment - Kudos, Tim. Thats some really nice clean code..!
          Hide
          Tim Hunt added a comment -

          Added UI Mockup: <Global filter settings>

          Show
          Tim Hunt added a comment - Added UI Mockup: <Global filter settings>
          Hide
          Tim Hunt added a comment -

          Progress update. (New patch_series.txt attached.)

          Done:

          • create database tables
          • upgrade from $CFG->textfilters
          • library functions for setting the global active state
          • library functions for setting local state overrides
          • library functions for getting and setting local config
          • library function get_active_filters
          • created moodle/filter:manage capability
          • way to pass local config to filters.
          • change format_text/string to use the new infrastructure
          • change admin settings page
          • backup
          • restore

          Todo now:

          • create local settings page - probably as a tab next to roles for now
          • hook to let filters have local settings UI
          • try to measure performance implication on a 'typical large site'

          Todo later after more nav 2.0 is done:

          • format_text/string need to be changed to get the right context once $PAGE->context
          • give local filter settings a better home
          Show
          Tim Hunt added a comment - Progress update. (New patch_series.txt attached.) Done: create database tables upgrade from $CFG->textfilters library functions for setting the global active state library functions for setting local state overrides library functions for getting and setting local config library function get_active_filters created moodle/filter:manage capability way to pass local config to filters. change format_text/string to use the new infrastructure change admin settings page backup restore Todo now: create local settings page - probably as a tab next to roles for now hook to let filters have local settings UI try to measure performance implication on a 'typical large site' Todo later after more nav 2.0 is done: format_text/string need to be changed to get the right context once $PAGE->context give local filter settings a better home
          Hide
          Tim Hunt added a comment -

          Performance testing done. See http://moodle.org/mod/forum/discuss.php?d=118580#p529572 results look fine to me.

          Show
          Tim Hunt added a comment - Performance testing done. See http://moodle.org/mod/forum/discuss.php?d=118580#p529572 results look fine to me.
          Hide
          Tim Hunt added a comment -

          New developer documentation at: http://docs.moodle.org/en/Development:Filters_2.0

          I've done the last two bits that do not rely on other Navigation 2.0 changes

          • create local settings page - probably as a tab next to roles for now
          • hook to let filters have local settings UI

          I am now attaching an updated patch-series, and also one big diff of the changes.

          I would be grateful of a code review before I check this in. Thanks.

          Show
          Tim Hunt added a comment - New developer documentation at: http://docs.moodle.org/en/Development:Filters_2.0 I've done the last two bits that do not rely on other Navigation 2.0 changes create local settings page - probably as a tab next to roles for now hook to let filters have local settings UI I am now attaching an updated patch-series, and also one big diff of the changes. I would be grateful of a code review before I check this in. Thanks.
          Hide
          Tim Hunt added a comment -

          Revised patches to fix MySQL issue. Thanks Nico for finding it.

          Show
          Tim Hunt added a comment - Revised patches to fix MySQL issue. Thanks Nico for finding it.
          Hide
          Dan Poltawski added a comment -

          I've seen a bit of weirdness with the javascript on the admin settings page - the first filter I 'enable' can not have its active status changed, it seems to not generate a new pageload.

          Show
          Dan Poltawski added a comment - I've seen a bit of weirdness with the javascript on the admin settings page - the first filter I 'enable' can not have its active status changed, it seems to not generate a new pageload.
          Hide
          Tim Hunt added a comment -

          Thanks for testing Dan. Naturally, I have not seen this. (In fact, I am just using the standard popup_forum function from weblib - I am not doing anything unusual). Usual question: which browser, etc? Also, if you try this in Firefox with Firebug open, any obvious error messages?

          Show
          Tim Hunt added a comment - Thanks for testing Dan. Naturally, I have not seen this. (In fact, I am just using the standard popup_forum function from weblib - I am not doing anything unusual). Usual question: which browser, etc? Also, if you try this in Firefox with Firebug open, any obvious error messages?
          Hide
          Dan Poltawski added a comment -

          FF/Safari.

          I've been testing a bit more with javascript disabled and:

          • It appears to always be the top filter in the order list
          • When javascript is disabled the plain html form tries to post to admin/settings.php rather than the intended course/jumpto.php

          (Related but another issue, you are using get_string('save') for the plain html form string and that doesn't exist)

          Show
          Dan Poltawski added a comment - FF/Safari. I've been testing a bit more with javascript disabled and: It appears to always be the top filter in the order list When javascript is disabled the plain html form tries to post to admin/settings.php rather than the intended course/jumpto.php (Related but another issue, you are using get_string('save') for the plain html form string and that doesn't exist)
          Hide
          Dan Poltawski added a comment -

          Thinking a bit more about this I am guessing its related to it being a form within a form, and the first filter submit action is actually being interpreted as submission for admintree settings form?

          Show
          Dan Poltawski added a comment - Thinking a bit more about this I am guessing its related to it being a form within a form, and the first filter submit action is actually being interpreted as submission for admintree settings form?
          Hide
          Martin Dougiamas added a comment -

          +1 from me (assuming Dan's buglet gets fixed before or after checkin of course)

          Show
          Martin Dougiamas added a comment - +1 from me (assuming Dan's buglet gets fixed before or after checkin of course)
          Hide
          Tim Hunt added a comment -

          Yes, indeed, it is a nested forms problem. The only sane solution is to separate Manage filters out into a separate admin_externalpage, and rename the existing page 'Common filter settings'. Doing.

          Show
          Tim Hunt added a comment - Yes, indeed, it is a nested forms problem. The only sane solution is to separate Manage filters out into a separate admin_externalpage, and rename the existing page 'Common filter settings'. Doing.
          Hide
          Tim Hunt added a comment -

          Committed!

          Show
          Tim Hunt added a comment - Committed!
          Hide
          Penny Leach added a comment -

          Hi Tim

          I've traced down an exception I'm getting to this commit. lib/weblib.php on line 995 is calling $PAGE->context. But what about in the case where there is no page - for example during xmlrpc call (which is where I'm seeing the error), or I presume cron...

          Maybe cron is setting up a fake $PAGE object and I should be doing the same in mnet? Can you give me a pointer about how to work around this, please?

          Show
          Penny Leach added a comment - Hi Tim I've traced down an exception I'm getting to this commit. lib/weblib.php on line 995 is calling $PAGE->context. But what about in the case where there is no page - for example during xmlrpc call (which is where I'm seeing the error), or I presume cron... Maybe cron is setting up a fake $PAGE object and I should be doing the same in mnet? Can you give me a pointer about how to work around this, please?

            People

            • Votes:
              11 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: