From fe52670fcdc9484071a069d0a436d64c37fd9bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar=20Perales?= Date: Thu, 19 Dec 2013 11:23:43 -0500 Subject: [PATCH] exercise progress report BT#7017 --- main/inc/ajax/model.ajax.php | 3 ++- main/inc/lib/sessionmanager.lib.php | 8 ++++++-- main/mySpace/index.php | 32 +++++++++++++++++++++++++++-- main/mySpace/myspace.lib.php | 4 ++-- 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/main/inc/ajax/model.ajax.php b/main/inc/ajax/model.ajax.php index 9df53a2d4e..87813d8e4e 100644 --- a/main/inc/ajax/model.ajax.php +++ b/main/inc/ajax/model.ajax.php @@ -621,6 +621,7 @@ switch ($action) { $sessionId = intval($_GET['session_id']); $courseId = intval($_GET['course_id']); $exerciseId = intval($_GET['exercise_id']); + $answer = intval($_GET['answer']); } $columns = array( @@ -637,7 +638,7 @@ switch ($action) { 'correct' ); - $result = SessionManager::get_exercise_progress($sessionId, $courseId, $exerciseId, + $result = SessionManager::get_exercise_progress($sessionId, $courseId, $exerciseId, $answer, array( 'where' => $where_condition, 'order' => "$sidx $sord", diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php index 563701cab3..dd44fcf6ea 100644 --- a/main/inc/lib/sessionmanager.lib.php +++ b/main/inc/lib/sessionmanager.lib.php @@ -506,7 +506,7 @@ class SessionManager * @param int session id * @return array */ - public static function get_exercise_progress($sessionId = 0, $courseId = 0, $exerciseId = 0, $options = array()) + public static function get_exercise_progress($sessionId = 0, $courseId = 0, $exerciseId = 0, $answer = 2, $options = array()) { $session = Database::get_main_table(TABLE_MAIN_SESSION); $user = Database::get_main_table(TABLE_MAIN_USER); @@ -521,6 +521,11 @@ class SessionManager $where = " WHERE a.session_id = %d AND a.course_code = '%s' AND q.id = %d"; + + if ($answer != 2) + { + $where .= sprintf(' AND qa.correct = %d', $answer); + } $limit = null; if (!empty($options['limit'])) { @@ -556,7 +561,6 @@ class SessionManager INNER JOIN $quiz q ON q.id = e.exe_exo_id INNER JOIN $user u ON u.user_id = a.user_id $where $order $limit"; - $sql_query = sprintf($sql, $sessionId, $course['code'], $exerciseId); $rs = Database::query($sql_query); diff --git a/main/mySpace/index.php b/main/mySpace/index.php index ae36d3ea6e..6b6e41032b 100644 --- a/main/mySpace/index.php +++ b/main/mySpace/index.php @@ -685,9 +685,9 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst }); '; } - //exercise if (in_array($display, array('exerciseprogress'))) { + //exercise $exerciseFilter = new FormValidator('student_filter', 'get', '', '', array('class'=> 'form-search'), false); $url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=search_exercise_by_course&session_id=' . $_GET['session_id'] . '&course_id=' . $_GET['course_id']; $exerciseList = array(); @@ -714,6 +714,33 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst }); }); '; + + //answer Type + $answerFilter = new FormValidator('answer_filter', 'get', '', '', array('class'=> 'form-search'), false); + $options = array( + 2 => get_lang('all'), + 0 => get_lang('incorrect'), + 1 => get_lang('correct'), + ); + $answerFilter->addElement('select', 'answer', get_lang('Answer'),$options, array('id' => 'answer')); + $courseListUrl = api_get_self(); + + echo '
'; + echo $answerFilter->return_form(); + echo '
'; + + echo ''; + } } @@ -772,7 +799,8 @@ if ($is_platform_admin && in_array($view, array('admin')) && $display != 'yourst { if (!empty($_GET['exercise_id'])) { - echo MySpace::display_tracking_exercise_progress_overview(intval($_GET['session_id']), intval($_GET['course_id']), intval($_GET['exercise_id'])); + $answer = (isset($_GET['answer'])) ? intval($_GET['answer']) : 2; + echo MySpace::display_tracking_exercise_progress_overview(intval($_GET['session_id']), intval($_GET['course_id']), intval($_GET['exercise_id']), $answer); } else { Display::display_warning_message(get_lang('ChooseExercise')); diff --git a/main/mySpace/myspace.lib.php b/main/mySpace/myspace.lib.php index 7712373838..a5c4930bde 100644 --- a/main/mySpace/myspace.lib.php +++ b/main/mySpace/myspace.lib.php @@ -335,7 +335,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 , Beeznest Team */ - function display_tracking_exercise_progress_overview($sessionId = 0, $courseId = 0, $exerciseId = 0) { + function display_tracking_exercise_progress_overview($sessionId = 0, $courseId = 0, $exerciseId = 0, $answer = 2) { /** * Column name @@ -375,7 +375,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_exercise_progress&session_id=' . intval($sessionId) . '&course_id=' . intval($courseId) . '&exercise_id=' . intval($exerciseId); + $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_progress&session_id=' . intval($sessionId) . '&course_id=' . intval($courseId) . '&exercise_id=' . intval($exerciseId) . '&answer=' . intval($answer); $tableId = 'exerciseProgressOverview'; $table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), $action_links, true);