Create template for exercise_result.php - refs BT#16791

pull/3375/head
Angel Fernando Quiroz Campos 5 years ago
parent 44836e74d8
commit f6b489c003
  1. 46
      main/exercise/exercise_result.php
  2. 7
      main/template/default/exercise/result.tpl

@ -84,6 +84,9 @@ if (!empty($objExercise->getResultAccess())) {
$showHeader = false; $showHeader = false;
$showFooter = false; $showFooter = false;
$pageActions = '';
$pageTop = '';
$pageBottom = '';
$pageContent = ''; $pageContent = '';
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable'])) {
@ -93,14 +96,13 @@ if (!in_array($origin, ['learnpath', 'embeddable'])) {
// I'm in a preview mode as course admin. Display the action menu. // I'm in a preview mode as course admin. Display the action menu.
if (api_is_course_admin() && !in_array($origin, ['learnpath', 'embeddable'])) { if (api_is_course_admin() && !in_array($origin, ['learnpath', 'embeddable'])) {
$pageContent .= Display::toolbarAction( $pageActions = Display::toolbarAction(
'exercise_result_actions', 'exercise_result_actions',
[ [
Display::url( Display::url(
Display::return_icon('back.png', get_lang('GoBackToQuestionList'), [], 32), Display::return_icon('back.png', get_lang('GoBackToQuestionList'), [], 32),
'admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id 'admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id
) )
.PHP_EOL
.Display::url( .Display::url(
Display::return_icon('edit.png', get_lang('ModifyExercise'), [], 32), Display::return_icon('edit.png', get_lang('ModifyExercise'), [], 32),
'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id 'exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id
@ -123,7 +125,7 @@ $logInfo = [
Event::registerLog($logInfo); Event::registerLog($logInfo);
if ($origin === 'learnpath') { if ($origin === 'learnpath') {
$pageContent .= ' $pageTop .= '
<form method="GET" action="exercise.php?'.api_get_cidreq().'"> <form method="GET" action="exercise.php?'.api_get_cidreq().'">
<input type="hidden" name="origin" value='.$origin.'/> <input type="hidden" name="origin" value='.$origin.'/>
<input type="hidden" name="learnpath_id" value="'.$learnpath_id.'"/> <input type="hidden" name="learnpath_id" value="'.$learnpath_id.'"/>
@ -162,17 +164,20 @@ if ($objExercise->selectAttempts() > 0) {
$learnpath_item_view_id $learnpath_item_view_id
); );
if ($attempt_count >= $objExercise->selectAttempts()) { if ($attempt_count >= $objExercise->selectAttempts()) {
$pageContent .= Display::return_message( Display::addFlash(
sprintf(get_lang('ReachedMaxAttempts'), $objExercise->selectTitle(), $objExercise->selectAttempts()), Display::return_message(
'warning', sprintf(get_lang('ReachedMaxAttempts'), $objExercise->selectTitle(), $objExercise->selectAttempts()),
false 'warning',
false
)
); );
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable'])) {
$showFooter = true; $showFooter = true;
} }
$template = new Template($nameTools, $showHeader, $showFooter); $template = new Template($nameTools, $showHeader, $showFooter);
$template->assign('content', $pageContent); $template->assign('actions', $pageActions);
$template->display_one_col_template(); $template->display_one_col_template();
exit; exit;
} else { } else {
@ -195,9 +200,11 @@ if (!empty($exercise_stat_info)) {
$max_score = $objExercise->get_max_score(); $max_score = $objExercise->get_max_score();
if ($origin === 'embeddable') { if ($origin === 'embeddable') {
$pageContent .= showEmbeddableFinishButton(); $pageTop .= showEmbeddableFinishButton();
} else { } else {
$pageContent .= Display::return_message(get_lang('Saved').'<br />', 'normal', false); Display::addFlash(
Display::return_message(get_lang('Saved'), 'normal', false)
);
} }
$saveResults = true; $saveResults = true;
@ -234,13 +241,13 @@ ExerciseLib::exercise_time_control_delete(
ExerciseLib::delete_chat_exercise_session($exe_id); ExerciseLib::delete_chat_exercise_session($exe_id);
if (!in_array($origin, ['learnpath', 'embeddable'])) { if (!in_array($origin, ['learnpath', 'embeddable'])) {
$pageContent .= '<div class="question-return">'; $pageBottom .= '<div class="question-return">';
$pageContent .= Display::url( $pageBottom .= Display::url(
get_lang('ReturnToCourseHomepage'), get_lang('ReturnToCourseHomepage'),
api_get_course_url(), api_get_course_url(),
['class' => 'btn btn-primary'] ['class' => 'btn btn-primary']
); );
$pageContent .= '</div>'; $pageBottom .= '</div>';
if (api_is_allowed_to_session_edit()) { if (api_is_allowed_to_session_edit()) {
Exercise::cleanSessionVariables(); Exercise::cleanSessionVariables();
@ -267,14 +274,21 @@ if (!in_array($origin, ['learnpath', 'embeddable'])) {
Session::write('attempt_remaining', $remainingMessage); Session::write('attempt_remaining', $remainingMessage);
// Record the results in the learning path, using the SCORM interface (API) // Record the results in the learning path, using the SCORM interface (API)
$pageContent .= "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>"; $pageBottom .= "<script>window.parent.API.void_save_asset('$total_score', '$max_score', 0, 'completed');</script>";
$pageContent .= '<script type="text/javascript">'.$href.'</script>'; $pageBottom .= '<script type="text/javascript">'.$href.'</script>';
$showFooter = false; $showFooter = false;
} }
$template = new Template($nameTools, $showHeader, $showFooter); $template = new Template($nameTools, $showHeader, $showFooter);
$template->assign('content', $pageContent); $template->assign('page_top', $pageTop);
$template->assign('page_content', $pageContent);
$template->assign('page_bottom', $pageBottom);
$layout = $template->fetch(
$template->get_template('exercise/result.tpl')
);
$template->assign('actions', $pageActions);
$template->assign('content', $layout);
$template->display_one_col_template(); $template->display_one_col_template();
function showEmbeddableFinishButton() function showEmbeddableFinishButton()

@ -0,0 +1,7 @@
{# Displayed from exercise_result.php #}
{{ page_top }}
{{ page_content }}
{{ page_bottom }}
Loading…
Cancel
Save