Minor - Format code - refs BT#17549

pull/3388/head
Angel Fernando Quiroz Campos 5 years ago
parent aacdbc8e31
commit b22b99fce0
  1. 178
      main/exercise/exercise.class.php

@ -3226,118 +3226,114 @@ class Exercise
$params['class'] .= ' no-header '; $params['class'] .= ' no-header ';
} }
$html .= Display::url( $html .= Display::url($urlTitle, $url, $params);
$urlTitle,
$url,
$params
);
$html .= '<br />'; $html .= '<br />';
} else {
// User return $html;
if (api_is_allowed_to_session_edit()) { }
$endReminderValue = false;
if (!empty($myRemindList)) { // User
$endValue = end($myRemindList); if (api_is_allowed_to_session_edit()) {
if ($endValue == $question_id) { $endReminderValue = false;
$endReminderValue = true; if (!empty($myRemindList)) {
} $endValue = end($myRemindList);
if ($endValue == $question_id) {
$endReminderValue = true;
} }
if ($this->type == ALL_ON_ONE_PAGE || $nbrQuestions == $questionNum || $endReminderValue) { }
if ($this->review_answers) { if ($this->type == ALL_ON_ONE_PAGE || $nbrQuestions == $questionNum || $endReminderValue) {
$label = get_lang('ReviewQuestions'); if ($this->review_answers) {
$class = 'btn btn-success'; $label = get_lang('ReviewQuestions');
} else { $class = 'btn btn-success';
$label = get_lang('EndTest');
$class = 'btn btn-warning';
}
} else { } else {
$label = get_lang('NextQuestion'); $label = get_lang('EndTest');
$class = 'btn btn-primary'; $class = 'btn btn-warning';
} }
// used to select it with jquery } else {
$class .= ' question-validate-btn'; $label = get_lang('NextQuestion');
if ($this->type == ONE_PER_PAGE) { $class = 'btn btn-primary';
if ($questionNum != 1) { }
if ($this->showPreviousButton()) { // used to select it with jquery
$prev_question = $questionNum - 2; $class .= ' question-validate-btn';
$showPreview = true; if ($this->type == ONE_PER_PAGE) {
if (!empty($myRemindList)) { if ($questionNum != 1 && $this->showPreviousButton()) {
$beforeId = null; $prev_question = $questionNum - 2;
for ($i = 0; $i < count($myRemindList); $i++) { $showPreview = true;
if (isset($myRemindList[$i]) && $myRemindList[$i] == $question_id) { if (!empty($myRemindList)) {
$beforeId = isset($myRemindList[$i - 1]) ? $myRemindList[$i - 1] : null; $beforeId = null;
break; for ($i = 0; $i < count($myRemindList); $i++) {
} if (isset($myRemindList[$i]) && $myRemindList[$i] == $question_id) {
} $beforeId = isset($myRemindList[$i - 1]) ? $myRemindList[$i - 1] : null;
break;
if (empty($beforeId)) {
$showPreview = false;
} else {
$num = 0;
foreach ($this->questionList as $originalQuestionId) {
if ($originalQuestionId == $beforeId) {
break;
}
$num++;
}
$prev_question = $num;
}
} }
}
if ($showPreview && 0 === $this->getPreventBackwards()) { if (empty($beforeId)) {
$buttonList[] = Display::button( $showPreview = false;
'previous_question_and_save', } else {
get_lang('PreviousQuestion'), $num = 0;
[ foreach ($this->questionList as $originalQuestionId) {
'type' => 'button', if ($originalQuestionId == $beforeId) {
'class' => 'btn btn-default', break;
'data-prev' => $prev_question, }
'data-question' => $question_id, $num++;
]
);
} }
$prev_question = $num;
} }
} }
// Next question if ($showPreview && 0 === $this->getPreventBackwards()) {
if (!empty($questions_in_media)) {
$buttonList[] = Display::button( $buttonList[] = Display::button(
'save_question_list', 'previous_question_and_save',
$label, get_lang('PreviousQuestion'),
[ [
'type' => 'button', 'type' => 'button',
'class' => $class, 'class' => 'btn btn-default',
'data-list' => implode(",", $questions_in_media), 'data-prev' => $prev_question,
'data-question' => $question_id,
] ]
); );
} else {
$buttonList[] = Display::button(
'save_now',
$label,
['type' => 'button', 'class' => $class, 'data-question' => $question_id]
);
} }
$buttonList[] = '<span id="save_for_now_'.$question_id.'" class="exercise_save_mini_message"></span>&nbsp;'; }
$html .= implode(PHP_EOL, $buttonList); // Next question
if (!empty($questions_in_media)) {
$buttonList[] = Display::button(
'save_question_list',
$label,
[
'type' => 'button',
'class' => $class,
'data-list' => implode(",", $questions_in_media),
]
);
} else { } else {
if ($this->review_answers) {
$all_label = get_lang('ReviewQuestions');
$class = 'btn btn-success';
} else {
$all_label = get_lang('EndTest');
$class = 'btn btn-warning';
}
// used to select it with jquery
$class .= ' question-validate-btn';
$buttonList[] = Display::button( $buttonList[] = Display::button(
'validate_all', 'save_now',
$all_label, $label,
['type' => 'button', 'class' => $class] ['type' => 'button', 'class' => $class, 'data-question' => $question_id]
); );
$buttonList[] = '&nbsp;'.Display::span(null, ['id' => 'save_all_response']);
$html .= implode(PHP_EOL, $buttonList);
} }
$buttonList[] = '<span id="save_for_now_'.$question_id.'" class="exercise_save_mini_message"></span>';
$html .= implode(PHP_EOL, $buttonList).PHP_EOL;
} else {
if ($this->review_answers) {
$all_label = get_lang('ReviewQuestions');
$class = 'btn btn-success';
} else {
$all_label = get_lang('EndTest');
$class = 'btn btn-warning';
}
// used to select it with jquery
$class .= ' question-validate-btn';
$buttonList[] = Display::button(
'validate_all',
$all_label,
['type' => 'button', 'class' => $class]
);
$buttonList[] = Display::span(null, ['id' => 'save_all_response']);
$html .= implode(PHP_EOL, $buttonList).PHP_EOL;
} }
} }

Loading…
Cancel
Save