Skip to content

Commit

Permalink
If using pagination don't show the total score info BT#15329
Browse files Browse the repository at this point in the history
Improve speed in exerices with many questions
  • Loading branch information
jmontoyaa committed Feb 20, 2019
1 parent e0acd6a commit dd83d78
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions main/exercise/admin.php
Expand Up @@ -56,6 +56,8 @@
$is_allowedToEdit = api_is_allowed_to_edit(null, true, false, false);
$sessionId = api_get_session_id();
$studentViewActive = api_is_student_view_active();
$showPagination = api_get_configuration_value('show_question_pagination');

if (!$is_allowedToEdit) {
api_not_allowed(true);
}
Expand Down Expand Up @@ -167,7 +169,6 @@

// creation of a new exercise if wrong or not specified exercise ID
if ($exerciseId) {
$showPagination = api_get_configuration_value('show_question_pagination');
$objExercise->read($exerciseId, $showPagination > 0 ? false : true);
}
// saves the object into the session
Expand Down Expand Up @@ -353,12 +354,14 @@
Display::return_icon('settings.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM).'</a>';

$maxScoreAllQuestions = 0;
$questionList = $objExercise->selectQuestionList(true, true);
if (!empty($questionList)) {
foreach ($questionList as $questionItemId) {
$question = Question::read($questionItemId);
if ($question) {
$maxScoreAllQuestions += $question->selectWeighting();
if ($showPagination === false) {
$questionList = $objExercise->selectQuestionList(true, true);
if (!empty($questionList)) {
foreach ($questionList as $questionItemId) {
$question = Question::read($questionItemId);
if ($question) {
$maxScoreAllQuestions += $question->selectWeighting();
}
}
}
}
Expand All @@ -377,17 +380,18 @@
);
}

echo '<div class="alert alert-info">';
echo sprintf(
get_lang('XQuestionsWithTotalScoreY'),
$nbrQuestions,
$maxScoreAllQuestions
);

$alert = '';
if ($showPagination === false) {
$alert .= sprintf(
get_lang('XQuestionsWithTotalScoreY'),
$nbrQuestions,
$maxScoreAllQuestions
);
}
if ($objExercise->random > 0) {
echo '<br />'.sprintf(get_lang('OnlyXQuestionsPickedRandomly'), $objExercise->random);
$alert .= '<br />'.sprintf(get_lang('OnlyXQuestionsPickedRandomly'), $objExercise->random);
}
echo '</div>';
echo Display::return_message($alert);
} elseif (isset($_GET['newQuestion'])) {
// we are in create a new question from question pool not in a test
echo '<div class="actions">';
Expand Down

0 comments on commit dd83d78

Please sign in to comment.