drh can access all content (courses, users) inside a session. A new setting must be added $_configuration['drh_can_access_all_session_content'] see BT#6770

1.9.x
Julio Montoya 12 years ago
parent 2a90cccbd7
commit 480eb84e5e
  1. 12
      main/inc/lib/course.lib.php
  2. 13
      main/inc/lib/main_api.lib.php
  3. 7
      main/mySpace/index.php
  4. 386
      main/mySpace/myStudents.php
  5. 29
      main/tracking/courseLog.php

@ -199,7 +199,8 @@ class CourseManager {
* @param string Course code
* @return int the status of the user in that course
*/
public static function get_user_in_course_status($user_id, $course_code) {
public static function get_user_in_course_status($user_id, $course_code)
{
$result = Database::fetch_array(Database::query(
"SELECT status FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)."
WHERE course_code = '".Database::escape_string($course_code)."' AND user_id = ".Database::escape_string($user_id))
@ -207,7 +208,13 @@ class CourseManager {
return $result['status'];
}
public static function get_tutor_in_course_status($user_id, $course_code) {
/**
* @param int $user_id
* @param string $course_code
* @return mixed
*/
public static function get_tutor_in_course_status($user_id, $course_code)
{
$result = Database::fetch_array(Database::query(
"SELECT tutor_id FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)."
WHERE course_code = '".Database::escape_string($course_code)."' AND user_id = ".Database::escape_string($user_id))
@ -215,7 +222,6 @@ class CourseManager {
return $result['tutor_id'];
}
/**
* Unsubscribe one or more users from a course
*

@ -6601,3 +6601,16 @@ function api_remove_tags_with_space($in_html, $in_double_quote_replace = true) {
$out_res = strip_tags($out_res);
return $out_res;
}
/**
* If true, the drh can access all content (courses, users) inside a session
* @return bool
*/
function api_drh_can_access_all_session_content()
{
global $_configuration;
if (isset($_configuration['drh_can_access_all_session_content'])) {
return $_configuration['drh_can_access_all_session_content'];
}
return false;
}

@ -373,9 +373,14 @@ if (empty($session_id)) {
$courses_from_session = SessionManager::get_course_list_by_session_id($session_id);
$courses = array();
foreach ($courses_from_session as $course_item) {
if (isset($courses_of_the_platform[$course_item['code']])) {
if (api_drh_can_access_all_session_content()) {
$courses[$course_item['code']] = $course_item['code'];
} else {
if (isset($courses_of_the_platform[$course_item['code']])) {
$courses[$course_item['code']] = $course_item['code'];
}
}
}

@ -28,7 +28,7 @@ api_block_anonymous_users();
if (!api_is_allowed_to_create_course() && !api_is_session_admin() && !api_is_drh()) {
// Check if the user is tutor of the course
$user_course_status = CourseManager::get_tutor_in_course_status(api_get_user_id(), api_get_course_id());
if ($user_course_status != 1) {
if ($user_course_status != 1) {
api_not_allowed(true);
}
}
@ -117,7 +117,7 @@ if (isset($_GET['details'])) {
"name" => get_lang("MyStudents")
);
$interbreadcrumb[] = array (
"url" => "myStudents.php?student=" . Security :: remove_XSS($_GET['student']),
"url" => "myStudents.php?student=" . Security :: remove_XSS($_GET['student']),
"name" => get_lang("StudentDetails")
);
}
@ -188,22 +188,22 @@ if ($check) {
case 'reset_lp' :
$course = isset($_GET['course']) ? $_GET['course']:"";
$lp_id = isset($_GET['lp_id']) ? intval($_GET['lp_id']):"";
if (api_is_allowed_to_edit() && !empty($course) && !empty($lp_id) && !empty($student_id)) {
$course_info = api_get_course_info($course);
if (api_is_allowed_to_edit() && !empty($course) && !empty($lp_id) && !empty($student_id)) {
$course_info = api_get_course_info($course);
delete_student_lp_events($student_id, $lp_id, $course_info, $session_id);
//@todo delete the stats.track_e_exercices records. First implement this http://support.chamilo.org/issues/1334
//@todo delete the stats.track_e_exercices records. First implement this http://support.chamilo.org/issues/1334
$message = Display::return_message(get_lang('LPWasReset'),'success');
}
break;
}
break;
default:
break;
break;
}
Security::clear_token();
}
Security::clear_token();
}
// infos about user
// user info
$user_info = api_get_user_info($student_id);
$courses_in_session = array();
@ -220,14 +220,14 @@ $courses = CourseManager::get_course_list_of_user_as_course_admin(api_get_user_i
$courses_in_session_by_coach = array();
$sessions_coached_by_user = Tracking::get_sessions_coached_by_user(api_get_user_id());
//RRHH or session admin
if (api_is_session_admin() || api_is_drh()) {
// RRHH or session admin
if (api_is_session_admin() || api_is_drh()) {
$courses = CourseManager::get_courses_followed_by_drh(api_get_user_id());
$session_by_session_admin = SessionManager::get_sessions_followed_by_drh(api_get_user_id());
if (!empty($session_by_session_admin)) {
foreach ($session_by_session_admin as $session_coached_by_user) {
$courses_followed_by_coach = Tracking :: get_courses_list_from_session($session_coached_by_user['id']);
foreach ($session_by_session_admin as $session_coached_by_user) {
$courses_followed_by_coach = Tracking :: get_courses_list_from_session($session_coached_by_user['id']);
$courses_in_session_by_coach[$session_coached_by_user['id']] = $courses_followed_by_coach;
}
}
@ -242,21 +242,23 @@ if (!empty($sessions_coached_by_user)) {
}
}
$sql = "SELECT course_code FROM $tbl_course_user WHERE relation_type <> ".COURSE_RELATION_TYPE_RRHH." AND user_id = ".intval($user_info['user_id']);
$sql = "SELECT course_code FROM $tbl_course_user
WHERE relation_type <> ".COURSE_RELATION_TYPE_RRHH." AND user_id = ".intval($user_info['user_id']);
$rs = Database::query($sql);
while ($row = Database :: fetch_array($rs)) {
while ($row = Database :: fetch_array($rs)) {
if ($drh_can_access_all_courses) {
$courses_in_session[0][] = $row['course_code'];
} else {
if (isset($courses[$row['course_code']])) {
$courses_in_session[0][] = $row['course_code'];
}
}
}
}
// Get the list of sessions where the user is subscribed as student
$sql = 'SELECT id_session, course_code FROM ' . Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . ' WHERE id_user=' . intval($user_info['user_id']);
$sql = 'SELECT id_session, course_code FROM ' . Database :: get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . '
WHERE id_user=' . intval($user_info['user_id']);
$rs = Database::query($sql);
$tmp_sessions = array();
while ($row = Database :: fetch_array($rs)) {
@ -274,20 +276,18 @@ while ($row = Database :: fetch_array($rs)) {
}
}
/*if (empty($courses_in_session)) {
Display :: display_header($nameTools);
echo '<div class="actions">';
echo '<a href="javascript: window.back();" ">'.Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
echo '</div>';
Display::display_warning_message(get_lang('NoDataAvailable'));
Display::display_footer();
exit;
}*/
if (!empty($student_id)) {
if (api_is_drh() && !UserManager::is_user_followed_by_drh($student_id, api_get_user_id())) {
api_not_allowed();
}
if (api_drh_can_access_all_session_content()) {
$sessions = SessionManager::get_sessions_followed_by_drh($user_id);
$sessionList = array_keys($sessions);
if (!in_array($session_id, $sessionList)) {
api_not_allowed();
}
} else {
if (api_is_drh() && !UserManager::is_user_followed_by_drh($student_id, api_get_user_id())) {
api_not_allowed();
}
}
}
Display :: display_header($nameTools);
@ -297,11 +297,11 @@ if (isset($message)) {
}
if (!empty($student_id)) {
// Actions bar
echo '<div class="actions">';
echo '<a href="javascript: window.back();" ">'.Display::return_icon('back.png', get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="javascript: void(0);" onclick="javascript: window.print();">'.Display::return_icon('printer.png', get_lang('Print'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="' . api_get_self() . '?' . Security :: remove_XSS($_SERVER['QUERY_STRING']) . '&export=csv">'.Display::return_icon('export_csv.png', get_lang('ExportAsCSV'),'',ICON_SIZE_MEDIUM).'</a> ';
if (!empty ($user_info['email'])) {
@ -313,7 +313,7 @@ if (!empty($student_id)) {
if (!empty($student_id) && !empty ($_GET['course'])) { //only show link to connection details if course and student were defined in the URL
echo '<a href="access_details.php?student=' . $student_id . '&course=' . Security :: remove_XSS($_GET['course']) . '&amp;origin=' . Security :: remove_XSS($_GET['origin']) . '&amp;cidReq='.Security::remove_XSS($_GET['course']).'&amp;id_session='.$session_id.'">' . Display :: return_icon('statistics.png', get_lang('AccessDetails'),'',ICON_SIZE_MEDIUM).'</a>';
}
echo '</div>';
echo '</div>';
// is the user online ?
if (user_is_online($_GET['student'])) {
@ -321,26 +321,26 @@ if (!empty($student_id)) {
} else {
$online = get_lang('No');
}
// get average of score and average of progress by student
$avg_student_progress = $avg_student_score = 0;
$course_code = Security :: remove_XSS($_GET['course']);
$course_code = Security :: remove_XSS($_GET['course']);
if (!CourseManager :: is_user_subscribed_in_course($user_info['user_id'], $course_code, true)) {
unset($courses[$key]);
} else {
} else {
$avg_student_progress = Tracking::get_avg_student_progress($user_info['user_id'], $course_code, array(), $session_id);
//the score inside the Reporting table
$avg_student_score = Tracking::get_avg_student_score($user_info['user_id'], $course_code, array(), $session_id);
//var_dump($avg_student_score);
}
//var_dump($avg_student_score);
}
$avg_student_progress = round($avg_student_progress, 2);
// time spent on the course
$time_spent_on_the_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($user_info['user_id'], $course_code, $session_id));
// get information about connections on the platform by student
$first_connection_date = Tracking :: get_first_connection_date($user_info['user_id']);
if ($first_connection_date == '') {
@ -351,7 +351,7 @@ if (!empty($student_id)) {
if ($last_connection_date == '') {
$last_connection_date = get_lang('NoConnexion');
}
// cvs informations
$csv_content[] = array (
get_lang('Informations', '')
@ -388,41 +388,41 @@ if (!empty($student_id)) {
$avg_student_score
);
//Show title
$info_course = CourseManager :: get_course_information($course_code);
$coachs_name = '';
$session_name = '';
$nb_login = Tracking :: count_login_per_student($user_info['user_id'], $_GET['course']);
$session_name = '';
$nb_login = Tracking :: count_login_per_student($user_info['user_id'], $_GET['course']);
//get coach and session_name if there is one and if session_mode is activated
if ($session_id > 0) {
$session_info = api_get_session_info($session_id);
$session_info = api_get_session_info($session_id);
$course_coachs = api_get_coachs_from_course($session_id, $course_code);
$nb_login = '';
$nb_login = '';
if (!empty($course_coachs)) {
$info_tutor_name = array();
foreach ($course_coachs as $course_coach) {
$info_tutor_name[] = api_get_person_name($course_coach['firstname'], $course_coach['lastname']);
}
$info_course['tutor_name'] = implode(",",$info_tutor_name);
} elseif ($session_coach_id != 0) {
$session_coach_id = intval($session_info['id_coach']);
} elseif ($session_coach_id != 0) {
$session_coach_id = intval($session_info['id_coach']);
$coach_info = UserManager::get_user_info_by_id($session_coach_id);
$info_course['tutor_name'] = api_get_person_name($coach_info['firstname'], $coach_info['lastname']);
}
$coachs_name = $info_course['tutor_name'];
$session_name = $session_info['name'];
} // end
$info_course = CourseManager :: get_course_information($get_course_code);
$info_course = CourseManager :: get_course_information($get_course_code);
$table_title = Display::return_icon('user.png', get_lang('User'), array(), ICON_SIZE_SMALL).$user_info['complete_name'];
echo Display::page_subheader($table_title);
echo '<table width="100%" border="0">';
echo '<tr>';
$image_array = UserManager :: get_user_picture_path_by_id($user_info['user_id'], 'web', false, true);
echo '<td class="borderRight" width="10%" valign="top">';
@ -453,7 +453,7 @@ if (!empty($student_id)) {
<td><?php echo get_lang('Name') . ' : '.$user_info['complete_name']; ?></td>
</tr>
<tr>
<td><?php echo get_lang('Email') . ' : ';
<td><?php echo get_lang('Email') . ' : ';
if (!empty ($user_info['email'])) {
echo '<a href="mailto:' . $user_info['email'] . '">' . $user_info['email'] . '</a>';
} else {
@ -462,7 +462,7 @@ if (!empty($student_id)) {
</td>
</tr>
<tr>
<td> <?php echo get_lang('Tel') . ' : ';
<td> <?php echo get_lang('Tel') . ' : ';
if (!empty ($user_info['phone'])) {
echo $user_info['phone'];
} else {
@ -472,7 +472,7 @@ if (!empty($student_id)) {
</td>
</tr>
<tr>
<td> <?php echo get_lang('OfficialCode') . ' : ';
<td> <?php echo get_lang('OfficialCode') . ' : ';
if (!empty ($user_info['official_code'])) {
echo $user_info['official_code'];
} else {
@ -485,7 +485,7 @@ if (!empty($student_id)) {
<td><?php echo get_lang('OnLine') . ' : '.$online; ?> </td>
</tr>
<?php
// Display timezone if the user selected one and if the admin allows the use of user's timezone
$timezone = null;
$timezone_user = UserManager::get_extra_user_data_by_field($user_info['user_id'],'timezone');
@ -503,7 +503,7 @@ if (!empty($student_id)) {
?>
</table>
</td>
<td class="borderLeft" width="35%" valign="top">
<table width="100%" class="data_table">
<tr>
@ -516,7 +516,7 @@ if (!empty($student_id)) {
<td align="right"><?php echo get_lang('LatestLogin') ?></td>
<td align="left"><?php echo $last_connection_date ?></td>
</tr>
<?php if (isset($_GET['details']) && $_GET['details'] == 'true') {?>
<tr>
<td align="right"><?php echo get_lang('TimeSpentInTheCourse') ?></td>
@ -542,7 +542,7 @@ if (!empty($student_id)) {
</td>
</tr>
</table>
<?php
$table_title = '';
@ -559,32 +559,32 @@ if (!empty($info_course['title'])) {
echo Display::page_subheader($table_title);
if (empty($_GET['details'])) {
$csv_content[] = array ();
$csv_content[] = array (
get_lang('Session', ''),
get_lang('Course', ''),
get_lang('Time', ''),
get_lang('Progress', ''),
get_lang('Score', ''),
get_lang('AttendancesFaults', ''),
get_lang('Evaluations')
);
$csv_content[] = array();
$csv_content[] = array(
get_lang('Session', ''),
get_lang('Course', ''),
get_lang('Time', ''),
get_lang('Progress', ''),
get_lang('Score', ''),
get_lang('AttendancesFaults', ''),
get_lang('Evaluations')
);
$attendance = new Attendance();
foreach ($courses_in_session as $key => $courses) {
foreach ($courses_in_session as $key => $courses) {
$session_id = $key;
$session_info = api_get_session_info($session_id);
$session_name = $session_info['name'];
$date_start = '';
if (!empty($session_info['date_start']) && $session_info['date_start'] != '0000-00-00') {
if (!empty($session_info['date_start']) && $session_info['date_start'] != '0000-00-00') {
$date_start = api_format_date($session_info['date_start'], DATE_FORMAT_SHORT);
}
$date_end = '';
if (!empty($session_info['date_end']) && $session_info['date_end'] != '0000-00-00') {
if (!empty($session_info['date_end']) && $session_info['date_end'] != '0000-00-00') {
$date_end = api_format_date($session_info['date_end'], DATE_FORMAT_SHORT);
}
if (!empty($date_start) && !empty($date_end)) {
@ -596,11 +596,11 @@ if (empty($_GET['details'])) {
} else {
$title = Display::return_icon('session.png', get_lang('Session'), array(), ICON_SIZE_SMALL).' '.$session_name.($date_session?' ('.$date_session.')':'');
}
// Courses
echo '<h3>'.$title.'</h3>';
echo '<table class="data_table">';
echo '<tr>
<th>'.get_lang('Course').'</th>
@ -609,52 +609,52 @@ if (empty($_GET['details'])) {
<th>'.get_lang('Score').'</th>
<th>'.get_lang('AttendancesFaults').'</th>
<th>'.get_lang('Evaluations').'</th>
<th>'.get_lang('Details').'</th>
<th>'.get_lang('Details').'</th>
</tr>';
if (!empty($courses)) {
if (!empty($courses)) {
foreach ($courses as $course_code) {
if (CourseManager :: is_user_subscribed_in_course($student_id, $course_code, true)) {
$course_info = CourseManager :: get_course_information($course_code);
$time_spent_on_course = api_time_to_hms(Tracking :: get_time_spent_on_the_course($user_info['user_id'], $course_code, $session_id));
// get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_by_course($student_id, $course_code, $session_id);
if (!empty($results_faults_avg['total'])) {
if (!empty($results_faults_avg['total'])) {
if (api_is_drh()) {
$attendances_faults_avg = '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$course_code.'&id_session='.$session_id.'&student_id='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
$attendances_faults_avg = '<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$course_code.'&id_session='.$session_id.'&student_id='.$student_id.'">'.$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
} else {
$attendances_faults_avg = $results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)';
}
} else {
$attendances_faults_avg = '0/0 (0%)';
}
// get evaluatios by student
// get evaluatios by student
$cats = Category::load(null, null, $course_code, null, null, $session_id);
$scoretotal = array();
if (isset($cats) && isset($cats[0])) {
if (!empty($session_id)) {
$scoretotal= $cats[0]->calc_score($student_id, $course_code, $session_id);
if (!empty($session_id)) {
$scoretotal= $cats[0]->calc_score($student_id, $course_code, $session_id);
} else {
$scoretotal= $cats[0]->calc_score($student_id, $course_code);
}
}
$scoretotal_display = '0/0 (0%)';
if (!empty($scoretotal)) {
$scoretotal_display = round($scoretotal[0],1).'/'.round($scoretotal[1],1).' ('.round(($scoretotal[0] / $scoretotal[1]) * 100,2) . ' %)';
}
$progress = Tracking::get_avg_student_progress($user_info['user_id'], $course_code, null, $session_id);
$score = Tracking :: get_avg_student_score($user_info['user_id'], $course_code, null, $session_id);
$progress = empty($progress) ? '0%' : $progress.'%';
$score = empty($score) ? '0%' : $score.'%';
$csv_content[] = array (
$session_name,
$course_info['title'],
@ -664,7 +664,7 @@ if (empty($_GET['details'])) {
$attendances_faults_avg,
$scoretotal_display
);
echo '<tr>
<td >'.$course_info['title'].'</td>
<td >'.$time_spent_on_course .'</td>
@ -672,7 +672,7 @@ if (empty($_GET['details'])) {
<td >'.$score.'</td>
<td >'.$attendances_faults_avg.'</td>
<td >'.$scoretotal_display.'</td>';
if (isset ($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$course_info['code'].'&id_coach='.Security::remove_XSS($_GET['id_coach']).'&origin='.Security::remove_XSS($_GET['origin']).'&id_session='.$session_id.'#infosStudent"><img src="'.api_get_path(WEB_IMG_PATH).'2rightarrow.gif" border="0" /></a></td>';
} else {
@ -688,10 +688,10 @@ if (empty($_GET['details'])) {
}
} else {
$csv_content[] = array ();
$csv_content[] = array (str_replace('&nbsp;', '', $table_title));
$csv_content[] = array (str_replace('&nbsp;', '', $table_title));
$t_lp = Database :: get_course_table(TABLE_LP_MAIN);
// csv export headers
$csv_content[] = array ();
$csv_content[] = array (
@ -702,18 +702,18 @@ if (empty($_GET['details'])) {
get_lang('Progress', ''),
get_lang('LastConnexion', '')
);
if (empty($session_id)) {
$sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp WHERE session_id = 0 AND c_id = {$info_course['real_id']} ORDER BY lp.display_order";
} else {
$sql_lp = " SELECT lp.name, lp.id FROM $t_lp lp WHERE c_id = {$info_course['real_id']} ORDER BY lp.display_order";
}
$rs_lp = Database::query($sql_lp);
$token = Security::get_token();
$token = Security::get_token();
if (Database :: num_rows($rs_lp) > 0) {
?>
<!-- LPs-->
<table class="data_table">
<tr>
@ -723,57 +723,57 @@ if (empty($_GET['details'])) {
<th><?php echo get_lang('LatestAttemptAverageScore').' '; Display :: display_icon('info3.gif', get_lang('AverageIsCalculatedBasedInTheLatestAttempts'), array ( 'align' => 'absmiddle', 'hspace' => '3px')); ?></th>
<th><?php echo get_lang('Progress').' '; Display :: display_icon('info3.gif', get_lang('LPProgressScore'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
<th><?php echo get_lang('LastConnexion').' '; Display :: display_icon('info3.gif', get_lang('LastTimeTheCourseWasUsed'), array ('align' => 'absmiddle','hspace' => '3px')); ?></th>
<?php
echo '<th>'.get_lang('Details').'</th>';
<?php
echo '<th>'.get_lang('Details').'</th>';
if (api_is_allowed_to_edit()) {
echo '<th>'.get_lang('ResetLP').'</th>';
}
?>
</tr>
<?php
$i = 0;
while ($learnpath = Database :: fetch_array($rs_lp)) {
$lp_id = intval($learnpath['id']);
$lp_name = $learnpath['name'];
$any_result = false;
// Get progress in lp
// Get progress in lp
$progress = Tracking::get_avg_student_progress($student_id, $course_code, array($lp_id), $session_id);
if ($progress === null) {
if ($progress === null) {
$progress = '0%';
} else {
} else {
$any_result = true;
}
// Get time in lp
$total_time = Tracking::get_time_spent_in_lp($student_id, $course_code, array($lp_id),$session_id);
$total_time = Tracking::get_time_spent_in_lp($student_id, $course_code, array($lp_id),$session_id);
if (!empty($total_time)) $any_result = true;
// Get last connection time in lp
$start_time = Tracking::get_last_connection_time_in_lp($student_id, $course_code, $lp_id, $session_id);
if (!empty($start_time)) {
$start_time = api_convert_and_format_date($start_time, DATE_TIME_FORMAT_LONG);
} else {
$start_time = '-';
}
if (!empty($total_time)) $any_result = true;
// Quizz in lp
// Quizz in lp
$score = Tracking::get_avg_student_score($student_id, $course_code, array($lp_id),$session_id);
// Latest exercise results in a LP
// Latest exercise results in a LP
$score_latest = Tracking :: get_avg_student_score($student_id, $course_code, array($lp_id),$session_id, false, true);
if ($i % 2 == 0) $css_class = "row_even";
else $css_class = "row_odd";
$i++;
// csv export content
$csv_content[] = array (
api_html_entity_decode(stripslashes($lp_name), ENT_QUOTES, $charset),
@ -782,38 +782,38 @@ if (empty($_GET['details'])) {
$score_latest . '%',
$progress.'%',
$start_time
);
echo '<tr class="'.$css_class.'">';
);
echo '<tr class="'.$css_class.'">';
echo Display::tag('td', stripslashes($lp_name));
echo Display::tag('td', api_time_to_hms($total_time));
if (!is_null($score)) {
if (is_numeric($score)) {
if (is_numeric($score)) {
$score = $score.'%';
}
}
echo Display::tag('td', $score);
if (!is_null($score_latest)) {
if (is_numeric($score_latest)) {
if (is_numeric($score_latest)) {
$score_latest = $score_latest.'%';
}
}
echo Display::tag('td', $score_latest);
if (is_numeric($progress)) {
}
echo Display::tag('td', $score_latest);
if (is_numeric($progress)) {
$progress = $progress.'%';
} else {
$progress = '-';
}
echo Display::tag('td', $progress);
//Do not change with api_convert_and_format_date, because this value came from the lp_item_view table
//which implies several other changes not a priority right now
echo Display::tag('td', $start_time);
//Do not change with api_convert_and_format_date, because this value came from the lp_item_view table
//which implies several other changes not a priority right now
echo Display::tag('td', $start_time);
if ($any_result === true) {
$from = '';
if ($from_myspace) {
@ -822,19 +822,19 @@ if (empty($_GET['details'])) {
$link = Display::url('<img src="../img/2rightarrow.gif" border="0" />','lp_tracking.php?course='.Security::remove_XSS($_GET['course']).$from.'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student_id='.$user_info['user_id'].'&id_session='.$session_id);
echo Display::tag('td', $link);
}
if (api_is_allowed_to_edit()) {
echo '<td>';
if ($any_result === true) {
if (api_is_allowed_to_edit()) {
echo '<td>';
if ($any_result === true) {
echo '<a href="myStudents.php?action=reset_lp&sec_token='.$token.'&course='.Security::remove_XSS($_GET['course']).'&details='.Security::remove_XSS($_GET['details']).'&origin='.Security::remove_XSS($_GET['origin']).'&lp_id='.$learnpath['id'].'&student='.$user_info['user_id'].'&details=true&id_session='.Security::remove_XSS($_GET['id_session']).'">';
echo Display::return_icon('clean.png',get_lang('Clean'),'',ICON_SIZE_SMALL).'</a>';
echo '</a>';
}
echo '</td>';
}
echo '</td>';
echo '</tr>';
}
}
$data_learnpath[$i][] = $lp_name;
$data_learnpath[$i][] = $progress . '%';
$data_learnpath[$i][] = $progress . '%';
}
} else {
//echo '<tr><td colspan="6">'.get_lang('NoLearnpath').'</td></tr>';
@ -859,22 +859,22 @@ if (empty($_GET['details'])) {
get_lang('Score'),
get_lang('Attempts')
);
$t_quiz = Database :: get_course_table(TABLE_QUIZ_TEST);
$sql_exercices = "SELECT quiz.title, id FROM " . $t_quiz . " AS quiz
WHERE quiz.c_id = ".$info_course['real_id']." AND
active='1' AND
active='1' AND
(quiz.session_id = $session_id OR quiz.session_id = 0)
ORDER BY quiz.title ASC ";
$result_exercices = Database::query($sql_exercices);
$i = 0;
if (Database :: num_rows($result_exercices) > 0) {
while ($exercices = Database :: fetch_array($result_exercices)) {
while ($exercices = Database :: fetch_array($result_exercices)) {
$exercise_id = intval($exercices['id']);
$count_attempts = Tracking::count_student_exercise_attempts($student_id, $course_code, $exercise_id, 0, 0, $session_id);
$score_percentage = Tracking::get_avg_student_exercise_score($student_id, $course_code, $exercise_id, $session_id);
$count_attempts = Tracking::count_student_exercise_attempts($student_id, $course_code, $exercise_id, 0, 0, $session_id);
$score_percentage = Tracking::get_avg_student_exercise_score($student_id, $course_code, $exercise_id, $session_id);
$csv_content[] = array (
$exercices['title'],
@ -886,9 +886,9 @@ if (empty($_GET['details'])) {
else $css_class = 'row_even';
echo '<tr class="'.$css_class.'"><td>'.$exercices['title'].'</td>';
echo '<td>';
if ($count_attempts > 0) {
echo $score_percentage . '%';
} else {
@ -900,14 +900,14 @@ if (empty($_GET['details'])) {
echo '<td>'.$count_attempts.'</td>';
echo '<td>';
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . '
WHERE exe_exo_id ="'.$exercise_id.'" AND
exe_user_id ="'.$student_id.'" AND
$sql_last_attempt = 'SELECT exe_id FROM ' . $tbl_stats_exercices . '
WHERE exe_exo_id ="'.$exercise_id.'" AND
exe_user_id ="'.$student_id.'" AND
exe_cours_id ="'.$course_code.'" AND
session_id ="'.$session_id.'" AND
status = "" AND
orig_lp_id = 0 AND
orig_lp_item_id = 0
status = "" AND
orig_lp_id = 0 AND
orig_lp_item_id = 0
ORDER BY exe_date DESC LIMIT 1';
$result_last_attempt = Database::query($sql_last_attempt);
if (Database :: num_rows($result_last_attempt) > 0) {
@ -916,11 +916,11 @@ if (empty($_GET['details'])) {
echo '<a href="../exercice/exercise_show.php?id=' . $id_last_attempt . '&cidReq='.$course_code.'&session_id='.$session_id.'&student='.$student_id.'&origin='.(empty($_GET['origin'])?'tracking':Security::remove_XSS($_GET['origin'])).'"> <img src="' . api_get_path(WEB_IMG_PATH) . 'quiz.gif" border="0" /> </a>';
}
echo '</td>';
echo '<td>';
$all_attempt_url = "../exercice/exercise_report.php?exerciseId=$exercise_id&cidReq=$course_code&filter_by_user=$student_id&id_session=$session_id";
echo Display::url(Display::return_icon('test_results.png', get_lang('AllAttempts'), array(), ICON_SIZE_SMALL), $all_attempt_url );
echo '</td></tr>';
$data_exercices[$i][] = $exercices['title'];
$data_exercices[$i][] = $score_percentage . '%';
@ -932,25 +932,25 @@ if (empty($_GET['details'])) {
echo '<tr><td colspan="6">'.get_lang('NoExercise').'</td></tr>';
}
echo '</table>';
//@when using sessions we do not show the survey list
if (empty($session_id)) {
$survey_list = survey_manager::get_surveys($course_code, $session_id);
$survey_list = survey_manager::get_surveys($course_code, $session_id);
$survey_data = array();
foreach($survey_list as $survey) {
$user_list = survey_manager::get_people_who_filled_survey($survey['survey_id'], false, $info_course['real_id']);
$survey_done = Display::return_icon("accept_na.png", get_lang('NoAnswer'), array(), ICON_SIZE_SMALL);
$survey_done = Display::return_icon("accept_na.png", get_lang('NoAnswer'), array(), ICON_SIZE_SMALL);
if (in_array($student_id, $user_list)) {
$survey_done = Display::return_icon("accept.png", get_lang('Answered'), array(), ICON_SIZE_SMALL);
$survey_done = Display::return_icon("accept.png", get_lang('Answered'), array(), ICON_SIZE_SMALL);
}
$data = array('title' => $survey['title'], 'done' => $survey_done);
$survey_data[] = $data;
}
$survey_data[] = $data;
}
if (!empty($survey_list)) {
$table = new HTML_Table(array('class' => 'data_table'));
$header_names = array(get_lang('Survey'), get_lang('Answered'));
$row = 0;
@ -974,21 +974,21 @@ if (empty($_GET['details'])) {
$row++;
}
}
echo $table->toHtml();
echo $table->toHtml();
}
}
// line about other tools
echo '<table class="data_table">';
$csv_content[] = array ();
$nb_assignments = Tracking::count_student_assignments($student_id, $course_code, $session_id);
$messages = Tracking::count_student_messages($student_id, $course_code, $session_id);
$links = Tracking::count_student_visited_links($student_id, $course_code, $session_id);
$chat_last_connection = Tracking::chat_last_connection($student_id, $course_code, $session_id);
$chat_last_connection = Tracking::chat_last_connection($student_id, $course_code, $session_id);
$documents = Tracking::count_student_downloaded_documents($student_id, $course_code, $session_id);
$uploaded_documents = Tracking::count_student_uploaded_documents($student_id, $course_code, $session_id);
$uploaded_documents = Tracking::count_student_uploaded_documents($student_id, $course_code, $session_id);
$csv_content[] = array (
get_lang('Student_publication'),
$nb_assignments
@ -1047,7 +1047,7 @@ if (empty($_GET['details'])) {
</table>
<?php
} //end details
} //end details
}
if ($export_csv) {
ob_end_clean();

@ -25,6 +25,10 @@ if (!empty($course_info)) {
$from_myspace = false;
$from = isset($_GET['from']) ? $_GET['from'] : null;
// Starting the output buffering when we are exporting the information.
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$session_id = intval($_REQUEST['id_session']);
if ($from == 'myspace') {
$from_myspace = true;
$this_section = "session_my_space";
@ -36,10 +40,29 @@ if ($from == 'myspace') {
$is_allowedToTrack = api_is_platform_admin() || api_is_allowed_to_create_course() || api_is_session_admin() || api_is_drh() || api_is_course_tutor();
if (!$is_allowedToTrack) {
api_not_allowed();
api_not_allowed(true);
exit;
}
if (api_is_drh()) {
// Blocking course for drh
if (api_drh_can_access_all_session_content()) {
$sessions = SessionManager::get_sessions_followed_by_drh($user_id);
$sessionList = array_keys($sessions);
if (!in_array($session_id, $sessionList)) {
api_not_allowed();
}
} else {
$coursesFollowedList = CourseManager::get_courses_followed_by_drh(api_get_user_id());
$coursesFollowedList = array_keys($coursesFollowedList);
if (!in_array(api_get_course_id(), $coursesFollowedList)) {
api_not_allowed(true);
exit;
}
}
}
// Including additional libraries.
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpath.class.php';
@ -53,10 +76,6 @@ require_once api_get_path(SYS_CODE_PATH).'resourcelinker/resourcelinker.inc.php'
require_once api_get_path(SYS_CODE_PATH).'survey/survey.lib.php';
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
// Starting the output buffering when we are exporting the information.
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$session_id = intval($_REQUEST['id_session']);
if ($export_csv) {
if (!empty($session_id)) {
$_SESSION['id_session'] = $session_id;

Loading…
Cancel
Save