Admin: Add config quiz_results_answers_report BT#17914

Show a link on the results page to download an answers report
pull/3586/head
Julio Montoya 5 years ago
parent 1a523782a3
commit fb7bf974ba
  1. 6
      main/exercise/exercise_result.php
  2. 47
      main/exercise/result.php
  3. 13
      main/inc/lib/exercise.lib.php
  4. 3
      main/install/configuration.dist.php
  5. 2
      main/lang/english/trad4all.inc.php
  6. 2
      main/lang/spanish/trad4all.inc.php
  7. 12
      main/template/default/exercise/partials/result_exercise.tpl

@ -212,7 +212,9 @@ $stats = ExerciseLib::displayQuestionListByAttempt(
$objExercise,
$exe_id,
$saveResults,
$remainingMessage
$remainingMessage,
false,
api_get_configuration_value('quiz_results_answers_report')
);
$pageContent .= ob_get_contents();
ob_end_clean();
@ -428,7 +430,6 @@ if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) {
if (api_is_allowed_to_session_edit()) {
Exercise::cleanSessionVariables();
}
Session::write('attempt_remaining', $remainingMessage);
$showFooter = false;
} else {
@ -446,7 +447,6 @@ if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) {
// Record the results in the learning path, using the SCORM interface (API)
$pageBottom .= "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>";
$pageBottom .= '<script type="text/javascript">'.$href.'</script>';
$showFooter = false;
}

@ -13,6 +13,7 @@ require_once __DIR__.'/../inc/global.inc.php';
$id = isset($_REQUEST['id']) ? (int) $_GET['id'] : 0; // exe id
$show_headers = isset($_REQUEST['show_headers']) ? (int) $_REQUEST['show_headers'] : null;
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$origin = api_get_origin();
if (in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) {
@ -105,17 +106,59 @@ if ($show_headers) {
$message = Session::read('attempt_remaining');
Session::erase('attempt_remaining');
$allowExportPdf = api_get_configuration_value('quiz_results_answers_report');
ob_start();
ExerciseLib::displayQuestionListByAttempt(
$stats = ExerciseLib::displayQuestionListByAttempt(
$objExercise,
$id,
false,
$message,
$allowSignature
$allowSignature,
$allowExportPdf
);
$pageContent = ob_get_contents();
ob_end_clean();
switch ($action) {
case 'export':
if ($allowExportPdf) {
$allAnswers = $stats['all_answers_html'];
@$pdf = new PDF();
$cssFile = api_get_path(SYS_CSS_PATH).'themes/chamilo/default.css';
$title = get_lang('ResponseReport');
$exerciseTitle = $objExercise->get_formated_title();
$studentInfo = api_get_user_info($student_id);
$userHeader = $objExercise->showExerciseResultHeader(
$studentInfo,
$track_exercise_info,
false,
false,
false
);
$filename = get_lang('Exercise').'_'.$exerciseTitle;
$pdf->content_to_pdf("
<html><body>
<h2 style='text-align: center'>$title</h2>
$userHeader
$allAnswers
</body></html>",
file_get_contents($cssFile),
$filename,
api_get_course_id(),
'D',
false,
null,
false,
true
);
} else {
api_not_allowed(true);
}
exit;
break;
}
$template = new Template('', $show_headers, $show_headers);
$template->assign('page_content', $pageContent);
$template->assign('allow_signature', $allowSignature);

@ -4434,13 +4434,16 @@ EOT;
* @param bool $save_user_result save users results (true) or just show the results (false)
* @param string $remainingMessage
* @param bool $allowSignature
* @param bool $allowExportPdf
*
*/
public static function displayQuestionListByAttempt(
$objExercise,
$exeId,
$save_user_result = false,
$remainingMessage = '',
$allowSignature = false
$allowSignature = false,
$allowExportPdf = false
) {
$origin = api_get_origin();
$courseId = api_get_course_int_id();
@ -4587,6 +4590,11 @@ EOT;
}
}
if ($allowExportPdf) {
$showTotalScore = false;
$showQuestionScore = false;
}
if ('embeddable' !== $origin &&
!empty($exercise_stat_info['exe_user_id']) &&
!empty($studentInfo)
@ -4596,7 +4604,8 @@ EOT;
$studentInfo,
$exercise_stat_info,
$save_user_result,
$allowSignature
$allowSignature,
$allowExportPdf
);
}

@ -1702,6 +1702,9 @@ $_configuration['auth_password_links'] = [
// Use exercise score in platform settings in gradebook total rows/columns.
//$_configuration['gradebook_use_exercise_score_settings_in_total'] = false;
// Show a link on the results page to download an answers report
// $_configuration['quiz_results_answers_report'] = false;
// KEEP THIS AT THE END
// -------- Custom DB changes
// Add user activation by confirmation email

@ -8676,4 +8676,6 @@ $CourseUsedInOtherURL = "This course is used in at least one other portal";
$SubscribeUserGroupsToLp = "Add classes to a learning path";
$ReplaceFile = "Replace file";
$SubscribeClassesToLpCategory = "Subscribe classes to category";
$ExportResponseReport = "Export response report";
$ResponseReport = "Response report";
?>

@ -8704,4 +8704,6 @@ $CourseUsedInOtherURL = "Este curso es usado en otro portal";
$SubscribeUserGroupsToLp = "Inscripción de clases a lección";
$ReplaceFile = "Reemplazar archivo";
$SubscribeClassesToLpCategory = "Suscribir clases a la categoría de lecciones";
$ExportResponseReport = "Exportar reporte de respuestas";
$ResponseReport = "Reporte de respuestas";
?>

@ -45,13 +45,23 @@
{% endif %}
{% if allow_signature %}
<div class="list-data ip">
<div class="list-data">
<span class="item"></span>
<a id="sign" class="btn btn-primary" href="javascript:void(0)">
<em class="fa fa-pencil"></em> {{ 'Sign'| get_plugin_lang('ExerciseSignaturePlugin') }}
</a>
</div>
{% endif %}
{% if allow_export_pdf %}
<br />
<div class="list-data">
<span class="item"></span>
<a href="{{ export_url }}" class="btn btn-default">
<img src="{{ 'pdf.png'|icon(22) }}" /> {{ 'ExportResponseReport'| get_lang }}
</a>
</div>
{% endif %}
</div>
<hr />
<div id="quiz_saved_answers_container">

Loading…
Cancel
Save