Commit a3f42f99 authored by Tim Hunt's avatar Tim Hunt
Browse files

MDL-66553 question bank: show idnumbers in category drop-down

parent 7ba73d16
...@@ -70,6 +70,9 @@ $string['categoryinfo'] = 'Category info'; ...@@ -70,6 +70,9 @@ $string['categoryinfo'] = 'Category info';
$string['categorymove'] = 'The category \'{$a->name}\' contains {$a->count} questions (some of which may be hidden questions or random questions that are still in use in a quiz). Please choose another category to move them to.'; $string['categorymove'] = 'The category \'{$a->name}\' contains {$a->count} questions (some of which may be hidden questions or random questions that are still in use in a quiz). Please choose another category to move them to.';
$string['categorymoveto'] = 'Save in category'; $string['categorymoveto'] = 'Save in category';
$string['categorynamecantbeblank'] = 'The category name cannot be blank.'; $string['categorynamecantbeblank'] = 'The category name cannot be blank.';
$string['categorynamewithcount'] = '{$a->name} ({$a->questioncount})';
$string['categorynamewithidnumber'] = '{$a->name} [{$a->idnumber}]';
$string['categorynamewithidnumberandcount'] = '{$a->name} [{$a->idnumber}] ({$a->questioncount})';
$string['clickflag'] = 'Flag question'; $string['clickflag'] = 'Flag question';
$string['clicktoflag'] = 'Flag this question for future reference'; $string['clicktoflag'] = 'Flag this question for future reference';
$string['clicktounflag'] = 'Remove flag'; $string['clicktounflag'] = 'Remove flag';
......
...@@ -1440,11 +1440,25 @@ function question_category_options($contexts, $top = false, $currentcat = 0, ...@@ -1440,11 +1440,25 @@ function question_category_options($contexts, $top = false, $currentcat = 0,
if ($category->contextid == $contextid) { if ($category->contextid == $contextid) {
$cid = $category->id; $cid = $category->id;
if ($currentcat != $cid || $currentcat == 0) { if ($currentcat != $cid || $currentcat == 0) {
$countstring = !empty($category->questioncount) ? $a = new stdClass;
" ($category->questioncount)" : ''; $a->name = format_string($category->indentedname, true,
$categoriesarray[$contextstring][$cid] = array('context' => $context));
format_string($category->indentedname, true, if ($category->idnumber !== null && $category->idnumber !== '') {
array('context' => $context)) . $countstring; $a->idnumber = s($category->idnumber);
}
if (!empty($category->questioncount)) {
$a->questioncount = $category->questioncount;
}
if (isset($a->idnumber) && isset($a->questioncount)) {
$formattedname = get_string('categorynamewithidnumberandcount', 'question', $a);
} else if (isset($a->idnumber)) {
$formattedname = get_string('categorynamewithidnumber', 'question', $a);
} else if (isset($a->questioncount)) {
$formattedname = get_string('categorynamewithcount', 'question', $a);
} else {
$formattedname = $a->name;
}
$categoriesarray[$contextstring][$cid] = $formattedname;
} }
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment