Disable Glossary Linking in Quizzes

Disable Glossary Linking in Quizzes

by David Mosher -
Number of replies: 9
I was having a hard time trying to find a way to disable glossary linking within certain sections of Moodle (ie: within quizzes) strictly by manipulating server-side code and the forum search wasn't helping me much, so I decided to create a small includable file that executes this functionality client-side via a little bit of javascript.

If anyone is interested, here's how I did it:

  1. I used the jQuery library as it is lightweight and provides smaller syntax for selecting DOM elements than others, I included my copy of the library within moodle/theme/yourtheme/header.html (you could include it only in the specific file but I'm using jQuery for further development so I stuck it in the header).

    http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js

  2. Create a file to house the script that removes the glossary links. I called mine "disableglossary.js" and placed it in /moodle/lib/yourlibs/


    This script simply iterates over the a elements with .glossary and .autolink classes, replacing the links with the text content inside.
    $(document).ready(function() { // when the dom is ready
    $("a.glossary, a.autolink").each(function(i, term) { // replace linked terms with content
    $(term).replaceWith($(term).html());
    });
    });

  3. I included the file within /moodle/mod/quiz/attempt.php near the bottom:
    include("../../lib/yourlib/disableglossary.js");


Note: If you're interested you can test the script from #2 by opening firebug and executing it on a quiz attempt in which you have glossary terms. You'll see the terms get removed live.

Hope this is of some use to someone smile



Average of ratings: -
In reply to David Mosher

Re: Disable Glossary Linking in Quizzes

by Stuart Mealor -
Hi David

I'm sure that will be of use in a specific context - thanks for posting smile

Note:

In a Quiz question it is possible to highlight the text and use the "Prevent automatic linking" button in the Editor of course smile

And any Glossary, or individual entry within it, can be set to not automatically link.

I'm adding this comment for the benefit of people who find this post by its title, but do not require a site wide hack smile

Stu
Average of ratings: Useful (2)
In reply to Stuart Mealor

Re: Disable Glossary Linking in Quizzes

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Stuart:

In a Quiz question it is possible to highlight the text and use the "Prevent automatic linking" button in the Editor of course

Yes, and you can do that in the text of any activity ; but it can get tiresome if you have to remember to use that "Prevent automatic linking" setting in all of the questions of a quiz. Personally, since I use quizzes for learning, not for testing purposes, it does not bother me at all (on the contrary) if there are Glossary hyperlinks in the text of my quizz questions.

any Glossary, or individual entry within it, can be set to not automatically link

Sure, but in my opinion that setting rather defeats the whole purpose of a Glossary, which is to provide hyperlinked help immediately available in the resources texts in Moodle.

May I air my view (yet once more in these forums) that the "moodle philosophy" (which is also mine) is to provide the students with as many opportunities as possible for learning, not to prevent them from doing things, provide "secure quizzes", remove glossary hyperlinks, etc.wink

Joseph

Average of ratings: Useful (2)
In reply to Joseph Rézeau

Re: Disable Glossary Linking in Quizzes

by David Mosher -
Hi Joseph,

Yes we're using the quizzes as a testing tool only so it didn't make sense to our client to have glossary terms linked within the quiz questions which, in some cases, could yield an answer smile

I have become familiar with the Moodle learning philosophy and I think it is a noble one, to be sure. However, in this case it doesn't line up with the goals of our client (which is to have scheduled training on safety procedures on an ongoing basis).

Hopefully through the comments and the subject line people will understand why this solution worked for us smile
In reply to Stuart Mealor

Re: Disable Glossary Linking in Quizzes

by David Mosher -
Hi Stuart,

We did realize that there were options with the "Moodle No Link" tool within the editor but this requires manual manipulation of each and every question. Our specific application is training employees at a mine site and there is a significant amount of material existing.

It was much easier for us to remove the links after the fact instead of preemptively having to mark specific words with nolink. Our glossary is also quite large smile
In reply to David Mosher

Re: Disable Glossary Linking in Quizzes

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
In Moodle 2.0 you will be able to enable or disable different filters for each activity. See Development:Filter_enable/disable_by_context
Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Disable Glossary Linking in Quizzes

by David Mosher -
Sounds great! Unfortunately Moodle 2.0 is nowhere near production ready and our clients needs a system up and running before it will be. We're working with the latest version of the 1.x series at the moment, but thanks for the knowledge about the future vision :D
In reply to David Mosher

Re: Disable Glossary Linking in Quizzes

by Sandra King -
David, you are a life saver - I just sat down tonight to figure out how to do this for an Insurance Licensing course - my deadline is Thursday, and you have already solved the problem for me. Now I just have to be smart enough to follow your instructions.


And yes... I know that I can disable it question by question - but that doesn't work on the answers to questions. I know because I tried right before logging onto moode.org

And yes... I know and agree that giving students instant help is ideal. But since I can't turn off linking selectively within my answers I will have to do it throughout the entire moodle installation on our server.

Again Thank you David... and thank you to every one else at Moodle for all of your hard work creating and maintaining Moodle

Sandra King
In reply to David Mosher

Re: Disable Glossary Linking in Quizzes

by John Doyle -

Hi David - 7+ years later - this is still useful - thanks!