From 3783b375ded28f6a3ea4bda70f17c0c95b599978 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 23 Dec 2011 16:45:03 +0100 Subject: [PATCH] Adding report by question page see #3864 --- main/exercice/exercise_report.php | 33 ++++++++++++++++--------------- main/exercice/stats.php | 21 ++++++++++++++------ main/inc/lib/template.lib.php | 13 ++++++++++++ main/user/subscribe_user.php | 2 +- 4 files changed, 46 insertions(+), 23 deletions(-) diff --git a/main/exercice/exercise_report.php b/main/exercice/exercise_report.php index ec917a0eb5..51042acdf1 100644 --- a/main/exercice/exercise_report.php +++ b/main/exercice/exercise_report.php @@ -60,13 +60,18 @@ $TBL_LP_ITEM_VIEW = Database :: get_course_table(TABLE_LP_ITEM_VIEW); $TBL_LP_ITEM = Database :: get_course_table(TABLE_LP_ITEM); -$course_id = api_get_course_int_id(); -$exercise_id = isset($_REQUEST['exerciseId']) ? intval($_REQUEST['exerciseId']) : null; +$course_id = api_get_course_int_id(); +$exercise_id = isset($_REQUEST['exerciseId']) ? intval($_REQUEST['exerciseId']) : null; if (empty($exercise_id)) { api_not_allowed(); } +if (!empty($exercise_id)) + $parameters['exerciseId'] = $exercise_id; +if (!empty($_GET['path'])) { + $parameters['path'] = Security::remove_XSS($_GET['path']); +} // filter display by student group // if $_GET['filterByGroup'] = -1 => do not filter @@ -266,7 +271,6 @@ if ($_GET['delete'] == 'delete' && ($is_allowedToEdit || api_is_coach()) && !emp exit; } - if (api_is_allowed_to_edit(null,true)) { if (!$_GET['filter']) { $filter_by_not_revised = true; @@ -286,6 +290,13 @@ if (api_is_allowed_to_edit(null,true)) { default : null; } + + //Report by question + $actions .= Display::url(Display::return_icon('statistics_admin.gif', get_lang("ReportByQuestion")), 'stats.php?exerciseId='.$exercise_id); + + //Live results + $actions .=''.Display :: return_icon('activity_monitor.png', get_lang('LiveResults'),'',32).''; + if (!empty($_GET['exerciseId']) && empty($_GET['filter_by_user'])) { if ($_GET['filter'] == '1' or !isset ($_GET['filter']) or $_GET['filter'] == 0 ) { $view_result = ''.Display :: return_icon('exercice_check.png', get_lang('ShowCorrectedOnly'),'','32').''; @@ -293,14 +304,12 @@ if (api_is_allowed_to_edit(null,true)) { $view_result = ''.Display :: return_icon('exercice_uncheck.png', get_lang('ShowUnCorrectedOnly'),'','32').''; } $actions .= $view_result; - // + // filter by student group menu - // - $exercice_id = intval($_GET['exerciseId']); $actions .= ""; @@ -308,19 +317,11 @@ if (api_is_allowed_to_edit(null,true)) { $actions .= Display::return_icon('group.gif', get_lang("FilterByGroup")); $actions .= displayGroupMenu("groupFilter", $filterByGroup, "doFilterByGroup()")." "; } - //Live results - $actions .=''.Display :: return_icon('activity_monitor.png', get_lang('LiveResults'),'',32).''; + } - - $parameters=array('cidReq'=>Security::remove_XSS($_GET['cidReq']),'filter' => Security::remove_XSS($_GET['filter']),'gradebook' =>Security::remove_XSS($_GET['gradebook'])); -if (!empty($exercise_id)) - $parameters['exerciseId'] = $exercise_id; -if (!empty($_GET['path'])) { - $parameters['path'] = Security::remove_XSS($_GET['path']); -} $table = new SortableTable('quiz_results', 'get_count_exam_results', 'get_exam_results_data', 1, 10); $table->set_additional_parameters($parameters); diff --git a/main/exercice/stats.php b/main/exercice/stats.php index d355509073..95a7d463f8 100644 --- a/main/exercice/stats.php +++ b/main/exercice/stats.php @@ -8,6 +8,7 @@ $language_file = array('exercice', 'tracking'); require_once '../inc/global.inc.php'; require_once 'exercise.lib.php'; $this_section = SECTION_COURSES; + $exercise_id = (isset($_GET['exerciseId']) && !empty($_GET['exerciseId'])) ? intval($_GET['exerciseId']) : 0; $objExercise = new Exercise(); @@ -29,7 +30,7 @@ $headers = array( get_lang('LowestScore'), get_lang('AverageScore'), get_lang('HighestScore'), - get_lang('MaximumScore') + get_lang('Weighting') ); if (!empty($question_list)) { @@ -39,10 +40,10 @@ if (!empty($question_list)) { $data[$question_id]['name'] = cut($question_obj->question, 100); $data[$question_id]['students_who_try_exercise'] = $exercise_stats['users']; - $data[$question_id]['lowest_score'] = $exercise_stats['min']; - $data[$question_id]['average_score'] = $exercise_stats['average']; - $data[$question_id]['highest_score'] = $exercise_stats['max']; - $data[$question_id]['max_score'] = $question_obj->weighting; + $data[$question_id]['lowest_score'] = round($exercise_stats['min'], 2); + $data[$question_id]['average_score'] = round($exercise_stats['average'], 2); + $data[$question_id]['highest_score'] = round($exercise_stats['max'], 2); + $data[$question_id]['max_score'] = round($question_obj->weighting, 2); } } @@ -80,6 +81,14 @@ $headers = array( $interbreadcrumb[] = array ("url" => "exercice.php?gradebook=$gradebook", "name" => get_lang('Exercices')); $interbreadcrumb[] = array ("url" => "admin.php?exerciseId=$exercise_id","name" => $objExercise->name); -$tpl = new Template(get_lang('Stats')); +$tpl = new Template(get_lang('ReportByQuestion')); + +//$actions = array(); +//$actions[]= array(get_lang('Back'), Display::return_icon('back.png', get_lang('Back'), 'exercise_report.php?'.$exercise_id)); +//$tpl->set_actions($actions); + +$actions = '' . Display :: return_icon('back.png', get_lang('GoBackToQuestionList'),'','32').''; +$actions = Display::div($actions, array('class'=> 'actions')); +$content = $actions.$content; $tpl->assign('content', $content); $tpl->display_one_col_template(); diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 3ca379b33e..2f71ab024e 100644 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -53,6 +53,19 @@ class Template extends Smarty { $this->assign('style', $this->style); } + /* + * Use smarty to parse the actions menu + * @todo finish it! + * */ + function set_actions($actions) { + $action_string = ''; + if (!empty($actions)) { + foreach($actions as $action) { + } + } + $this->assign('actions', $actions); + } + /** * Shortcut to display a 1 col layout (index.php) * */ diff --git a/main/user/subscribe_user.php b/main/user/subscribe_user.php index 88eb382ffc..e51c1a4c0d 100644 --- a/main/user/subscribe_user.php +++ b/main/user/subscribe_user.php @@ -643,7 +643,7 @@ function email_filter($email) { */ function reg_filter($user_id) { if(isset($_REQUEST['type']) && $_REQUEST['type']=='teacher') $type='teacher'; else $type='student'; - $result = ''.get_lang("reg").''; + $result = ''.get_lang("reg").''; return $result; }