gorzan's blog
When managing tests, the instructor can click on the "statistics" button to view statistics for each question of the test. Last year we added (on request from some of our users) a small bar chart to more easily visualize these statistics. However, because we used a css trick to create this bar that utilized the property "background", these bars didn't appear on printouts. This little patch fixes the printout problem and enables these bars for the default theme. (I thought they already were enabled for default theme but it seems they were not..)
One feature of ATutor that many of our users at helsekompetanse.no appreciates is the email subscription to forum threads. Last year we also subscription to the announcement feed that is on the front page of each course, and the newest addition to the feed subscription family is the blog subscription that I posted under contributions just a few minutes ago.
The announcement feed subscription posted last year was a bit of a quick hack. It works, but on the code side it isn't particularly pretty. This time around, I wrote a class called subscription that can easily be used to add email subscription to other feeds (should this become an issue in the future), and which also can easily be used to handle subscription for the already implemented forum and announcement subscription. The latter wouldn't in any way add to today's functionality, but it would serve to 'clean up' the codebase somewhat, as we now actually have four different methods of subscribing and sending out emails for four different feeds. (Forums, forum threads, announcements and blogs.)
As I mentioned earlier, I've been working on an implementation of the Akismet spam filter for ATutor. This is now ready for download. The spam filter utilises Wordpress' Akismet spam prevention, and as such requires an Akismet API key to work properly. (My original post has some discussion on how to aquire this, including some correspondence with Akismet regarding pricing.) This means that ATutor will need to check with the Akismet servers whenever a new post is made to ensure it is legit. Should the Akismet servers be down, or the API key be invalid, or the Akismet servers return any other error, the post will be marked as not spam and allowed through the filter.
To install the spam filter, both the module and the patch needs to be installed. The patch will make some alterations to the following files:
- /include/vitals.inc.php
- /forum/new_thread.php
- /forum/delete_thread.php
- /forum/move_thread.php
The spam filter is only implemented for the forum as of yet. However, implementing it for other input forms is a rather small job and patches for this could easily be assembled following the example in forum/new_thread.php.
All new forum posts are now stored in a log that can be accessed from the administrator panel. Spam posts will be marked as such, and the administrator will have the option to clear these posts, inserting them into the forum and telling Akismet that these posts are legit (ham). The administrator also has the option to mark clean posts as spam, should which will remove them from the forum and tell Akismet that these posts are spam.
Developers, please note that the code that handles insertions of posts that are caught in the filter and are later cleared of their spam status is somewhat tangled. This is due to the way the forums handle insertions (and updates), especially with respect to post counts. If the forums in the future are rewritten/improved this code will need to be revisited.
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 :)

ATutor and canned meat products sold by the Hormel Foods Corporation since 1937
July 2, 2008 - 10:15 — gorzanSo, we've been worried about spam for a while now. Admittedly, ATutor is no phpBB, but it does have forum functionality as well as other user input areas. ATutor user account registration has no Captcha and no email confirmation, so when the spammers do decide to hit, they won't have to work very hard to ruin the system. Making restrictions on the registration process isn't really compatible with the way we wish to use ATutor either, so we figured the best thing to do is install a proper spam filter. Which is what I'm working on this week.
Having checked around a bit, we decided to use Akismet, which is the spam filter developed for WordPress. Vegard has been using it on his wordpress account for a while and says it seems to work very well, and having checked the stats and read the reviews I'm inclined to believe him. There are already Akismet implementations for a number of systems, so what I'm doing is just adapting the PHP 4 Akismet class for ATutor.
What the Akismet plugin does, really, is just provide a function which checks your comment against the Akismet servers and returns true or false (spam or not spam). Since all spam filters inevitably are wrong every now and then, however, I also have to store all comments in a backlog so that the administrator can override Akismet's decision and allow a comment that has been marked as spam (while also letting the Akismet servers know that this isn't spam, and by doing so improving the filter) or marking a spam comment that found its way through the filter as spam (again letting the Akismet servers know).
I'm implementing this as a ATutor Module, (although it'll also require a patch to be run, I'll post the installation instructions when I'm done) and using it will require an Akismet API Key, which is free if you use Akismet for your personal blog, but not for commercial use. The Akismet payment plan is based on Akismet being used as a spam filter in a blog and as such doesn't really apply very well to ATutor, so we're currently trying to work out a good solution with the Akismet people. As most ATutor users will most likely find themselves in a similar situation, I'll make sure to post the results of this dialogue here as well as the module.
I'll post everything here when it's done.