patches

Include jquery in ATutor default theme! Getting ready for 1.6.2
December 16, 2008 - 14:54 — Vegard A. JohansenWe're hard at work updating our contributions to work with 1.6.2, and as we have hired a new developer we'll also improve on the patches, to hopefully get them included in the 1.6.3 core!
BTW: We will only maintain patches for whatever is the latest version of ATutor, so if you need any for 1.6.1 you will have to hurry to get them before they are updated to 1.6.2!
We will also soon replace the dated overlib.js that is used for the hover effect on glossary terms.
To make these contributions as good as they can be, I am now introducing a patch that many other patches will be dependent on, which is a patch that includes the jquery library in the default ATutor theme. Jquery is actually bundled with ATutor 1.6.2 allready, but not all themes make use of it.
This patch will simply include jquery in the default theme, and you will have to install it first to make many other patches work. For the Redux theme I will include jquery by default.
Just a small note to announce our contributions list. This is where you will easily find the patches, modules and howtos we produce, and where we will update them if bugs are found. They will also link to any blog posts we might have written about them.
In this way you can follow the blog if you'd like, but also have a way to easy get the goods without following the blog!
We'd be happy to accept contributions here from others, and also to test them out and spotlight them on the demo server!

Add subscription icons to the forum subscribe / unsubscribe link
July 14, 2008 - 12:30 — Vegard A. JohansenSome time ago we added a small modification to the forum listings in ATutor, which adds a small visual cue to whether you are subscribed to a forum or not.
It's best explained by example. This is the way forums look by default:

While you see the "Subscribe" / "Unsubscribe" text, it's not very easy to see which you are subscribed to and which not at a glance.
Our modification changes this listing to:
![]()
..so there's a small envelope showing if you are not subscribed, and a stop sign if you are. It's a detail, but has proved to be quite useful - have a look at our demo server! (note: you have to be registered and enrolled to see it).
Today I made this as a patch so yo can add it yourself. The patch changes the forum/list.php and adds the two small icons to the same folder.
Allthough you can argue that each user should always choose for himself / herself which media player to use to play sound and video files over the web, this has several downsides too.
One downside is that it's hard to include a player you don't know the apperance of in your content design, and another (more important) downside is that many users does not have any media players set up on their computers. So they will be asked to configure iTunes / Windows Media Player / whatever just to listen to one small embedded file.
So, we created a patch that changes the way the media tag in ATutor works. If you add a mp3 file to your content with the media tag, this will open in a nice and small embedded Flash player created by 1 Pixel Out, and available under a generous Creative Commons license.
The patch changes include/lib/output.inc.php and themes/default/include/header.inc.php, adds a javascript file to jscripts and a .swf file to include.
It looks like this:
Thanks to Bob Dylan for letting us use one of his nicest songs to demonstrate this! Ahm.
For those wishing to install this without the patch, say to have the player files located outside the ATutor installation, here's how output.lib.php looks now:
<?php
// .mp3 flash player added by patch
preg_match_all("#\[media[0-9a-z\|]*\](.+[^\s\"]+).mp3\[/media\]#i",$text,$media_matches[7],PREG_SET_ORDER);
$media_replace[7] = "<object type=\"application/x-shockwave-flash\" data=\"".AT_BASE_HREF.AT_INCLUDE_PATH."player.swf\" id=\"audioplayer1\" height=\"24\" width=\"200\"><param name=\"movie\" value=\"".AT_BASE_HREF.AT_INCLUDE_PATH."player.swf\"><param name=\"FlashVars\" value=\"playerID=1&soundFile=##MEDIA1##.mp3\"><param name=\"quality\" value=\"high\"><param name=\"menu\" value=\"false\"><param name=\"wmode\" value=\"transparent\"></object>";
?>Change the data and value references to your liking, manually upload the javascript file and refer to it from your theme.
Or, just run the patch!
Subscribe to announcement newsfeed
I've been chanting about this announcement subscription hack of mine on the official forums for the better part of six months now. Why? Because I never could get this quite simple thing to install as it should on our production server, and when it finally did, it didn't work properly. However, after the introduction of the Patcher (thanks to Cindy) I revisited this once again, and it now seems to both install and function flawlessly. I've made the announcement subscription hack available as a patch which is ready to install on 1.6.1.
What this patch does is give members the option to subscribe to the announcement newsfeed in courses they are enrolled in, and then email them whenever a new announcement is made, much like the very similar functionality in the forums. The mail that is sent out uses the format_content() function in ATutor to parse HTML if the announcement contains any.
The patch automatically fixes the index.tmpl.php file in the default theme, and the newest ATutor-redux theme already has its index.tmpl.php file set up to handle this patch, but if you use a different theme you will need to add a few lines to this file:
<?php
if (file_exists(AT_INCLUDE_PATH."../editor/news_subscribe.php")){
$sql = "SELECT subscribe FROM ".TABLE_PREFIX."courses_members_subscription WHERE member_id=".$_SESSION['member_id']." AND course_id=".$_SESSION['course_id']." LIMIT 1";
$subscribed = mysql_fetch_assoc(mysql_query($sql));
if ($subscribed['subscribe']=="1"){
$sub_href = "../editor/news_subscribe.php?a=unsubscribe";
$sub_button = _AT('announcement_subscription_unsubscribe');
} else {
$sub_href = "../editor/news_subscribe.php?a=subscribe";
$sub_button = _AT('announcement_subscription_subscribe');
}
echo "<a href=$sub_href>$sub_button</a>";
}
?>Just insert this block where you want the button to appear.
New and improved directory
Responding to feedback from both users and superusers here at NST, I've created a new and improved member directory, also available as a patch for 1.6.1. I ended up tossing the old filter functions out the window and replacing them with a search bar which responds to usernames, first-, second,- and last names, phone numbers, group titles, and email adresses if these are set to public. The search bar uses ajax to display the results so everything looks very sleek and sezzy, but there is also a search button should javascript be disabled.
The new directory introduces two new javascripts, two new template files and a completely rewritten directory.php. One of the javascripts (xmlhttp.js) could be of some future interest, as this is where the XMLhttpObject is created and handled, and thus could be used for more ajax functionality should this be desired. Its found in /jscripts/ and is included by the new template files. The template files are only included into the default template, but since they don't already exist they should then be automagically be included in any templates where they aren't present. I encourage theme-makers to have a look-see at the theme files (directory.tmpl.php and directory.search.tmpl.php) because there is no doubt in my mind that they can still be improved upon, and I've left some explainatory comments in there so it shouldn't be very hard to understand. In fact, we're already planning some minor changes to go with the ATutor-redux theme.
Oh, and yes, both of these patches will of course be installed on our demo install of ATutor once we get that up and running :)
