Automatic Linking

Automatic Linking

by Williams Castillo -
Number of replies: 36

Hello dear moodlers,

It has been a little bit of time but I've been moodling in other way. Sorry.

Just trying to close this circle, I would like close all issues regarding this matter...

I've seen the following alternatives so far:

  • automatically link this word (on/off)
  • this word is case sensitive (on/off)
  • synonyms for "look" are "look after", "look for" (AKA "alias")
  • Marking text as "don't link" ... <nolink>perhaps using an XML tag</nolink>..

Is there anything else I would need to implement in the glossary?

Will

Average of ratings: -
In reply to Williams Castillo

Re: Automatic Linking

by Tom Murdock -
link category names, too? so when the category name appears somewhere it will link to a list of the items within that category?

i.e. Parts of Speech (a category containing words like: noun, verb, adverb, etc..)

Can a word be in more than one category? (Benjamin Franklin in the inventor category as well as politician category?)

Also, can these links appear everywhere in Moodle--not just resources (I'm talking about forums, labels, instructions, summaries, etc..)? Can you use the existing library hooks for this? (When I make an assignment or comment on a journal, the words should link for more context/clarity).

Finally, is it possible to attach forums to individual glossary entries for potential discussions? (I'm thinking a vocab word might receive sample sentences from a class learning to use the word). Or a glossary term might invoke a discussion from a class about its ideas.

Thanks,
Tom
In reply to Tom Murdock

Re: Automatic Linking

by Tom Murdock -
Glossary is really looking good. I want to follow-up on a couple of these requests.

Linking to a category could be really helpful. For a teacher to say: I'd like you to look at all of the Moodle Terms tonight (and having a link to that category turn into a link) would be helpful.

I'm also interested in entries having multiple categories. Maybe a teacher needs to create five vocab lists (with some words that are shared between lists). If you create a master list and then create 5 categories that select from that master list, then the indexing will be incredibly flexible and you won't have any duplication issues.

Thanks!
Tom
In reply to Tom Murdock

Re: Automatic Linking

by Williams Castillo -

Sure.. Categories' name will be linked asap.

By the way, an entry CAN have multiple categories indeed. Since the beginning.. Are you having problems with it?


By the way... I'm implementing the nolink tag but I'm having a little problem: it disappear from the source code... There seems to be a sort of validation on allowed tags... Where should I add this tag, uncle Martin? EDIT: Found in weblib (where it should be)... But I think I should not change it... Martin are you so kind?

 

In reply to Tom Murdock

Re: Automatic Linking

by Williams Castillo -

As you wrote Moodle Terms it was not linked.. Why? The category name is Moodle terms.. smile

Not a very useful comment.. I just wanted to see this feature implemented here.. smile

Update: 182? Holy smokes! dead.gif Back to work.
Update2: What a shame! I leave it hard-coded!!!! Sorry guys...
Update3: Wow... How quick! Solved now (by two people.. smile) It was useful after all!

In reply to Williams Castillo

Re: Automatic Linking

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Another suggestion ... when link words are found within an existing HTML link, don't link them.

I've finished a text filter system and the glossary linking is working system wide: http://moodle.org/mod/forum/discuss.php?d=2968

but this link within link issue is the only thing holding me back from turning it on in this site. smile
In reply to Martin Dougiamas

Re: Automatic Linking

by Williams Castillo -

but this link within link issue is the only thing holding me back from turning it on in this site.

Well... It is now solved in CVS...

By the way... that textfilters works great!

Just a thought... I think that all text filters files should be as small as possible... I mean, I think the parsing function should not be included in the common lib file of each module... it could take forever to parse a text if you have many text filters defined...

In the same vein... I think this file should be a good candidate to be exclude from one of the coding convention (the one that say that all files should be linked to ../../config.php and to lib.php for the same reason...

Anyway... The ball in in your field now!!! ;)

In reply to Williams Castillo

Re: Automatic Linking

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Nice job! I've turned it on in this site. smile

Yes, the filters really need to be efficient and small as possible, since they can be called a lot - and yes - no need for them to call any libraries.

I notice you went back to normal links ... didn't like my <ACRONYM> tags? blush

I'm not a real big fan of the normal-looking links ... I think they are a bit distracting and one isn't sure which are links the author put in and which are automatic ... I've just made a new style called "autolink" so this can be defined in the stylesheets. smile
In reply to Martin Dougiamas

Re: Automatic Linking

by Williams Castillo -

I notice you went back to normal links ... didn't like my <ACRONYM> tags? <img class=" src="http://moodle.org/pix/s/blush.gif" width="15" />

OMG!!! It was you! Sincerly, I though I was drunk when I see those tags.. Can't remenber when I use them so I zap them... blush.gifblush.gifblush.gifblush.gifblush.gifbiggrin.gif

hehehe.. It was funny.. Sorry... Rolling back right now... smile

Will

In reply to Williams Castillo

Re: Automatic Linking

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
No, don't worry about it! tongueout The new style is probably better anyway! big grin

Notice the gray links on this site?

I also just checked in a small change that allows the glossary to be chosen even from a text filter (by using a separate CFG parameter) ... the reason is that I wanted the glossary in this site to be a secondary one (so students could edit it) yet still have it being used for links. This now works if I have this in config.php:

$CFG->glossary_link[5] = 5;

It's a quick hack, though ... it would be much better to have a "dynalink" field (on/off) in the "glossary" table (as well as one for each entry).

I am really starting to love this glossary module! big grin

I have two more suggestions to add to your list that starts this topic

- only search for "whole" words ... for example "url" is currently linked within "hourly".

- the format of the entry in the popup window should match the format chosen for the main glossary display.

I'll file them in the bug tracker. big grin
In reply to Martin Dougiamas

Re: Automatic Linking

by Williams Castillo -

Notice the gray links on this site?

Nope sad.gif But I'm half blind anyway... smile

it would be much better to have a "dynalink" field (on/off) in the "glossary" table (as well as one for each entry).

Sure... Both, at glossary level and entry level, won't it slow down the process??? Imagine if you have three fat glossaries... sad I think it should be only at glossary level... Let's see what other poeple thinks about it.

Cheers,
Will

 

In reply to Williams Castillo

Re: Automatic Linking

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
(You actually have the entry-level flag in your list of things to do at the top of this topic wink )

I don't think it will slow things down much at all, basically where you currently retrieve the entries from glossary_entries using get_records, you would first get the list of dynalink glossaries:

$glossaries = get_records("glossary", "dynalink", 1);

..then you make a little 1,2,3 list of the returned IDs using implode(), then you can get all the entries with one SQL call using get_records_select() and specifying the select conditions like this:

"glossaryid IN ($glossarylist) AND dynalink = 1"

If people go over the top with huge glossaries it will slow down, yes, but it's exactly the same with even one big glossary. smile

(Can you really not see the gray HTML links ...?)
In reply to Martin Dougiamas

Re: Automatic Linking

by Williams Castillo -

Oops.. I forgot that list... smile

And, once again, you are right about the dynalink field... smile

(Can you really not see the gray HTML links ...?)

I swear! smile

See the attached image... Tell me if you can see the gray link... Perhaps it is an issue of my monitor.

Will

Attachment link.jpg
In reply to Williams Castillo

Re: Automatic Linking

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Wierd ... what browser/OS are you using?

Attached is how it looks to me ...

(If we can't trust CSS for something so simple what hope is there for CSS positioning?)
Attachment gray-words.gif
In reply to Martin Dougiamas

Re: Automatic Linking

by Sean Keogh -
Working ok for me on Windows 2000 / Mozilla 1.5 displayed on CTX and IIyama LCD monitors.
In reply to Martin Dougiamas

Re: Automatic Linking

by Williams Castillo -

Wait wait... you can trust CSS... you should think twice before trsuting me... smile I forgot to set the style tags in the appropiate file... blush.gif

BTW, don't remember me that thread... I'm still blushed... blush.gif biggrin.gif (and I think Tom Floyd too.. wink.gif)

In reply to Martin Dougiamas

Re: Automatic Linking

by Williams Castillo -
By the way, I think that every module should have a flag which specify if it should or should not make use of the text filters... Don't you think?
In reply to Williams Castillo

Re: Automatic Linking

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
It's a good idea but quite hard to implement currently since that information is not available to the text filters ... it would have to be passed in from every module.
In reply to Williams Castillo

Re: Automatic Linking

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Hi moodlers...

I think that they both checks should exist:

  • One defining if every activity (not module) should execute one or some text filters. That info could be stored in course_modules (a comma separated list of text filters to apply or empty if no filters are desired at all). That info could be cached to improve performance.
  • One field in glossary table to mark when text filters should be applied against one glossary at all.

Finally, one field in the entries table to mark when every term is "in the game" could be implemented, but I think that it's less critical.

Ciao, Eloy smile
In reply to Eloy Lafuente (stronk7)

Re: Automatic Linking

by Eloy Lafuente (stronk7) -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Peer reviewers Picture of Plugin developers Picture of Testers
Comenting my previous message...

Why the "sequence of filters to apply" (see my previous post) cannot be included in the "options" field of format_text() function to make the filter_text() function knows what filters to apply ?

Only one idea.... smile
In reply to Williams Castillo

Re: Automatic Linking

by Shai Coggins -
How do you activate auto linking?
In reply to Shai Coggins

Re: Automatic Linking

by Timothy Takemoto -

Apparently you need to put this in config.php


$CFG->textfilter1 = 'mod/glossary/dynalink.php';


But alas, I do not see autolinks (if I am understanding what they are).
I put the above in my config.php, and saved it. (Here is the top of my config.php)

<?PHP  // $Id: config.php,v 1.19 2003/09/26 08:04:48 moodler Exp $
       // config.php - allows admin to edit all configuration variables

    require_once("../config.php");
   
$CFG->textfilter1 = 'mod/glossary/dynalink.php';
 

Then I added a glossary to week 0 of my file. It is a secondary glossary so the students can add to it.

Then I added two entries. One is an entry (word) that appears in one of my resources. The other is an entry that appears on the comment of week 0. Both are entered exactly as they are in their respective places in the course.

I have waited now for about 5 minutes. No, 15 minutes. I think that I heard in reference to the library that there is a cron or something that parses the database every X minutes, updating links. Perhaps I need to wait for longer. Or I am waiting for the wrong thing. I was anticipating that the instances of the words that I had entered in the glossary would be magically linked to the respective entries. This would be really great for language teachers.

It is not quite as good as the idea of a library because I don't think that I will be getting too many of my students to come to the  glossary and make entries. They are shy for one thing. But maybe they will. The chances that they would come to the glossary and make entries would be radically increased if there were marks for glossary entries. In the longer term the possibility of grading would be nice, but either way a default point or .01 point per glossary entry would be nice. But this is all an aside, since what I am really wondering about is the lack of automatic linking and for your kind suggestions about what I might have done wrong. Hold on a minute. Perhaps I need to upload a later version of the glossary?

I will try that. I have yet to to use the "cvs." It will be a big challenge. I am sorry if this is just because I have an old version. But perhaps this will serve as a warning?

Update

I tried uploading the latest CVS of the dynalink.php to my glossary module. This did not seem to do anything. I also updated style.php from one of the standard themes to my custom theme (vanity). That did not do anything either. Then I downloaded the latest "nightly" (hourly?) changed my glossary to "oldglossary" and uploaded the whole thing, plonk. Then the below appeared in my latest activities framething on the right. (I now have turned latest activities off!). 


Fatal error: Cannot redeclare glossary_upgrade() (previously declared in /home/tim/mootim/moodle/mod/glossary/db/mysql.php:5) in /home/tim/mootim/moodle/mod/oldglossary/db/mysql.php on line 5

One of my two glossary entries has dissappeared. I don't mind the fact that it has dissappeared but I hope it does not cause a database corruption that has nasty side effects.

Then I tried reentering the missing entry. I was taken to a pink message saying that the entry alread exist. And then to a page which says "Glossary module needs upgrading" and a lot of success signs, with

Fatal error: Cannot redeclare glossary_add_instance() (previously declared in /home/tim/mootim/moodle/mod/glossary/lib.php:13) in /home/tim/mootim/moodle/mod/oldglossary/lib.php on line 15 

Aha! I realise the problem. It is no good leaving the old glossary as "oldglossary" in the mod directory since it will be treated as a glossary and will clash with the new one, as above.

In reply to Timothy Takemoto

Re: Automatic Linking

by Timothy Takemoto -

Hmm. When I remove the clashing "oldglossary" (that was stupid, durr) and then turn the "latest activities" back on, the "fatal error" message has disppeared. All looks rosey.

The entry that I thought had disppeared is still there. Sorry. I just had not selected "display alphabet" so I could not see it.

I tried running, or accessing "config.php" in my browser. It seem fine. Nothing much happened. All seems well, the glossary is a glossary, and it has entries and there are no fatal messages The only problem is the absence of dynalinks (and a couple of translations, which of course I will have to update).

Perhaps I am waiting for the cron (sounds like a daemon?) to kick in and spider around the database updating and making links. I tried updating all the resources and comments in which the dynalinks should exist but that made no difference. I had a look at the modules on the settings page and glossary is there fine. Perhaps it needs to be updated in someway.

Perhaps my version of moodle, 1.1.9 is not adequate in other ways.


 

In reply to Timothy Takemoto

Re: Automatic Linking

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
The line was right:

$CFG->textfilter1 = 'mod/glossary/dynalink.php';

but the location was incorrect.. you've put it in admin/config.php, but you want the main config.php (the one with all the other config info in it)

Cron is not involved - all the links are done on the fly.

Note also that you will need a very recent development version of Moodle for all this to work (ie something from this week)
In reply to Martin Dougiamas

Re: Automatic Linking

by Timothy Takemoto -

Thanks Martin.

I don't have a very recent version. The Glossary is the latest but the rest of Moodle is about 3 weeks old. Is something very horrible going to happen if put the line in the right config.php, I wonder.
Everything has been so robust so far....I may try it at my peril.

But I am scared of reinstalling a very recent moodle on my production course. I have never really done that before. And there are a number of tweaks, Chris's timer, the new rte, the multi-moodle configuration.  

In the meantime I had tried deleting the glossary, reinstalling it (this time no fatal errors) and adding about three different glossaries. This is a very useful way of giving language learners some help with difficult texts. 

Tim

In reply to Timothy Takemoto

Re: Automatic Linking

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Putting the line in won't do anything if you don't have this week's text filters ...

Since you have a motley version anyway you could try just replacing your lib/weblib.php, since that's where the code changes are.
In reply to Martin Dougiamas

Re: Automatic Linking

by Timothy Takemoto -

Thanks again. I will try that and let you know how my motley Moodle goes.

In reply to Timothy Takemoto

Re: Automatic Linking

by Timothy Takemoto -

Tried the new weblib.php but alas, no go. At first the rich editor disappeared since (possibly for the image insertion?) their is a new "richedit.php."

I did not want to use the new rich edit since my one works with two byte characters while this one still does not. I replaced the print_richedit function from the old weblib.php and everything seems to be working fine, despite being very motley now, but still no dynalinks.

I think I will leave well alone for a while. Or try uploading a new moodle soonish. Is there a time of day or the week when the nightly (hourly) is more stable than at others?

I managed to back up all my courses. I deleted and reloaded glossary a few times and despite a couple of "can delete this or that" every thing when smoothly at last instertion. Moodle seems very robust.

The dynalinking will be nice when it happens.

Tim

In reply to Timothy Takemoto

Re: Automatic Linking

by Williams Castillo -

Hi Timothy,

A couple of comments:

1) Why don't you create a second moodle installation in order to test the latest features? A Moodle arena so to speak

All those "revolutionary" changes in Moodle works, in fact, very smoothly as far as your current version is at least 1.0.9.. Thus, you will be enjoying far more cool features than before.

Perhaps it could make yourself more confident in doing an upgrade (because you have already test it and knows its pros/cons or hacks to perform.

2) I have no tested this features with multi-byte languages.. Perhaps that could be a problem... Here the step-to-do list to make autolink happen:

  • Be sure to have a recent version of moodle (there's was an important change in weblib.php yesterday! -no crucial but will could loose the ability to specify that certain words won't be linked in the process).
  • Modify your theme: Styles.php and add a style named autolink
  • Upload all the glossary files to its current directory (don't rename the first one! Move it "out of the reach of Moodle" if you want)
  • Modify /config.php and add the textfilterline somewhere... The standard location is right before the comment of the include of setup.php
  • That's it... Get into your admin area, watch that all upgrades went fine and get back to the course where you have a glossary defined AND that this glossary has the Auolink setting enable AND that some entries has that setting enabled also. There are other switches that you should care about.

I hope it helps,

Will

Average of ratings: Useful (1)
In reply to Williams Castillo

Re: Automatic Linking

by Timothy Takemoto -

Thanks Will

I do have a test arena, and I may update it. It is rather slow these days, so I have not been using it much lately since my production area site is so much easier to use.

Apart from the fear, I guess it is also the time taken to add in config.php, mutilple-moodle config.php, themes, extra icons and new styles.php in the themes, timer,  richtext editor (mine works okay with twobyte characters) and some other things that I may have forgotten. I guess I could use vanilla moodle on my test site.

I have upgraded once, now to 1.0.9 on my test site and 1.2 Development from 18th September on production - but now rather motlely.  I have uploaded before. I tend to find it takes me a while.

Thanks for the suggestion about adding a style for the autolinks. I have done the rest as above but my moodle was too old. And thank you for the wonderful module. I will do a practice and then even try it on production. It is so useful, especially to my English reading class, that I want to use it as soon as possible.

By the way, is there any chance that we are overdoing the autolinks? E.g. "download"?! Perhaps not. They are great either way.

I have seen one site that uses them for advertising. Advertisers are charged for adding a dynalink from forum posts to their site.

Tim

In reply to Timothy Takemoto

Re: Automatic Linking

by Williams Castillo -

By the way, is there any chance that we are overdoing the autolinks? E.g. "download"?! Perhaps not. They are great either way.

Sorry... I don't understand what you mean by "overdoing"... sad

I have seen one site that uses them for advertising. Advertisers are charged for adding a dynalink from forum posts to their site.

Oh Evil minds!! XD *nice* idea... ;)

In reply to Williams Castillo

Re: Automatic Linking

by koen roggemans -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Translators

Hallo Will

Translating the helpfiles I found a file on case sensitve and one on full word matching. Is it already implemented (can't find the button), are you going to or can I just dump those 2 files ?

In reply to koen roggemans

Re: Automatic Linking

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Those features are definitely there, Koen, when editing an individual glossary entry.

Make sure you have the very latest English language files, too, because they were updated last week.