A forum version that allows subscription by discussion thread

A forum version that allows subscription by discussion thread

by John White -
Number of replies: 18
Hi all,

I have been doing a bit of beavering on the issue of making a forum that allows the user (with teacher or administrator control) to subscribe to a discussion, and receive emails of all posts to that discussion, rather than necessarily having to receive emails of every posting in that forum.

I have based these changes on version 1.9.3, but annotated all of them so that they could be incorporated in later versions (that is, without overwriting other version changes). The result of these changes may mean fewer emails hitting the user, or more pertinent ones at least, and more willingness on the part of some users to be subscribed to a forum at all!
In the forum settings you will get 3 new options to add to the 4 you have...

4. Allow thread or forum subscriptions
5. Automatic thread-based subscriptions
6. Force thread-based subscriptions

Depending on what you choose some more options are made available to the user...

3. Receive emails from discussions
4. Don't receive emails from discussions

But better still, when such subscriptions are forced you get a 'Thread Subscribed?' column in the forum view with a yes/no for every discussion, and when they are allowed but not forced, the yes/no become buttons for the user to use to switch on and off subscriptions - as they can with the forum as a whole currently. The current options have effectively been left intact!

At this stage I have tested the changes as thoroughly as I possibly can, but I would like to ask some experienced administrators to give this a go (especially if they are running 1.9.3). As Martin D and the team have just announced a security update in 1.9.4, I shall put these changes into 1.9.4 and post that copy up as soon as possible! Also I have not created a full-blown package as I would like to get some feedback first, so there are a number of steps to take to update your 1.9.3, all of which you can reverse if you wish to.

EDIT: See instructions and attachment in later post - Helen Foster

When you create or update a forum you should find more options and be able to experiment with their effects. Broadly, Option 4 lets the user choose which if any kind of subscription they will enjoy, Option 5 is much the same, but the default value is always to subscribe to a discussion thread that you begin or post in. Option 6 is analogous to the Option 1 'Yes, forever', except that if you start off with users subscribed to the forum (so the teacher can offer encouragement), then their first post gets them subscription by thread only from then on.

Finally, if you want to find all the changes made, search for JWC in all of those files.

Please let me know how you got on.

Regards,

John


(Edited by Helen Foster to remove text and attachment by request of author - original submission Friday, 30 January 2009, 01:41 AM)

Average of ratings: -
In reply to John White

Re: A forum version that allows subscription by discussion thread

by John White -
...and here is a handy picture of what you might see if you chose Automatic thread-based subscriptions as your forum setting...

...and to illustrate (for those really techie) how it works in the cron we have...

Processing module function forum_cron ...
user: 15, forum: 62, discussions: all
user: 2, forum: 62, discussion: 154, post: 250
user: 17, forum: 62, discussion: 153, post: 251
user: 2, forum: 62, discussion: 153, post: 251
Processing user 2
Sending post 250: Re: My new discussion
Sending post 251: Re: A test discussion
Processing user 15
Sending post 250: Re: My new discussion
Sending post 251: Re: A test discussion
Processing user 17
Sending post 251: Re: A test discussion
2 users were sent post 250, 'Re: My new discussion'
3 users were sent post 251, 'Re: A test discussion'
Regards,

John
In reply to John White

Re: A forum version that allows subscription by discussion thread

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It will be easier for developers to review your changes if you can make a patch containing just your changes.

The same patch would probably work with either Moodle 1.9.3 or 1.9.4.


In reply to Tim Hunt

Re: A forum version that allows subscription by discussion thread

by John White -
Thanks Tim.

I was pretty certain that changes in forums from 1.9.3 to 1.9.4 would be limited, but I had not yet had opportunity to look into it.

Thanks for the link, I will create a patch next although I will either need to use diff in the command-line or move to a pc for Tortoise as I mainly work on a Mac.

I appreciate the need to use XMLDB too. But in that area I admit to being a bit green!

I have also spotted 2 small omissions overnight, neither of which is serious, and the first of which (at least) I will fix for the patch.
I'll mention these in case anyone keen as mustard uses the zip attachment, and comes back to me with an 'Ah, but it doesn't do...'

1. If you have forum administrative rights the 'Move this discussion to...' box appears over the top of a new link 'Subscribe to this discussion thread' (or its converse). NOT very convenient!

2. If you split a discussion, the subscriptions to the new discussion are copied from the parent one (so that subscribers automatically stay informed), but if you move a discussion to another forum they do not. This may require a bit more work, but it is less than a tragedy.

Regards,

John
In reply to John White

Re: A forum version that allows subscription by discussion thread

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It should be quite easy to install either diff or cvs on a Mac computer. I guess either the Apple developer tools or Darwin ports would do it, but I am not entirely sure.

The other alternative would be to start using an IDE like Eclipse with this built in.


One way to transfer your changes to 1.9.4 would be to create a patch between 1.9.3 and your version, and then apply that patch to a new 1.9.4 install.


Development:Installing_and_upgrading_plugin_database_tables tries to explain how to use XMLDB.
In reply to Tim Hunt

Re: A forum version that allows subscription by discussion thread

by John White -
Tim,

This is much, much harder than writing the code in the first place!
Its true I've spent a bit of time fixing the two issues I mentioned above, both done and dusted, and en route I found a third and fixed that too,
but the rest of the day I have been banging my head against a variety of CVS software clients!

svnX seems to me to be completely unintuitive rubbish!

smartCVS won't produce a 'patch' from the downloadable version,

And now I'm on CrossVC-XXL which is a pretty program with pretty terrible help!

I did have XCode installed previously, but I still had to run Subversion 1.5.5 to install CVS

So I am a little way from producing a Patch - unless its a Nicotine one - and I don't even smoke!

I can write code in 8 or 10 languages, but can I understand the jargonese these CVS people speak??? This is going to take me a while... angry

Yours (frustratedly),

John
In reply to John White

Re: A forum version that allows subscription by discussion thread

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm sorry. It should not be that hard, but I know how it can be when the computer decides not to co-operate.

Going the 'sledgehammer to crack a nut' route and installing Eclipse by following the instructions on Development:Setting_up_Eclipse is the easiest thing I can think of to suggest now. That page walks you through various operations in Eclipse, including making a patch.
In reply to Tim Hunt

Re: A forum version that allows subscription by discussion thread

by John White -
Okay Tim, I've managed to crack that, I do believe!
Jargon-busting my way through CVS and CrossVC-XXL (with its somewhat flowery translation from German - but it is actually a very neat program), I have created a patch file - attached. smile

Could you please check it over, as I have done already, but your eagle-eye would be appreciated. Structurally it looks fine to me, and has the edits from all the right files (bar styles_layout.css)

If you are happy that it looks right, then the steps are reduced to...

1. Add the following to theme/standard/styles_layout.css:

#mod-forum-discuss .subscription {
float: right;
text-align:right;
white-space: nowrap;
}

(Later I could try getting that into the patch, but it isn't at all critical)


2. Run this sql statement in phpMyAdmin (backup first for absolute safety):

ALTER TABLE `mdl_forum_subscriptions` ADD COLUMN `thread` BIGINT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `forum`, ADD INDEX `mdl_forusubs_thr_ix` (`thread`);


3. And apply the patch.

Regards, and thanks for the suggestions on the way up the learning curve,

John
In reply to John White

Re: A forum version that allows subscription by discussion thread

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
That certainly looks like a patch in the right format to me. I think the next step is to attach it to MDL-1626.

The last time I tried to change something relating to forum subscriptions, I broke it, so I am hoping that someone who knows more about this area of code will be able to review it.
In reply to Tim Hunt

Re: A forum version that allows subscription by discussion thread

by John White -
Tim,

Thanks again. I have posted some similar information and the attachment into that tracker issue.

Cheers,

John
In reply to John White

Re: A forum version that allows subscription by discussion thread

by John White -
... a further screen clip: the drop-down from the forum settings page:


Attachment forum_subs.jpg
In reply to John White

Re: A forum version that allows subscription by discussion thread

by John White -
...and the extra 2 items in the user's drop-down when posting, though of course it would be more common to use the fast buttons shown earlier.
In reply to John White

Re: A forum version that allows subscription by discussion thread

by Hellmuth Sole -
Hi John, I see that the link to the plugin has been removed.  Can you inform where I can find it?
Thank you!
In reply to Hellmuth Sole

Re: A forum version that allows subscription by discussion thread

by John White -
Hellmuth,

Its now a patch that is attached to a post further up. And in the tacker issue (several links to that above).

Do you want it back in zip form?

Tim's point is that the zip form makes it much more dependent on which version you are writing it onto!
I created it in (1.9.3 Build 20081015), overwriting other versions could have unwanted results.

Regards,

John


In reply to John White

Re: A forum version that allows subscription by discussion thread

by Hellmuth Sole -
Thanks John for the quick reply.  Just to confirm, if it's a patch then you just install it the same way as a normal plugin is installed into moodle?  If so then the zip file isn't needed, just wanted to confirm this wasn't a patch to your plugin!!
I have 2 sites, one which is 1.9.2 and the other which is 1.9.4.  I'll try it on the latter first and give you my impressions, but I'd expect that it should work on both since the updates have basically been security related.
Regards,
Hellmuth.
In reply to Hellmuth Sole

Re: A forum version that allows subscription by discussion thread

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
To apply a patch, see the instructions on How to apply a patch. You will also need to follow John's instructions about changing the database.
In reply to Tim Hunt

Re: A forum version that allows subscription by discussion thread

by John White -
Tim, Hellmuth, and all,

I have now provided a patch for version 1.9.4 which also addresses a good number of issues from the previous patch (do I mean bugs? surely not!). The original one was not so much buggy as less comprehensive!

This one has 'bells and whistles' I think.

The patch is in the tracker at MDL-1626.

Regards,

John
In reply to John White

Re: A forum version that allows subscription by discussion thread

by ben reynolds -
This is just a "me too" of excitement.

The biggest problem we've had with forums is parents using their email address to enroll kids online, then having the forum email flood aimed at them instead of their child.

Plus, this: "(9) and, in a similar vein, if $CFG->forum_countposts==1 then the count of the number of forum posts a user has contributed in that course appears in parenthesis after the user's name. This latter one was in response to http://moodle.org/mod/forum/discuss.php?d=116200#p513188."

WOW! <-- my students would want this to be a blinking marquee in 3 colors, mammoth font, and bold.

Thanks <-- the more modest adult accolade.
In reply to ben reynolds

Re: A forum version that allows subscription by discussion thread

by John White -
Thanks for your enthusiasm Ben!

I hope that some administrators/developers will be willing to apply the patch in a 1.9.4 environment and give feedback on its performance. Putting any bug reports in the tracker link.

So far I am very pleased with the results, but it can take you back how a peculiar set of circumstances can reveal a flaw. I've repeatedly tested the patch and its new features - even so I have found one minor bug tonight, which I will report on, and fix. But if you have AJAX enabled (in forum admin settings) as well as thread-based subscriptions enabled, you will never see this bug!

Regards,

John