You are here

function _quiz_pagination_helper in Quiz 6.x

Same name and namespace in other branches
  1. 8.6 quiz.module \_quiz_pagination_helper()
  2. 8.6 quiz.theme.inc \_quiz_pagination_helper()
  3. 8.5 quiz.module \_quiz_pagination_helper()
  4. 8.5 quiz.theme.inc \_quiz_pagination_helper()
  5. 7.6 quiz.pages.inc \_quiz_pagination_helper()
  6. 7.5 quiz.theme.inc \_quiz_pagination_helper()

Help us with special pagination.

Why not the Drupal theme_pager()?

It uses query strings. We have access on each menu argument (quiz question number) so we unfortunately cannot use it.

1 call to _quiz_pagination_helper()
QuizQuestionController::take in src/Controller/QuizQuestionController.php
Take a quiz questions.

File

./quiz.module, line 558
Contains quiz.module

Code

function _quiz_pagination_helper($total, $perpage = NULL, $current = NULL, $siblings = NULL) {
  $result = [];
  if (isset($total, $perpage) === TRUE) {
    $result = range(1, ceil($total / $perpage));
    if (isset($current, $siblings) === TRUE) {
      if (($siblings = floor($siblings / 2) * 2 + 1) >= 1) {
        $result = array_slice($result, max(0, min(count($result) - $siblings, intval($current) - ceil($siblings / 2))), $siblings);
      }
    }
  }
  return $result;
}