From d4d772dbd5d687df14bca40e574d32f533c3cc9a Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Fri, 25 Jun 2021 08:47:14 +0200 Subject: [PATCH] Question stats: Fix order BT#18880 --- main/exercise/question_stats.php | 38 ++++++++++++++++++++------ main/mySpace/question_stats_global.php | 1 + 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/main/exercise/question_stats.php b/main/exercise/question_stats.php index 99baad8843..dddb3c125d 100644 --- a/main/exercise/question_stats.php +++ b/main/exercise/question_stats.php @@ -103,6 +103,7 @@ foreach ($headers as $header) { } $row++; $scoreDisplay = new ScoreDisplay(); +$orderedData = []; if ($form->validate()) { $questions = ExerciseLib::getWrongQuestionResults($courseId, $exerciseId, $sessionId, $groups, $users); @@ -116,24 +117,43 @@ if ($form->validate()) { $groups, $users ); - $table->setCellContents($row, 0, $data['question']); - $table->setCellContents($row, 1, $data['count'].' / '.$total); - $table->setCellContents($row, 2, $scoreDisplay->display_score([$data['count'], $total], SCORE_AVERAGE)); - $row++; + $orderedData[] = [ + $data['question'], + $data['count'].' / '.$total, + $scoreDisplay->display_score([$data['count'], $total], SCORE_AVERAGE), + ]; } } else { $questions = ExerciseLib::getWrongQuestionResults($courseId, $exerciseId, $sessionId); foreach ($questions as $data) { $questionId = (int) $data['question_id']; $total = ExerciseLib::getTotalQuestionAnswered($courseId, $exerciseId, $questionId, $sessionId); - $table->setCellContents($row, 0, $data['question']); - $table->setCellContents($row, 1, $data['count'].' / '.$total); - $table->setCellContents($row, 2, $scoreDisplay->display_score([$data['count'], $total], SCORE_AVERAGE)); - $row++; + $orderedData[] = [ + $data['question'], + $data['count'].' / '.$total, + $scoreDisplay->display_score([$data['count'], $total], SCORE_AVERAGE), + ]; } } +$table = new SortableTableFromArray( + $orderedData, + 0, + 100, + 'question_tracking' +); + +$table->hideNavigation = true; + +$table->column = 2; +$column = 0; +foreach ($headers as $header) { + $table->set_header($column, $header, false); + $column++; +} + + Display::display_header($nameTools, get_lang('Exercise')); echo $formToString; -echo $table->toHtml(); +echo $table->return_table(); Display::display_footer(); diff --git a/main/mySpace/question_stats_global.php b/main/mySpace/question_stats_global.php index 894d91e450..97079146e6 100644 --- a/main/mySpace/question_stats_global.php +++ b/main/mySpace/question_stats_global.php @@ -175,6 +175,7 @@ if ($form->validate()) { 100, 'question_tracking' ); + $table->hideNavigation = true; $table->column = 4; $column = 0; foreach ($headers as $header) {