|
|
|
@ -187,7 +187,7 @@ class ExerciseResult |
|
|
|
|
if (empty($user_id)) { |
|
|
|
|
$return[$i]['last_name'] = $results[$i]['userpart1']; |
|
|
|
|
$return[$i]['first_name'] = $results[$i]['userpart2']; |
|
|
|
|
$return[$i]['user_id'] = $results[$i]['userid']; |
|
|
|
|
$return[$i]['user_id'] = $results[$i]['excruid']; |
|
|
|
|
$return[$i]['email'] = $results[$i]['exemail']; |
|
|
|
|
} |
|
|
|
|
$return[$i]['title'] = $results[$i]['extitle']; |
|
|
|
@ -228,7 +228,7 @@ 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 = array(), $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); |
|
|
|
|
$filename = 'exercise_results_'.date('YmdGis').'.csv'; |
|
|
|
@ -248,10 +248,10 @@ 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,1000,5,'ASC',false, 1); |
|
|
|
|
$num = count($extra_user_fields); |
|
|
|
|
foreach($extra_user_fields as $field) { |
|
|
|
|
$data .= '"'.str_replace("\r\n",' ',api_html_entity_decode(strip_tags($field[4]), ENT_QUOTES, $charset)).'";'; |
|
|
|
|
$data .= '"'.str_replace("\r\n",' ',api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset)).'";'; |
|
|
|
|
} |
|
|
|
|
$display_extra_user_fields = true; |
|
|
|
|
} |
|
|
|
@ -274,7 +274,7 @@ class ExerciseResult |
|
|
|
|
} |
|
|
|
|
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); |
|
|
|
|
$user_fields_values = UserManager::get_extra_user_data($row['user_id'],false,false, false, true); |
|
|
|
|
foreach($user_fields_values as $value) { |
|
|
|
|
$data .= '"'.str_replace('"','""',api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset)).'";'; |
|
|
|
|
} |
|
|
|
@ -309,14 +309,15 @@ class ExerciseResult |
|
|
|
|
* Exports the complete report as an XLS file |
|
|
|
|
* @return boolean False on error |
|
|
|
|
*/ |
|
|
|
|
public function exportCompleteReportXLS($document_path='',$user_id=null, $export_user_fields=array(), $export_filter = 0, $exercise_id=0, $hotpotato_name = null) { |
|
|
|
|
public function exportCompleteReportXLS($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); |
|
|
|
|
$filename = 'exercise_results_'.date('YmdGis').'.xls'; |
|
|
|
|
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'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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->setVersion(8); // BIFF8 |
|
|
|
@ -337,6 +338,7 @@ class ExerciseResult |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($with_column_user) { |
|
|
|
|
|
|
|
|
|
$worksheet->write($line,$column,get_lang('Email')); |
|
|
|
|
$column++; |
|
|
|
|
$worksheet->write($line,$column,get_lang('LastName')); |
|
|
|
@ -344,17 +346,18 @@ class ExerciseResult |
|
|
|
|
$worksheet->write($line,$column,get_lang('FirstName')); |
|
|
|
|
$column++; |
|
|
|
|
} |
|
|
|
|
$export_user_fields = true; |
|
|
|
|
|
|
|
|
|
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, 1); |
|
|
|
|
$extra_user_fields = UserManager::get_extra_fields(0,1000,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)); |
|
|
|
|
$column++; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$worksheet->write($line,$column,get_lang('Title')); |
|
|
|
|
$column++; |
|
|
|
|
$worksheet->write($line,$column,get_lang('Date')); |
|
|
|
@ -374,9 +377,11 @@ class ExerciseResult |
|
|
|
|
$worksheet->write($line,$column,api_html_entity_decode(strip_tags($row['first_name']), 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(intval($row['user_id']),false,false, false, true); |
|
|
|
|
$user_fields_values = UserManager::get_extra_user_data($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++; |
|
|
|
|