[svn r17551] Logic Changes - Implemented tracking for activity in forum and chat into learners tracking and course tracking see FS#1099

skala
Cristian Fasanando 17 years ago
parent 15ef79fbb7
commit 63b652f80a
  1. 133
      main/inc/lib/tracking.lib.php
  2. 17
      main/mySpace/myStudents.php
  3. 45
      main/tracking/courseLog.php

@ -788,7 +788,116 @@ class Tracking {
}
}
function last_three_connection_chat($student_id,$course_code) {
/**
* This function counts the number of post by course
* @param string $course_code - Course ID
* @return int the number of post by course
* @author Christian Fasanando <christian.fasanando@dokeos.com>,
* @version enero 2009, dokeos 1.8.6
*/
function count_number_of_posts_by_course($course_code) {
//protect data
$course_code = addslashes($course_code);
// get the informations of the course
$a_course = CourseManager :: get_course_information($course_code);
$count = 0;
if (!empty($a_course['db_name'])) {
$tbl_posts = Database :: get_course_table(TABLE_FORUM_POST, $a_course['db_name']);
$sql = "SELECT * FROM $tbl_posts";
$result = api_sql_query($sql, __FILE__, __LINE__);
$count = Database::num_rows($result);
return $count;
} else {
return null;
}
}
/**
* This function counts the number of threads by course
* @param string $course_code - Course ID
* @return int the number of threads by course
* @author Christian Fasanando <christian.fasanando@dokeos.com>,
* @version enero 2009, dokeos 1.8.6
*/
function count_number_of_threads_by_course($course_code) {
//protect data
$course_code = addslashes($course_code);
// get the informations of the course
$a_course = CourseManager :: get_course_information($course_code);
$count = 0;
if (!empty($a_course['db_name'])) {
$tbl_threads = Database :: get_course_table(TABLE_FORUM_THREAD, $a_course['db_name']);
$sql = "SELECT * FROM $tbl_threads";
$result = api_sql_query($sql, __FILE__, __LINE__);
$count = Database::num_rows($result);
return $count;
} else {
return null;
}
}
/**
* This function counts the number of forums by course
* @param string $course_code - Course ID
* @return int the number of forums by course
* @author Christian Fasanando <christian.fasanando@dokeos.com>,
* @version enero 2009, dokeos 1.8.6
*/
function count_number_of_forums_by_course($course_code) {
//protect data
$course_code = addslashes($course_code);
// get the informations of the course
$a_course = CourseManager :: get_course_information($course_code);
$count = 0;
if (!empty($a_course['db_name'])) {
$tbl_forums = Database :: get_course_table(TABLE_FORUM, $a_course['db_name']);
$sql = "SELECT * FROM $tbl_forums";
$result = api_sql_query($sql, __FILE__, __LINE__);
$count = Database::num_rows($result);
return $count;
} else {
return null;
}
}
/**
* This function counts the chat last connections by course in x days
* @param string $course_code - Course ID
* @param int $last_days - last x days
* @return int the chat last connections by course in x days
* @author Christian Fasanando <christian.fasanando@dokeos.com>,
* @version enero 2009, dokeos 1.8.6
*/
function chat_connections_during_last_x_days_by_course($course_code,$last_days) {
//protect data
$last_days = intval($last_days);
$course_code = addslashes($course_code);
// get the informations of the course
$a_course = CourseManager :: get_course_information($course_code);
$count = 0;
if (!empty($a_course['db_name'])) {
$tbl_stats_access = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS, $a_course['db_name']);
$sql = "SELECT * FROM $tbl_stats_access WHERE DATE_SUB(NOW(),INTERVAL $last_days DAY) <= access_date
AND access_cours_code = '$course_code' AND access_tool='".TOOL_CHAT."'";
$result = api_sql_query($sql, __FILE__, __LINE__);
$count = Database::num_rows($result);
return $count;
} else {
return null;
}
}
/**
* This function gets the last student's connection in chat
* @param int $student_id - Student ID
* @param string $course_code - Course ID
* @return string the last connection
* @author Christian Fasanando <christian.fasanando@dokeos.com>,
* @version enero 2009, dokeos 1.8.6
*/
function chat_last_connection($student_id,$course_code) {
require_once (api_get_path(LIBRARY_PATH) . 'course.lib.php');
//protect datas
@ -797,25 +906,23 @@ class Tracking {
// get the informations of the course
$a_course = CourseManager :: get_course_information($course_code);
$date_time = '';
if (!empty($a_course['db_name'])) {
// table definition
$tbl_stats_access = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS, $a_course['db_name']);
$sql = "SELECT access_date FROM $tbl_stats_access
WHERE access_tool='".TOOL_CHAT."' AND access_user_id='$student_id' AND access_cours_code = '$course_code' ORDER BY access_date DESC limit 3";
WHERE access_tool='".TOOL_CHAT."' AND access_user_id='$student_id' AND access_cours_code = '$course_code' ORDER BY access_date DESC limit 1";
$rs = api_sql_query($sql, __LINE__, __FILE__);
$last_connnections = array();
while ($row = Database::fetch_array($rs)) {
$last_connection = $row['access_date'];
if (isset($last_connection)) {
$date_format_long = format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($last_connection));
$time = explode(' ',$last_connection);
$date_time = $date_format_long.' '.$time[1];
$last_connnections[] = $date_time;
}
$row = Database::fetch_array($rs);
$last_connection = $row['access_date'];
if (!empty($last_connection)) {
$date_format_long = format_locale_date(get_lang('DateFormatLongWithoutDay'), strtotime($last_connection));
$time = explode(' ',$last_connection);
$date_time = $date_format_long.' '.$time[1];
}
return $last_connnections;
return $date_time;
} else {
return null;
}

@ -1,4 +1,4 @@
<?php //$Id: myStudents.php 17486 2008-12-31 00:46:42Z yannoo $
<?php //$Id: myStudents.php 17551 2009-01-06 19:31:15Z cfasanando $
/* For licensing terms, see /dokeos_license.txt */
/**
* Implements the tracking of students in the Reporting pages
@ -868,12 +868,13 @@ if(!empty($_GET['student']))
$messages = Tracking :: count_student_messages($a_infosUser['user_id'], $a_infosCours['code']);
$links = Tracking :: count_student_visited_links($a_infosUser['user_id'], $a_infosCours['code']);
$documents = Tracking :: count_student_downloaded_documents($a_infosUser['user_id'], $a_infosCours['code']);
$last_three_connections_chat = Tracking::last_three_connection_chat($a_infosUser['user_id'], $a_infosCours['code']);
$chat_last_connection = Tracking::chat_last_connection($a_infosUser['user_id'], $a_infosCours['code']);
$csv_content[] = array(get_lang('Student_publication'), $nb_assignments);
$csv_content[] = array(get_lang('Messages'), $messages);
$csv_content[] = array(get_lang('LinksDetails'), $links);
$csv_content[] = array(get_lang('DocumentsDetails'), $documents);
$csv_content[] = array(get_lang('ChatLastConnection'), $chat_last_connection);
?>
<tr>
@ -915,18 +916,10 @@ if(!empty($_GET['student']))
</tr>
<tr><!-- Chats -->
<td>
<?php echo get_lang('LastConnectionsInChat') ?>
<?php echo get_lang('ChatLastConnection') ?>
</td>
<td>
<?php
$last_connections_chat ='';
for($i=0;$i<count($last_three_connections_chat);$i++){
echo $last_three_connections_chat[$i].'<br/>';
$last_connections_chat .= str_replace(',', ' ', $last_three_connections_chat[$i]).' ';
}
$csv_content[] = array(get_lang('LastConnectionsInChat'), $last_connections_chat);
?>
<?php echo $chat_last_connection; ?>
</td>
</tr>
</table>

@ -261,6 +261,51 @@ if($_GET['studentlist'] == 'false') {
echo '</table></div>';
echo '<div class="clear"></div>';
/**********************
* FORUMS
**********************/
echo '<div class="admin_section">
<h4>
<img src="../img/forum.gif" align="absbottom">&nbsp;'.get_lang('Forum').' <a href="../forum/index.php?cidReq='.$_course['id'].'">'.get_lang('SeeDetail').'</a>
</h4>
<table class="data_table">';
$count_number_of_posts_by_course = Tracking :: count_number_of_posts_by_course($_course['id']);
$count_number_of_forums_by_course = Tracking :: count_number_of_forums_by_course($_course['id']);
$count_number_of_threads_by_course = Tracking :: count_number_of_threads_by_course($_course['id']);
if ($export_csv) {
$csv_content[] = array(get_lang('Forum'),'');
$csv_content[] = array(get_lang('ForumForumsNumber'),$count_number_of_forums_by_course);
$csv_content[] = array(get_lang('ForumThreadsNumber'),$count_number_of_threads_by_course);
$csv_content[] = array(get_lang('ForumPostsNumber'),$count_number_of_posts_by_course);
}
echo '<tr><td>'.get_lang('ForumForumsNumber').'</td><td align="right">'.$count_number_of_forums_by_course.'</td></tr>';
echo '<tr><td>'.get_lang('ForumThreadsNumber').'</td><td align="right">'.$count_number_of_threads_by_course.'</td></tr>';
echo '<tr><td>'.get_lang('ForumPostsNumber').'</td><td align="right">'.$count_number_of_posts_by_course.'</td></tr>';
echo '</table></div>';
echo '<div class="clear"></div>';
/**********************
* CHAT
**********************/
echo '<div class="admin_section">
<h4>
<img src="../img/chat.gif" align="absbottom">&nbsp;'.get_lang('Chat').'</a>
</h4>
<table class="data_table">';
$chat_connections_during_last_x_days_by_course = Tracking :: chat_connections_during_last_x_days_by_course($_course['id'],7);
if ($export_csv) {
$csv_content[] = array(get_lang('Chat'),'');
$csv_content[] = array(sprintf(get_lang('ChatConnectionsDuringLastXDays'),'7'),$chat_connections_during_last_x_days_by_course);
}
echo '<tr><td>'.sprintf(get_lang('ChatConnectionsDuringLastXDays'),'7').'</td><td align="right">'.$chat_connections_during_last_x_days_by_course.'</td></tr>';
echo '</table></div>';
echo '<div class="clear"></div>';
/**********************
* TOOLS
**********************/

Loading…
Cancel
Save