Changing color of unread posts on nested threaded forum in Moodle 3.7

Changing color of unread posts on nested threaded forum in Moodle 3.7

by Eugene Matusov -
Number of replies: 5

Hello--

My students want to see what posts they didn't read yet on a nested threaded forum in a different color from read posts (regardless of a browser they used). In previous versions of Moodle, I edited the forum_print_posts_threaded function in lib.php to do so. But in Moodle 3.7, the technology of forming the list of posts on a nested threaded forum is very different. Can somebody help me address this problem, please? Where (what page) can I add this feature?

I'm actually surprised that this very helpful feature has not been developed in regular Moodle yet.

Thanks,

Eugene

Average of ratings: -
In reply to Eugene Matusov

Re: Changing color of unread posts on nested threaded forum in Moodle 3.7

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hello Eugene,

As you mention, unread post highlighting is a very helpful feature. You should find it in standard Moodle, though users need to select 'Yes: highlight new posts for me' in their forum preferences in order to see the highlighting.

In reply to Helen Foster

Re: Changing color of unread posts on nested threaded forum in Moodle 3.7

by Eugene Matusov -
Dear Helen--

Thanks for your fast reply. The option you are talking about has been selected. Yes, when I OPEN a post it shows whether it is read or not. However, my students need to see on a list of nested threads (on view.php or discuss.php pages). Currently, all links on the list are the same, regardless of posts being read or not. This is rather confusing...

Any idea of how to do that? Again in past I managed to do it by editing the lib.php file. But I think Moodle 3.7 has moved this technology to "mustache template"...

I highly appreciate your help,

Eugene
In reply to Eugene Matusov

Re: Changing color of unread posts on nested threaded forum in Moodle 3.7

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

Hmm, the highlighting should display on discussion thread pages (as you see here on moodle.org). For view pages, I guess you mean the forum page e.g. https://moodle.org/mod/forum/view.php?id=732 which has a column for the number of unread posts in each discussion (assuming read tracking is enabled in the forum settings).

In reply to Helen Foster

Re: Changing color of unread posts on nested threaded forum in Moodle 3.7

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
Is this tracker issue related? MDL-65666 It suggests it will be fixed in the next version in the first week of July.
Average of ratings: Useful (1)
In reply to Mary Cooch

Re: Changing color of unread posts on nested threaded forum in Moodle 3.7

by Eugene Matusov -

Dear Helen and Mary--

Helen, please, see below what I meant by coloring read vs. unread post links on a single nested threaded forum.

Mary, thanks for the good news!!!! Just before reading your post, I successfully solved the problem (as you may see below) in Moodle 3.7. Here is my solution based on editing a mustache template for the forum discussion threaded post. The file forum_discussion_threaded_post.mustache is located in /moodle/mod/forum/class/templates directory (in Windows, it is \moodle\mod\forum\class\templates folder, of course). It is a rather short script there. 

Find and replace:
      <a href="{{{urls.viewisolated}}}">{{subject}}</a>
with:

{{#unread}} 
<img src="emailUnreadIcon.gif" alt="posting unread">
                <a style="color:blue;" href="{{{urls.viewisolated}}}&mark=read">{{subject}}</a> 
{{/unread}} 
{{^unread}} 
                <a style="color:purple;" href="{{{urls.viewisolated}}}">{{subject}}</a> 
{{/unread}}

As you may see on the snapshot below, I added an icon of unopen envelop in front of unread posts. To do so, you need to place the emailUnreadIcon.gif file (see attached) into the /moodle/mod/forum directory. Also, when a forum participant opens an unread post, it will be automatically marked as read by the script above. You can adjust the colors of the links as it fits your aesthetics. The first four lines of my script are about unread post links the the three last ones describe read post links.

Let me know what you think or if you have questions. I'm looking forward for the July update of Moodle.

Eugene

Attachment Colored read links on forum.JPG
Attachment emailUnreadIcon.gif