Allow to select all the sessions for reports

1.9.x
Francis Gonzales 11 years ago
parent ed420efb1c
commit 0aa8e0d8ae
  1. 83
      main/inc/lib/sessionmanager.lib.php
  2. 73
      main/mySpace/index.php

@ -744,8 +744,10 @@ class SessionManager
*/
public static function get_session_progress($sessionId, $courseId, $date_from, $date_to, $options)
{
$getAllSessions = false;
if (empty($sessionId)) {
$sessionId = 0;
$getAllSessions = true;
}
//tables
$session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
@ -794,14 +796,18 @@ class SessionManager
if (!empty($sessionId)) {
$where .= ' AND id_session = %s';
$queryVariables[] = $sessionId;
$sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.course_code
$sql = "SELECT u.user_id, u.lastname, u.firstname, u.username,
u.email, s.course_code, s.id_session
FROM $session_course_user s
INNER JOIN $user u ON u.user_id = s.id_user
$where $order $limit";
} else {
$sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.course_code
FROM $course_rel_user s
INNER JOIN $user u ON u.user_id = s.user_id
// $where .= ' AND id_session = %s';
// $queryVariables[] = $sessionId;
$sql = "SELECT u.user_id, u.lastname, u.firstname, u.username,
u.email, s.course_code, s.id_session
FROM $session_course_user s
INNER JOIN $user u ON u.user_id = s.id_user
$where $order $limit";
}
@ -838,21 +844,29 @@ class SessionManager
* Exercises
*/
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
$exercises = get_all_exercises($course, $sessionId);
$exercises = get_all_exercises($course, $sessionId, false, '', $getAllSessions);
$exercises_total = count($exercises);
/**
* Assignments
*/
//total
$sql = "SELECT count(w.id) as count
FROM $workTable w
LEFT JOIN $workTableAssignment a ON (a.publication_id = w.id AND a.c_id = w.c_id)
WHERE w.c_id = %s
AND parent_id = 0
AND active IN (1, 0)
AND session_id = %s";
if ($getAllSessions) {
$sql = "SELECT count(w.id) as count
FROM $workTable w
LEFT JOIN $workTableAssignment a ON (a.publication_id = w.id AND a.c_id = w.c_id)
WHERE w.c_id = %s
AND parent_id = 0
AND active IN (1, 0)";
} else {
$sql = "SELECT count(w.id) as count
FROM $workTable w
LEFT JOIN $workTableAssignment a ON (a.publication_id = w.id AND a.c_id = w.c_id)
WHERE w.c_id = %s
AND parent_id = 0
AND active IN (1, 0)
AND session_id = %s";
}
$sql_query = sprintf($sql, $course['real_id'], $sessionId);
if (self::$_debug) {
@ -865,8 +879,13 @@ class SessionManager
/**
* Wiki
*/
$sql = "SELECT count(distinct page_id) as count FROM $wiki
WHERE c_id = %s and session_id = %s";
if ($getAllSessions) {
$sql = "SELECT count(distinct page_id) as count FROM $wiki
WHERE c_id = %s";
} else {
$sql = "SELECT count(distinct page_id) as count FROM $wiki
WHERE c_id = %s and session_id = %s";
}
$sql_query = sprintf($sql, $course['real_id'], $sessionId);
if (self::$_debug) {
error_log($sql_query);
@ -895,9 +914,15 @@ class SessionManager
* Forums
*/
//total
$sql = "SELECT count(*) as count
FROM $forum f
where f.c_id = %s and f.session_id = %s";
if ($getAllSessions) {
$sql = "SELECT count(*) as count
FROM $forum f
where f.c_id = %s";
} else {
$sql = "SELECT count(*) as count
FROM $forum f
where f.c_id = %s and f.session_id = %s";
}
$sql_query = sprintf($sql, $course['real_id'], $sessionId);
if (self::$_debug) {
error_log($sql_query);
@ -917,7 +942,7 @@ class SessionManager
AND access_cours_code = '%s'
AND access_session_id = %s
AND access_user_id = %s ";
$sql_query = sprintf($sql, $course['code'], $sessionId, $user['user_id']);
$sql_query = sprintf($sql, $course['code'], $user['id_session'], $user['user_id']);
if (self::$_debug) {
error_log($sql_query);
}
@ -927,17 +952,17 @@ class SessionManager
//Lessons
//TODO: Lessons done and left is calculated by progress per item in lesson, maybe we should calculate it only per completed lesson?
$lessons_progress = Tracking::get_avg_student_progress($user['user_id'], $course['code'], array(), $sessionId);
$lessons_progress = Tracking::get_avg_student_progress($user['user_id'], $course['code'], array(), $user['id_session']);
$lessons_done = ($lessons_progress * $lessons_total) / 100;
$lessons_left = $lessons_total - $lessons_done;
//Exercises
$exercises_progress = str_replace('%', '', Tracking::get_exercise_student_progress($exercises, $user['user_id'], $course['code'], $sessionId));
$exercises_progress = str_replace('%', '', Tracking::get_exercise_student_progress($exercises, $user['user_id'], $course['code'], $user['id_session']));
$exercises_done = ($exercises_progress * $exercises_total) / 100;
$exercises_left = $exercises_total - $exercises_done;
//Assignments
$assignments_done = Tracking::count_student_assignments($user['user_id'], $course['code'], $sessionId);
$assignments_done = Tracking::count_student_assignments($user['user_id'], $course['code'], $user['id_session']);
$assignments_left = $assignments_total - $assignments_done;
if (!empty($assignments_total)) {
$assignments_progress = round((( $assignments_done * 100 ) / $assignments_total ), 2);
@ -951,7 +976,7 @@ class SessionManager
$sql = "SELECT count(*) as count
FROM $wiki
where c_id = %s and session_id = %s and user_id = %s";
$sql_query = sprintf($sql, $course['real_id'], $sessionId, $user['user_id']);
$sql_query = sprintf($sql, $course['real_id'], $user['id_session'], $user['user_id']);
if (self::$_debug) {
error_log($sql_query);
}
@ -996,7 +1021,7 @@ class SessionManager
$sql = "SELECT count(distinct f.forum_id) as count FROM $forum_post p
INNER JOIN $forum f ON f.forum_id = p.forum_id
WHERE p.poster_id = %s and f.session_id = %s and p.c_id = %s";
$sql_query = sprintf($sql, $user['user_id'], $sessionId, $course['real_id']);
$sql_query = sprintf($sql, $user['user_id'], $user['id_session'], $course['real_id']);
if (self::$_debug) {
error_log($sql_query);
}
@ -1014,11 +1039,11 @@ class SessionManager
//Overall Total
$overall_total = ($course_description_progress + $exercises_progress + $forums_progress + $assignments_progress + $wiki_progress + $surveys_progress) / 6;
$link = '<a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student='. $user[0]. '&details=true&course=' . $course['code'] . '&id_session=' . $sessionId . '"> %s </a>';
$linkForum = '<a href="' . api_get_path(WEB_CODE_PATH) . 'forum/index.php?cidReq=' . $course['code'] . '&id_session=' . $sessionId . '"> %s </a>';
$linkWork = '<a href="' . api_get_path(WEB_CODE_PATH) . 'work/work.php?cidReq=' . $course['code'] . '&id_session=' . $sessionId . '"> %s </a>';
$linkWiki = '<a href="' . api_get_path(WEB_CODE_PATH) . 'wiki/index.php?cidReq=' . $course['code'] . '&session_id=' . $sessionId . '&action=statistics"> %s </a>';
$linkSurvey = '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php?cidReq=' . $course['code'] . '&id_session=' . $sessionId . '"> %s </a>';
$link = '<a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student='. $user[0]. '&details=true&course=' . $course['code'] . '&id_session=' . $user['id_session'] . '"> %s </a>';
$linkForum = '<a href="' . api_get_path(WEB_CODE_PATH) . 'forum/index.php?cidReq=' . $course['code'] . '&id_session=' . $user['id_session'] . '"> %s </a>';
$linkWork = '<a href="' . api_get_path(WEB_CODE_PATH) . 'work/work.php?cidReq=' . $course['code'] . '&id_session=' . $user['id_session'] . '"> %s </a>';
$linkWiki = '<a href="' . api_get_path(WEB_CODE_PATH) . 'wiki/index.php?cidReq=' . $course['code'] . '&session_id=' . $user['id_session'] . '&action=statistics"> %s </a>';
$linkSurvey = '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php?cidReq=' . $course['code'] . '&id_session=' . $user['id_session'] . '"> %s </a>';
$table[] = array(
'lastname' => $user[1],

@ -644,6 +644,7 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
break;
case 'progressoverview':
$tool_name = get_lang('DisplayProgressOverview');
$a = $an = 'search_session_all';
break;
case 'exerciseprogress':
$tool_name = get_lang('DisplayExerciseProgress');
@ -654,11 +655,7 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
}
$sessionFilter->addElement('header', '', $tool_name);
//<<<<<<< HEAD
//=======
// $url = $ajax_path . 'session.ajax.php?a=' . $sessionAjax;
//>>>>>>> 3d4cd1fb23d8b65bea0b816416dc9c45302ccf9a
$sessionList = array();
$courseList = array();
$sessionId = isset($_GET['session_id']) ? $_GET['session_id'] : null;
@ -666,9 +663,7 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
if (!empty($sessionId)) {
$sessionList = array();
//<<<<<<< HEAD
// $sessionInfo = SessionManager::fetch($sessionId);
// $sessionList[] = array('id' => $sessionInfo['id'], 'text' => $sessionInfo['name']);
if ($sessionId == 'T') {
$sessionInfo = SessionManager::fetch($sessionId);
$sessionList[] = array('id' => 'T', 'text' => 'TODOS');
@ -684,9 +679,7 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
$courseInfo = api_get_course_info_by_id($courseId);
$courseList[] = array('id' => $courseInfo['real_id'], 'text' => $courseInfo['name']);
$an = 'search_session_by_course';
//=======
//
//>>>>>>> 3d4cd1fb23d8b65bea0b816416dc9c45302ccf9a
}
$url = $ajax_path . 'session.ajax.php?a='. $an . '&course_id=' . $_GET['course_id'];
@ -702,11 +695,9 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
if ($display == 'lpprogressoverview') {
$a = 'search_course_by_session_all';
}
<<<<<<< HEAD
*/
//=======
//
//>>>>>>> 3d4cd1fb23d8b65bea0b816416dc9c45302ccf9a
$url = $ajax_path . 'course.ajax.php?a='. $a .'&session_id=' . $_GET['session_id'];
$sessionFilter->addElement('select_ajax', 'course_name', get_lang('SearchCourse'), null, array('url' => $url, 'defaults' => $courseList, 'width' => '400px', 'minimumInputLength' => $minimumInputLength));
@ -817,10 +808,10 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
}*/
//date filter
// if (!in_array($display, array('surveyoverview', 'progressoverview', 'lpprogressoverview'))) {
if (!in_array($display, array('surveyoverview', 'progressoverview'))) {
$sessionFilter->addElement('text', 'from', get_lang('From'), array('id' => 'date_from', 'value' => (!empty($_GET['date_from']) ? $_GET['date_from'] : ''), 'style' => 'width:75px' ));
$sessionFilter->addElement('text', 'to', get_lang('Until'), array('id' => 'date_to', 'value' => (!empty($_GET['date_to']) ? $_GET['date_to'] : ''), 'style' => 'width:75px' ));
// }
}
$sessionFilter->addElement('submit', '', get_lang('Generate'), 'id="generateReport"');
echo '<div class="">';
@ -832,10 +823,10 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
$a = 'search_course_by_session';
}
if ($display == 'lpprogressoverview') {
if ($display == 'lpprogressoverview' || $display == 'progressoverview') {
$a = 'search_course_by_session_all';
}
$url = $ajax_path . 'course.ajax.php?a='. $a .'&session_id=' . $_GET['session_id'];
echo '<script>
$(function() {
@ -879,42 +870,22 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
dateFormat: "yy-mm-dd"
});
$("#session_name").on("change", function() {
var sessionId = $("#session_name").val();
var courseId = $("#course_name").val();
if (isEmpty(sessionId)) {
select2("#course_name", "' . $ajax_path . 'course.ajax.php?a=search_course");
if (isEmpty(courseId)) {
select2("#session_name", "' . $ajax_path . 'session.ajax.php?a=search_session");
} else {
select2("#session_name", "' . $ajax_path . 'session.ajax.php?a=search_session_by_course&course_id=" + courseId);
}
} else {
select2("#course_name", "' . $ajax_path . 'course.ajax.php?a=search_course_by_session&session_id=" + sessionId);
}
$("#session_name").on("change", function() {
var sessionId = $(this).val();
//window.location = "'.$self.'?view=admin&display='.$display.'&session_id="+sessionId;
//<<<<<<< HEAD
// /*
// if (isEmpty(courseId)) {
// select2("#course_name", "'. $ajax_path . 'course.ajax.php?a=' . $a . '&session_id=" + sessionId);
//=======
select2("#course_name", "' . $ajax_path . 'course.ajax.php?a=' . $a . '&session_id=" + sessionId);
// });
// if (display == "lpprogressoverview" || display == "progressoverview" || display == "surveyoverview") {
// if (isEmpty($("#session_name").val())) {
// $("#course_name").select2("readonly", true);
//>>>>>>> 3d4cd1fb23d8b65bea0b816416dc9c45302ccf9a
// }
// */
select2("#course_name", "' . $ajax_path . 'course.ajax.php?a=' . $a . '&session_id=" + sessionId);
});
if (display == "lpprogressoverview" || display == "progressoverview" || display == "surveyoverview") {
if (isEmpty($("#session_name").val())) {
$("#course_name").select2("readonly", true);
}}
});
$("#course_name").on("change", function() {
var sessionId = $("#session_name").val();
var courseId = $("#course_name").val();
var display = "' . $display . '";
console.log("session:"+sessionId);
console.log("course:"+courseId);
if (isEmpty(courseId)) {
select2("#session_name", "' . $ajax_path . 'session.ajax.php?a=search_session");
if (isEmpty(sessionId)) {
@ -949,8 +920,8 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
select2("#course_name", "' . $ajax_path . 'course.ajax.php?a=search_course_by_session&session_id=" + sessionId);
}
select2("#student_name", urlajax);
}*/
});
}
});*/
' . $script . '
});
function areBothFilled() {
@ -1038,7 +1009,7 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
} else if($display == 'progressoverview') {
if (!empty($_GET['session_id'])) {
if (!empty($_GET['course_id'])) {
echo MySpace::display_tracking_progress_overview(intval($_GET['session_id']), intval($_GET['course_id']), $_GET['date_from'], $_GET['date_to']);
echo MySpace::display_tracking_progress_overview($sessionId, intval($_GET['course_id']), $_GET['date_from'], $_GET['date_to']);
} else {
Display::display_warning_message(get_lang('ChooseCourse'));
}

Loading…
Cancel
Save