## General help

### Messaging: What facilities are there for seeing users' messages?

Messaging: What facilities are there for seeing users' messages?

I'm just wondering about what facilities there are, if any, for admins or teachers to read the messages being exchanged in Moodle. I'm asking because it seems there needs to be a way to ensure that the system isn't being used for sending insulting or threatening messages. Having the ability to view all messages would be helpful in this regard. Are the messages saved somewhere after they have been sent and read?

Average of ratings: Useful (1)
Re: Messaging: What facilities are there for seeing users' messages?

In the site logs look for message write

You can also log in as if you wish to investigate things further  ...

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

And then this would mean that a teacher could log in and read private messages from throughout the Moodle installation that had been sent to the student, not just the ones sent within that course? Seems to me that is a serious security breech.

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

This would be essential in, say, a criminal investigation. Either way, if you prevent it then database admins would still be able to read it. If you encrypt it and the police need essential information then you're stuffed.

Anyway, since when has communication via the internet / network been private?

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

Agreed.  I think we need to keep in mind that the system is supposed to be used for course activities.  If someone is writing notes irrelevant to the course then she/he should have to take the risk that someone else might read it.  Hey, I recall teachers intercepting my hand written notes when I was in school.  I didn't want them to read the contents (especially not outloud to the rest of the class) but I couldn't stop them from doing so.

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?
Sorry, I've missed something. How would a teacher have access to the messages of a student who is not in her class?

For example, a teacher woudn't be able to see the logs of a different class, nor would she have "loginas" rights for students who are not in her course's "participant list."

If there is a way, I'd love to know how so that I can let teachers know.

Thanks!
Tom

LATER EDIT.... Oh, you mean, if a student wrote an off-course comment, it would still be visible to any of his current teachers? Yeah, that's true. I guess at the k-12 level this kind of potential audit is really necessary and critical...

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

What I would be concerned about is that if a teacher could log in as one of their students, they would be able to read all the messages in his box, including those that were not relevant to that course at all, and perhaps even messages between that student and his other teachers. I don't think a teacher has the right to know what is going on in classes other than their own. I don't think this is at all necessary at the K-12 level. I had a really awful teacher in high school who I happened to have for my last class of the day when report cards were handed out. He became very invasive and insisted on all of the students showing him their grades in all their other classes. One of my friends wanted to keep it private and he was harrassing her mercilessly in front of the whole class. Teachers don't have any right to know what goes on in other classes in my opinion, but there needs to be a mechanism by which admins can monitor what is going on if necessary. If messages were on a course by course basis, then I might say go ahead and give teachers the right to see them, but not if the messaging system is Moodlewide.

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

Darren,

How do I "look" for message write in the log file?

It seems very tedious to manually search the logs for this if only 1 in 30 logged activities is a message write.

Is there a filter available for this?

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?
Admins can read everything - use the Search tab in the main Messages interface.

Teachers have no special powers in this regard (should they?)

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?
I would vote to let teachers see message logs for their students.

-- Art

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

I would leave it at admins, if they have an issue then check with the admins. If you try to restrict to messages in a teachers courses what happens when the messages are to/from a student not in their course?

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

Being the admin of two sites that are for high school students, I believe it would be necessary for the teacher of that course to view these logs.  With 2600 students it is important that teachers know what is going on "in" their classes and it is too much for the site admin to do.

Neil

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

I agree that it is too much to ask the admin to monitor student messages and teachers do need to know what is going on in their classes, but I don't think a teacher can see the content of messages from logs.

I'm the admin for a couple of public schools sites as well and we have decided to just disable the messaging feature...too big a liability to provide an unmonitored messaging system to public school students.

Steve

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

I totally agree - a pity but if teacher cannot see then we have seen real abuse.

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

Martin,

I agree with Hansen and Steve Hyndman had rightly disabled the feature. I do not know how many of you will agree with me on the following points. I'm probably too dumb to understand what additional facility this message service is providing. Everyone here using moodle purely for educational purpose and anything related to a particular course one always has a forum to discuss various points (all teachers of that course can really see) and there is always a site forum to discuss about everything else. I do not think any use of having private messaging service and eat the server resources. Students have various chat programme to do that sort of thing. This will also put less pressure on teacher and admin in monitoring security breaches or similar sort of thing.

I understand that the importance of this message service if moodle itself wants to transform itself into a comprehensive one pot general content management system with educational management as a part of it.

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

We are institution uses Moodle at the graduate level and the messaging feature has been a great asset for us and serves an important purpose within our educational program!  It enables our students and instructors to communicate 1-1 about assignments, their thesis, etc..., and have a history of that communication in one place.  It also serves as a resource for immediate technical assistance for our students and instructors with our Moodle administration and support team - it is incredibly beneficial to our users to know they can get immediate technical support by pinging one of us who is online.  Because our program runs in the DL mode about 80% of the time this feature helps everyone feel "connected" to fellow students and the rest of the program even when they are away - it definitely has become a key component  in the success of Moodle over the proprietary system that had been used previously.

Perhaps the login as student feature could be modified at the instructor level so instructors are prohibited from viewing a students "messages"  - but as an administrator we have had to have a peek into students and instructors messages from time to time to help provide technical assistance.

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

Hello,

I realize that this is 3 years after the initial posts, but feel compelled to reply in case someone else, like myself, is searching for answers to these types of questions, e.g., how do we control the use of the messaging system within Moodle.

I am in charge of an online program that provides supplementary courses for students enrolled in school districts within a rural geographic area in Oregon. One of the issues we face, which is actually faced by EVERY school, is which battles we want to fight. While I am not necessarily in favor of adding to my own workload or that of anyone else's, I believe we need to look at how the world does business before we make decisions regarding blocking communications technologies.

A recent study by the National School Boards Association found that "96 percent of students with online access use social networking technologies."

The new NETS standards for Students, published by ISTE in July, 2007, states that students need to learn to communicate and collaborate (among other things).

How can we prepare our students for THEIR futures if our knee-jerk response is always to block what's difficult or uncomfortable for us? At a workshop this spring, someone compared this practice to working with young students and teaching them to cross the street:  We don't completely prevent them from crossing the street, but we begin by teaching them about the danger, then hold their hand when they cross the street, and after much practice, monitoring, and some maturity (?!), we allow them to cross the street independently. What we are currently doing with much of our educational technology problems, e.g. MySpace, chat, cellphones, etc., is ignoring the fact that students need to learn to cross the street/use technology safely by preventing them from doing so while they are still within the safe confines of school. This point of view is not uniquely mine; it is shared by well-known educational technology gurus as Marc Prensky and David Warlick, among others.

To me the question is: How can we help students learn to communicate effectively and responsibly?

Kudos to all who are helping us to explore ways of preparing our students for their futures.

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?
I decided to turn the messaging feature off for the following reasons:

1) I don't want to have to explain that I (I'm the administrator and teacher) can read anyone's messages.

2) My students can see who is online, and they can email that student, if needed.

3) I do include a "General" comments forum, which is where students can engage in back-and-forth discussions, with EVERYONE seeing what is being discussed.

4) Students can use other social networks for social discussions, not mine (I pay for my own server space).

By the way, I think that the messaging system is really cool, but not in my environment. So I think it is important that administrators be able to turn this switch on and off. Maybe this should be a setting that teachers can enable or disable?

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

If you have access to the database you could try running this query

inner join moodlenew.mdl_message_read b on a.useridto = b.useridfrom
inner join moodlenew.mdl_user c on a.useridfrom=c.id
inner join moodlenew.mdl_user d on a.useridto=d.id

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

I've hacked Ian's database query around a bit, and made the results a bit prettier. The result is a quick 'n' dirty script that you can put in the /message directory, e.g. /message/listall.php

Perhaps the easiest way to get to it is to create a link to it by "adding a resource" to a course of your choice (I have one for admin links) and choosing "link to a file or web site".

By default it displays every message that has ever been sent, showing when it was sent, the sender and recipient, and when/if it was read. If you hover the mouse over a user's name, it will show you when he/she last accessed Moodle, and if you click on the name it will bring up their profile page.

You can also restrict it to the last 'n' days by calling it with the parameter, days=n, e.g. /message/listall.php?days=14 to show the last two weeks' worth.

Finally, it respects the existing permissions, only producing output if the currently logged in user has the "moodle/site:readallmessages" capability. You can also hide your link to it from students by making it a hidden resource (click on the little eye thing when you're editing the page). That way, it will appear grey (but useable) to teachers and admins, but invisible to students.

Edit: You can separate the read/unread messages by reversing the ORDER BY statement so it reads ORDER BY 5 ASC, 1 DESC;

Here's the code. Paste it all into a file using Notepad or TextWranger, or whatever, and upload it to your Moodle. My suggested location is /message but anywhere should work, as long as it can still find config.php.

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

<?PHP

require_once('../config.php');

$context = get_context_instance(CONTEXT_SYSTEM); require_capability('moodle/site:readallmessages',$context);

$PAGE = page_create_object(PAGE_COURSE_VIEW, 1); // Complete hack - no idea how to use this function properly$PAGE->print_header('View all messages'); // Should probably be PAGE_ADMIN but I can't get this to work

if ( isset($_GET['days']) ) {$qualifierr = 'WHERE msgr.timecreated > UNIX_TIMESTAMP(DATE_ADD(CURDATE(),INTERVAL - 10 DAY))';
$qualifieru = 'WHERE msgu.timecreated > UNIX_TIMESTAMP(DATE_ADD(CURDATE(),INTERVAL - 10 DAY))'; } else {$qualifierr = '';
$qualifieru = ''; } // SQL based on a suggestion by Ian Cannonier, in this thread: http://moodle.org/mod/forum/discuss.php?d=27559$query = <<< END_OF_SQL
FROM {$CFG->prefix}message_read msgr INNER JOIN {$CFG->prefix}user senderr ON msgr.useridfrom=senderr.id
INNER JOIN {$CFG->prefix}user recipientr ON msgr.useridto=recipientr.id$qualifierr
UNION ALL
FROM {$CFG->prefix}message msgu INNER JOIN {$CFG->prefix}user senderu ON msgu.useridfrom=senderu.id
INNER JOIN {$CFG->prefix}user recipientu ON msgu.useridto=recipientu.id$qualifieru
ORDER BY 1 DESC, 5 ASC;
END_OF_SQL;

if ( ! $connection = mysql_connect($CFG->dbhost, $CFG->dbuser,$CFG->dbpass) ) {
print_error("Could not connect to MySQL database");
}

if ( ! mysql_select_db($CFG->dbname) ) { print_error("Could not select database"); } // print_header(''); // This seems to be unnecessary / pointless if ( !$result = mysql_query($query) ) { echo "<p>No messages have been sent</p>\n\n"; } else { echo "<table border=\"1\">\n"; echo " <tr><th>Sent</th><th>From</th><th>To</th><th>Read</th><th>Message</th></tr>\n"; while($row = mysql_fetch_array(result) ) { echo " <tr>\n"; echo " <td align=\"center\">". substr(row[0],0,10) .'<br>'. substr(row[0],11,8) ."</td>\n"; echo " <td align=\"center\" nowrap><a href=\"{CFG->wwwroot}/user/view.php?id={$row[5]}\" title=\"last access: {$row[7]}\">{row[1]}</a></td>\n"; echo " <td align=\"center\" nowrap><a href=\"{CFG->wwwroot}/user/view.php?id={$row[6]}\" title=\"last access: {$row[8]}\">{row[3]}</a></td>\n"; echo " <td align=\"center\">". substr(row[4],0,10) .'<br>'. substr($row[4],11,8) ."</td>\n"; echo " <td>". str_replace("\n","<br>\n",$row[2]) ."</td>\n";
echo "  </tr>\n";
}
echo "</table>\n";
}

print_footer();

?>

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

Thanks for this- I've found it really useful. I have however added some extra links which I thought I'd share. Find my version attached

Mike

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

Hi Mike,

I'm glad you found it useful.

Actually, your additions inspired me to give the whole thing a bit of an overhaul. In a nutshell, I've:

* incorporated your filters by sender, recipient, both or either
* fixed a bug to allow proper filtering by message age
* added the ability to sort results in various ways
* tidied the SQL generation code so there isn't so much duplication
* added a front end to the various options

I'm quite pleased with it but I haven't tested it extensively. Let me know what you think.

-Will.

EDIT: Filtering by user is now done by username so, for example, I might filter with 'joebloggs' instead of having to remember that Joe's user ID is 274.

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

A couple of further tweaks:

* I've added a pair of links to each row to quickly allow you to re-filter to see all messages involving sender or recipient
* I've added a link at the top the quickly remove all filters

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

Thanks for that- it looks a lot neater than mine

Mike

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

Very nice work!!! Thanks!!

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

I've had a bit of a fiddle with the code so that it displays actual names rather than usernames. I've also changed the direct mysql access to use moodle's get_records_sql function; as a consiquence it may now work on other databases.

Mike

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?
Mike & Will H,

I've been looking for a good messaging log report and this one does the trick quite well.

What do you think about setting this up as a report to drop into admin/report, and adding an export option of some sort?

It would be nice to see this in contrib.

Thanks,
Matt

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

You make a good point about the tracker- I've added it: CONTRIB-1143

As far as admin reports go, I haven't really played with them- might well be worth looking into at some point

Thanks,
Mike

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?
I've got it working as an admin report, will add it to the tracker.

Thanks,
Matt

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

Hi, I'd just like to say thank you for sorting this script out. Got it implemented and set up in no time.... all working perfectly!

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

I've been using listall.php since a couple of months.
Always worked like a charm.
Since a recent server upgrade (php 5.2.9, MySQL 5.0.67 and apache 2.2.11) I'm getting an internal server error.
Any idea how to solve this?

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

I've been using a very similar query myself (I didn't find this until after I'd done it myself) but it isn't showing all the messages, whereas if I click on the 'message write' link that is in the logs I can see the message history complete with missing messages.

Anyone got any idea what's going on?

Thanks,
Mike

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

Unread messages and read messages are stored in separate tables. That's why mine does the UNION to combine the results from both.

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

Ah- I'd missed that. I'm using your script now and it works grand.

Thanks,
Mike

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?

How can I stop message service using admin ?

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?
Hi Kamal,

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?
Hi,
I tried to install this on a couple of sites, our test site and our main site.
On the test site 1.9.4 it went in fine with no problems. On the main site 1.9.2+ I get an error when I click on 'Message Logs' - which links to http://docs.moodle.org/en/error/admin/sectionerror.

The text of that page reads...

The error means that a new admin page 'foo' (the one you're developing right now) is not registered with the Admin menu. It is triggered with the call:

admin_externalpage_setup('foo');


The solution is to add a reference to the page in the appropriate file in admin/settings/XXX.php. Something like:

$ADMIN->add("parent_section", new admin_externalpage('foo', "Foo Admin Component", "$CFG->wwwroot/$CFG->admin/foo.php"));  What am I missing?? Paul Average of ratings: - Re: Messaging: What facilities are there for seeing users' messages? Same Moodle version, same error over here. Average of ratings: - Re: Messaging: What facilities are there for seeing users' messages? I seem to remember Tim Hunt making some changes a while back on how admin reports are handled - I'm pretty sure it would have changed how admin reports are handled, either for 1.9.3 or 1.9.4, and obviously I wrote this for the the current method. Tim's post about this is at http://moodle.org/mod/forum/discuss.php?d=81452 - basically, you need to add a string for the message log report to /lang/en_utf8/admin.php - something like:$string["messagelog"] = 'Message Log';

This should be all you need to do to correct it - but let me know, and I'll keep digging if it doesn't fix it for you.

Thanks,
Matt

Average of ratings: -
Re: Messaging: What facilities are there for seeing users' messages?
Solving it as stated in CONTRIB-1185 - confirmed that it is not working for Moodle 1.9.1, 1.9.2 or 1.9.3. It DOES work as expected in 1.9.4. I'll update the readme and include the fix on how to make it work on earlier versions.

Thanks,
Matt

Average of ratings: -