From 228533be802bd012391edf8a38c4d7d93bf44b6f Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 29 Aug 2012 22:43:28 +0100 Subject: [PATCH] MDL-27818 question bank: multilang category names don't work. --- lib/questionlib.php | 12 +++++++----- question/category_class.php | 7 +++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/questionlib.php b/lib/questionlib.php index ec51052bc2e..8375ba6d375 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -1117,16 +1117,18 @@ function question_category_options($contexts, $top = false, $currentcat = 0, // sort cats out into different contexts $categoriesarray = array(); - foreach ($pcontexts as $pcontext) { - $contextstring = print_context_name( - get_context_instance_by_id($pcontext), true, true); + foreach ($pcontexts as $contextid) { + $context = context::instance_by_id($contextid); + $contextstring = $context->get_context_name(true, true); foreach ($categories as $category) { - if ($category->contextid == $pcontext) { + if ($category->contextid == $contextid) { $cid = $category->id; if ($currentcat != $cid || $currentcat == 0) { $countstring = !empty($category->questioncount) ? " ($category->questioncount)" : ''; - $categoriesarray[$contextstring][$cid] = $category->indentedname.$countstring; + $categoriesarray[$contextstring][$cid] = + format_string($category->indentedname, true, + array('context' => $context)) . $countstring; } } } diff --git a/question/category_class.php b/question/category_class.php index 07c2d91be93..c71197d6eae 100644 --- a/question/category_class.php +++ b/question/category_class.php @@ -102,9 +102,12 @@ class question_category_list_item extends list_item { /// Each section adds html to be displayed as part of this list item $questionbankurl = new moodle_url("/question/edit.php", ($this->parentlist->pageurl->params() + array('category'=>"$category->id,$category->contextid"))); $catediturl = $this->parentlist->pageurl->out(true, array('edit' => $this->id)); - $item = "edit}\" href=\"$catediturl\">".$category->name ." ".'('.$category->questioncount.')'; + $item = "edit}\" href=\"$catediturl\">" . + format_string($category->name, true, array('context' => $this->parentlist->context)) . + " ".'('.$category->questioncount.')'; - $item .= ' '. $category->info; + $item .= ' ' . format_text($category->info, $category->infoformat, + array('context' => $this->parentlist->context, 'noclean' => true)); // don't allow delete if this is the last category in this context. if (count($this->parentlist->records) != 1) {