[svn r11397] improve reporting for the coach

skala
Eric Marguin 19 years ago
parent df49b92110
commit f5215b9346
  1. BIN
      main/img/printmgr.gif
  2. 37
      main/inc/lib/tracking.lib.php
  3. 2
      main/messaging/email_editor.php
  4. 781
      main/mySpace/index.php
  5. 516
      main/mySpace/myStudents.php
  6. 498
      main/mySpace/student.php

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

@ -414,6 +414,43 @@ class Tracking {
$rs = api_sql_query($sql, __LINE__, __FILE__);
return mysql_num_rows($rs);
}
function count_student_visited_links ($student_id, $course_code)
{
// protect datas
$student_id = intval($student_id);
$course_code = addslashes($course_code);
// table definition
$tbl_stats_links = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
$sql = 'SELECT 1
FROM '.$tbl_stats_links.'
WHERE links_user_id='.$student_id.'
AND links_cours_id="'.$course_code.'"';
$rs = api_sql_query($sql, __LINE__, __FILE__);
return mysql_num_rows($rs);
}
function count_student_downloaded_documents ($student_id, $course_code)
{
// protect datas
$student_id = intval($student_id);
$course_code = addslashes($course_code);
// table definition
$tbl_stats_documents = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$sql = 'SELECT 1
FROM '.$tbl_stats_documents.'
WHERE down_user_id='.$student_id.'
AND down_cours_id="'.$course_code.'"';
$rs = api_sql_query($sql, __LINE__, __FILE__);
return mysql_num_rows($rs);
}
}

@ -77,7 +77,7 @@ Display::display_header(get_lang('SendEmail'));
<label for="email_title"><?php echo get_lang('EmailTitle');?></label>
</td>
<td>
<input name="email_title" id="email_title" value="<?php echo $_POST['email_title'];?>"></input>
<input name="email_title" id="email_title" value="<?php echo $_POST['email_title'];?>" size="60"></input>
</td>
</tr>
<tr>

@ -9,12 +9,20 @@ $cidReset=true;
require ('../inc/global.inc.php');
require (api_get_path(LIBRARY_PATH).'tracking.lib.php');
require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
$nameTools= get_lang("MySpace");
require_once(api_get_path(LIBRARY_PATH).'export.lib.inc.php');
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$csv_content = array();
$nameTools= get_lang("MySpace");
$this_section = "session_my_space";
api_block_anonymous_users();
Display :: display_header($nameTools);
if(!$export_csv)
{
Display :: display_header($nameTools);
}
// Database table definitions
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
@ -33,6 +41,19 @@ $isCoach = api_is_coach();
if($isCoach)
{
/****************************************
* Print and export
****************************************/
if(!$export_csv)
{
echo '<div align="right">
<a href="#" onclick="window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
<a href="'.$_SERVER['PHP_SELF'].'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
</div>';
}
/****************************************
* Infos about students of the coach
****************************************/
@ -45,8 +66,10 @@ if($isCoach)
$avgTotalProgress = 0;
$avgResultsToExercises = 0;
$nb_inactive_students = 0;
$nb_posts = $nb_assignments = 0;
foreach($a_students as $student_id)
{
// inactive students
if($last_connection_date = Tracking :: get_last_connection_date($student_id))
{
list($last_connection_date, $last_connection_hour) = explode(' ',$last_connection_date);
@ -72,6 +95,8 @@ if($isCoach)
if(CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true))
{
$nb_courses_student++;
$nb_posts += Tracking :: count_student_messages($student_id,$course_code);
$nb_assignments += Tracking :: count_student_assignments($student_id,$course_code);
$avgStudentProgress += Tracking :: get_avg_student_progress($student_id,$course_code);
$avgStudentScore += Tracking :: get_avg_student_score($student_id,$course_code);
}
@ -97,57 +122,96 @@ if($isCoach)
// average time spent on the platform
$avgTimeSpent = $totalTimeSpent / $nbStudents;
// average assignments
$nb_assignments = $nb_assignments / $nbStudents;
// average posts
$nb_posts = $nb_posts / $nbStudents;
echo '
<div class="admin_section">
<h4>
<a href="student.php"><img src="'.api_get_path(WEB_IMG_PATH).'students.gif">&nbsp;'.get_lang('Probationers').' ('.$nbStudents.')'.'</a>
</h4>
<table class="data_table">
<tr>
<td>
'.get_lang('InactivesStudents').'
</td>
<td>
'.$nb_inactive_students.'
</td>
</tr>
<tr>
<td>
'.get_lang('AverageTimeSpentOnThePlatform').'
</td>
<td>
'.api_time_to_hms($avgTimeSpent).'
</td>
</tr>
<tr>
<td>
'.get_lang('AverageCoursePerStudent').'
</td>
<td>
'.$avgCoursesPerStudent.'
</td>
</tr>
<tr>
<td>
'.get_lang('AverageProgressInLearnpath').'
</td>
<td>
'.round($avgTotalProgress,1).' %
</td>
</tr>
<tr>
<td>
'.get_lang('AverageResultsToTheExercices').'
</td>
<td>
'.round($avgResultsToExercises,1).'
</td>
</tr>
</table>
<a href="student.php">'.get_lang('SeeStudentList').'</a>
</div>';
//csv part
if($export_csv)
{
$csv_content[] = array( get_lang('Probationers'));
$csv_content[] = array( get_lang('InactivesStudents'),$nb_inactive_students );
$csv_content[] = array( get_lang('AverageTimeSpentOnThePlatform'),$avgTimeSpent);
$csv_content[] = array( get_lang('AverageCoursePerStudent'),$avgCoursesPerStudent);
$csv_content[] = array( get_lang('AverageProgressInLearnpath'),$avgTotalProgress);
$csv_content[] = array( get_lang('AverageResultsToTheExercices'),$avgResultsToExercises);
$csv_content[] = array( get_lang('AveragePostsInForum'),$nb_posts);
$csv_content[] = array( get_lang('AverageAssignments'),$nb_assignments);
$csv_content[] = array();
}
// html part
else
{
echo '
<div class="admin_section">
<h4>
<a href="student.php"><img src="'.api_get_path(WEB_IMG_PATH).'students.gif">&nbsp;'.get_lang('Probationers').' ('.$nbStudents.')'.'</a>
</h4>
<table class="data_table">
<tr>
<td>
'.get_lang('InactivesStudents').'
</td>
<td align="right">
'.$nb_inactive_students.'
</td>
</tr>
<tr>
<td>
'.get_lang('AverageTimeSpentOnThePlatform').'
</td>
<td align="right">
'.api_time_to_hms($avgTimeSpent).'
</td>
</tr>
<tr>
<td>
'.get_lang('AverageCoursePerStudent').'
</td>
<td align="right">
'.$avgCoursesPerStudent.'
</td>
</tr>
<tr>
<td>
'.get_lang('AverageProgressInLearnpath').'
</td>
<td align="right">
'.round($avgTotalProgress,1).' %
</td>
</tr>
<tr>
<td>
'.get_lang('AverageResultsToTheExercices').'
</td>
<td align="right">
'.round($avgResultsToExercises,1).' %
</td>
</tr>
<tr>
<td>
'.get_lang('AveragePostsInForum').'
</td>
<td align="right">
'.round($nb_posts,1).'
</td>
</tr>
<tr>
<td>
'.get_lang('AverageAssignments').'
</td>
<td align="right">
'.round($nb_assignments,1).'
</td>
</tr>
</table>
<a href="student.php">'.get_lang('SeeStudentList').'</a>
</div>';
}
/****************************************
@ -186,356 +250,381 @@ if($isCoach)
$a_courses = array_merge($a_courses, Tracking::get_courses_list_from_session($a_session['id']));
}
$nb_courses_per_session = round(count($a_courses)/$nbSessions,1);
echo '
<div class="admin_section">
<h4>
<a href="session.php"><img src="'.api_get_path(WEB_IMG_PATH).'sessions.gif">&nbsp;'.get_lang('Sessions').' ('.$nbSessions.')'.'</a>
</h4>
<table class="data_table">
<tr>
<td>
'.get_lang('NbActiveSessions').'
</td>
<td>
'.$nb_sessions_current.'
</td>
</tr>
<tr>
<td>
'.get_lang('NbPastSessions').'
</td>
<td>
'.$nb_sessions_past.'
</td>
</tr>
<tr>
<td>
'.get_lang('NbFutureSessions').'
</td>
<td>
'.$nb_sessions_future.'
</td>
</tr>
<tr>
<td>
'.get_lang('NbStudentPerSession').'
</td>
<td>
'.round($nbStudents/$nbSessions,1).'
</td>
</tr>
<tr>
<td>
'.get_lang('NbCoursesPerSession').'
</td>
<td>
'.$nb_courses_per_session.'
</td>
</tr>
</table>
<a href="student.php">'.get_lang('SeeSessionList').'</a>
</div>';
//csv part
if($export_csv)
{
$csv_content[] = array( get_lang('Sessions'));
$csv_content[] = array( get_lang('NbActiveSessions').';'.$nb_sessions_current);
$csv_content[] = array( get_lang('NbPastSessions').';'.$nb_sessions_past);
$csv_content[] = array( get_lang('NbFutureSessions').';'.$nb_sessions_future);
$csv_content[] = array( get_lang('NbStudentPerSession').';'.round($nbStudents/$nbSessions,1));
$csv_content[] = array( get_lang('NbCoursesPerSession').';'.$nb_courses_per_session);
$csv_content[] = array();
}
// html part
else
{
echo '
<div class="admin_section">
<h4>
<a href="session.php"><img src="'.api_get_path(WEB_IMG_PATH).'sessions.gif">&nbsp;'.get_lang('Sessions').' ('.$nbSessions.')'.'</a>
</h4>
<table class="data_table">
<tr>
<td>
'.get_lang('NbActiveSessions').'
</td>
<td align="right">
'.$nb_sessions_current.'
</td>
</tr>
<tr>
<td>
'.get_lang('NbPastSessions').'
</td>
<td align="right">
'.$nb_sessions_past.'
</td>
</tr>
<tr>
<td>
'.get_lang('NbFutureSessions').'
</td>
<td align="right">
'.$nb_sessions_future.'
</td>
</tr>
<tr>
<td>
'.get_lang('NbStudentPerSession').'
</td>
<td align="right">
'.round($nbStudents/$nbSessions,1).'
</td>
</tr>
<tr>
<td>
'.get_lang('NbCoursesPerSession').'
</td>
<td align="right">
'.$nb_courses_per_session.'
</td>
</tr>
</table>
<a href="student.php">'.get_lang('SeeSessionList').'</a>
</div>';
}
Display::display_footer();
exit;
}
else
{
//Trainers
if(api_is_platform_admin())
{
$sqlNbFormateurs = "SELECT COUNT(user_id) FROM $tbl_user WHERE status = 1";
$resultNbFormateurs = api_sql_query($sqlNbFormateurs);
$a_nbFormateurs = mysql_fetch_array($resultNbFormateurs);
$nbFormateurs = $a_nbFormateurs[0];
}
//Coachs
$nbCoachs=0;
if(api_is_platform_admin())
{
$sqlNbCoachs = "SELECT COUNT(DISTINCT id_coach) FROM $tbl_session_course WHERE id_coach<>'0'";
$resultNbCoachs = api_sql_query($sqlNbCoachs);
$a_nbCoachs = mysql_fetch_array($resultNbCoachs);
$nbCoachs = $a_nbCoachs[0];
}
elseif($is_allowedCreateCourse)
{
$a_coach=array();
$sqlNbCours = " SELECT course_code
FROM $tbl_course_user
WHERE user_id='".$_user['user_id']."' AND status='1'
";
$resultNbCours = api_sql_query($sqlNbCours);
while($a_courses=mysql_fetch_array($resultNbCours))
//Trainers
if(api_is_platform_admin())
{
$sql="SELECT DISTINCT id_coach FROM $tbl_session_course WHERE course_code='".$a_courses["course_code"]."'";
$resultCoach = api_sql_query($sql);
if(mysql_num_rows($resultCoach)>0)
{
while($a_temp=mysql_fetch_array($resultCoach))
{
$a_coach[]=$a_temp["id_coach"];
}
}
$sqlNbFormateurs = "SELECT COUNT(user_id) FROM $tbl_user WHERE status = 1";
$resultNbFormateurs = api_sql_query($sqlNbFormateurs);
$a_nbFormateurs = mysql_fetch_array($resultNbFormateurs);
$nbFormateurs = $a_nbFormateurs[0];
}
$a_coach=array_unique($a_coach);
$nbCoachs=count($a_coach);
}
//Nombre de stagiaires (cours dans lesquels il est coach ou formateurs)
$nbStagiaire=0;
$a_stagiaire_teacher=array();
//La personne est admin
//Coachs
$nbCoachs=0;
if(api_is_platform_admin())
{
$sqlNbStagiaire = " SELECT COUNT(user_id)
FROM $tbl_user
WHERE status = 5
";
$resultNbStagiaire = api_sql_query($sqlNbStagiaire);
$a_nbStagiaire = mysql_fetch_array($resultNbStagiaire);
$nbStagiaire = $a_nbStagiaire[0];
$sqlNbCoachs = "SELECT COUNT(DISTINCT id_coach) FROM $tbl_session_course WHERE id_coach<>'0'";
$resultNbCoachs = api_sql_query($sqlNbCoachs);
$a_nbCoachs = mysql_fetch_array($resultNbCoachs);
$nbCoachs = $a_nbCoachs[0];
}
else
elseif($is_allowedCreateCourse)
{
//La personne a le statut de professeur
if($is_allowedCreateCourse){
//Cours ou la personne est formateur mais dont les cours ne sont pas dans une session
$sql_select_courses="SELECT course_rel_user.course_code FROM $tbl_course_user as course_rel_user LEFT OUTER JOIN $tbl_session_course as src ON course_rel_user.course_code=src.course_code WHERE user_id='$_uid' AND status='1' AND src.course_code IS NULL";
$result_courses=api_sql_query($sql_select_courses);
while($a_courses=mysql_fetch_array($result_courses))
$a_coach=array();
$sqlNbCours = " SELECT course_code
FROM $tbl_course_user
WHERE user_id='".$_user['user_id']."' AND status='1'
";
$resultNbCours = api_sql_query($sqlNbCours);
while($a_courses=mysql_fetch_array($resultNbCours))
{
$sql="SELECT DISTINCT id_coach FROM $tbl_session_course WHERE course_code='".$a_courses["course_code"]."'";
$resultCoach = api_sql_query($sql);
if(mysql_num_rows($resultCoach)>0)
{
$s_course_code=$a_courses["course_code"];
$sqlStudents = "SELECT user.user_id,lastname,firstname,email FROM $tbl_course_user as course_rel_user, $tbl_user as user WHERE course_rel_user.user_id=user.user_id AND course_rel_user.status='5' AND course_rel_user.course_code='$s_course_code'";
$result_students=api_sql_query($sqlStudents);
if(mysql_num_rows($result_students)>0)
{
while($a_students_temp=mysql_fetch_array($result_students))
{
$a_stagiaire_teacher[]=$a_students_temp["user_id"];
}
}
while($a_temp=mysql_fetch_array($resultCoach))
{
$a_coach[]=$a_temp["id_coach"];
}
}
$sqlNbStagiaire="SELECT DISTINCT srcru.id_user FROM $tbl_course_user as course_rel_user, $tbl_session_course_user as srcru " .
"WHERE course_rel_user.user_id='".$_user['user_id']."' AND course_rel_user.status='1' AND course_rel_user.course_code=srcru.course_code";
$resultNbStagiaire = api_sql_query($sqlNbStagiaire);
}
while($a_temp = mysql_fetch_array($resultNbStagiaire))
{
$a_stagiaire_teacher[]=$a_temp[0];
}
$a_coach=array_unique($a_coach);
$nbCoachs=count($a_coach);
}
if($isCoach)
//Nombre de stagiaires (cours dans lesquels il est coach ou formateurs)
$nbStagiaire=0;
$a_stagiaire_teacher=array();
//La personne est admin
if(api_is_platform_admin())
{
$a_stagiaire_coach=array();
$sql="SELECT id_session, course_code FROM $tbl_session_course WHERE id_coach='".$_user['user_id']."'";
$result=api_sql_query($sql);
while($a_courses=mysql_fetch_array($result))
{
$course_code=$a_courses["course_code"];
$id_session=$a_courses["id_session"];
$sqlStudents = "SELECT distinct srcru.id_user
FROM $tbl_session_course_user AS srcru
INNER JOIN $tbl_user as user
ON srcru.id_user = user.user_id
AND user.status = 5
WHERE course_code='$course_code' AND id_session='$id_session'";
$q_students=api_sql_query($sqlStudents);
$sqlNbStagiaire = " SELECT COUNT(user_id)
FROM $tbl_user
WHERE status = 5
";
$resultNbStagiaire = api_sql_query($sqlNbStagiaire);
$a_nbStagiaire = mysql_fetch_array($resultNbStagiaire);
$nbStagiaire = $a_nbStagiaire[0];
}
else
{
//La personne a le statut de professeur
if($is_allowedCreateCourse){
//Cours ou la personne est formateur mais dont les cours ne sont pas dans une session
$sql_select_courses="SELECT course_rel_user.course_code FROM $tbl_course_user as course_rel_user LEFT OUTER JOIN $tbl_session_course as src ON course_rel_user.course_code=src.course_code WHERE user_id='$_uid' AND status='1' AND src.course_code IS NULL";
$result_courses=api_sql_query($sql_select_courses);
while($a_temp=mysql_fetch_array($q_students))
while($a_courses=mysql_fetch_array($result_courses))
{
$a_stagiaire_coach[]=$a_temp[0];
$s_course_code=$a_courses["course_code"];
$sqlStudents = "SELECT user.user_id,lastname,firstname,email FROM $tbl_course_user as course_rel_user, $tbl_user as user WHERE course_rel_user.user_id=user.user_id AND course_rel_user.status='5' AND course_rel_user.course_code='$s_course_code'";
$result_students=api_sql_query($sqlStudents);
if(mysql_num_rows($result_students)>0)
{
while($a_students_temp=mysql_fetch_array($result_students))
{
$a_stagiaire_teacher[]=$a_students_temp["user_id"];
}
}
}
$sqlNbStagiaire="SELECT DISTINCT srcru.id_user FROM $tbl_course_user as course_rel_user, $tbl_session_course_user as srcru " .
"WHERE course_rel_user.user_id='".$_user['user_id']."' AND course_rel_user.status='1' AND course_rel_user.course_code=srcru.course_code";
}
$a_stagiaires=array_merge($a_stagiaire_teacher,$a_stagiaire_coach);
$resultNbStagiaire = api_sql_query($sqlNbStagiaire);
$a_stagiaires=array_unique($a_stagiaires);
$nbStagiaire=count($a_stagiaires);
}
else
{
$nbStagiaire=count($a_stagiaire_teacher);
while($a_temp = mysql_fetch_array($resultNbStagiaire))
{
$a_stagiaire_teacher[]=$a_temp[0];
}
}
}
if($isCoach)
{
$a_stagiaire_coach=array();
$sql="SELECT id_session, course_code FROM $tbl_session_course WHERE id_coach='".$_user['user_id']."'";
//Nombre de cours
//La personne est admin donc on compte le nombre total de cours
if(api_is_platform_admin())
{
$result=api_sql_query($sql);
while($a_courses=mysql_fetch_array($result))
{
$course_code=$a_courses["course_code"];
$id_session=$a_courses["id_session"];
$sqlStudents = "SELECT distinct srcru.id_user
FROM $tbl_session_course_user AS srcru
INNER JOIN $tbl_user as user
ON srcru.id_user = user.user_id
AND user.status = 5
WHERE course_code='$course_code' AND id_session='$id_session'";
$sqlNbCours = " SELECT COUNT(code)
FROM $tbl_course
";
$resultNbCours = api_sql_query($sqlNbCours);
$a_nbCours = mysql_fetch_array($resultNbCours);
$nbCours = $a_nbCours[0];
$q_students=api_sql_query($sqlStudents);
while($a_temp=mysql_fetch_array($q_students))
{
$a_stagiaire_coach[]=$a_temp[0];
}
}
$a_stagiaires=array_merge($a_stagiaire_teacher,$a_stagiaire_coach);
$a_stagiaires=array_unique($a_stagiaires);
$nbStagiaire=count($a_stagiaires);
}
else
{
$nbStagiaire=count($a_stagiaire_teacher);
}
}
}
else{
//Nombre de cours
//La personne est admin donc on compte le nombre total de cours
if(api_is_platform_admin())
{
$a_cours=array();
$sqlNbCours = " SELECT COUNT(code)
FROM $tbl_course
";
$resultNbCours = api_sql_query($sqlNbCours);
$a_nbCours = mysql_fetch_array($resultNbCours);
$nbCours = $a_nbCours[0];
}
//La personne a le statut de professeur
if($is_allowedCreateCourse)
{
else{
$sqlNbCours = " SELECT DISTINCT course_code
FROM $tbl_course_user
WHERE user_id='".$_user['user_id']."' AND status='1'
";
$resultCours = api_sql_query($sqlNbCours);
$a_cours=array();
while($a_cours_teacher = mysql_fetch_array($resultCours)){
$a_cours[]=$a_cours_teacher["course_code"];
//La personne a le statut de professeur
if($is_allowedCreateCourse)
{
$sqlNbCours = " SELECT DISTINCT course_code
FROM $tbl_course_user
WHERE user_id='".$_user['user_id']."' AND status='1'
";
$resultCours = api_sql_query($sqlNbCours);
while($a_cours_teacher = mysql_fetch_array($resultCours)){
$a_cours[]=$a_cours_teacher["course_code"];
}
}
$a_cours=array_unique($a_cours);
$nbCours=count($a_cours);
}
$a_cours=array_unique($a_cours);
$nbCours=count($a_cours);
}
//Nombre de sessions
//La personne est admin donc on compte le nombre total de sessions
if(api_is_platform_admin())
{
$sqlNbSessions = " SELECT COUNT(id)
FROM $tbl_sessions
";
$resultNbSessions = api_sql_query($sqlNbSessions);
$a_nbSessions= mysql_fetch_array($resultNbSessions);
$nbSessions = $a_nbSessions[0];
}
else
{
$a_sessions=array();
//Nombre de sessions
if($is_allowedCreateCourse)
//La personne est admin donc on compte le nombre total de sessions
if(api_is_platform_admin())
{
$sqlNbSessions = " SELECT DISTINCT id_session
FROM $tbl_session_course as session_course, $tbl_course_user as course_rel_user
WHERE session_course.course_code=course_rel_user.course_code AND course_rel_user.status='1' AND course_rel_user.user_id='".$_user['user_id']."'
";
$sqlNbSessions = " SELECT COUNT(id)
FROM $tbl_sessions
";
$resultNbSessions = api_sql_query($sqlNbSessions);
$a_nbSessions= mysql_fetch_array($resultNbSessions);
$nbSessions = $a_nbSessions[0];
}
else
{
$a_sessions=array();
while($a_temp = mysql_fetch_array($resultNbSessions))
if($is_allowedCreateCourse)
{
$a_sessions[]=$a_temp["id_session"];
$sqlNbSessions = " SELECT DISTINCT id_session
FROM $tbl_session_course as session_course, $tbl_course_user as course_rel_user
WHERE session_course.course_code=course_rel_user.course_code AND course_rel_user.status='1' AND course_rel_user.user_id='".$_user['user_id']."'
";
$resultNbSessions = api_sql_query($sqlNbSessions);
while($a_temp = mysql_fetch_array($resultNbSessions))
{
$a_sessions[]=$a_temp["id_session"];
}
}
}
if($isCoach)
{
$sqlNbSessions = " SELECT DISTINCT id_session
FROM $tbl_session_course
WHERE id_coach='".$_user['user_id']."'
";
$resultNbSessions = api_sql_query($sqlNbSessions);
while($a_temp = mysql_fetch_array($resultNbSessions))
if($isCoach)
{
$a_sessions[]=$a_temp["id_session"];
$sqlNbSessions = " SELECT DISTINCT id_session
FROM $tbl_session_course
WHERE id_coach='".$_user['user_id']."'
";
$resultNbSessions = api_sql_query($sqlNbSessions);
while($a_temp = mysql_fetch_array($resultNbSessions))
{
$a_sessions[]=$a_temp["id_session"];
}
}
$a_sessions=array_unique($a_sessions);
$nbSessions = count($a_sessions);
}
if(api_is_platform_admin())
{
echo '<div class="admin_section">
<h4>
<a href="teachers.php"><img src="'.api_get_path(WEB_IMG_PATH).'teachers.gif">&nbsp;'.get_lang('Trainers').' ('.$nbFormateurs.')</a>
</h4>
</div>';
}
if((api_is_platform_admin() || ($is_allowedCreateCourse && $nbCoachs>0)) && api_get_setting('use_session_mode')=='true')
{ // if the user is platform admin, or if he's a teacher which manage coaches
echo '<div class="admin_section">
<h4>
<a href="coaches.php"><img src="'.api_get_path(WEB_IMG_PATH).'coachs.gif">&nbsp;'.get_lang("Tutors").' ('.$nbCoachs.')</a>
</h4>
</div>';
}
if(api_is_platform_admin())
{
$a_sessions=array_unique($a_sessions);
$nbSessions = count($a_sessions);
$sql_nb_admin="SELECT count(user_id) FROM $tbl_admin";
$resultNbAdmin = api_sql_query($sql_nb_admin);
$i_nb_admin=mysql_result($resultNbAdmin,0,0);
echo '
<div class="admin_section">
<h4>
<a href="admin.php"><img src="'.api_get_path(WEB_IMG_PATH).'admins.gif>&nbsp;'.get_lang('Administrators').' ('.$i_nb_admin.')</a>
</h4>
</div>';
}
if($nbCours)
{
echo '
<div class="admin_section">
<h4>
<a href="cours.php"><img src="'.api_get_path(WEB_IMG_PATH).'courses.gif">&nbsp;'.get_lang('Courses').' ('.$nbCours.')'.'</a>
</h4>
</div>';
}
if(api_get_setting('use_session_mode')=='true'){
echo '
<div class="admin_section">
<h4>
<a href="session.php"><img src="'.api_get_path(WEB_IMG_PATH).'sessions.gif">&nbsp;'.get_lang('Sessions').' ('.$nbSessions.')'.'</a>
</h4>
</div>';
}
if(api_is_platform_admin())
{
echo '<div class="admin_section">
<h4>
<a href="teachers.php"><img src="'.api_get_path(WEB_IMG_PATH).'teachers.gif">&nbsp;'.get_lang('Trainers').' ('.$nbFormateurs.')</a>
</h4>
</div>';
}
if((api_is_platform_admin() || ($is_allowedCreateCourse && $nbCoachs>0)) && api_get_setting('use_session_mode')=='true')
{ // if the user is platform admin, or if he's a teacher which manage coaches
echo '<div class="admin_section">
<h4>
<a href="coaches.php"><img src="'.api_get_path(WEB_IMG_PATH).'coachs.gif">&nbsp;'.get_lang("Tutors").' ('.$nbCoachs.')</a>
</h4>
</div>';
}
if(api_is_platform_admin())
// send the csv file if asked
if($export_csv)
{
$sql_nb_admin="SELECT count(user_id) FROM $tbl_admin";
$resultNbAdmin = api_sql_query($sql_nb_admin);
$i_nb_admin=mysql_result($resultNbAdmin,0,0);
echo '
<div class="admin_section">
<h4>
<a href="admin.php"><img src="'.api_get_path(WEB_IMG_PATH).'admins.gif>&nbsp;'.get_lang('Administrators').' ('.$i_nb_admin.')</a>
</h4>
</div>';
}
if($nbCours)
{
echo '
<div class="admin_section">
<h4>
<a href="cours.php"><img src="'.api_get_path(WEB_IMG_PATH).'courses.gif">&nbsp;'.get_lang('Courses').' ('.$nbCours.')'.'</a>
</h4>
</div>';
}
if(api_get_setting('use_session_mode')=='true'){
echo '
<div class="admin_section">
<h4>
<a href="session.php"><img src="'.api_get_path(WEB_IMG_PATH).'sessions.gif">&nbsp;'.get_lang('Sessions').' ('.$nbSessions.')'.'</a>
</h4>
</div>';
Export :: export_table_csv($csv_content, 'reporting_index');
}
/*
==============================================================================
FOOTER
==============================================================================
*/
Display::display_footer();
if(!$export_csv)
{
Display::display_footer();
}
?>

@ -8,21 +8,29 @@ $language_file = array ('registration', 'index', 'tracking', 'exercice');
$cidReset=true;
include ('../inc/global.inc.php');
include_once(api_get_path(LIBRARY_PATH).'tracking.lib.php');
include_once(api_get_path(LIBRARY_PATH).'export.lib.inc.php');
include_once(api_get_path(LIBRARY_PATH).'usermanager.lib.php');
include_once(api_get_path(LIBRARY_PATH).'course.lib.php');
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
if($export_csv)
{
ob_start();
}
$csv_content = array();
$this_section = "session_my_space";
$nameTools=get_lang("MyStudents");
$nameTools=get_lang("StudentDetails");
$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
$interbreadcrumb[] = array ("url" => "student.php", "name" => get_lang("MyStudents"));
if(isset($_GET["user_id"]) && $_GET["user_id"]!="" && !isset($_GET["type"])){
$interbreadcrumb[] = array ("url" => "teachers.php", "name" => get_lang('Teachers'));
}
if(isset($_GET["user_id"]) && $_GET["user_id"]!="" && isset($_GET["type"]) && $_GET["type"]=="coach"){
$interbreadcrumb[] = array ("url" => "coaches.php", "name" => get_lang('Tutors'));
if(isset($_GET['details']))
{
$interbreadcrumb[] = array ("url" => "myStudents.php?student=".$_GET['student'], "name" => get_lang("StudentDetails"));
$nameTools=get_lang("DetailsStudentInCourse");
}
api_block_anonymous_users();
@ -33,91 +41,7 @@ $language_file = array ('registration', 'index', 'tracking', 'exercice');
* FUNCTIONS
* ======================================================================================
*/
function exportCsv($a_infosUser,$tableTitle,$a_header,$a_dataLearnpath,$a_dataExercices,$a_dataProduction)
{
global $archiveDirName;
$fileName = 'test.csv';
$archivePath = api_get_path(SYS_PATH).$archiveDirName.'/';
$archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
if(!$open = fopen($archivePath.$fileName,'w+'))
{
$message = get_lang('noOpen');
}
else
{
$info = '';
$info .= $a_infosUser['name'];
$info .= "\r\n";
$info .= $a_infosUser['email'];
$info .= "\r\n";
$info .= $a_infosUser['phone'];
/*$info .= "\r\n";
$info .= $a_infosUser['adresse'];*/
$info .= "\r\n";
$info .= "\r\n";
$info .= $tableTitle;
$info .= "\r\n";
for($i=0;$i<4;$i++)
{
$info .= $a_header[$i].';';
}
$info .= "\r\n";
foreach($a_dataLearnpath as $a_learnpath)
{
foreach($a_learnpath as $learnpath)
{
$info .= $learnpath.';';
}
$info .= "\r\n";
}
for($i=4;$i<8;$i++)
{
$info .= $a_header[$i].';';
}
$info .= "\r\n";
foreach($a_dataExercices as $a_exercice)
{
foreach($a_exercice as $exercice)
{
$info .= $exercice.';';
}
$info .= "\r\n";
}
for($i=8;$i<12;$i++)
{
$info .= $a_header[$i].';';
}
$info .= "\r\n";
foreach($a_dataProduction as $a_production)
{
foreach($a_production as $production)
{
$info .= $production.';';
}
$info .= "\r\n";
}
fwrite($open,$info);
fclose($open);
chmod($fileName,0777);
$message = get_lang('UsageDatacreated');
header("Location:".$archiveURL.$fileName);
}
return $message;
}
function calculHours($seconds)
@ -194,6 +118,13 @@ else
if(!empty($_GET['student']))
{
echo '<div align="right">
<a href="#" onclick="window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
<a href="'.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
</div>';
// is the user online ?
$statistics_database = Database :: get_statistic_database();
$a_usersOnline = WhoIsOnline($_GET['student'], $statistics_database, 30);
@ -231,7 +162,21 @@ if(!empty($_GET['student']))
}
$avg_student_progress = round($avg_student_progress / $nb_courses,1);
$avg_student_score = round($avg_student_score / $nb_courses,1);
$last_connection_date = Tracking::get_last_connection_date($a_infosUser['user_id']);
$time_spent_on_the_platform = api_time_to_hms(Tracking::get_time_spent_on_the_platform($a_infosUser['user_id']));
// cvs informations
$csv_content[] = array(get_lang('Informations'));
$csv_content[] = array(get_lang('Name'), get_lang('Email'), get_lang('Tel'));
$csv_content[] = array($a_infosUser['name'], $a_infosUser['email'],$a_infosUser['phone']);
$csv_content[] = array();
// csv tracking
$csv_content[] = array(get_lang('Tracking'));
$csv_content[] = array(get_lang('LatestLogin'), get_lang('TimeSpentOnThePlatform'), get_lang('Progress'), get_lang('Score'));
$csv_content[] = array($last_connection_date, $time_spent_on_the_platform , $avg_student_progress.' %',$avg_student_score.' %');
?>
<a name="infosStudent"></a>
@ -247,13 +192,13 @@ if(!empty($_GET['student']))
echo ' <td class="borderRight" width="10%">
<img src="'.$a_infosUser['picture_uri'].'" />
</td>
';
';
}
else{
echo ' <td class="borderRight" width="10%">
<img src="../img/unknown.jpg" />
</td>
';
';
}
?>
@ -329,7 +274,7 @@ if(!empty($_GET['student']))
<?php echo get_lang('LatestLogin') ?>
</td>
<td class="none">
<?php echo Tracking::get_last_connection_date($a_infosUser['user_id']) ?>
<?php echo $last_connection_date ?>
</td>
</tr>
<tr>
@ -337,7 +282,7 @@ if(!empty($_GET['student']))
<?php echo get_lang('TimeSpentOnThePlatform') ?>
</td>
<td class="none">
<?php echo api_time_to_hms(Tracking::get_time_spent_on_the_platform($a_infosUser['user_id'])) ?>
<?php echo $time_spent_on_the_platform ?>
</td>
</tr>
<tr>
@ -398,18 +343,12 @@ if(!empty($_GET['student']))
</tr>
</table>
<table class="data_table">
<tr><td colspan="5" style="border-width: 0px;">&nbsp;</td></tr>
</a>
<tr>
<td colspan="5" style="border-width: 0px;">&nbsp;</td>
</tr>
<?php
if(!empty($_GET['details']))
{
?>
<br /><br />
<div align="left">
<a href="<?php echo $_SERVER['PHP_SELF']; ?>?student=<?php echo $a_infosUser['user_id']; ?>#infosStudent"><?php echo get_lang('Back'); ?></a>
</div>
<br />
<?php
$sqlInfosCourse = " SELECT course.code,
course.title,
@ -436,7 +375,9 @@ if(!empty($_GET['student']))
$date_end = $a_date_end[2].'/'.$a_date_end[1].'/'.$a_date_end[0];
$dateSession = get_lang('From').' '.$date_start.' '.get_lang('To').' '.$date_end;
$tableTitle = $a_infosCours['title'].'&nbsp; | &nbsp;'.get_lang('Tutor').' : '.$a_infosCours['tutor_name'];
$csv_content[] = array();
$csv_content[] = array($tableTitle);
?>
<tr class="tableName">
@ -444,20 +385,23 @@ if(!empty($_GET['student']))
<strong><?php echo $tableTitle; ?></strong>
</td>
</tr>
<tr>
<th class="head">
<?php echo get_lang('Learnpath'); ?>
</th>
<th class="head" colspan="2">
<?php echo get_lang('Time'); ?>
</th>
<th class="head">
<?php echo get_lang('Progress'); ?>
</th>
<th class="head" colspan="2">
<?php echo get_lang('LastConnexion'); ?>
</th>
</tr>
<tr> <!-- line about learnpaths -->
<td>
<table class="data_table">
<tr>
<th>
<?php echo get_lang('Learnpaths'); ?>
</th>
<th>
<?php echo get_lang('Time'); ?>
</th>
<th>
<?php echo get_lang('Progress'); ?>
</th>
<th>
<?php echo get_lang('LastConnexion'); ?>
</th>
</tr>
<?php
$a_headerLearnpath = array(get_lang('Learnpath'),get_lang('Time'),get_lang('Progress'),get_lang('LastConnexion'));
@ -467,6 +411,9 @@ if(!empty($_GET['student']))
$resultLearnpath = api_sql_query($sqlLearnpath);
$csv_content[] = array();
$csv_content[] = array(get_lang('Learnpath'),get_lang('Time'),get_lang('Progress'),get_lang('LastConnexion'));
if(mysql_num_rows($resultLearnpath)>0)
{
$i = 0;
@ -492,6 +439,29 @@ if(!empty($_GET['student']))
$progress = round(($a_nbItem['nbItem'] * 100)/$a_totalItem['totalItem']);
// calculates time
$sql = 'SELECT SUM(total_time)
FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' AS item_view
INNER JOIN '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view.' AS view
ON item_view.lp_view_id = view.id
AND view.lp_id = '.$a_learnpath['id'].'
AND view.user_id = '.$_GET['student'];
$rs = api_sql_query($sql, __FILE__, __LINE__);
$total_time = mysql_result($rs, 0, 0);
// calculates last connection time
$sql = 'SELECT MAX(start_time)
FROM '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view_item.' AS item_view
INNER JOIN '.$a_infosCours['db_name'].'.'.$tbl_course_lp_view.' AS view
ON item_view.lp_view_id = view.id
AND view.lp_id = '.$a_learnpath['id'].'
AND view.user_id = '.$_GET['student'];
$rs = api_sql_query($sql, __FILE__, __LINE__);
$start_time = mysql_result($rs, 0, 0);
if($i%2==0){
$s_css_class="row_odd";
}
@ -501,19 +471,21 @@ if(!empty($_GET['student']))
$i++;
$csv_content[] = array(stripslashes($a_learnpath['name']),api_time_to_hms($total_time),$progress.' %',date('Y-m-d',$start_time));
?>
<tr class="<?php echo $s_css_class;?>">
<td>
<?php echo stripslashes($a_learnpath['name']); ?>
</td>
<td colspan="2">
<td align="center">
<?php echo api_time_to_hms($total_time) ?>
</td>
<td align="center">
<?php echo $progress.'%'; ?>
<?php echo $progress.' %'; ?>
</td>
<td colspan="2">
<td align="center">
<?php echo date('Y-m-d',$start_time) ?>
</td>
</tr>
@ -535,28 +507,29 @@ if(!empty($_GET['student']))
";
}
?>
<tr>
<th class="head">
<?php echo get_lang('Exercices'); ?>
</th>
<th class="head">
<?php echo get_lang('Score') ?>
</th>
<th class="head">
<?php echo get_lang('Details'); ?>
</th>
<th class="head">
<?php echo get_lang('Attempts'); ?>
</th>
<th class="head">
<?php echo get_lang('Correction'); ?>
</th>
<th class="head">
<?php echo get_lang('CorrectTest'); ?>
</th>
</table>
</td>
</tr>
<?php
$a_headerExercices = array(get_lang('Exercices'),get_lang('Score'),get_lang('Attempts'),get_lang('Correction'));
<tr> <!-- line about exercises -->
<td>
<table class="data_table">
<tr>
<th>
<?php echo get_lang('Exercices'); ?>
</th>
<th>
<?php echo get_lang('Score') ?>
</th>
<th>
<?php echo get_lang('Attempts'); ?>
</th>
<th>
<?php echo get_lang('CorrectTest'); ?>
</th>
</tr>
<?php
$csv_content[] = array();
$csv_content[] = array(get_lang('Exercices'),get_lang('Score'),get_lang('Attempts'));
$sqlExercices = " SELECT quiz.title,id
FROM ".$a_infosCours['db_name'].".".$tbl_course_quiz." AS quiz
";
@ -575,11 +548,12 @@ if(!empty($_GET['student']))
$resultEssais = api_sql_query($sqlEssais);
$a_essais = mysql_fetch_array($resultEssais);
$sqlScore = "SELECT exe_result,exe_weighting
$sqlScore = "SELECT exe_id, exe_result,exe_weighting
FROM $tbl_stats_exercices
WHERE exe_user_id = ".$_GET['student']."
AND exe_cours_id = '".$a_infosCours['code']."'
AND exe_exo_id = ".$a_exercices['id']
AND exe_exo_id = ".$a_exercices['id']."
ORDER BY exe_date DESC LIMIT 1"
;
$resultScore = api_sql_query($sqlScore);
@ -588,11 +562,14 @@ if(!empty($_GET['student']))
{
$score = $score + $a_score['exe_result'];
$weighting = $weighting + $a_score['exe_weighting'];
$exe_id = $a_score['exe_id'];
}
$pourcentageScore = round(($score*100)/$weighting);
$weighting = 0;
$csv_content[] = array($a_exercices['title'], $pourcentageScore.' %', $a_essais['essais']);
if($i%2==0){
$s_css_class="row_odd";
}
@ -610,22 +587,15 @@ if(!empty($_GET['student']))
";
echo " <td align='center'>
";
echo $pourcentageScore.'%';
echo " </td>
<td align='center'>
";
echo "<a href='".$_SERVER['PHP_SELF']."?student=".$_GET['student']."&details=true&course=".$_GET['course']."&exe_id=".$a_exercices['id']."#infosExe'> -> </a>";
echo $pourcentageScore.' %';
echo " </td>
<td align='center'>
";
echo $a_essais['essais'];
echo " </td>
<td>
";
echo " </td>
<td align='center'>
";
echo "<a href=''> -> </a>";
echo '<a href="../exercice/exercise_show.php?id='.$exe_id.'&cidReq='.$a_infosCours['code'].'"> <img src="'.api_get_path(WEB_IMG_PATH).'quiz.gif" border="0"> </a>';
echo " </td>
</tr>
";
@ -647,119 +617,72 @@ if(!empty($_GET['student']))
</tr>
";
}
?>
<tr>
<th class="head">
<?php echo get_lang('Productions'); ?>
</th>
<th class="head" colspan="2">
<?php echo get_lang('LimitDate'); ?>
</th>
<th class="head">
<?php echo get_lang('SentDate'); ?>
</th>
<th class="head">
<?php echo get_lang('Comments'); ?>
</th>
<th class="head">
<?php echo get_lang('Annotate'); ?>
</th>
</tr>
<?php
$a_headerProductions = array(get_lang('Productions'),get_lang('LimitDate'),get_lang('SentDate'),get_lang('Comments'));
$sqlProduction = " SELECT title,sent_date
FROM ".$a_infosCours['db_name'].".".$course_student_publication."
";
$resultProduction = api_sql_query($sqlProduction);
if(mysql_num_rows($resultProduction)>0)
{
$i = 0;
while($a_production = mysql_fetch_array($resultProduction))
{
//$tmp_limitDate = $newDate = mktime(0 , 0 , 0 , date("m") , date("d") , date("Y"));
$tmp_limitDate = $newDate = mktime(0 , 0 , 0 ,8 , 20 , 2006);
$a_sentDate = explode(' ',$a_production['sent_date']);
$a_sentDate = explode('-',$a_sentDate[0]);
$tmp_sentDate = mktime(0,0,0,$a_sentDate[1],$a_sentDate[2],$a_sentDate[0]);
$sentDate = $a_sentDate[2].'/'.$a_sentDate[1].'/'.$a_sentDate[0];
if($i%2==0){
$s_css_class="row_odd";
}
else{
$s_css_class="row_even";
}
$i++;
echo "<tr class='$s_css_class'>
<td>
";
echo $a_production['title'];
echo " </td>
";
echo " <td align='center' colspan='2'>
";
echo " </td>
";
if($tmp_sentDate > $tmp_limitDate)
{
echo "<td align='center' class='redText'>";
$tmp_retard = $tmp_sentDate - $tmp_limitDate;
$retard = round($tmp_retard/86400);
echo $retard.' '.get_lang('DayOfDelay');
echo "</td>";
}
else
{
echo "<td align='center'>";
echo $sentDate;
echo "</td>";
}
echo " <td align='center'>
";
$remarque = '';
if($remarque == '')
{
echo "--";
}
echo " </td>
<td align='center'>
";
echo "<a href=''> -> </a>";
echo " </td>
</tr>
";
$dataProduction[$i][] = $a_production['title'];
//$dataProduction[$i][] = $a_production['sent_date'];
$dataProduction[$i][] = $a_production['sent_date'];
//$dataProduction[$i][] = remarques;
$i++;
}
}
else
{
echo " <tr>
<td colspan='6'>
".get_lang('NoProduction')."
</td>
</tr>
";
}
?>
</table>
</td>
</tr>
<tr><!-- line about other tools -->
<td>
<table class="data_table">
<?php
$csv_content[] = array();
}
else
{
$nb_assignments = Tracking :: count_student_assignments($a_infosUser['user_id'], $a_infosCours['code']);
$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']);
$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);
?>
<tr>
<th colspan="2">
<?php echo get_lang('OtherTools'); ?>
</th>
</tr>
<tr><!-- assignments -->
<td width="40%">
<?php echo get_lang('Student_publication') ?>
</td>
<td>
<?php echo $nb_assignments ?>
</td>
</tr>
<tr><!-- messages -->
<td>
<?php echo get_lang('Messages') ?>
</td>
<td>
<?php echo $messages ?>
</td>
</tr>
<tr><!-- links -->
<td>
<?php echo get_lang('LinksDetails') ?>
</td>
<td>
<?php echo $links ?>
</td>
</tr>
<tr><!-- documents -->
<td>
<?php echo get_lang('DocumentsDetails') ?>
</td>
<td>
<?php echo $documents ?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
}
else
{
?>
<tr>
<th>
@ -781,29 +704,35 @@ if(!empty($_GET['student']))
<?php
if(count($a_courses)>0)
{
$csv_content[] = array();
$csv_content[] = array(get_lang('Course'),get_lang('Time'),get_lang('Progress'),get_lang('Score'));
foreach($a_courses as $course_code)
{
$course_infos = CourseManager :: get_course_information($course_code);
$time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($a_infosUser['user_id'], $course_code));
$progress = Tracking :: get_avg_student_progress($a_infosUser['user_id'], $course_code).' %';
$score = Tracking :: get_avg_student_score($a_infosUser['user_id'], $course_code).' %';
$csv_content[] = array($course_infos['title'], $time_spent_on_course, $progress, $score);
echo '
<tr>
<td>
'.$course_infos['title'].'
</td>
<td>
'.api_time_to_hms(Tracking :: get_time_spent_on_the_course($a_infosUser['user_id'], $course_code)).'
</td>
<td>
'.Tracking :: get_avg_student_progress($a_infosUser['user_id'], $course_code).' %
</td>
<td>
'.Tracking :: get_avg_student_score($a_infosUser['user_id'], $course_code).' %
</td>
<td>
<a href="'.$_SERVER['PHP_SELF'].'?student='.$a_infosUser['user_id'].'&details=true&course='.$course_infos['code'].'#infosStudent"> -> </a>
</td>
';
<tr>
<td align="right">
'.$course_infos['title'].'
</td>
<td align="right">
'.$time_spent_on_course.'
</td>
<td align="right">
'.$progress.'
</td>
<td align="right">
'.$score.'
</td>
<td align="center" width="10">
<a href="'.$_SERVER['PHP_SELF'].'?student='.$a_infosUser['user_id'].'&details=true&course='.$course_infos['code'].'#infosStudent"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>
</td>
</tr>
';
}
}
else
@ -903,13 +832,14 @@ if(!empty($_GET['student']))
}
$a_header = array_merge($a_headerLearnpath,$a_headerExercices,$a_headerProductions);
if($_GET['csv'] == "true")
{
$exportResult = exportCsv($a_infosUser,$tableTitle,$a_header,$dataLearnpath,$dataExercices,$dataProduction);
Display :: display_error_message($exportResult);
}
}
if($export_csv)
{
ob_end_clean();
Export :: export_table_csv($csv_content, 'reporting_student');
}
/*
==============================================================================

@ -2,34 +2,42 @@
/*
* Created on 28 juil. 2006 by Elixir Interactive http://www.elixir-interactive.com
*/
ob_start();
// name of the language file that needs to be included
$language_file = array ('registration', 'index', 'tracking');
$cidReset=true;
require ('../inc/global.inc.php');
require_once (api_get_path(LIBRARY_PATH).'tracking.lib.php');
require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
$cidReset=true;
require ('../inc/global.inc.php');
require_once (api_get_path(LIBRARY_PATH).'tracking.lib.php');
require_once (api_get_path(LIBRARY_PATH).'export.lib.inc.php');
require_once (api_get_path(LIBRARY_PATH).'course.lib.php');
require_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php');
$nameTools= get_lang("Students");
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
if($export_csv)
{
ob_start();
}
$csv_content = array();
$this_section = "session_my_space";
$nameTools= get_lang("Students");
api_block_anonymous_users();
$this_section = "session_my_space";
$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
api_block_anonymous_users();
if(isset($_GET["user_id"]) && $_GET["user_id"]!="" && !isset($_GET["type"])){
$interbreadcrumb[] = array ("url" => "teachers.php", "name" => get_lang('Teachers'));
}
$interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('MySpace'));
if(isset($_GET["user_id"]) && $_GET["user_id"]!="" && isset($_GET["type"]) && $_GET["type"]=="coach"){
$interbreadcrumb[] = array ("url" => "coaches.php", "name" => get_lang('Tutors'));
}
if(isset($_GET["user_id"]) && $_GET["user_id"]!="" && !isset($_GET["type"])){
$interbreadcrumb[] = array ("url" => "teachers.php", "name" => get_lang('Teachers'));
}
Display :: display_header($nameTools);
if(isset($_GET["user_id"]) && $_GET["user_id"]!="" && isset($_GET["type"]) && $_GET["type"]=="coach"){
$interbreadcrumb[] = array ("url" => "coaches.php", "name" => get_lang('Tutors'));
}
Display :: display_header($nameTools);
// Database Table Definitions
$tbl_course = Database :: get_main_table(TABLE_MAIN_COURSE);
@ -45,220 +53,6 @@ $tbl_session_rel_user = Database :: get_main_table(TABLE_MAIN_SESSION_USER);
FUNCTION
===============================================================================
*/
function exportCsv($a_header,$a_data)
{
global $archiveDirName;
$fileName = 'students.csv';
$archivePath = api_get_path(SYS_PATH).$archiveDirName.'/';
$archiveURL = api_get_path(WEB_CODE_PATH).'course_info/download.php?archive=';
if(!$open = fopen($archivePath.$fileName,'w+'))
{
$message = get_lang('noOpen');
}
else
{
$info = '';
foreach($a_header as $header)
{
$info .= $header.';';
}
$info .= "\r\n";
foreach($a_data as $data)
{
foreach($data as $infos)
{
$info .= $infos.';';
}
$info .= "\r\n";
}
fwrite($open,$info);
fclose($open);
chmod($fileName,0777);
header("Location:".$archiveURL.$fileName);
}
return $message;
}
/**
* Returns an array of students of courses (who belong to no sessions) which in the given user is a teacher
* @param int teacher_id The id of the teacher
*/
function getStudentsFromCoursesNoSession($i_teacher_id, $a_students){
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
//$sql_select_courses="SELECT course_rel_user.course_code, src.course_code as test FROM $tbl_course_user as course_rel_user LEFT OUTER JOIN $tbl_session_course as src ON course_rel_user.course_code=src.course_code WHERE user_id='$i_teacher_id' AND status='1' AND src.course_code IS NULL";
$sql_select_courses="SELECT course_rel_user.course_code FROM $tbl_course_user as course_rel_user WHERE user_id='$i_teacher_id' AND status='1'";
$result_courses=api_sql_query($sql_select_courses);
while($a_courses=mysql_fetch_array($result_courses)){
$s_course_code=$a_courses["course_code"];
$sqlStudents = "SELECT user.user_id,lastname,firstname,email FROM $tbl_course_user as course_rel_user, $tbl_user as user WHERE course_rel_user.user_id=user.user_id AND course_rel_user.status='5' AND course_rel_user.course_code='$s_course_code'";
$result_students=api_sql_query($sqlStudents);
if(mysql_num_rows($result_students)>0){
while($a_students_temp=mysql_fetch_array($result_students)){
$a_current_student=array();
//If the user has already been added to the table
if(!array_key_exists($a_students,$a_students_temp["user_id"])){
$a_current_student[]=$a_students_temp["user_id"];
$a_current_student[]=$a_students_temp["lastname"];
$a_current_student[]=$a_students_temp["firstname"];
$a_current_student[]=$a_students_temp["email"];
$a_students[$a_students_temp["user_id"]]=$a_current_student;
$a_students[$a_students_temp["user_id"]]["teacher"]=true;
}
}
}
}
return $a_students;
}
/**
* Returns an array of students of courses (who belong to at least one session) which in the given user is a teacher
* @param int teacher_id The id of the teacher
*/
function getStudentsFromCoursesFromSessions($i_teacher_id, $a_students){
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
$sql_select_courses="SELECT course_rel_user.course_code FROM $tbl_course_user as course_rel_user, $tbl_session_course as session_rel_course WHERE user_id='$i_teacher_id' AND status='1' AND session_rel_course.course_code=course_rel_user.course_code";
$result_courses=api_sql_query($sql_select_courses);
while($a_courses=mysql_fetch_array($result_courses)){
$s_course_code=$a_courses["course_code"];
$sqlStudents = "SELECT DISTINCT user.user_id,lastname,firstname,email FROM $tbl_session_course_user as srcru, $tbl_user as user WHERE srcru.id_user=user.user_id AND srcru.course_code='$s_course_code'";
$result_students=api_sql_query($sqlStudents);
if(mysql_num_rows($result_students)>0){
while($a_students_temp=mysql_fetch_array($result_students)){
$a_current_student=array();
//If the user has already been added to the table
if(!array_key_exists($a_students,$a_students_temp["user_id"])){
$a_current_student[]=$a_students_temp["user_id"];
$a_current_student[]=$a_students_temp["lastname"];
$a_current_student[]=$a_students_temp["firstname"];
$a_current_student[]=$a_students_temp["email"];
$a_students[$a_students_temp["user_id"]]=$a_current_student;
$a_students[$a_students_temp["user_id"]]["teacher"]=true;
}
}
}
}
return $a_students;
}
/**
* Returns an array of students of courses which in the given user is a coach
* @param int coach_id The id of the coach
*/
function getStudentsFromCoursesFromSessionsCoach($i_coach_id, $a_students){
$tbl_session_course_user = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_user = Database :: get_main_table(TABLE_MAIN_USER);
$tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
$sql_select_courses="SELECT course_code, id_session FROM $tbl_session_course as session_rel_course WHERE session_rel_course.id_coach='$i_coach_id'";
$result_courses=api_sql_query($sql_select_courses);
while($a_courses=mysql_fetch_array($result_courses)){
$s_course_code=$a_courses["course_code"];
$i_id_session=$a_courses["id_session"];
$sqlStudents="SELECT user.user_id,lastname,firstname,email
FROM $tbl_session_course_user as srcru, $tbl_user as user
WHERE srcru.course_code='$s_course_code' AND srcru.id_session='$i_id_session' AND srcru.id_user=user.user_id
";
$result_students=api_sql_query($sqlStudents);
if(mysql_num_rows($result_students)>0){
while($a_students_temp=mysql_fetch_array($result_students)){
$a_current_student=array();
//If the user has already been added to the table
if(!array_key_exists($a_students,$a_students_temp["user_id"])){
$a_current_student[]=$a_students_temp["user_id"];
$a_current_student[]=$a_students_temp["lastname"];
$a_current_student[]=$a_students_temp["firstname"];
$a_current_student[]=$a_students_temp["email"];
$a_students[$a_students_temp["user_id"]]=$a_current_student;
$a_students[$a_students_temp["user_id"]]["teacher"]=false;
}
}
}
}
return $a_students;
}
function mysort($a , $b){
if($a[1]>$b[1]){
return 1;
}
else if($b[1]>$a[1]){
return -1;
}
else {
return 0;
}
}
function count_student_coached()
{
@ -266,30 +60,60 @@ function count_student_coached()
return count($a_students);
}
function sort_users($a, $b)
{
global $tracking_column;
if($a[$tracking_column] > $b[$tracking_column])
return 1;
else
return -1;
}
/*
===============================================================================
MAIN CODE
===============================================================================
*/
*/
echo '<div align="right">
<a href="#" onclick="window.print()"><img align="absbottom" src="../img/printmgr.gif">&nbsp;'.get_lang('Print').'</a>
<a href="'.$_SERVER['PHP_SELF'].'?export=csv"><img align="absbottom" src="../img/excel.gif">&nbsp;'.get_lang('ExportAsCSV').'</a>
</div>';
$a_courses = Tracking :: get_courses_followed_by_coach($_user['user_id']);
$a_students = Tracking :: get_student_followed_by_coach($_user['user_id']);
$tracking_column = isset($_GET['tracking_column']) ? $_GET['tracking_column'] : 0;
$tracking_direction = isset($_GET['tracking_direction']) ? $_GET['tracking_direction'] : DESC;
if(count($a_students)>0)
{
$table = new SortableTable('tracking', 'count_student_coached');
$table -> set_header(0, get_lang('Name'),false);
$table -> set_header(1, get_lang('Time'),false);
$table -> set_header(2, get_lang('Progress'),false);
$table -> set_header(3, get_lang('Score'),false);
$table -> set_header(4, get_lang('Student_publication'),false);
$table -> set_header(5, get_lang('Messages'),false);
$table -> set_header(6, get_lang('LatestLogin'),false);
$table -> set_header(7, get_lang('Details'),false);
$table -> set_header(0, get_lang('LastName'));
$table -> set_header(1, get_lang('FirstName'));
$table -> set_header(2, get_lang('Time'),false);
$table -> set_header(3, get_lang('Progress'),false);
$table -> set_header(4, get_lang('Score'),false);
$table -> set_header(5, get_lang('Student_publication'),false);
$table -> set_header(6, get_lang('Messages'),false);
$table -> set_header(7, get_lang('LatestLogin'),false);
$table -> set_header(8, get_lang('Details'),false);
if($export_csv)
{
$csv_content[] = array (
get_lang('LastName'),
get_lang('FirstName'),
get_lang('Time'),
get_lang('Progress'),
get_lang('Score'),
get_lang('Student_publication'),
get_lang('Messages'),
get_lang('LatestLogin')
);
}
$all_datas = array();
foreach($a_students as $student_id)
{
$student_datas = UserManager :: get_user_info_by_id($student_id);
@ -313,181 +137,55 @@ if(count($a_students)>0)
$avg_student_progress = $avg_student_progress / $nb_courses_student;
$row = array();
$row[] = $student_datas['firstname'].' '.$student_datas['lastname'];
$row[] = $student_datas['lastname'];
$row[] = $student_datas['firstname'];
$row[] = api_time_to_hms($avg_time_spent);
$row[] = $avg_student_progress.' %';
$row[] = $avg_student_score.' %';
$row[] = $total_assignments;
$row[] = $total_messages;
$row[] = Tracking :: get_last_connection_date($student_id);
$row[] = '<a href="myStudents.php?student='.$student_id.'">-></a>';
$table -> addRow($row);
}
$table -> display();
echo '</table>';
}
else
{
echo get_lang('NoStudent');
}
exit;
$a_students=array();
//La personne est admin
if(api_is_platform_admin() && !isset($_GET["user_id"])){
$sqlStudent = " SELECT user_id,lastname,firstname,email
FROM $tbl_user
WHERE status = '5'
ORDER BY lastname ASC
";
$resultStudent = api_sql_query($sqlStudent);
while($a_students_temp=mysql_fetch_array($resultStudent)){
$a_current_student=array();
//If the user has already been added to the table
$a_current_student[]=$a_students_temp["user_id"];
$a_current_student[]=$a_students_temp["lastname"];
$a_current_student[]=$a_students_temp["firstname"];
$a_current_student[]=$a_students_temp["email"];
$a_students[$a_students_temp["user_id"]]=$a_current_student;
$a_students[$a_students_temp["user_id"]]["teacher"]=true;
if($export_csv)
{
$csv_content[] = $row;
}
}
elseif(api_is_platform_admin() && isset($_GET["user_id"])){
$sqlStudent = " SELECT user_id,lastname,firstname,email
FROM $tbl_user
WHERE user_id='".$_GET["user_id"]."'
ORDER BY lastname ASC
";
$resultStudent = api_sql_query($sqlStudent);
$a_current_student[]=mysql_result($resultStudent,0,"user_id");
$a_current_student[]=mysql_result($resultStudent,0,"lastname");
$a_current_student[]=mysql_result($resultStudent,0,"firstname");
$a_current_student[]=mysql_result($resultStudent,0,"email");
$row[] = '<a href="myStudents.php?student='.$student_id.'"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a>';
$a_students[$_GET["user_id"]]=$a_current_student;
$a_students[$_GET["user_id"]]["teacher"]=true;
$all_datas[] = $row;
}
else{
if(isset($_GET["user_id"])){
//It's a teacher
if(!isset($_GET["type"])){
$a_students=getStudentsFromCoursesNoSession($_GET["user_id"], $a_students);
$a_students=getStudentsFromCoursesFromSessions($_GET["user_id"], $a_students);
}
//It's a coach
else{
$a_students=getStudentsFromCoursesFromSessionsCoach($_user['user_id'], $a_students);
}
}
else{
$a_students=getStudentsFromCoursesNoSession($_user['user_id'], $a_students);
$a_students=getStudentsFromCoursesFromSessions($_user['user_id'], $a_students);
usort($all_datas, 'sort_users');
if($tracking_direction == 'ASC')
rsort($all_datas);
$a_students=getStudentsFromCoursesFromSessionsCoach($_user['user_id'], $a_students);
}
if($export_csv)
{
usort($csv_content, 'sort_users');
}
usort($a_students,"mysort");
foreach($all_datas as $row)
{
$table -> addRow($row,'align="right"');
}
$table -> display();
}
else
{
echo get_lang('NoStudent');
}
if(isset($_POST['export'])){
exportCsv($a_header,$a_data);
}
echo "<br /><br />";
echo "<form method='post' action='student.php'>
<input type='submit' name='export' value='".get_lang('exportExcel')."'/>
<form>";
// send the csv file if asked
if($export_csv)
{
ob_end_clean();
Export :: export_table_csv($csv_content, 'reporting_student_list');
}
if(!empty($_GET['student']))
{
$sqlSessionSuivie = " SELECT session.name
FROM $tbl_session as session
INNER JOIN $tbl_session_rel_user as relUser
ON session.id = relUser.id_session
AND relUser.id_user = ".$_GET['student']
;
$resultSessionSuivie = api_sql_query($sqlSessionSuivie);
echo "<br /><br />";
echo "<a name='sessionSuivie'></a>";
if(mysql_num_rows($resultSessionSuivie)>0)
{
echo "<table class='data_table'>
<tr class='tableName'>
<td colspan='2'>
<strong>".get_lang('TakenSessions')."</strong>
</td>
</tr>
<tr>
<th>
".get_lang('Session')."
</th>
<th>
".get_lang('FollowUp')."
</th>
</tr>
";
while($a_sessionSuivie = mysql_fetch_array($resultSessionSuivie))
{
echo "<tr>
<td>
".$a_sessionSuivie['name']."
</td>
<td align='center'>
<a href='../../myStudents.php?student=".$_GET['student']."#infosStudent'> -> </a>
</td>
</tr>
";
}
echo "</table>";
}
else
{
echo "<h4>".get_lang('TakenSessions')."</h4><br />";
echo get_lang('NoSession');
}
}
/*
==============================================================================
@ -495,5 +193,5 @@ exit;
==============================================================================
*/
Display :: display_footer();
Display :: display_footer();
?>

Loading…
Cancel
Save