Fixing exam export results we only show the extra user data that have the filter option on

skala
Julio Montoya 14 years ago
parent b8e0e2c46e
commit 1a98c84bdc
  1. 7
      main/exercice/exercice.php
  2. 18
      main/exercice/exercise_result.class.php
  3. 8
      main/inc/lib/usermanager.lib.php

@ -655,9 +655,9 @@ if ($show == 'result') {
null;
}
if ($_GET['filter'] == '1' or !isset ($_GET['filter']) or $_GET['filter'] == 0 ) {
$view_result = '<a href="' . api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=2&exerciseId='.intval($_GET['exerciseId']).'&gradebook='.$gradebook.'" >'.Display :: return_icon('exercice_check.png', get_lang('ShowCorrectedOnly'),'','32').'</a>';
$view_result = '<a href="' . api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=2&id_session='.intval($_GET['id_session']).'&exerciseId='.intval($_GET['exerciseId']).'&gradebook='.$gradebook.'" >'.Display :: return_icon('exercice_check.png', get_lang('ShowCorrectedOnly'),'','32').'</a>';
} else {
$view_result = '<a href="' .api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=1&exerciseId='.intval($_GET['exerciseId']).'&gradebook='.$gradebook.'" >'.Display :: return_icon('exercice_uncheck.png', get_lang('ShowUnCorrectedOnly'),'','32').'</a>';
$view_result = '<a href="' .api_get_self() . '?cidReq=' . api_get_course_id() . '&show=result&filter=1&id_session='.intval($_GET['id_session']).'&exerciseId='.intval($_GET['exerciseId']).'&gradebook='.$gradebook.'" >'.Display :: return_icon('exercice_uncheck.png', get_lang('ShowUnCorrectedOnly'),'','32').'</a>';
}
echo $view_result;
}
@ -806,7 +806,8 @@ if ($show == 'test') {
// Export qti ...
$actions .= Display::url(Display::return_icon('export_qti2.png','IMS/QTI','','22'), 'exercice.php?choice=exportqti2&exerciseId='.$row['id']);
} else { // not session resource
$actions = Display::return_icon('edit.gif', get_lang('ExerciseEditionNotAvailableInSession'));
$actions = Display::return_icon('edit.gif', get_lang('ExerciseEditionNotAvailableInSession'));
$actions .='<a href="exercice.php?' . api_get_cidreq() . '&show=result&exerciseId='.$row['id'].'">' . Display :: return_icon('show_test_results.gif', get_lang('Results')).'</a>';
$actions .= Display::url(Display::return_icon('cd.gif', get_lang('CopyExercise')), '', array('onclick'=>"javascript:if(!confirm('".addslashes(api_htmlentities(get_lang('AreYouSureToCopy'),ENT_QUOTES,$charset))." ".addslashes($row['title'])."?"."')) return false;",'href'=>'exercice.php?'.api_get_cidreq().'&choice=copy_exercise&sec_token='.$token.'&exerciseId='.$row['id']));
}

@ -324,13 +324,12 @@ class ExerciseResult
global $charset;
$this->_getExercisesReporting($document_path,$user_id,$export_filter, $exercise_id);
$filename = 'exercise_results_'.date('YmdGis').'.xls';
if(!empty($user_id))
{
if(!empty($user_id)) {
$filename = 'exercise_results_user_'.$user_id.'_'.date('YmdGis').'.xls';
} //build the results
require_once(api_get_path(LIBRARY_PATH).'pear/Spreadsheet_Excel_Writer/Writer.php');
$workbook = new Spreadsheet_Excel_Writer();
$workbook ->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
$workbook->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
$workbook->setVersion(8); // BIFF8
$workbook->send($filename);
@ -358,7 +357,7 @@ class ExerciseResult
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,0,5,'ASC',false);
$extra_user_fields = UserManager::get_extra_fields(0,0,5,'ASC',false, 1);
//show the fields names for user fields
foreach($extra_user_fields as $field) {
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
@ -382,12 +381,10 @@ class ExerciseResult
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
$column++;
}
if($export_user_fields) {
if ($export_user_fields) {
//show user fields data, if any, for this user
$user_fields_values = UserManager::get_extra_user_data(intval($row['user_id']),false,false);
foreach($user_fields_values as $value)
{
$user_fields_values = UserManager::get_extra_user_data(intval($row['user_id']),false,false, false, true);
foreach($user_fields_values as $value) {
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
$column++;
}
@ -406,5 +403,4 @@ class ExerciseResult
return true;
}
}
endif;
?>
endif;

@ -1134,9 +1134,10 @@ class UserManager
* @param integer Column on which sorting is made
* @param string Sorting direction
* @param boolean Optional. Whether we get all the fields or just the visible ones
* @param int Optional. Whether we get all the fields with field_filter 1 or 0 or everything
* @return array Extra fields details (e.g. $list[2]['type'], $list[4]['options'][2]['title']
*/
public static function get_extra_fields($from = 0, $number_of_items = 0, $column = 5, $direction = 'ASC', $all_visibility = true) {
public static function get_extra_fields($from = 0, $number_of_items = 0, $column = 5, $direction = 'ASC', $all_visibility = true, $field_filter = null) {
$fields = array();
$t_uf = Database :: get_main_table(TABLE_MAIN_USER_FIELD);
$t_ufo = Database :: get_main_table(TABLE_MAIN_USER_FIELD_OPTIONS);
@ -1150,6 +1151,11 @@ class UserManager
if (!$all_visibility) {
$sqlf .= " WHERE field_visible = 1 ";
}
if (!is_null($field_filter)) {
$field_filter = intval($field_filter);
$sqlf .= " WHERE field_filter = $field_filter ";
}
$sqlf .= " ORDER BY ".$columns[$column]." $sort_direction " ;
if ($number_of_items != 0) {
$sqlf .= " LIMIT ".Database::escape_string($from).','.Database::escape_string($number_of_items);

Loading…
Cancel
Save