Flagging Forums with Unread Posts?

Flagging Forums with Unread Posts?

by Paul Norrod -
Number of replies: 12
Is there any potential way to have Moodle somehow flag those forums that contain postings that have been unread by that particular user? I know that new items will show up in the Recent Activity and that one can subscribe to a forum and receive new posts by email, but (I know - what more can this guy possibly want surprise) it would be nice to also make the link color of forums that have new unread postings to be different or have some type of icon next to them to indicate that there are unread postings in there. And, of course, it would follow that the unread topics within a forum should be somehow differentiated as well.

Products such as phpBB do this type of thing and I was wondering if the architecture of Moodle precludes it or if it could someday be a possiblilty? Just wondering .....

Average of ratings: -
In reply to Paul Norrod

Re: Flagging Forums with Unread Posts?

by Richard Treves -

>Is there any potential way to have Moodle somehow flag those forums that contain >postings that have been unread by that particular user?

Having used this functionality in firstclass I also miss it in moodle.  Also, am I alone in not liking the email from forum function?  Maybe its working with FC for 3 years but I'd prefer to see unread forums flagged in some way and be able to turn the email function off completely (is this possible and I've missed how to do it?)

If I knew any php I'd offer to get into the code and have a go but I'm afraid I don't...

Richard

In reply to Richard Treves

Re: Flagging Forums with Unread Posts?

by Paul Norrod -
Richard, one possibility is to run a postnuke site with the phpBB for postnuke and embed  Moodle with the pnMoodle mod.  I have thought of this, but don't want to mess around with the added complexity of two products trying to work together, plus I think the Moodle forums are simpler and actually nicer.  But, I do really miss the ability to see which topics I have read and which are unread.

The email function is really nice, but if you have a lot of forums in the course, you just get flooded with email.

I also do not know much about php, but I am trying to learn.  I was a programmer for many years, so I know I can learn it and Moodle, but it is really difficult to teach full-time, run my Moodle site, and try and learn php/Moodle in the 10-15 minutes of "learning time" I get every now and then.  I would really like to do more of my own mods plus be able to give back something to the wonderful community that has grown up around Moodle.

Maybe someday someone will make a "Moodle Architecture" course that we can enroll in to learn about the structure of Moodle wink

As a side note, I find it very interesting that "out of the box" Moodle meets about 95% of my online teaching needs.  I used to use WebCT which met only about 75% of my online teaching needs.  WebCT is certainly not a bad product, but I find it quite ironic that one man (Martin, of course) can better relate to the needs of teachers teaching online than a huge outfit like WebCT  (plus look at the price differential - $0 versus $mega-bucks) big grin
In reply to Paul Norrod

Re: Flagging Forums with Unread Posts?

by Richard Treves -

Richard, one possibility is to run a postnuke site with the phpBB for postnuke and embed  Moodle with the pnMoodle mod.  I have thought of this, but don't want to mess around with the added complexity of two products trying to work together, plus I think the Moodle forums are simpler and actually nicer. 

I guess that would be a solution but, as you say, at what cost in bugs? .

I also do not know much about php, but I am trying to learn.  I was a programmer for many years, so I know I can learn it and Moodle, but it is really difficult to teach full-time, run my Moodle site, and try and learn php/Moodle in the 10-15 minutes of "learning time" I get every now and then.  I would really like to do more of my own mods plus be able to give back something to the wonderful community that has grown up around Moodle.
I know what you mean.  Having seen the mess many people were making with multimedia I taught myself Flash and Actionscript last year, it was fun and I've done some cool stuff but looking back and knowing about various open source projects as well as moodle learning php would have been possibly more useful.

As a side note, I find it very interesting that "out of the box" Moodle meets about 95% of my online teaching needs.  I used to use WebCT which met only about 75% of my online teaching needs.  WebCT is certainly not a bad product, but I find it quite ironic that one man (Martin, of course) can better relate to the needs of teachers teaching online than a huge outfit like WebCT  (plus look at the price differential - $0 versus $mega-bucks) big grin
I'm currently having to work with the UKeU platform, part of a UK government funded project.  They've been at it 5 years and haven't come up with most of the features in moodle (although to be fair to them they've had to invent an online registration system as well). Not sure what slice of funding went to development but they started out with £60 million. 

I came across moodle while researching postNuke, it seemed to me that developments like WebCT, BB, FirstClass were incredibly expensive for what you got and that something like postNuke could be customised to be close to a LMS: I thought I'd have a go at building one.  Of course, I discovered Martin had produced moodle and was 4 years ahead of me with a better training in computer systems and pedagogy!

I have heard the term 'guerrilla course' used to describe a course developed outside the usual rules of an institution - I guess this is what you are doing, good luck with it!

Richard 

In reply to Paul Norrod

Re: Flagging Forums with Unread Posts?

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
This bug is relevant: Bug #141 - Read and unread postings

The trick is doing it a way that's accurate and efficient. Does phpBB actually track the views for each post x each user or just flag things posted after a given date?

Note also, the half-finished, unnurtured and unlinked Recent Activity page  ...
In reply to Martin Dougiamas

Re: Flagging Forums with Unread Posts?

by Paul Norrod -
Martin, thanks for the reply.  I know just about nothing about the inner workings of phpBB, but from using several sites (one of my own included) it seems that it is somehow able to track the posts (topics) read by a given user.  I will have to look at some phpBB code when I get a chance to see exactly what it is doing.

Even without understanding the mechanics of Moodle, I can see the issue in terms of the amount of processing required to keep track of this for any given user.

I will keep the issue in the back of my mind for the time when I learn enough about php/Moodle to examine things with some level of technical understanding.
In reply to Martin Dougiamas

Re: Flagging Forums with Unread Posts?

by Przemyslaw Stencel -
Just an idea that might do the trick without the huge amount of data on who has read what - why not simply flag the messages which appear in the user's Recent Activity?

I have many times been in a situation when, coming to the Using Moodle course, I found a lot of new messages in one or two particular threads. Of course, they belonged to many different branches of the thread, so I kept opening them individually, just to make sure I didn't miss anything. For example, a few days ago there was a discussion about icons from hell. When I entered Using Moodle, there were about 10 messages from this thread in my Recent Activity, many of them in different branches of the discussion. It would've made life much easier if I could simply display the whole thread at once and see immediately, which 10 of the 83 messages are new for me.
In reply to Przemyslaw Stencel

Re: Flagging Forums with Unread Posts?

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
What I normally do when I want to clarify a situation like that is view forums using "Display with oldest first".

It would be quite trivial to simply flag all posts newer than the last login - not sure how useful it would be overall ..
In reply to Paul Norrod

Re: Flagging Forums with Unread Posts?

by Bruno Vernier -
I spent the weekend writing a function for flagging unread, and providing stats on who has read a particular posting and when.

here is the essential code: (not very long) ... it also performs primitive caching using the SESSION variable ... so a caching timeout can be set in CFG->forum_refresh_read

this code is inserted into mod/forum/lib_local.php and works as explained in this posting:
http://moodle.org/mod/forum/discuss.php?d=5020&parent=29428 about the Frugal Forum Format

Anyways, this is very alpha but it seems to work .... it adds "read by x people" to each posting and if you click on those words, a javacript trick causes it to expand to show a table of those who have read the posting and when (and how many times too). Also the words "UNREAD" appear in big red fonts if the reader has not yet read that posting... this is calculated based on the logs (see the SQL) which keep track of who has read which discussions.

function forum_log_read($post) {
global $CFG,$USER,$SESSION;
// show who has read a particular discussion
// REFRESH rate for read/unread discussion statistics
if (!isset($CFG->forum_refresh_read)) {$CFG->forum_refresh_read=10;} //default refresh rate
$discussion=$post->discussion;
if (isset($SESSION->reads[$discussion])) {
$ago = time() - $SESSION->reads[0]; // is it time to update the cache in SESSION?
if ($ago >= $CFG->forum_refresh_read) {unset($SESSION->reads); }
}
if ((!isset($SESSION->reads[$discussion])) or ($SESSION->reads[0]+1>time()) ) {
$query = "select count(time) as counted, max(time)as time, firstname, lastname,userid
from {$CFG->prefix}log l
inner join {$CFG->prefix}user u on (l.userid=u.id)
where module='forum' and info='$discussion'
group by userid order by time desc";
$logs = get_records_sql($query);
$SESSION->reads[0] = time(); // primitive caching mechanism
$unread="<font size=+2 color=red> UNREAD </font>"; //flag for unread posting
$SESSION->reads[$discussion] = count($logs); // how many people have read latest version of this post
$details="<table>";
foreach ($logs as $log) {
if (($USER->id == $log->userid) and ($post->modified<=$log->time)) {$unread='';} // don't flag if read
$ago2 = userdate($log->time);
if ($post->modified>$log->time) {
$u1='<s>';$u2="</s>"; // mark with strike-through if read but before latest modifications
$SESSION->reads[$discussion] = $SESSION->reads[$discussion] - 1; // but don't count as read in stats
}else{
$u1='';$u2='';
$details .= "<tr><td>$u1$log->firstname $log->lastname$u2</td><td>$ago2</td><td>$log->counted times</td> ";
}
}
$SESSION->reads_details[$discussion] = $details . " </table>refreshed every $CFG->forum_refresh_read seconds ";
$output="$unread read by ". $SESSION->reads[$discussion] .' people ';
$stuff = $unread.$SESSION->reads_details[$discussion];
$SESSION->reads_details[$discussion]= "<spanxxx'this.innerHTML=\"$stuff\"' title='click to see details'>$output</span>";
}
return $SESSION->reads_details[$discussion];
}

In reply to Paul Norrod

Re: Flagging Forums with Unread Posts?

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

I've attached a file containing code for the 'forum_count_unread_replies' function that can be included in your 'forum/lib.php' (or local version, if you have one). This returns an array of discussions with counts of 'unread' posts (or replies). The unread count is determined from the last time the user read that discussion as stored in the Moodle log file compared with the last time that discussion was updated.

I use it in conjunction with the existing 'forum_count_discussion_replies' function to show the number of unread replies over the number of total replies on the forum view main screen.

The next post shows how I have used it. What I do is replace the 'Replies' column data with two numbers: unread / total (see next post). So the user can quickly see how many replies in each discussion they have yet to read.

Anyway, here is the code.

mike

In reply to Mike Churchward

Re: Flagging Forums with Unread Posts?

by Mike Churchward -
Picture of Core developers Picture of Plugin developers Picture of Testers

Here is a screen shot of that code in use. I have circled the column in question.

mike

Attachment unreadposts.jpg
In reply to Mike Churchward

Re: Flagging Forums with Unread Posts?

by Peter Sereinigg -

Hi any chance to get this in the "official" version, its very helpfull!

Peter

In reply to Mike Churchward

Re: Flagging Forums with Unread Posts?

by Bruno Vernier -
thanks Mike, I have included your code in my moodle site and have begun testing it ... initial reaction is positive smile

I put your function in lib_local.php or mod/forum and attach it here ...

perhaps Martin can advise us which of the following he would prefer us to upload such development code:

- here as attachments to postings
- in the bug report system as attachments to feedback
- in cvs contrib
- in cvs mod/forum as lib_local.php

warning: this code is very alpha, and is intended for developers only ... instructions for use are too cryptic