diff --git a/main/inc/ajax/course.ajax.php b/main/inc/ajax/course.ajax.php index e8b58d47ba..41afaafcd0 100644 --- a/main/inc/ajax/course.ajax.php +++ b/main/inc/ajax/course.ajax.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)) { diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 18e74230aa..392a9811c9 100644 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -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", diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index c9f046d0df..6de1ebd70b 100644 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -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)) { diff --git a/main/mySpace/index.php b/main/mySpace/index.php index 94a01537d0..ca30a85d57 100644 --- a/main/mySpace/index.php +++ b/main/mySpace/index.php @@ -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 '
'; @@ -761,14 +765,38 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst echo ''; } + if (in_array($display, array('exerciseprogress'))) { //exercise @@ -796,28 +824,28 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst echo '