the behaviour of the [nolink] tag

the behaviour of the [nolink] tag

by Joseph Rézeau -
Number of replies: 5
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi everyone,

I'd like to share some thoughts about the present behaviour of the <nolink> tag in Moodle (using version 1.5.3 stable).

1- Usefulness of the <nolink> tag

There are a number of reasons why a teacher would want to prevent the "overzealous" automatic linking of Glossary entries in his course resources. It is possible to restrict the automatic linking to one occurrence per page or one per text, by using these lines in \moodle\config.php

$CFG->filtermatchoneperpage = true; //To autolink each term only once per page

$CFG->filtermatchonepertext = true; //To autolink each term once per text block

It is also possible to use either the <nolink></nolink> or the <span class="nolink"></span> tag in passages of HTML documents or whole HTML documents (resources, forums, lessons, quizzes, etc.).

2- Using the "Prevent automatic linking" button in the HTML editor

If you use this button to prevent automatic linking and apply it to a selection of text which contains already formatted passages (i.e. italics, font color, heading, etc.), it will remove all of your formatting when surrounding your selection with the <span class="nolink"></span> tag.

Workaround A: do not format any part of your text if you plan to Prevent automatic linking in some parts (or the whole) of it. Type all of your text, apply the Prevent automatic linking and only then can you format your text as you want.

Workaround B: do not use the Prevent automatic linking button. When you have finished typing your text, click on the Toggle HTML Source button, add <nolink> right at the beginning of the code and </nolink> right at the end. I always do this.

3- Restricted use of the "nolink" class

The <span class="nolink"></span> tag was introduced in version 1.5 (I think) but the former <nolink></nolink> is still valid in current versions. Unfortunately the "class" interpretation has not been implemented to its fullest, I think. At the moment, using the two linking-prevention systems, here is what works (no links) and what does not work (links).


result
1- <span class="nolink"><p>...</p></span>
no links
2- <nolink><p>...</p></nolink> no links
3- <div class="nolink">...</div> links
4- <p class="nolink">...</p> links
5- no links-preventing links

The way the "nolink" class is implemented at the moment does not conform to strict HTML syntax, as it leads to a) a mixture of tags belonging to different levels in the DOM hierarchy and b) the mere impossibility to use the "nolink" class within HTML tags other than <span>, as shown above. In fact, I do not see what we have gained over the former system with the introduction of the "nolink" class since its use is strictly limited to the <span> tag.

Can we hope to have an implementation more compliant with HTML syntax in further versions of Moodle?

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

Re: the behaviour of the [nolink] tag

by Garrett Murphy -

Joseph:

Great tips, but I have a question:

$CFG->filtermatchoneperpage = true; //To autolink each term only once per page
$CFG->filtermatchonepertext = true; //To autolink each term once per text block

Do these two methods also work for autolinked Wikipedia entries?

In reply to Garrett Murphy

Re: the behaviour of the [nolink] tag

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Garrett,
Not sure what you mean by "autolinked Wikipedia entries"
Where are those entries? / links ???

In reply to Joseph Rézeau

Re: the behaviour of the [nolink] tag

by Chris Collman -
Picture of Documentation writers
Joseph,
Revisited the glossary linking in quizzes and the nolink solution and saw your Feb 11 post.    I almost thought "Dawn was breaking over Marblehead" but it is minus 10 F this morning and it was too cold.  I am probably misunderstanding or doing something that is not exact enough in the right places.

You wrote: It is also possible to use either the <nolink></nolink> or the <span class="nolink"></span> tag in passages of HTML documents or whole HTML documents (resources, forums, lessons, quizzes, etc.).

I was hoping this said that I could insert some html code at the start of a lesson and turn it off at the end.   Probably don't understand "whole html documents" defination.   Suspect what I call a branch is a whole html document.

I just played around with nolink in a lesson question 1.5.3+.  I have not played with quizzes.   I found out that with a question in a lesson, every "question/introduction" and "answer/jump" needs to have the nolink applied.     I was able to turn it off and on inside the question. But when I inserted a "<nolink> before the end of the question, it did not carry to jump 4.  Something converted it to the span class and automatically inserted an "</span>" at the end of the question.    I was able to turn linking off and on inside an answer.

Got to go back and look to see if GIFT format supports HTML, then see if my marblehead can tweak the most excellent "Word.doc to GIFT.txt" template's VB code to automatically insert the right stuff as part of the export process.  

Seems to me the majority of users  want to have the glossary links turned off for any question in a lesson or in a quiz.  Is there a template PHP is going to when we create questions via (insert question) in a lesson or in a quiz?  A little clutzy to add the no linke code there as a default but wouldn't that work as a temp fix until the global switch thing is added as a feature.    Pardon my non-technical language. 

Chris



In reply to Chris Collman

Re: the behaviour of the [nolink] tag

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

Chris,

>You wrote: It is also possible to use either the <nolink></nolink> or the <span class="nolink"></span> tag in passages of HTML documents or whole HTML documents (resources, forums, lessons, quizzes, etc.). I was hoping this said that I could insert some html code at the start of a lesson and turn it off at the end.

By HTML documents I meant HTML files that you create on your computer and then upload to your Moodle course, to the moodledata files, and link to as uploaded resourses. This has nothing to do with the contents of the lessons or quizzes.sad

To turn off automatic glossary linking in a lesson or quiz, the only method available so far is to insert the <nolink></nolink> tags by hand for each and every question.

Obviously what is needed is an option somewhere, either at Lesson (or Quiz) settings level or at the level of each question page or question for turning off automatic linking.

I have no idea how this can be done, however.

All the best

Joseph

PS I hope you managed to warm-up.wink

In reply to Joseph Rézeau

Re: the behaviour of the [nolink] tag

by Chris Collman -
Picture of Documentation writers
Joseph,
Well it is getting warmer at 11 AM all the way up to  -3 F but the wind is kicking up so the windchill is around -30 F  brrrrr.

I was hoping I was missing something.  Where is the right place to do a MoodleSqueak about the fix.  Is there someplace I can vote?   I am completely intimidated in the Bug section smile

best  Chris