Permalink
Browse files

"MDL-20587, chat module, show sessions with just one users, credits t…

…o Daniel Neis"
  • Loading branch information...
1 parent 8aadf87 commit 44d34e89909728913d01e508feb6ddbc79c59bf2 @dcai dcai committed Dec 4, 2009
Showing with 30 additions and 6 deletions.
  1. +4 −0 lang/en_utf8/chat.php
  2. +26 −6 mod/chat/report.php
View
@@ -33,6 +33,9 @@
$string['generalconfig'] = 'General configuration';
$string['helpchatting'] = 'Help with chatting';
$string['idle'] = 'Idle';
+$string['list_complete_sessions'] = 'List just complete sessions.';
+$string['list_all_sessions'] = 'List all sessions.';
+$string['listing_all_sessions'] = 'Listing all sessions.';
$string['messagebeepseveryone'] = '$a beeps everyone!';
$string['messagebeepsyou'] = '$a has just beeped you!';
$string['messageenter'] = '$a has just entered this chat';
@@ -45,6 +48,7 @@
$string['modulenameplural'] = 'Chats';
$string['neverdeletemessages'] = 'Never delete messages';
$string['nextsession'] = 'Next scheduled session';
+$string['no_complete_sessions_found'] = 'No complete sessions found.';
$string['noguests'] = 'The chat is not open to guests';
$string['nomessages'] = 'No messages yet';
$string['normalkeepalive'] = 'KeepAlive';
View
@@ -10,6 +10,7 @@
$end = optional_param('end', 0, PARAM_INT); // End of period
$deletesession = optional_param('deletesession', 0, PARAM_BOOL);
$confirmdelete = optional_param('confirmdelete', 0, PARAM_BOOL);
+ $show_all = optional_param('show_all', 0, PARAM_BOOL);
if (! $cm = get_coursemodule_from_id('chat', $id)) {
error('Course Module ID was incorrect');
@@ -132,13 +133,21 @@
}
}
+ if ($show_all) {
+ print_heading(get_string('listing_all_sessions', 'chat') .
+ '&nbsp;<a href="report.php?id='.$cm->id.'&amp;show_all=0">'.
+ get_string('list_complete_sessions', 'chat').
+ '</a>', '', 3);
+ }
+
/// Show all the sessions
- $sessiongap = 5 * 60; // 5 minutes silence means a new session
- $sessionend = 0;
- $sessionstart = 0;
- $sessionusers = array();
- $lasttime = 0;
+ $sessiongap = 5 * 60; // 5 minutes silence means a new session
+ $sessionend = 0;
+ $sessionstart = 0;
+ $sessionusers = array();
+ $lasttime = 0;
+ $complete_sessions = 0;
$messagesleft = count($messages);
@@ -163,7 +172,8 @@
} else {
$sessionstart = $lasttime;
- if ($sessionend - $sessionstart > 60 and count($sessionusers) > 1) {
+ $is_complete = ($sessionend - $sessionstart > 60 and count($sessionusers) > 1);
+ if ($show_all or $is_complete) {
echo '<p align="center">'.userdate($sessionstart).' --> '. userdate($sessionend).'</p>';
@@ -186,6 +196,9 @@
echo '</p>';
print_simple_box_end();
}
+ if ($is_complete) {
+ $complete_sessions++;
+ }
$sessionend = $message->timestamp;
$sessionusers = array();
@@ -194,6 +207,13 @@
$lasttime = $message->timestamp;
}
+ if (!$show_all and $complete_sessions == 0) {
+ print_heading(get_string('no_complete_sessions_found', 'chat') .
+ '&nbsp;<a href="report.php?id='.$cm->id.'&amp;show_all=1">'.
+ get_string('list_all_sessions', 'chat').
+ '</a>', '', 3);
+ }
+
/// Finish the page
print_footer($course);

0 comments on commit 44d34e8

Please sign in to comment.