MDL-61589 Questions: Top question category naming improvement

Display the context name next to the top question category name.
This commit is contained in:
Shamim Rezaie
2018-03-15 18:47:25 +11:00
parent 1287039e62
commit c185e4fe21
4 changed files with 13 additions and 11 deletions
+7 -6
View File
@@ -6548,15 +6548,16 @@ function question_add_tops($categories, $pcontexts) {
DEBUG_DEVELOPER);
$topcats = array();
foreach ($pcontexts as $context) {
$topcat = question_get_top_category($context, true);
foreach ($pcontexts as $contextid) {
$topcat = question_get_top_category($contextid, true);
$context = context::instance_by_id($contextid);
$newcat = new stdClass();
$newcat->id = "{$topcat->id},$context";
$newcat->name = get_string('top');
$newcat->id = "{$topcat->id},$contextid";
$newcat->name = get_string('topfor', 'question', $context->get_context_name(false));
$newcat->parent = 0;
$newcat->contextid = $context;
$topcats["{$topcat->id},$context"] = $newcat;
$newcat->contextid = $contextid;
$topcats["{$topcat->id},$contextid"] = $newcat;
}
// Put topcats in at beginning of array - they'll be sorted into different contexts later.
return array_merge($topcats, $categories);
+2 -1
View File
@@ -1422,7 +1422,8 @@ function question_fix_top_names($categories) {
foreach ($categories as $id => $category) {
if ($category->parent == 0) {
$categories[$id]->name = get_string('top');
$context = context::instance_by_id($category->contextid);
$categories[$id]->name = get_string('topfor', 'question', $context->get_context_name(false));
}
}