From 6b51fae1a37d3c7b3f7c656e3631cb2eb50d028e Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Tue, 5 Apr 2016 09:22:24 +0200 Subject: [PATCH] Add function needed for BT#10052 --- main/inc/lib/database.constants.inc.php | 3 +- main/inc/lib/display.lib.php | 147 ++++++++++++++++++++++++ 2 files changed, 149 insertions(+), 1 deletion(-) diff --git a/main/inc/lib/database.constants.inc.php b/main/inc/lib/database.constants.inc.php index 171f7703f5..0d6c7bc3df 100755 --- a/main/inc/lib/database.constants.inc.php +++ b/main/inc/lib/database.constants.inc.php @@ -197,7 +197,7 @@ define('TABLE_DROPBOX_POST', 'dropbox_post'); define('TABLE_DROPBOX_FILE', 'dropbox_file'); define('TABLE_DROPBOX_PERSON', 'dropbox_person'); -// Course quiz (or test, or exercice) tables +// Course quiz (or test, or exercise) tables define('TABLE_QUIZ_QUESTION', 'quiz_question'); define('TABLE_QUIZ_TEST', 'quiz'); define('TABLE_QUIZ_ORDER', 'quiz_order'); @@ -206,6 +206,7 @@ define('TABLE_QUIZ_TEST_QUESTION', 'quiz_rel_question'); define('TABLE_QUIZ_QUESTION_OPTION', 'quiz_question_option'); define('TABLE_QUIZ_QUESTION_CATEGORY', 'quiz_question_category'); define('TABLE_QUIZ_QUESTION_REL_CATEGORY', 'quiz_question_rel_category'); +define('TABLE_QUIZ_REL_CATEGORY', 'quiz_rel_category'); // Linked resource table //@todo table exists? diff --git a/main/inc/lib/display.lib.php b/main/inc/lib/display.lib.php index 369705c3ce..d43308f678 100755 --- a/main/inc/lib/display.lib.php +++ b/main/inc/lib/display.lib.php @@ -2030,6 +2030,153 @@ class Display return null; } + /** + * + * @param int $nextValue + * @param array $list + * @param int $current + * @param int $fixedValue + * @param array $conditions + * @param string $link + * @param bool $isMedia + * @param bool $addHeaders + * @return string + */ + public static function progressPaginationBar( + $nextValue, + $list, + $current, + $fixedValue = null, + $conditions = array(), + $link = null, + $isMedia = false, + $addHeaders = true, + $linkAttributes = array() + ) { + if ($addHeaders) { + $pagination_size = 'pagination-mini'; + $html = ''; + } + return $html; + } + /** + * + * @param int $itemId + * @param bool $isCurrent + * @param array $conditions + * @param string $link + * @param int $nextValue + * @param bool $isMedia + * @param int $localCounter + * @param int $fixedValue + * @return string + */ + static function parsePaginationItem( + $itemId, + $isCurrent, + $conditions, + $link, + $nextValue = 0, + $isMedia = false, + $localCounter = null, + $fixedValue = null, + $linkAttributes = array()) + { + $defaultClass = "before"; + $class = $defaultClass; + foreach ($conditions as $condition) { + $array = isset($condition['items']) ? $condition['items'] : array(); + $class_to_applied = $condition['class']; + $type = isset($condition['type']) ? $condition['type'] : 'positive'; + $mode = isset($condition['mode']) ? $condition['mode'] : 'add'; + switch ($type) { + case 'positive': + if (in_array($itemId, $array)) { + if ($mode == 'overwrite') { + $class = " $defaultClass $class_to_applied"; + } else { + $class .= " $class_to_applied"; + } + } + break; + case 'negative': + if (!in_array($itemId, $array)) { + if ($mode == 'overwrite') { + $class = " $defaultClass $class_to_applied"; + } else { + $class .= " $class_to_applied"; + } + } + break; + } + } + if ($isCurrent) { + $class = "before current"; + } + if ($isMedia && $isCurrent) { + $class = "before current"; + } + if (empty($link)) { + $link_to_show = "#"; + } else { + $link_to_show = $link.($nextValue + $localCounter); + } + $label = $nextValue + $localCounter + 1; + if ($isMedia) { + $label = ($fixedValue + 1) .' '.chr(97 + $localCounter); + $link_to_show = $link.$fixedValue.'#questionanchor'.$itemId; + } + $link = Display::url($label.' ', $link_to_show, $linkAttributes); + return '
  • '.$link.'
  • '; + } + + /** + * @param int $current + * @param int $total + * @return string + */ + public static function paginationIndicator($current, $total) + { + $html = null; + if (!empty($current) && !empty($total)) { + $label = sprintf(get_lang('PaginationXofY'), $current, $total); + $html = self::url($label, '#', array('class' => 'btn disabled')); + } + return $html; + } + /** * Adds a message in the queue * @param string $message