Pages

Thursday, August 23, 2012

Tweak your forum so that it shows ALL posts of a specific user made in the same forum. For Moodle 1.9

I dare say that the forum activity in Moodle is a hotbed of ideas and student engagement. For students who love to share their ideas, the forum will be a frequently used resource. Today, I came across this interesting and very useful tweak by Tony Hursh that dates back to 2008. Tony's patch will make a teacher's life easier to track who posted what on a specific forum. This is especially useful in popular forums where there is much debate, views and repartee going back and forth among students.



Learning Outcome
At the end of this post you will gain access to the patch code that allows you to click a link and display all forum posts made by a specific student within one specific forum.




What does the patch do?
It allows you to add a direct link to "other user posts in this forum". For example, in a Forum named "Forum: IT and You", there is a  discussion thread entitled "Do you play any computer games?". Let's suppose that it is a pretty popular forum with many threads and active student participation. If I wanted to see ALL of Wahidah's posts in the "Forum: IT and You" forum ONLY, then with the patch installed, I could just click on the link that says "Wahidah's other posts in this forum" like so....



....and wholah! The next screen will show me ALL of Ms. Wahidah's posts in the same forum, and only that forum named "Forum: IT and You"!



This is very useful indeed for the teacher to cut through all the "clutter" and to zero in onto Wahidah's specific posts. You can get the patch (diff) files from this tracker. I've implemented it on my Moodle 1.9.15 production site and immediately I can see the benefit of this for the teacher. I hope that this short post will help you and brings an extra edge to your online classroom's forums!

Regards
Frankie Kam

APPENDIX
Here's the patch data duplicated below for you to check it out first. I looks like a lot, but you can add the + code all within less than 15 minutes if you are careful and meticulous. Additive code portions are shown in red. Deletion code portion is shown in magenta.

Index: lang/en_utf8/forum.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en_utf8/forum.php,v
retrieving revision 1.21.4.10
diff -u -r1.21.4.10 forum.php
--- lang/en_utf8/forum.php    7 Jul 2008 21:51:40 -0000    1.21.4.10
+++ lang/en_utf8/forum.php    28 Jul 2008 12:47:27 -0000
@@ -39,6 +39,7 @@
 $string['configmanydiscussions'] = 'Maximum number of discussions shown in a forum per page';
 $string['configmaxbytes'] = 'Default maximum size for all forum attachments on the site (subject to course limits and other local settings)';
 $string['configoldpostdays'] = 'Number of days old any post is considered read.';
+$string['configotheruserposts'] = 'If yes, a link to show the other posts by the same user in the same forum';
 $string['configreplytouser'] = 'When a forum post is mailed out, should it contain the user\'s email address so that recipients can reply personally rather than via the forum? Even if set to \'Yes\' users can choose in their profile to keep their email address secret.';
 $string['configshortpost'] = 'Any post under this length (in characters not including HTML) is considered short (see below).';
 $string['configtrackreadposts'] = 'Set to \'yes\' if you want to track read/unread for each user.';
@@ -180,6 +181,7 @@
 $string['openmode0'] = 'No discussions, no replies';
 $string['openmode1'] = 'No discussions, but replies are allowed';
 $string['openmode2'] = 'Discussions and replies are allowed';
+$string['otheruserposts'] = '\'s other posts in this forum';
 $string['overviewnumpostssince'] = 'posts since last login';
 $string['overviewnumunread'] = 'total unread';
 $string['parent'] = 'Show parent';
@@ -249,6 +251,7 @@
 $string['seeallposts'] = 'See all posts made by this user';
 $string['sendinratings'] = 'Send in my latest ratings';
 $string['shortpost'] = 'Short post';
+$string['showotheruserposts'] = 'Show other posts in this forum';
 $string['showsubscribers'] = 'Show/edit current subscribers';
 $string['singleforum'] = 'A single simple discussion';
 $string['startedby'] = 'Started by';


Index: mod/forum/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/forum/lib.php,v
retrieving revision 1.609.2.64
diff -u -r1.609.2.64 lib.php
--- mod/forum/lib.php    24 Jul 2008 21:58:07 -0000    1.609.2.64
+++ mod/forum/lib.php    28 Jul 2008 12:47:28 -0000
@@ -2824,7 +2824,9 @@
 // Commands

     $commands = array();
-
+    if (!empty($CFG->forum_showotheruserposts)) {
+        $commands[] ='<a href="'.$CFG->wwwroot.'/mod/forum/search.php?id='.$course->id. "&forumid=".$post->forum."&userid=".$post->userid.'">'.$fullname.get_string('otheruserposts','forum').'</a>';
+    }
     if ($istracked) {
         // SPECIAL CASE: The front page can display a news item post to non-logged in users.
         // Don't display the mark read / unread controls in this case.
Index: mod/forum/settings.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/forum/settings.php,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 settings.php
--- mod/forum/settings.php    13 Feb 2008 17:01:42 -0000    1.1.2.4
+++ mod/forum/settings.php    28 Jul 2008 12:47:28 -0000
@@ -61,4 +61,7 @@
 $settings->add(new admin_setting_configcheckbox('forum_logblocked', get_string('logblocked', 'forum'),
                    get_string('configlogblocked', 'forum'), 1));

+$settings->add(new admin_setting_configcheckbox('forum_showotheruserposts', get_string('showotheruserposts', 'forum'),
+                   get_string('configotheruserposts', 'forum'), 0));
+
 ?>
 

Index: mod/forum/mod_form.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/forum/mod_form.php,v
retrieving revision 1.32
diff -u -r1.32 mod_form.php
--- mod/forum/mod_form.php    28 Jul 2008 15:58:50 -0000    1.32
+++ mod/forum/mod_form.php    28 Jul 2008 21:02:53 -0000
@@ -53,6 +53,14 @@
         $mform->addElement('select', 'maxbytes', get_string('maxattachmentsize', 'forum'), $choices);
         $mform->setHelpButton('maxbytes', array('maxattachmentsize', get_string('maxattachmentsize', 'forum'), 'forum'));
         $mform->setDefault('maxbytes', $CFG->forum_maxbytes);
+       
+        $options = array();
+        $options[0] = get_string('no');
+        $options[1] = get_string('yes');
+        $mform->addElement('select', 'showotheruserposts', get_string('showotheruserposts', 'forum'), $options);
+        $mform->setHelpButton('showotheruserposts', array('showotheruserposts', get_string('showotheruserposts', 'forum'), 'forum'));
+        $mform->setDefault('showotheruserposts', 0);
+   

         if ($CFG->enablerssfeeds && isset($CFG->forum_enablerssfeeds) && $CFG->forum_enablerssfeeds) {
 //-------------------------------------------------------------------------------
Index: mod/forum/lib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/forum/lib.php,v
retrieving revision 1.693
diff -u -r1.693 lib.php
--- mod/forum/lib.php    28 Jul 2008 15:58:50 -0000    1.693
+++ mod/forum/lib.php    28 Jul 2008 21:02:53 -0000
@@ -3018,6 +3018,10 @@

     $commands = array();

+    if (!empty($forum->showotheruserposts)) {
+        $commands[] ='<a href="'.$CFG->wwwroot.'/mod/forum/search.php?id='.$course->id. "&forumid=".$post->forum."&userid=".$post->userid.'">'.$fullname.get_string('otheruserposts','forum').'</a>';
+    }
+
     if ($istracked) {
         // SPECIAL CASE: The front page can display a news item post to non-logged in users.
         // Don't display the mark read / unread controls in this case.
Index: mod/forum/db/upgrade.php
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/forum/db/upgrade.php,v
retrieving revision 1.20
diff -u -r1.20 upgrade.php
--- mod/forum/db/upgrade.php    28 Jul 2008 17:27:33 -0000    1.20
+++ mod/forum/db/upgrade.php    28 Jul 2008 21:02:53 -0000
@@ -114,6 +114,15 @@
         if(!$dbman->field_exists($table,$field)) {
             $dbman->add_field($table, $field);
         }
+    /// Define field showotheruserposts to be added to forum
+           
+        $field = new xmldb_field('showotheruserposts');
+        $field->set_attributes(XMLDB_TYPE_INTEGER, '1', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'completionposts');
+       
+       
+        if(!$dbman->field_exists($table,$field)) {
+            $dbman->add_field($table, $field);
+        }
         upgrade_mod_savepoint($result, 2008072800, 'forum');
     }

Index: mod/forum/db/install.xml
===================================================================
RCS file: /cvsroot/moodle/moodle/mod/forum/db/install.xml,v
retrieving revision 1.7
diff -u -r1.7 install.xml
--- mod/forum/db/install.xml    28 Jul 2008 12:31:33 -0000    1.7
+++ mod/forum/db/install.xml    28 Jul 2008 21:02:53 -0000
@@ -26,7 +26,8 @@
         <FIELD NAME="blockperiod" TYPE="int" LENGTH="10" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="blockafter" NEXT="completiondiscussions"/>
         <FIELD NAME="completiondiscussions" TYPE="int" LENGTH="9" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Nonzero if a certain number of posts are required to mark this forum completed for a user." PREVIOUS="blockperiod" NEXT="completionreplies"/>
         <FIELD NAME="completionreplies" TYPE="int" LENGTH="9" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Nonzero if a certain number of replies are required to mark this forum complete for a user." PREVIOUS="completiondiscussions" NEXT="completionposts"/>
-        <FIELD NAME="completionposts" TYPE="int" LENGTH="9" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Nonzero if a certain number of posts or replies (total) are required to mark this forum complete for a user." PREVIOUS="completionreplies"/>
+        <FIELD NAME="completionposts" TYPE="int" LENGTH="9" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" COMMENT="Nonzero if a certain number of posts or replies (total) are required to mark this forum complete for a user." PREVIOUS="completionreplies" NEXT="showotheruserposts"/>
+        <FIELD NAME="showotheruserposts" TYPE="int" LENGTH="1" NOTNULL="true" UNSIGNED="true" DEFAULT="0" SEQUENCE="false" ENUM="false" PREVIOUS="completionposts"/>
       </FIELDS>
       <KEYS>
         <KEY NAME="primary" TYPE="primary" FIELDS="id"/>
Index: lang/en_utf8/forum.php
 

===================================================================
RCS file: /cvsroot/moodle/moodle/lang/en_utf8/forum.php,v
retrieving revision 1.40
diff -u -r1.40 forum.php
--- lang/en_utf8/forum.php    28 Jul 2008 12:31:34 -0000    1.40
+++ lang/en_utf8/forum.php    28 Jul 2008 21:02:52 -0000
@@ -58,6 +58,7 @@
 $string['configmanydiscussions'] = 'Maximum number of discussions shown in a forum per page';
 $string['configmaxbytes'] = 'Default maximum size for all forum attachments on the site (subject to course limits and other local settings)';
 $string['configoldpostdays'] = 'Number of days old any post is considered read.';
+$string['configotheruserposts'] = 'If yes, a link to show the other posts by the same user in the same forum';
 $string['configreplytouser'] = 'When a forum post is mailed out, should it contain the user\'s email address so that recipients can reply personally rather than via the forum? Even if set to \'Yes\' users can choose in their profile to keep their email address secret.';
 $string['configshortpost'] = 'Any post under this length (in characters not including HTML) is considered short (see below).';
 $string['configtrackreadposts'] = 'Set to \'yes\' if you want to track read/unread for each user.';
@@ -211,6 +212,7 @@
 $string['openmode0'] = 'No discussions, no replies';
 $string['openmode1'] = 'No discussions, but replies are allowed';
 $string['openmode2'] = 'Discussions and replies are allowed';
+$string['otheruserposts'] = '\'s other posts in this forum';
 $string['overviewnumpostssince'] = 'posts since last login';
 $string['overviewnumunread'] = 'total unread';
 $string['parent'] = 'Show parent';
@@ -280,6 +282,7 @@
 $string['seeallposts'] = 'See all posts made by this user';
 $string['sendinratings'] = 'Send in my latest ratings';
 $string['shortpost'] = 'Short post';
+$string['showotheruserposts'] = 'Show other posts in this forum';
 $string['showsubscribers'] = 'Show/edit current subscribers';
 $string['singleforum'] = 'A single simple discussion';
 $string['startedby'] = 'Started by';
Index: lang/en_utf8/help/forum/showotheruserposts.html


===================================================================

(Lastly, create a new HTML file named showotheruserposts.html)

RCS file: lang/en_utf8/help/forum/showotheruserposts.html
diff -N lang/en_utf8/help/forum/showotheruserposts.html
--- /dev/null    1 Jan 1970 00:00:00 -0000
+++ lang/en_utf8/help/forum/showotheruserposts.html    1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,11 @@
+<h1>Forum Show Other User Posts</h1>
+
+<p>Being able to see the other posts by the user in the same forum can be helpful to teachers during grading.
+It can also be useful to easily identify other posts made by the same user.
+</p>
+
+<p>If you choose yes, a link will be provided to show other user posts.
+</p>
+
+<p>If you choose no (the default), the link to show other user posts will not be shown.
+</p>
 

That's all folks!

If you like this post or site
a small donation would be nice but would last only a day,
otherwise leaving a comment (or a compliment) below will last me a month!

No comments:

Post a Comment

Ratings and Recommendations by outbrain