Fix exercise export see BT#12312

pull/2487/head
jmontoyaa 8 years ago
parent ae77dbf0ea
commit 1680c3042f
  1. 8
      main/exercise/exercise_report.php
  2. 39
      main/exercise/exercise_result.class.php
  3. 2
      main/exercise/hotpotatoes_exercise_report.php
  4. 4
      main/inc/lib/exercise.lib.php

@ -213,14 +213,6 @@ if (isset($_REQUEST['comments']) &&
if (isset($_POST['send_notification'])) {
//@todo move this somewhere else
$subject = get_lang('ExamSheetVCC');
/*$message = ExerciseLib::getEmailNotification(
api_get_user_id(),
$course_info,
$test,
$lp_id,
$url
);*/
$message = isset($_POST['notification_content']) ? $_POST['notification_content'] : '';
MessageManager::send_message_simple(

@ -296,7 +296,13 @@ class ExerciseResult
$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
);
$now = api_get_local_time();
$filename = 'exercise_results_'.$now.'.csv';
if (!empty($user_id)) {
@ -304,7 +310,6 @@ class ExerciseResult
}
$filename = api_replace_dangerous_char($filename);
$data = '';
if (api_is_western_name_order()) {
if (!empty($this->results[0]['first_name'])) {
@ -391,11 +396,12 @@ class ExerciseResult
}
}
}
$duration = !empty($row['duration']) ? round($row['duration'] / 60) : 0;
$data .= str_replace("\r\n",' ', api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset)).';';
$data .= str_replace("\r\n", ' ', $row['start_date']).';';
$data .= str_replace("\r\n", ' ', $row['end_date']).';';
$data .= str_replace("\r\n", ' ', $row['duration']).';';
$data .= str_replace("\r\n", ' ', $duration).';';
$data .= str_replace("\r\n", ' ', $row['result']).';';
$data .= str_replace("\r\n", ' ', $row['max']).';';
$data .= str_replace("\r\n", ' ', $row['status']).';';
@ -427,7 +433,14 @@ class ExerciseResult
/**
* Exports the complete report as an XLS file
* @return boolean False on error
*
* @param string $document_path
* @param null $user_id
* @param bool $export_user_fields
* @param int $export_filter
* @param int $exercise_id
* @param null $hotpotato_name
* @return bool
*/
public function exportCompleteReportXLS(
$document_path = '',
@ -438,17 +451,24 @@ class ExerciseResult
$hotpotato_name = null
) {
global $charset;
$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
$filename = 'exercise_results_'.api_get_local_time().'.xlsx';
$this->getExercisesReporting(
$document_path,
$user_id,
$export_filter,
$exercise_id,
$hotpotato_name
);
$now = api_get_local_time();
$filename = 'exercise_results_'.$now.'.xlsx';
if (!empty($user_id)) {
$filename = 'exercise_results_user_'.$user_id.'_'.api_get_local_time().'.xlsx';
$filename = 'exercise_results_user_'.$user_id.'_'.$now.'.xlsx';
}
$spreadsheet = new PHPExcel();
$spreadsheet->setActiveSheetIndex(0);
$worksheet = $spreadsheet->getActiveSheet();
$line = 0;
$line = 1; // Skip first line
$column = 0; //skip the first column (row titles)
// check if exists column 'user'
@ -648,7 +668,8 @@ class ExerciseResult
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, $row['end_date']);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, $row['duration']);
$duration = !empty($row['duration']) ? round($row['duration'] / 60) : 0;
$worksheet->setCellValueByColumnAndRow($column, $line, $duration);
$column++;
$worksheet->setCellValueByColumnAndRow($column, $line, $row['result']);
$column++;

@ -318,7 +318,7 @@ $(function() {
<?php } ?>
});
</script>
<form id="export_report_form" method="post" action="hotpotatoes_exercise_report.php">
<form id="export_report_form" method="post" action="hotpotatoes_exercise_report.php?<?php echo api_get_cidreq(); ?>">
<input type="hidden" name="csvBuffer" id="csvBuffer" value="" />
<input type="hidden" name="export_report" id="export_report" value="1" />
<input type="hidden" name="path" id="path" value="<?php echo $hotpotatoes_path ?>" />

@ -1995,9 +1995,7 @@ HOTSPOT;
}
} else {
$attempt_url = api_get_path(
WEB_CODE_PATH
) . 'exercise/result.php?' . api_get_cidreq() . '&id=' . $results[$i]['exe_id'] . '&id_session=' . $sessionId;
$attempt_url = api_get_path(WEB_CODE_PATH) . 'exercise/result.php?' . api_get_cidreq() . '&id=' . $results[$i]['exe_id'] . '&id_session=' . $sessionId;
$attempt_link = Display::url(
get_lang('Show'),
$attempt_url,

Loading…
Cancel
Save