diff --git a/classes/output/mobile.php b/classes/output/mobile.php new file mode 100644 index 000000000..88732ab38 --- /dev/null +++ b/classes/output/mobile.php @@ -0,0 +1,42 @@ +. + +namespace local_moodlemobileapp\output; + +defined('MOODLE_INTERNAL') || die(); + +class mobile { + + /** + * Render index page. + * + * @return array View data. + */ + public static function view_index() { + $templates = [ + [ + 'id' => 'main', + 'html' => '

Hello!

', + ], + ]; + + $javascript = file_get_contents(__DIR__ . '/../../js/mobile/index.js'); + + return compact('templates', 'javascript'); + } + +} diff --git a/db/mobile.php b/db/mobile.php new file mode 100644 index 000000000..91b0def21 --- /dev/null +++ b/db/mobile.php @@ -0,0 +1,34 @@ +. + +$addons = [ + 'local_moodlemobileapp' => [ + 'handlers' => [ + 'index' => [ + 'delegate' => 'CoreMainMenuDelegate', + 'method' => 'view_index', + 'displaydata' => [ + 'title' => 'pluginname', + 'icon' => 'language', + ], + ], + ], + 'lang' => [ + ['pluginname', 'local_moodlemobileapp'], + ], + ], +]; diff --git a/js/mobile/index.js b/js/mobile/index.js new file mode 100644 index 000000000..4576f5024 --- /dev/null +++ b/js/mobile/index.js @@ -0,0 +1,5 @@ +this.CoreSitesProvider.getSite().then(site => { + const username = site.infos.username; + + document.getElementById('username').innerText = `, ${username}`; +}); diff --git a/tests/behat/plugins.feature b/tests/behat/plugins.feature new file mode 100644 index 000000000..501e5a707 --- /dev/null +++ b/tests/behat/plugins.feature @@ -0,0 +1,16 @@ +@app @javascript +Feature: Plugins work properly. + + Background: + Given the following "users" exist: + | username | + | studentusername | + + Scenario: See main menu button + When I enter the app + And I log in as "studentusername" + And I press the main menu button in the app + Then I should find "Moodle Mobile language strings" in the app + + When I press "Moodle Mobile language strings" in the app + Then I should find "studentusername" in the app