Adding $_configuration['show_official_code_exercise_result_list'] see

BT#8746
1.9.x
Julio Montoya 11 years ago
parent 78fd12781e
commit fc3508ec07
  1. 22
      main/exercice/exercise.class.php
  2. 14
      main/exercice/exercise.lib.php
  3. 12
      main/exercice/exercise_report.php
  4. 83
      main/exercice/exercise_result.class.php
  5. 29
      main/exercice/exercise_show.php
  6. 4
      main/inc/ajax/model.ajax.php
  7. 1
      main/inc/lib/main_api.lib.php
  8. 2
      main/install/configuration.dist.php

@ -3659,11 +3659,25 @@ class Exercise
}
}
function show_exercise_result_header($user_data, $start_date = null, $duration = null) {
/**
* @param array $user_data result of api_get_user_info()
* @param null $start_date
* @param null $duration
* @return string
*/
public function show_exercise_result_header($user_data, $start_date = null, $duration = null)
{
$array = array();
if (!empty($user_data)) {
$array[] = array('title' => get_lang("User"), 'content' => $user_data);
$array[] = array('title' => get_lang("Name"), 'content' => $user_data['complete_name']);
$array[] = array('title' => get_lang("Username"), 'content' => $user_data['username']);
if (!empty($user_data['official_code'])) {
$array[] = array(
'title' => get_lang("OfficialCode"),
'content' => $user_data['official_code']
);
}
}
// Description can be very long and is generally meant to explain
// rules *before* the exam. Leaving here to make display easier if
@ -3681,7 +3695,9 @@ class Exercise
$array[] = array('title' => get_lang("Duration"), 'content' => $duration);
}
$html = Display::page_header(Display::return_icon('quiz_big.png', get_lang('Result')).' '.$this->exercise.' : '.get_lang('Result'));
$html = Display::page_header(
Display::return_icon('quiz_big.png', get_lang('Result')).' '.$this->exercise.' : '.get_lang('Result')
);
$html .= Display::description($array);
return $html;
}

@ -999,8 +999,8 @@ function get_exam_results_hotpotatoes_data($in_from, $in_number_of_items, $in_co
* Gets the exam'data results
* @todo this function should be moved in a library + no global calls
*/
function get_exam_results_data($from, $number_of_items, $column, $direction, $exercise_id, $extra_where_conditions = null, $get_count = false) {
function get_exam_results_data($from, $number_of_items, $column, $direction, $exercise_id, $extra_where_conditions = null, $get_count = false)
{
//@todo replace all this globals
global $documentPath, $filter;
@ -1099,12 +1099,11 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
$is_empty_sql_inner_join_tbl_user = true;
$sql_inner_join_tbl_user = "
(
SELECT u.user_id, firstname, lastname, email, username, ' ' as group_name, '' as group_id
SELECT u.user_id, firstname, lastname, email, username, ' ' as group_name, '' as group_id, official_code
FROM $TBL_USER u
)";
}
$sqlFromOption = " , $TBL_GROUP_REL_USER AS gru ";
$sqlWhereOption = " AND gru.c_id = ".api_get_course_int_id()." AND gru.user_id = user.user_id ";
@ -1116,6 +1115,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
$sql_select = "SELECT DISTINCT
user_id,
$first_and_last_name,
official_code,
ce.title,
username,
te.exe_result,
@ -1154,6 +1154,7 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
$hpsql_select = "SELECT
$first_and_last_name ,
username,
official_code,
tth.exe_name,
tth.exe_result ,
tth.exe_weighting,
@ -1348,7 +1349,6 @@ function get_exam_results_data($from, $number_of_items, $column, $direction, $ex
}
}
} else {
//echo $hpsql; var_dump($hpsql);
$hpresults = getManyResultsXCol($hpsql, 6);
// Print HotPotatoes test results.
@ -2325,10 +2325,10 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
}
if ($show_results || $show_only_score) {
$user_info = api_get_user_info($exercise_stat_info['exe_user_id']);
$user_info = api_get_user_info($exercise_stat_info['exe_user_id']);
//Shows exercise header
echo $objExercise->show_exercise_result_header(
$user_info['complete_name'],
$user_info,
api_convert_and_format_date($exercise_stat_info['start_date'], DATE_TIME_FORMAT_LONG),
$exercise_stat_info['duration']
);

@ -378,9 +378,12 @@ if (!empty($group_parameters)) {
$group_parameters = implode(';', $group_parameters);
}
$officialCodeInList = api_get_configuration_value('show_official_code_exercise_result_list');
if ($is_allowedToEdit || $is_tutor) {
//The order is important you need to check the the $column variable in the model.ajax.php file
$columns = array(
get_lang('FirstName'),
get_lang('LastName'),
@ -395,6 +398,10 @@ if ($is_allowedToEdit || $is_tutor) {
get_lang('Actions')
);
if ($officialCodeInList == true) {
$columns = array_merge(array(get_lang('OfficialCode')), $columns);
}
//Column config
$column_model = array(
array('name' => 'firstname', 'index' => 'firstname', 'width' => '50', 'align' => 'left', 'search' => 'true'),
@ -422,6 +429,11 @@ if ($is_allowedToEdit || $is_tutor) {
array('name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false')
);
if ($officialCodeInList == true) {
$officialCodeRow = array('name' => 'official_code', 'index' => 'official_code', 'width' => '50', 'align' => 'left', 'search' => 'true');
$column_model = array_merge(array($officialCodeRow), $column_model);
}
$action_links = '
// add username as title in lastname filed - ref 4226
function action_formatter(cellvalue, options, rowObject) {

@ -1,21 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
/**
* ExerciseResult class: This class allows to instantiate an object
* of type ExerciseResult
* which allows you to export exercises results in multiple presentation forms
* @package chamilo.exercise
* @author Yannick Warnier
* @version $Id: $
*/
/**
* Code
*/
if(!class_exists('ExerciseResult')):
/**
* Exercise results class
* @package chamilo.exercise
*/
*/
class ExerciseResult
{
private $exercises_list = array(); //stores the list of exercises
@ -83,7 +75,8 @@ class ExerciseResult
* @param string The document path (for HotPotatoes retrieval)
* @param integer User ID. Optional. If no user ID is provided, we take all the results. Defauts to null
*/
function _getExercisesReporting($document_path, $user_id = null, $filter=0, $exercise_id = 0, $hotpotato_name = null) {
public function _getExercisesReporting($document_path, $user_id = null, $filter=0, $exercise_id = 0, $hotpotato_name = null)
{
$return = array();
$TBL_EXERCISES = Database::get_course_table(TABLE_QUIZ_TEST);
@ -105,7 +98,9 @@ class ExerciseResult
}
if (empty($user_id)) {
$user_id_and = null;
$sql = "SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
official_code,
ce.title as extitle,
te.exe_result as exresult ,
te.exe_weighting as exweight,
@ -118,8 +113,8 @@ class ExerciseResult
te.exe_duration as duration,
te.orig_lp_id as orig_lp_id,
tlm.name as lp_name
FROM $TBL_EXERCISES AS ce
INNER JOIN $TBL_TRACK_EXERCISES AS te ON (te.exe_exo_id = ce.id)
FROM $TBL_EXERCISES AS ce
INNER JOIN $TBL_TRACK_EXERCISES AS te ON (te.exe_exo_id = ce.id)
INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id)
LEFT JOIN $TBL_TABLE_LP_MAIN AS tlm ON tlm.id = te.orig_lp_id AND tlm.c_id = ce.c_id
WHERE ce.c_id = $course_id AND
@ -127,6 +122,7 @@ class ExerciseResult
te.exe_cours_id='" . Database :: escape_string($cid) . "' $user_id_and $session_id_and AND
ce.active <>-1";
$hpsql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
official_code,
email,
tth.exe_name,
tth.exe_result,
@ -142,6 +138,7 @@ class ExerciseResult
$user_id_and = ' AND te.exe_user_id = ' . api_get_user_id() . ' ';
// get only this user's results
$sql="SELECT ".(api_is_western_name_order() ? "firstname as userpart1, lastname userpart2" : "lastname as userpart1, firstname as userpart2").",
official_code,
ce.title as extitle,
te.exe_result as exresult,
te.exe_weighting as exweight,
@ -155,22 +152,24 @@ class ExerciseResult
ce.results_disabled as exdisabled,
te.orig_lp_id as orig_lp_id,
tlm.name as lp_name
FROM $TBL_EXERCISES AS ce
INNER JOIN $TBL_TRACK_EXERCISES AS te ON (te.exe_exo_id = ce.id)
FROM $TBL_EXERCISES AS ce
INNER JOIN $TBL_TRACK_EXERCISES AS te ON (te.exe_exo_id = ce.id)
INNER JOIN $TBL_USER AS user ON (user.user_id = exe_user_id)
LEFT JOIN $TBL_TABLE_LP_MAIN AS tlm ON tlm.id = te.orig_lp_id AND tlm.c_id = ce.c_id
WHERE ce.c_id = $course_id AND
te.status != 'incomplete' AND
te.exe_cours_id='" . Database :: escape_string($cid) . "' $user_id_and $session_id_and AND
ce.active <>-1 AND
WHERE
ce.c_id = $course_id AND
te.status != 'incomplete' AND
te.exe_cours_id='" . Database :: escape_string($cid) . "' $user_id_and $session_id_and AND
ce.active <>-1 AND
ORDER BY userpart2, te.exe_cours_id ASC, ce.title ASC, te.exe_date DESC";
$hpsql = "SELECT '', exe_name, exe_result , exe_weighting, exe_date
FROM $TBL_TRACK_HOTPOTATOES
WHERE exe_user_id = '" . $user_id . "' AND
exe_cours_id = '" . Database :: escape_string($cid) . "' AND
tth.exe_name = '$hotpotato_name'
ORDER BY exe_cours_id ASC, exe_date DESC";
FROM $TBL_TRACK_HOTPOTATOES
WHERE
exe_user_id = '" . $user_id . "' AND
exe_cours_id = '" . Database :: escape_string($cid) . "' AND
tth.exe_name = '$hotpotato_name'
ORDER BY exe_cours_id ASC, exe_date DESC";
}
$results = array();
@ -186,6 +185,9 @@ class ExerciseResult
$hpresults[] = $rowx;
}
$filter_by_not_revised = false;
$filter_by_revised = false;
if ($filter) {
switch ($filter) {
case 1 :
@ -218,6 +220,7 @@ class ExerciseResult
$return[$i] = array();
if (empty($user_id)) {
$return[$i]['official_code'] = $results[$i]['official_code'];
$return[$i]['first_name'] = $results[$i]['userpart1'];
$return[$i]['last_name'] = $results[$i]['userpart2'];
$return[$i]['user_id'] = $results[$i]['excruid'];
@ -232,7 +235,7 @@ class ExerciseResult
$return[$i]['status'] = $revised ? get_lang('Validated') : get_lang('NotValidated');
$return[$i]['lp_id'] = $results[$i]['orig_lp_id'];
$return[$i]['lp_name'] = $results[$i]['lp_name'];
}
}
@ -268,16 +271,22 @@ class ExerciseResult
* @param boolean Whether to include user fields or not
* @return boolean False on error
*/
public function exportCompleteReportCSV($document_path='',$user_id=null, $export_user_fields = false, $export_filter = 0, $exercise_id = 0, $hotpotato_name = null) {
public function exportCompleteReportCSV(
$document_path = '',
$user_id = null,
$export_user_fields = false,
$export_filter = 0,
$exercise_id = 0,
$hotpotato_name = null
) {
global $charset;
$this->_getExercisesReporting($document_path,$user_id, $export_filter, $exercise_id, $hotpotato_name);
$this->_getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
$filename = 'exercise_results_'.date('YmdGis').'.csv';
if(!empty($user_id)) {
$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.csv';
}
$data = '';
if (api_is_western_name_order()) {
if(!empty($this->results[0]['first_name'])) {
$data .= get_lang('FirstName').';';
@ -293,6 +302,11 @@ class ExerciseResult
$data .= get_lang('FirstName').';';
}
}
$officialCodeInList = api_get_configuration_value('show_official_code_exercise_result_list');
if ($officialCodeInList) {
$data .= get_lang('OfficialCode').';';
}
$data .= get_lang('Email').';';
$data .= get_lang('Groups').';';
@ -316,7 +330,7 @@ class ExerciseResult
$data .= "\n";
//results
foreach($this->results as $row) {
foreach ($this->results as $row) {
if (api_is_western_name_order()) {
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
@ -326,6 +340,10 @@ class ExerciseResult
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset)).';';
}
if ($officialCodeInList) {
$data .= $row['official_code'].';';
}
$data .= str_replace("\r\n",' ',api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset)).';';
$data .= str_replace("\r\n",' ',implode(", ", GroupManager :: get_user_group_name($row['user_id']))).';';
@ -418,7 +436,7 @@ class ExerciseResult
}
$worksheet->write($line,$column,get_lang('Groups'));
$column++;
if ($export_user_fields) {
//show user fields section with a big th colspan that spans over all fields
$extra_user_fields = UserManager::get_extra_fields(0,1000,5,'ASC',false, 1);
@ -468,7 +486,7 @@ class ExerciseResult
$worksheet->write($line,$column,api_html_entity_decode(strip_tags(implode(", ", GroupManager :: get_user_group_name($row['user_id']))), ENT_QUOTES, $charset));
$column++;
if ($export_user_fields) {
//show user fields data, if any, for this user
$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true);
@ -500,4 +518,3 @@ class ExerciseResult
return true;
}
}
endif;

@ -10,9 +10,7 @@
* @todo small letters for table variables
*
*/
/**
* Code
*/
// name of the language file that needs to be included
use \ChamiloSession as Session;
@ -47,16 +45,17 @@ $TBL_TRACK_ATTEMPT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ATTE
// General parameters passed via POST/GET
if ($debug) { error_log('Entered exercise_result.php: '.print_r($_POST,1)); }
if ( empty ( $formSent ) ) { $formSent = $_REQUEST['formSent']; }
if ( empty ( $exerciseResult ) ) { $exerciseResult = $_SESSION['exerciseResult'];}
if ( empty ( $questionId ) ) { $questionId = $_REQUEST['questionId'];}
if ( empty ( $choice ) ) { $choice = $_REQUEST['choice'];}
if ( empty ( $questionNum ) ) { $questionNum = $_REQUEST['num'];}
if ( empty ( $nbrQuestions ) ) { $nbrQuestions = $_REQUEST['nbrQuestions'];}
if ( empty ( $questionList ) ) { $questionList = $_SESSION['questionList'];}
if ( empty ( $objExercise ) ) { $objExercise = $_SESSION['objExercise'];}
if ( empty ( $exeId ) ) { $exeId = $_REQUEST['id'];}
if ( empty ( $action ) ) { $action = $_REQUEST['action']; }
if (empty($formSent)) { $formSent = isset($_REQUEST['formSent']) ? $_REQUEST['formSent'] : null; }
if (empty($exerciseResult)) { $exerciseResult = isset($_SESSION['exerciseResult']) ? $_SESSION['exerciseResult'] : null; }
if (empty($questionId)) { $questionId = isset($_REQUEST['questionId']) ? $_REQUEST['questionId'] : null;}
if (empty($choice)) { $choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null;}
if (empty($questionNum)) { $questionNum = isset($_REQUEST['num']) ? $_REQUEST['num'] : null;}
if (empty($nbrQuestions)) { $nbrQuestions = isset($_REQUEST['nbrQuestions']) ? $_REQUEST['nbrQuestions'] : null;}
if (empty($questionList)) { $questionList = isset($_SESSION['questionList']) ? $_SESSION['questionList'] : null;}
if (empty($objExercise)) { $objExercise = isset($_SESSION['objExercise']) ? $_SESSION['objExercise'] : null;}
if (empty($exeId)) { $exeId = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;}
if (empty($action)) { $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;}
$id = intval($_REQUEST['id']); //exe id
@ -204,9 +203,9 @@ if ($origin == 'learnpath' && !isset($_GET['fb_type']) ) {
}
if ($show_results || $show_only_total_score) {
$user_info = api_get_user_info($student_id);
$user_info = api_get_user_info($student_id);
//Shows exercise header
echo $objExercise->show_exercise_result_header($user_info['complete_name'], api_convert_and_format_date($exercise_date));
echo $objExercise->show_exercise_result_header($user_info, api_convert_and_format_date($exercise_date));
}
$i = $totalScore = $totalWeighting = 0;

@ -614,6 +614,10 @@ switch ($action) {
$columns = array(
'firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score', 'status', 'lp', 'actions'
);
$officialCodeInList = api_get_configuration_value('show_official_code_exercise_result_list');
if ($officialCodeInList == true) {
$columns = array_merge(array('official_code'), $columns);
}
}
$result = get_exam_results_data($start, $limit, $sidx, $sord, $exercise_id, $whereCondition);
break;

@ -2097,6 +2097,7 @@ function api_get_session_visibility(
}
}
// If the end date was set.
if (!empty($row['date_end']) && $row['date_end'] != '0000-00-00') {
// End date finish at midnight.

@ -232,3 +232,5 @@ $_configuration['system_stable'] = NEW_VERSION_STABLE;
//);
// Define the frequency to which the data must be stored in the database
//$_configuration['session_stored_after_n_times'] = 10;
// Show official code in exercise report list.
//$_configuration['show_official_code_exercise_result_list'] = false;

Loading…
Cancel
Save