Survey Report, added date filter refs BT#7277

1.9.x
César Perales 12 years ago committed by Yannick Warnier
parent f5e0a67a90
commit 3c3a504454
  1. 2
      main/inc/ajax/course.ajax.php
  2. 6
      main/inc/ajax/model.ajax.php
  3. 20
      main/inc/lib/sessionmanager.lib.php
  4. 66
      main/mySpace/index.php
  5. 4
      main/mySpace/myspace.lib.php

@ -194,7 +194,7 @@ switch ($action) {
$result = Database::query($sql_query);
while ($survey = Database::fetch_assoc($result))
{
$data[] = array('id' => $survey['id'], 'text' => $survey['title'] );
$data[] = array('id' => $survey['id'], 'text' => strip_tags($survey['title']));
}
if (!empty($data))
{

@ -281,7 +281,7 @@ switch ($action) {
break;
case 'get_survey_overview':
//@TODO replace this for a more efficient function (not retrieving the whole data)
$records = SessionManager::get_survey_overview(intval($_GET['session_id']), intval($_GET['course_id']), intval($_GET['survey_id']), $options);
$records = SessionManager::get_survey_overview(intval($_GET['session_id']), intval($_GET['course_id']), intval($_GET['survey_id']), $_GET['date_from'], $_GET['date_to'], $options);
$count = count($records);
break;
/*case 'get_extra_fields':
@ -692,6 +692,8 @@ switch ($action) {
$sessionId = intval($_GET['session_id']);
$courseId = intval($_GET['course_id']);
$surveyId = intval($_GET['survey_id']);
$date_from = $_GET['date_from'];
$date_to = $_GET['date_to'];
//$course = api_get_course_info_by_id($courseId);
}
/**
@ -710,7 +712,7 @@ switch ($action) {
$columns[] = $question_id;
}
$result = SessionManager::get_survey_overview($sessionId, $courseId, $surveyId,
$result = SessionManager::get_survey_overview($sessionId, $courseId, $surveyId, $date_from, $date_to,
array(
'where' => $where_condition,
'order' => "$sidx $sord",

@ -611,12 +611,15 @@ class SessionManager
* @param array options order and limit keys
* @return array table with user name, lp name, progress
*/
public static function get_survey_overview($sessionId = 0, $courseId = 0, $surveyId = 0, $options)
public static function get_survey_overview($sessionId = 0, $courseId = 0, $surveyId = 0, $date_from, $date_to, $options)
{
//tables
$session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$user = Database::get_main_table(TABLE_MAIN_USER);
$tbl_course_lp_view = Database::get_course_table(TABLE_LP_VIEW);
$c_survey = Database::get_course_table(TABLE_SURVEY);
$c_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
$c_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
$course = api_get_course_info_by_id($courseId);
@ -637,6 +640,12 @@ class SessionManager
$order = " ORDER BY ".$options['order'];
}
$where_survey = '';
if (!empty($date_to) && !empty($date_from)) {
$where_survey = sprintf(" AND s.avail_from >= '%s'
AND s.avail_till <= '%s'", $date_from, $date_to);
}
$sql = "SELECT u.user_id, u.lastname, u.firstname, u.username, u.email, s.course_code
FROM $session_course_user s
INNER JOIN $user u ON u.user_id = s.id_user
@ -663,14 +672,15 @@ class SessionManager
//Get questions by user
$sql = "SELECT sa.question_id, sa.option_id
FROM c_survey_answer sa
INNER JOIN c_survey_question sq ON sq.question_id = sa.question_id
WHERE sa.survey_id = %d AND sa.c_id = %d AND sa.user = %d";
FROM $c_survey_answer sa
INNER JOIN $c_survey_question sq ON sq.question_id = sa.question_id
INNER JOIN $c_survey s ON sq.survey_id = s.survey_id
WHERE sa.survey_id = %d AND sa.c_id = %d AND sa.user = %d" . $where_survey;
$sql_query = sprintf($sql, $surveyId, $courseId, $user['user_id']);
$result = Database::query($sql_query);
$user_questions = array();
while ($row = Database::fetch_array($result))
{

@ -678,8 +678,8 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
$studentList[] = array('id' => $studentInfo['id'], 'text' => $studentInfo['username']);
}
$studentFilter->addElement('text', 'from', get_lang('From'), array('id' => 'date_from', 'value' => $_GET['date_from']));
$studentFilter->addElement('text', 'to', get_lang('Until'), array('id' => 'date_to', 'value' => $_GET['date_to']));
$studentFilter->addElement('text', 'from', get_lang('From'), array('id' => 'date_from', 'value' => (!empty($_GET['date_from']) ? $_GET['date_from'] : '') ));
$studentFilter->addElement('text', 'to', get_lang('Until'), array('id' => 'date_to', 'value' => (!empty($_GET['date_to']) ? $_GET['date_to'] : '') ));
$studentFilter->addElement('select_ajax', 'student_name', get_lang('SearchStudent'), null, array('url' => $url, 'defaults' => $studentList), array('class' => 'pull-left'));
$options = array(
@ -749,9 +749,13 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
$course = api_get_course_info_by_id($courseId);
$surveyList = array();
$exerciseInfo = survey_manager::get_survey($surveyId, 0, $course['code']);
$surveyList[] = array('id' => $exerciseInfo['id'], 'text' => $exerciseInfo['title']);
$surveyList[] = array('id' => $exerciseInfo['survey_id'], 'text' => strip_tags($exerciseInfo['title']));
}
$surveyOverview->addElement('select_ajax', 'survey_name', get_lang('SearchSurvey'), null, array('url' => $url, 'defaults' => $surveyList));
$surveyOverview->addElement('text', 'from', get_lang('From'), array('id' => 'date_from', 'value' => (!empty($_GET['date_from']) ? $_GET['date_from'] : '') ));
$surveyOverview->addElement('text', 'to', get_lang('Until'), array('id' => 'date_to', 'value' => (!empty($_GET['date_to']) ? $_GET['date_to'] : '') ));
$courseListUrl = api_get_self();
echo '<div class="">';
@ -761,14 +765,38 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
echo '<script>
$(function() {
$("#survey_name").on("change", function() {
var sessionId = $("#session_name").val();
var courseId = $("#course_name").val();
var surveyId = $("#survey_name").val();
window.location = "'.$courseListUrl.'?view=admin&display='.$display.'&session_id="+sessionId+"&course_id="+courseId+"&survey_id="+surveyId;
var date_to = $("#date_to").val();
var date_from = $("#date_from").val();
var sessionId = $("#session_name").val();
var courseId = $("#course_name").val();
var surveyId = $("#survey_name").val();
window.location = "'.$courseListUrl.'?view=admin&display='.$display.'&session_id="+sessionId+"&course_id="+courseId+"&survey_id="+surveyId+"&date_to="+date_to+"&date_from="+date_from;
});
$("#date_from, #date_to").datepicker({
dateFormat: "yy-mm-dd",
onSelect: function( selectedDate ) {
var filled = areBothFilled();
if (filled) {
var date_to = $("#date_to").val();
var date_from = $("#date_from").val();
var sessionId = $("#session_name").val();
var courseId = $("#course_name").val();
var surveyId = $("#survey_name").val();
window.location = "'.$courseListUrl.'?view=admin&display='.$display.'&session_id="+sessionId+"&course_id="+courseId+"&survey_id="+surveyId+"&date_to="+date_to+"&date_from="+date_from;
}
}
});
});
function areBothFilled() {
var returnValue = false;
if ((document.getElementById("date_from").value != "") && (document.getElementById("date_to").value != "")){
returnValue = true;
}
return returnValue;
}
</script>';
}
if (in_array($display, array('exerciseprogress')))
{
//exercise
@ -796,28 +824,28 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
echo '<script>
$(function() {
$("#exercise_name").on("change", function() {
var date_to = $(\'#date_to\').val();
var date_from = $(\'#date_from\').val();
var sessionId = $("#session_name").val();
var courseId = $("#course_name").val();
var date_to = $("#date_to").val();
var date_from = $("#date_from").val();
var sessionId = $("#session_name").val();
var courseId = $("#course_name").val();
var exerciseId = $("#exercise_name").val();
window.location = "'.$courseListUrl.'?view=admin&display='.$display.'&session_id="+sessionId+"&course_id="+courseId+"&exercise_id="+exerciseId+"&date_to="+date_to+"&date_from="+date_from;
});
});
$("#date_from, #date_to").datepicker({
dateFormat: \'yy-mm-dd\',
dateFormat: "yy-mm-dd",
onSelect: function( selectedDate ) {
var filled = areBothFilled();
if (filled) {
var date_to = $(\'#date_to\').val();
var date_from = $(\'#date_from\').val();
var date_to = $("#date_to").val();
var date_from = $("#date_from").val();
var sessionId = $("#session_name").val();
var courseId = $("#course_name").val();
var exerciseId = $("#exercise_name").val();
var exerciseId = $("#exercise_name").val();
window.location = "'.$courseListUrl.'?view=admin&display='.$display.'&session_id="+sessionId+"&course_id="+courseId+"&exercise_id="+exerciseId+"&date_to="+date_to+"&date_from="+date_from;
}
}
});
});
function areBothFilled() {
var returnValue = false;
if ((document.getElementById("date_from").value != "") && (document.getElementById("date_to").value != "")){
@ -851,13 +879,13 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
}
} else if($display == 'lpprogressoverview') {
if (!empty($_GET['course_id'])) {
echo MySpace::display_tracking_lp_progress_overview(intval($_GET['session_id']), intval($_GET['course_id']));
echo MySpace::display_tracking_lp_progress_overview(intval($_GET['session_id']), intval($_GET['course_id']), $_GET['date_to'], $_GET['date_from']);
} else {
Display::display_warning_message(get_lang('ChooseCourse'));
}
} else if($display == 'progressoverview') {
if (!empty($_GET['course_id'])) {
echo MySpace::display_tracking_progress_overview(intval($_GET['session_id']), intval($_GET['course_id']));
echo MySpace::display_tracking_progress_overview(intval($_GET['session_id']), intval($_GET['course_id']), $_GET['date_to'], $_GET['date_from']);
} else {
Display::display_warning_message(get_lang('ChooseCourse'));
}
@ -874,7 +902,7 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst
} else if($display == 'surveyoverview') {
if (!empty($_GET['course_id'])) {
if (!empty($_GET['survey_id'])) {
echo MySpace::display_survey_overview(intval($_GET['session_id']), intval($_GET['course_id']), intval($_GET['survey_id']));
echo MySpace::display_survey_overview(intval($_GET['session_id']), intval($_GET['course_id']), intval($_GET['survey_id']), $_GET['date_to'], $_GET['date_from']);
} else {
Display::display_warning_message(get_lang('ChooseSurvey'));
}

@ -417,7 +417,7 @@ class MySpace {
* Display a sortable table that contains an overview off all the progress of the user in a session
* @author César Perales <cesar.perales@beeznest.com>, Beeznest Team
*/
function display_survey_overview($sessionId = 0, $courseId = 0, $surveyId = 0, $answer = 2) {
function display_survey_overview($sessionId = 0, $courseId = 0, $surveyId = 0, $date_to, $date_from) {
$course = api_get_course_info_by_id($courseId);
/**
@ -454,7 +454,7 @@ class MySpace {
$action_links = '';
// jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_survey_overview&session_id=' . intval($sessionId) . '&course_id=' . intval($courseId) . '&survey_id=' . intval($surveyId);
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_survey_overview&session_id=' . intval($sessionId) . '&course_id=' . intval($courseId) . '&survey_id=' . intval($surveyId) . '&date_to=' . $date_to . '&date_from=' . $date_from;
//Table Id
$tableId = 'lpProgress';

Loading…
Cancel
Save