New block idea: external links summary (help please)

New block idea: external links summary (help please)

by Paul Vaughan -
Number of replies: 13
Hi all. I've been putting together some teaching materials and realised I would like to be able to do something which I don't seem to be able to do.

I would like a block which lists (summarises) all of the external links within my course. Scattered throughout my 12 topics are a number of external links, and the icon is not so different that the unaware could tell it apart from a normal resource (web page in my case). So what I would like is the ability to summarise all of the course's external web links in a block. At least then I and my students can see the external resources at a glance.

I can't find a block like this so have set myself the challenge of making one if it doesn't exist. I've not got too far with my other block(s) but they were an exercise for me to get used to Moodle's coding structure, and classes, and the community too.

I guess I will need a bit more help this time, as my other blocks didn't go near the database, so pointers in the right direction would be **most** welcome. smile
Average of ratings: -
In reply to Paul Vaughan

Re: New block idea: external links summary (help please)

by Janet DiVincenzo -

Great minds think alike!  I was just remarking last week that a feature such as this was needed! 

I'm brand new to Moodle and not a programmer, so I can't help. But chalk up another fan for this feature!

In reply to Paul Vaughan

Re: New block idea: external links summary (help please)

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Paul - It is an interesting idea. As I read it, I thought you might be interested or find it helpful to look at the code that creates the autolinking for a URL as having the regular expression syntax may be of help for you. Take a look at the convert_urls_into_links function in /lib/weblib.php. Also, could you specify exactly what all you would like to search for. Obviously resources but where else would you like to look for external links. I like the idea of being able to get a listing of the links as that would then allow for some checking to ensure they are still valid links. You may want to ask around in the Developers forum and see if others have been working along similar lines and point to discussion here in the blocks forum. Let me know what questions arise and I'll do my best to help you along in developing this. Peace - Anthony
In reply to Anthony Borrow

Re: New block idea: external links summary (help please)

by Paul Vaughan -
Hi Anthony.

Your idea actually goes a little further than I wanted to: I basically wanted to pick up all instances within a course of the visible "link to a file or website" resources and summarise them. I didn't want to scan through the content of the whole site and pick up links that the course creator embedded... BUT I will certainly consider it for the future.

I did look at a few regex websites but quite frankly they scared me! I could copy-and-paste some appropriate code to pattern-match URL's but if it didn't work properly I wouldn't know where to start.

Thanks for your feedback both.

Paul. smile
In reply to Paul Vaughan

Re: New block idea: external links summary (help please)

by Michael Goncharenko -
Hi Paul,

Why use regexps? As far as I understand, if the URL does not contain the $config->wwwroot, but contains "http://" at the beginning of it, then it is external URL. A simple strstr(...) PHP function will be enough. I hope you use PHP smile
In reply to Michael Goncharenko

Re: New block idea: external links summary (help please)

by Paul Vaughan -
Thanks Michael, that's useful. Yes, I do use PHP ;)

Paul.
In reply to Paul Vaughan

Re: New block idea: external links summary (help please)

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Paul - RegEx expressions intimidate me too. One question, how is what you describe different than what you see on the /mod/resource/index.php page? Peace - Anthony
In reply to Anthony Borrow

Re: New block idea: external links summary (help please)

by Paul Vaughan -
@Anthony - good point...

If I take that resource page, strip out anything which isn't an external link, summarise it into a block, then I'm done!! Easy peasy! :o

I suppose my idea won't set the world alight, but for me and my students it would be useful to summarise the links which go outside of the site into one place (especially as it's not obvious from the icon next to the text) and a course-side block is ideal. At the very least it is a personal project which will get me further involved in Moodle development, which I am keen for.

P.
In reply to Paul Vaughan

Re: New block idea: external links summary (help please)

by Itamar Tzadok -
This is indeed a course specific project because in my courses for instance there are internal links which your block would pick up too. Out of curiosity, If you have this summary block why do you need the links also scattered all over the course? Doesn't the block make those redundant? And if they are redundant why do you need a new block type when you can use a simple HTML block to which you can simply add new links? smile
In reply to Itamar Tzadok

Re: New block idea: external links summary (help please)

by Paul Vaughan -
I'm pretty sure I could differentiate between an internal link and an external link, it's just a matter of collecting all the links which do not point in part to the same base location of the moodle site. I'm not sure exactly what the $config->wwwroot variable contains, but if it is http://www.mysite.org, then I can just exclude all links which start with that. If I am missing something, please let me know!

If I have my external links scattered all over the place then why NOT have them all collected (and, yes, duplicated, but at what cost?) in one nice neat place? I simply want to differentiate between the 'safety/security' of links which stay within the Moodle system, and the 'potential risk' of the links which go outside. I suppose the page may take a little time to load due to the extra processing the PHP engine has to do and the database queries, but it is minimal for something I believe people may find useful.

I would have the links scattered all over the shop due to context. If an external link points to a website with such-and-such an example of e.g. my topic/week 2, then it makes sense to have it up in topic/week 2. I wouldn't have a link to a totally different resource there, I'd have it in the relevant topic/week.

I can actually justify the 'why' behind this idea with one word: Because. smile

Regards,

P.
In reply to Paul Vaughan

Re: New block idea: external links summary (help please)

by Itamar Tzadok -
Fair enough. I'm just wondering how my courses could benefit from your contribution. So I'm thinking that instead of this external/internal distinction perhaps you could make a sort of favorites list. When I open the 'Adding a new resource' form I have the option to choose or upload a file or search the web. Suppose I had also the option to choose or upload a favorite link. This option would open a page where I could specify or look up a url and that page would record the url in a favorites list which would be displayed in the new block. So you could use this list for distinguishing external and internal links and I could use it differently. What do you think? smile
In reply to Paul Vaughan

Re: New block idea: external links summary (help please)

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Paul - Actually that is what gave birth to the Birthday block - wanting to take something already in existence and modify it a bit. Sounds like fun but be careful because that is the same kind of attitude that pulled me into the wonderful world of Moodle code and development wink Peace - Anthony
In reply to Anthony Borrow

Re: New block idea: external links summary (help please)

by Paul Vaughan -
Well I was *hoping* to have fun here!! As I said earlier I wouldn't care if nobody else on Earth finds it useful, it will fill a perceived need and get me involved in the code, which is something I want to do.

Regards,

P.
In reply to Paul Vaughan

Re: New block idea: external links summary (help please)

by Robert Brenstein -
There is an old tracker entry MDL-3562 asking to split this resource into two separate ones, one being a link to a local file and the other a link to remote web address. One of the benefits is that they could have better differentiating icons.

I have actually hacked our Moodle into using different icons for the two types. It is really an ugly low-level hack. Local files have an icon depending on their type, whereas remote links all have the same "world-doc" icon.