mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
Merge branch 'MDL-71084-master' of git://github.com/peterRd/moodle
This commit is contained in:
commit
fa7c534032
@ -35,6 +35,7 @@ $string['activities_help'] = 'Activities, such as forums, quizzes and wikis, ena
|
||||
$string['activity'] = 'Activity';
|
||||
$string['activityclipboard'] = 'Moving this activity: {$a}';
|
||||
$string['activityiscurrentlyhidden'] = 'Sorry, this activity is currently hidden';
|
||||
$string['activityheader'] = 'Activity menu';
|
||||
$string['activitymodule'] = 'Activity module';
|
||||
$string['activitymodules'] = 'Activity modules';
|
||||
$string['activityreport'] = 'Activity report';
|
||||
@ -310,6 +311,7 @@ $string['costdefault'] = 'Default cost';
|
||||
$string['counteditems'] = '{$a->count} {$a->items}';
|
||||
$string['country'] = 'Country';
|
||||
$string['course'] = 'Course';
|
||||
$string['courseheader'] = 'Course menu';
|
||||
$string['courseadministration'] = 'Course administration';
|
||||
$string['courseapprovedemail'] = 'Your requested course, {$a->name}, has been approved and you have been made a {$a->teacher}. To access your new course, go to {$a->url}';
|
||||
$string['courseapprovedemail2'] = 'Your requested course, {$a->name}, has been approved. To access your new course, go to {$a->url}';
|
||||
@ -1195,6 +1197,7 @@ $string['logs'] = 'Logs';
|
||||
$string['logtoomanycourses'] = '[ <a href="{$a->url}">more</a> ]';
|
||||
$string['logtoomanyusers'] = '[ <a href="{$a->url}">more</a> ]';
|
||||
$string['lookback'] = 'Look back';
|
||||
$string['menu'] = 'Menu';
|
||||
$string['mailadmins'] = 'Inform admins';
|
||||
$string['mailstudents'] = 'Inform students';
|
||||
$string['mailteachers'] = 'Inform teachers';
|
||||
|
@ -30,6 +30,8 @@ use navigation_node;
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class secondary extends view {
|
||||
/** @var string $headertitle The header for this particular menu*/
|
||||
public $headertitle;
|
||||
/**
|
||||
* Defines the default structure for the secondary nav in a course context.
|
||||
*
|
||||
@ -116,14 +118,17 @@ class secondary extends view {
|
||||
}
|
||||
$this->id = 'secondary_navigation';
|
||||
$context = $this->context;
|
||||
$this->headertitle = get_string('menu');
|
||||
|
||||
switch ($context->contextlevel) {
|
||||
case CONTEXT_COURSE:
|
||||
if ($this->page->course->id != $SITE->id) {
|
||||
$this->headertitle = get_string('courseheader');
|
||||
$this->load_course_navigation();
|
||||
}
|
||||
break;
|
||||
case CONTEXT_MODULE:
|
||||
$this->headertitle = get_string('activityheader');
|
||||
$this->load_module_navigation();
|
||||
break;
|
||||
case CONTEXT_SYSTEM:
|
||||
|
@ -36,6 +36,8 @@ abstract class view extends navigation_node {
|
||||
protected $page;
|
||||
/** @var bool $initialised A switch to see if the navigation node is initialised */
|
||||
protected $initialised = false;
|
||||
/** @var navigation_node $activenode A string identifier for the active node*/
|
||||
public $activenode;
|
||||
|
||||
/**
|
||||
* Function to initialise the respective view
|
||||
@ -116,7 +118,9 @@ abstract class view extends navigation_node {
|
||||
$child->make_inactive();
|
||||
} else {
|
||||
$child->make_active();
|
||||
$this->activenode = $child;
|
||||
}
|
||||
|
||||
return $node; // We have found the active node, set the parent status, no need to continue.
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,10 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use core\navigation\views\secondary;
|
||||
namespace core\navigation\views;
|
||||
|
||||
use navigation_node;
|
||||
use ReflectionMethod;
|
||||
|
||||
/**
|
||||
* Class core_secondary_testcase
|
||||
@ -26,7 +29,7 @@ use core\navigation\views\secondary;
|
||||
* @copyright 2021 onwards Peter Dias
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_secondary_testcase extends advanced_testcase {
|
||||
class secondary_test extends \advanced_testcase {
|
||||
/**
|
||||
* Test the get_leaf_nodes function
|
||||
* @param float $siteorder The order for the siteadmin node
|
||||
@ -81,9 +84,12 @@ class core_secondary_testcase extends advanced_testcase {
|
||||
*
|
||||
* @param string $context The context to setup for - course, module, system
|
||||
* @param string $expectedfirstnode The expected first node
|
||||
* @param string $header The expected string
|
||||
* @param string $activenode The expected active node
|
||||
* @dataProvider test_setting_initialise_provider
|
||||
*/
|
||||
public function test_setting_initialise(string $context, string $expectedfirstnode) {
|
||||
public function test_setting_initialise(string $context, string $expectedfirstnode,
|
||||
string $header, string $activenode) {
|
||||
global $PAGE, $SITE;
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
@ -92,21 +98,21 @@ class core_secondary_testcase extends advanced_testcase {
|
||||
switch ($context) {
|
||||
case 'course':
|
||||
$pagecourse = $this->getDataGenerator()->create_course();
|
||||
$contextrecord = context_course::instance($pagecourse->id, MUST_EXIST);
|
||||
$pageurl = new moodle_url('/course/view.php', ['id' => $pagecourse->id]);
|
||||
$contextrecord = \context_course::instance($pagecourse->id, MUST_EXIST);
|
||||
$pageurl = new \moodle_url('/course/view.php', ['id' => $pagecourse->id]);
|
||||
break;
|
||||
case 'module':
|
||||
$pagecourse = $this->getDataGenerator()->create_course();
|
||||
$assign = $this->getDataGenerator()->create_module('assign', ['course' => $pagecourse->id]);
|
||||
$cm = get_coursemodule_from_id('assign', $assign->cmid);
|
||||
$contextrecord = context_module::instance($cm->id);
|
||||
$pageurl = new moodle_url('/mod/assign/view.php', ['id' => $cm->instance]);
|
||||
$contextrecord = \context_module::instance($cm->id);
|
||||
$pageurl = new \moodle_url('/mod/assign/view.php', ['id' => $cm->instance]);
|
||||
$PAGE->set_cm($cm);
|
||||
break;
|
||||
case 'system':
|
||||
$contextrecord = context_system::instance();
|
||||
$contextrecord = \context_system::instance();
|
||||
$PAGE->set_pagelayout('admin');
|
||||
$pageurl = new moodle_url('/admin/index.php');
|
||||
$pageurl = new \moodle_url('/admin/index.php');
|
||||
|
||||
}
|
||||
$PAGE->set_url($pageurl);
|
||||
@ -116,7 +122,9 @@ class core_secondary_testcase extends advanced_testcase {
|
||||
$node = new secondary($PAGE);
|
||||
$node->initialise();
|
||||
$children = $node->get_children_key_list();
|
||||
$this->assertEquals($children[0], $expectedfirstnode);
|
||||
$this->assertEquals($expectedfirstnode, $children[0]);
|
||||
$this->assertEquals(get_string($header), $node->headertitle);
|
||||
$this->assertEquals($activenode, $node->activenode->text);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,9 +133,9 @@ class core_secondary_testcase extends advanced_testcase {
|
||||
*/
|
||||
public function test_setting_initialise_provider(): array {
|
||||
return [
|
||||
'Testing in a course context' => ['course', 'coursehome'],
|
||||
'Testing in a module context' => ['module', 'modulepage'],
|
||||
'Testing in a site admin' => ['system', 'siteadminnode'],
|
||||
'Testing in a course context' => ['course', 'coursehome', 'courseheader', 'Course Page'],
|
||||
'Testing in a module context' => ['module', 'modulepage', 'activityheader', 'Activity'],
|
||||
'Testing in a site admin' => ['system', 'siteadminnode', 'menu', 'Site administration'],
|
||||
];
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user