Skip to content

Commit 42a621a

Browse files
committed
Fix blank page in exercise inside a LP with all question in one page
See BT#14310
1 parent c3b4fc1 commit 42a621a

File tree

2 files changed

+46
-46
lines changed

2 files changed

+46
-46
lines changed

main/exercise/exercise.class.php

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6108,11 +6108,10 @@ public function is_visible(
61086108
}
61096109
}
61106110

6111-
//3. We check if the time limits are on
6111+
// 3. We check if the time limits are on
6112+
$limitTimeExists = false;
61126113
if (!empty($this->start_time) || !empty($this->end_time)) {
61136114
$limitTimeExists = true;
6114-
} else {
6115-
$limitTimeExists = false;
61166115
}
61176116

61186117
if ($limitTimeExists) {
@@ -7276,36 +7275,40 @@ public function renderQuestion(
72767275
);
72777276
break;
72787277
case ALL_ON_ONE_PAGE:
7279-
$button = [
7280-
Display::button(
7281-
'save_now',
7282-
get_lang('SaveForNow'),
7283-
['type' => 'button', 'class' => 'btn btn-primary', 'data-question' => $questionId]
7284-
),
7285-
'<span id="save_for_now_'.$questionId.'" class="exercise_save_mini_message"></span>',
7286-
];
7287-
$exercise_actions .= Display::div(
7288-
implode(PHP_EOL, $button),
7289-
['class' => 'exercise_save_now_button']
7290-
);
7278+
if (api_is_allowed_to_session_edit()) {
7279+
$button = [
7280+
Display::button(
7281+
'save_now',
7282+
get_lang('SaveForNow'),
7283+
['type' => 'button', 'class' => 'btn btn-primary', 'data-question' => $questionId]
7284+
),
7285+
'<span id="save_for_now_'.$questionId.'" class="exercise_save_mini_message"></span>',
7286+
];
7287+
$exercise_actions .= Display::div(
7288+
implode(PHP_EOL, $button),
7289+
['class' => 'exercise_save_now_button']
7290+
);
7291+
}
72917292
break;
72927293
}
72937294

72947295
if (!empty($questions_in_media)) {
72957296
$count_of_questions_inside_media = count($questions_in_media);
72967297
if ($count_of_questions_inside_media > 1) {
7297-
$button = [
7298-
Display::button(
7299-
'save_now',
7300-
get_lang('SaveForNow'),
7301-
['type' => 'button', 'class' => 'btn btn-primary', 'data-question' => $questionId]
7302-
),
7303-
'<span id="save_for_now_'.$questionId.'" class="exercise_save_mini_message"></span>&nbsp;',
7304-
];
7305-
$exercise_actions = Display::div(
7306-
implode(PHP_EOL, $button),
7307-
['class' => 'exercise_save_now_button']
7308-
);
7298+
if (api_is_allowed_to_session_edit()) {
7299+
$button = [
7300+
Display::button(
7301+
'save_now',
7302+
get_lang('SaveForNow'),
7303+
['type' => 'button', 'class' => 'btn btn-primary', 'data-question' => $questionId]
7304+
),
7305+
'<span id="save_for_now_'.$questionId.'" class="exercise_save_mini_message"></span>&nbsp;',
7306+
];
7307+
$exercise_actions = Display::div(
7308+
implode(PHP_EOL, $button),
7309+
['class' => 'exercise_save_now_button']
7310+
);
7311+
}
73097312
}
73107313

73117314
if ($last_question_in_media && $this->type == ONE_PER_PAGE) {

main/exercise/exercise_submit.php

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@
756756
error_log('12. Exercise ALL_ON_ONE_PAGE -> Redirecting to exercise_result.php');
757757
}
758758

759-
//We check if the user attempts before sending to the exercise_result.php
759+
// We check if the user attempts before sending to the exercise_result.php
760760
if ($objExercise->selectAttempts() > 0) {
761761
$attempt_count = Event::get_attempt_count(
762762
api_get_user_id(),
@@ -774,7 +774,7 @@
774774
if ($origin != 'learnpath') {
775775
//so we are not in learnpath tool
776776
echo '</div>'; //End glossary div
777-
Display :: display_footer();
777+
Display::display_footer();
778778
} else {
779779
echo '</body></html>';
780780
}
@@ -790,11 +790,6 @@
790790
exit;
791791
}
792792
}
793-
} else {
794-
if ($debug) {
795-
error_log('Redirecting to exercise_submit.php');
796-
}
797-
exit;
798793
}
799794
}
800795
} else {
@@ -1428,18 +1423,20 @@ function validate_all() {
14281423
);
14291424
break;
14301425
case ALL_ON_ONE_PAGE:
1431-
$button = [
1432-
Display::button(
1433-
'save_now',
1434-
get_lang('SaveForNow'),
1435-
['type' => 'button', 'class' => 'btn btn-info', 'data-question' => $questionId]
1436-
),
1437-
'<span id="save_for_now_'.$questionId.'"></span>&nbsp;',
1438-
];
1439-
$exerciseActions .= Display::div(
1440-
implode(PHP_EOL, $button),
1441-
['class' => 'exercise_save_now_button']
1442-
);
1426+
if (api_is_allowed_to_session_edit()) {
1427+
$button = [
1428+
Display::button(
1429+
'save_now',
1430+
get_lang('SaveForNow'),
1431+
['type' => 'button', 'class' => 'btn btn-info', 'data-question' => $questionId]
1432+
),
1433+
'<span id="save_for_now_'.$questionId.'"></span>&nbsp;',
1434+
];
1435+
$exerciseActions .= Display::div(
1436+
implode(PHP_EOL, $button),
1437+
['class' => 'exercise_save_now_button']
1438+
);
1439+
}
14431440
break;
14441441
}
14451442

0 commit comments

Comments
 (0)