Pages

Wednesday, January 18, 2012

Online Users block (Part III) Feeling moody? Show off your mood.

WHAT IF you could display your mood or status on the Online Users block by Andy J. Davis? Imagine with me if you will.

You're on your Moodle coursepage. Just before you go to make phone call, you display a BRB (Be Right Back) status next to your username on the block. Or before you attempt a quiz for the next one hour, you display a Busy status for the world to see.





Well, I've done it on my Moodle site, and so can you.
All thanks to a talented Italian PHP developer named Matteo Scaramuccia.  Thanks for help on the PHP code, mate! Much appreciated and credit to you, Matteo.

A trivial feature? Frivolous? Childish? A complete waste of time? Tell you what, give it a try on your victims, erm...I mean users. Inform them of this feature. Demo it to them. Then sit back and see what happens. If no one in the class sets< a mood for others to see, then yeah, this is a waste of time. But if just one student sets his or her mood, then you might have chanced upon something here. Perhaps you have managed to make Moodle a bit more human-like. A bit more Web 2.0ish. Perhaps this one feature will make the Moodle experience a bit more social for your students.

If you would like to experiment with this feature on your students, read on! Otherwise, well, you can just hit the Back button of your web browser.  Here's how I did it.



Step1: I created a new User profile field named mood (Menu of choices) 


Moodle 1.9.15 version screenshot.


Make sure that the default value is "blank" as shown in the image above.



Moodle 2.2 version screenshot.



The beauty of this that you can add text (feelings and status) at will. Just type them one line at a time inside the text box. Or you could copy and paste a list of feelings into the text box.

I took 127 positive feelings from here. Not the negative feelings like "annoyed, embarrassed, inferior, upset, guilty, ..." etc. Too depressing. Maybe to be realistic, you can add "frustrated", "confused", "need a little help here!?", etc. To save you time, I have compiled my own list of moods and statuses (one phrase or word per line). You can download my list here.



Step2: I modified the same, usual, suspect: block_online_users.php (Moodle 1.9.15):





Yes, I know. I can read your mind! The image above is too difficult to read. So here's the crucial code that does most of the work, especially the bold-faced code (Moodle 1.9.15):


$invisible_status_count = 0;  //Initialise the count of invisible users to zero

if ($users = get_records_sql($SQL, 0, 50)) {
   // We'll just take the most recent 50 maximum
   foreach ($users as $user) {
       require_once("$CFG->dirroot/user/profile/lib.php");
       $user->profile = (array)profile_user_record($user->id);
     
     
       if (isset($user->profile) && !empty($user->profile['stealth']))
       {
          //Invisible user
          unset($users[$user->id]); // i.e., display the avatar data, just loop back up
          $invisible_status_count++; //Increase the count of invisible users.
       }     else {  //Visible user
                         if($user->profile['mood'] == "blank")
                            $users[$user->id]->fullname = fullname($user);
                         else
                            $users[$user->id]->fullname = fullname($user)." (".$user->profile['mood'].")";
                      } 

    } //foreach
} else {
                   $users = array();
           }





"Argh, Frankie!? Yeah that's really helpful. Thanks a lot  (read: sacarsm). So erm, where to place that code huh, Frankie?" Don't worry, I've made available for download the file below.



A WORD OF WARNING BEFORE YOU PROCEED


Note: the block_online_users.php downloads for both Moodle 1.9.15 and Moodle 2.x are found below.
If you intend to use the code below, please be advised of the following:

I.   Make a backup of your original block _online_users.php file!!!
II.  Turn debugging on to "ALL: show all reasonable PHP debug messages" to catch any errors or warning
      messages.
III. Make SURE you create the user profile fields, stealth (checklist) and mood (menu options) first!!



Only after you have done precautionary steps I to III, should you attempt to use the download code on this post.


DOWNLOADS


Moodle 1.9.15 Code Download
Here's the adapted Moodle version 1.9.15 block_online_users.php file.


Moodle 2.x Code Download
Here's the Moodle version 2.2 block_online_users.php file.

The file has been tested on Moodle version 2.2. To show you that the code works, check out the image below. It's my Moodle 2.2 test site running on the excellent Facebooky theme by Julian Ridden. The image shows the Online Users block working as expected with the new behaviour incorporated.


Yup it seems to work fine on my Moodle 2.2 system...

Again, I remind: before using any of the code on my download links, please, please, PLEASE, remember to BACKUP your original block_online_users.php file!! So use the code at your own risk. You have been warned.  ;-)

In conclusion, I feel that this "innovation" is worth trying. If for no particular value, then just for the fun of it. I would like to think that it makes my Moodle 1.9.15 and 2.2 coursepages more human. More sociable. More ... friendly! I'll let you know what my students think of it in a few weeks time.

SUMMARY

Pros:
  • you can easily add and customise the status and feelings text. Just type text inside the mood user profile field's menu options text box.
  • Users can choose from many status/feelings by scrolling through the dropdown box.
  • In my humble opinion, this makes the Online User block, and indirectly, your Moodle course page, more "sociable". Will you users use it often, sparingly, or never? Will it just be a 'fad', igniting some students, only to fizzle out after a week or two? Perhaps you can share with me your experience.
  • students might actually improve their English vocabulary by examining the word feeling list against their English dictionary.
Cons:
  • User can only change his or her mood by editing the user profile. Usually the user does this by clicking on his or her username and then selecting the "Edit Profile" tab. Too many steps and clicks involved.
  • There is no way, a this point of time, to directly change the status/feelings directly from the Online Users block.

So there you have it. The next best thing since sliced white bread. Give it a try?

If you want to help develop the Online Users block, why not post a query on this Moodle forum for help? Or, you could comment (below) on this post and I'll try to respond to you.

Cheers,
Frankie Kam.
Melaka, Malaysia
;-)


APPENDIX

Related posts:
http://moodurian.blogspot.com/2012/01/how-to-be-invisible-on-online-users.html
and
http://moodurian.blogspot.com/2012/01/how-your-moodle-users-can-hide.html

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