MDL-77667 contentbank: display course fullnames in context navigation.

This commit is contained in:
Paul Holden 2023-03-16 23:17:43 +00:00
parent 5d320dd7d1
commit 280ed5b62f
No known key found for this signature in database
GPG Key ID: A81A96D6045F6164
3 changed files with 16 additions and 13 deletions

View File

@ -247,7 +247,7 @@ class contentbank {
if ($categories === false || $courses === false) { if ($categories === false || $courses === false) {
list($categories, $courses) = get_user_capability_contexts($capability, true, $userid, true, list($categories, $courses) = get_user_capability_contexts($capability, true, $userid, true,
'shortname, ctxlevel, ctxinstance, ctxid', 'name, ctxlevel, ctxinstance, ctxid', 'shortname', 'name'); 'fullname, ctxlevel, ctxinstance, ctxid', 'name, ctxlevel, ctxinstance, ctxid', 'fullname', 'name');
$categoriescache->set($userid, $categories); $categoriescache->set($userid, $categories);
$coursescache->set($userid, $courses); $coursescache->set($userid, $courses);
} }

View File

@ -16,6 +16,7 @@
namespace core_contentbank\output; namespace core_contentbank\output;
use context_course;
use context_coursecat; use context_coursecat;
use core_contentbank\content; use core_contentbank\content;
use core_contentbank\contentbank; use core_contentbank\contentbank;
@ -142,7 +143,9 @@ class bankcontent implements renderable, templatable {
foreach ($this->allowedcourses as $allowedcourse) { foreach ($this->allowedcourses as $allowedcourse) {
// Don't add the frontpage course to the list. // Don't add the frontpage course to the list.
if ($allowedcourse->id != $SITE->id) { if ($allowedcourse->id != $SITE->id) {
$options[$allowedcourse->ctxid] = $allowedcourse->shortname; $options[$allowedcourse->ctxid] = format_string($allowedcourse->fullname, true, [
'context' => context_course::instance($allowedcourse->ctxinstance),
]);
} }
} }
if (!empty($options)) { if (!empty($options)) {

View File

@ -37,9 +37,9 @@ Feature: Navigate to different contexts in the content bank
And the "Choose course or category" select box should contain "System" And the "Choose course or category" select box should contain "System"
And the "Choose course or category" select box should contain "Cat 1" And the "Choose course or category" select box should contain "Cat 1"
And the "Choose course or category" select box should contain "Cat 2" And the "Choose course or category" select box should contain "Cat 2"
And the "Choose course or category" select box should contain "C0" And the "Choose course or category" select box should contain "Course 0"
And the "Choose course or category" select box should contain "C1" And the "Choose course or category" select box should contain "Course 1"
And the "Choose course or category" select box should contain "C2" And the "Choose course or category" select box should contain "Course 2"
And I should see "santjordi.h5p" And I should see "santjordi.h5p"
And I should not see "santjordi_rose.h5p" And I should not see "santjordi_rose.h5p"
And I should not see "Dragon.h5p" And I should not see "Dragon.h5p"
@ -47,7 +47,7 @@ Feature: Navigate to different contexts in the content bank
Then I should not see "santjordi.h5p" Then I should not see "santjordi.h5p"
And I should see "santjordi_rose.h5p" And I should see "santjordi_rose.h5p"
And I should not see "Dragon.h5p" And I should not see "Dragon.h5p"
And I set the field "Choose course or category" to "C0" And I set the field "Choose course or category" to "Course 0"
And I should not see "santjordi.h5p" And I should not see "santjordi.h5p"
And I should not see "santjordi_rose.h5p" And I should not see "santjordi_rose.h5p"
And I should see "Dragon.h5p" And I should see "Dragon.h5p"
@ -68,17 +68,17 @@ Feature: Navigate to different contexts in the content bank
And I add the "Navigation" block if not present And I add the "Navigation" block if not present
And I expand "Site pages" node And I expand "Site pages" node
When I click on "Content bank" "link" When I click on "Content bank" "link"
And the "Choose course or category" select box should contain "C0" And the "Choose course or category" select box should contain "Course 0"
And the "Choose course or category" select box should contain "C1" And the "Choose course or category" select box should contain "Course 1"
And the "Choose course or category" select box should not contain "System" And the "Choose course or category" select box should not contain "System"
And the "Choose course or category" select box should not contain "Cat 1" And the "Choose course or category" select box should not contain "Cat 1"
And the "Choose course or category" select box should not contain "Cat 2" And the "Choose course or category" select box should not contain "Cat 2"
And the "Choose course or category" select box should not contain "C2" And the "Choose course or category" select box should not contain "Course 2"
And I should see "Dragon.h5p" And I should see "Dragon.h5p"
And I should not see "princess.h5p" And I should not see "princess.h5p"
And I should not see "santjordi.h5p" And I should not see "santjordi.h5p"
And I should not see "santjordi_rose.h5p" And I should not see "santjordi_rose.h5p"
And I set the field "Choose course or category" to "C1" And I set the field "Choose course or category" to "Course 1"
Then I should not see "Dragon.h5p" Then I should not see "Dragon.h5p"
And I should see "princess.h5p" And I should see "princess.h5p"
And I should not see "santjordi.h5p" And I should not see "santjordi.h5p"
@ -89,12 +89,12 @@ Feature: Navigate to different contexts in the content bank
And I am on the "C0" "Course" page logged in as "teacher" And I am on the "C0" "Course" page logged in as "teacher"
And I expand "Site pages" node And I expand "Site pages" node
When I click on "Content bank" "link" When I click on "Content bank" "link"
And the "Choose course or category" select box should contain "C0" And the "Choose course or category" select box should contain "Course 0"
And the "Choose course or category" select box should contain "C1" And the "Choose course or category" select box should contain "Course 1"
And the "Choose course or category" select box should contain "Cat 1" And the "Choose course or category" select box should contain "Cat 1"
And the "Choose course or category" select box should not contain "System" And the "Choose course or category" select box should not contain "System"
And the "Choose course or category" select box should not contain "Cat 2" And the "Choose course or category" select box should not contain "Cat 2"
And the "Choose course or category" select box should not contain "C2" And the "Choose course or category" select box should not contain "Course 2"
And I should see "Dragon.h5p" And I should see "Dragon.h5p"
And I set the field "Choose course or category" to "Cat 1" And I set the field "Choose course or category" to "Cat 1"
And I should not see "Dragon.h5p" And I should not see "Dragon.h5p"