diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1dd10f6..638edf7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,123 +1,11 @@ -name: Moodle Plugin CI - +name: ci on: [push, pull_request] - jobs: - test: - runs-on: ubuntu-18.04 - - services: - postgres: - image: postgres:10 - env: - POSTGRES_USER: 'postgres' - POSTGRES_HOST_AUTH_METHOD: 'trust' - ports: - - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 - mariadb: - image: mariadb:10.5 - env: - MYSQL_USER: 'root' - MYSQL_ALLOW_EMPTY_PASSWORD: "true" - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval 10s --health-timeout 5s --health-retries 3 - - strategy: - fail-fast: false - matrix: - include: - - php: '7.4' - moodle-branch: 'MOODLE_311_STABLE' - database: pgsql - - php: '7.4' - moodle-branch: 'MOODLE_310_STABLE' - database: mariadb - - php: '7.3' - moodle-branch: 'MOODLE_39_STABLE' - database: pgsql - - steps: - - name: Check out repository code - uses: actions/checkout@v2 - with: - path: plugin - - - name: Setup PHP ${{ matrix.php }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php }} - extensions: ${{ matrix.extensions }} - ini-values: max_input_vars=5000 - coverage: none - - - name: Initialise moodle-plugin-ci - run: | - composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^3 - echo $(cd ci/bin; pwd) >> $GITHUB_PATH - echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH - sudo locale-gen en_AU.UTF-8 - echo "NVM_DIR=$HOME/.nvm" >> $GITHUB_ENV - - - name: Install moodle-plugin-ci - run: | - moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 - env: - DB: ${{ matrix.database }} - MOODLE_BRANCH: ${{ matrix.moodle-branch }} - - - name: PHP Lint - if: ${{ always() }} - run: moodle-plugin-ci phplint - - - name: PHP Copy/Paste Detector - continue-on-error: true # This step will show errors but will not fail - if: ${{ always() }} - run: moodle-plugin-ci phpcpd - - - name: PHP Mess Detector - continue-on-error: true # This step will show errors but will not fail - if: ${{ always() }} - run: moodle-plugin-ci phpmd - - - name: Moodle Code Checker - if: ${{ always() }} - run: moodle-plugin-ci codechecker --max-warnings 0 - - - name: Moodle PHPDoc Checker - if: ${{ always() }} - run: moodle-plugin-ci phpdoc - - - name: Validating - if: ${{ always() }} - run: moodle-plugin-ci validate - - - name: Check upgrade savepoints - if: ${{ always() }} - run: moodle-plugin-ci savepoints - - - name: Mustache Lint - if: ${{ always() }} - run: moodle-plugin-ci mustache - - - name: Grunt - continue-on-error: true # This step will show errors but will not fail - if: ${{ always() }} - run: moodle-plugin-ci grunt --max-lint-warnings 0 - - - name: PHPUnit tests - if: ${{ always() }} - run: moodle-plugin-ci phpunit - - - name: Core privacy tests - if: ${{ always() }} - run: | - cd moodle - php admin/tool/phpunit/cli/init.php - vendor/bin/phpunit --fail-on-risky --disallow-test-output -v --filter tool_dataprivacy_metadata_registry_testcase - vendor/bin/phpunit --fail-on-risky --disallow-test-output -v --filter provider_testcase - - - name: Behat features - if: ${{ always() }} - run: moodle-plugin-ci behat --profile chrome \ No newline at end of file + ci: + uses: catalyst/catalyst-moodle-workflows/.github/workflows/ci.yml@main + # Required if you plan to publish (uncomment the below) + # secrets: + # moodle_org_token: ${{ secrets.MOODLE_ORG_TOKEN }} + with: + disable_behat: false + disable_grunt: false diff --git a/classes/navigation.php b/classes/navigation.php index 6515ecc..9f7d0a6 100644 --- a/classes/navigation.php +++ b/classes/navigation.php @@ -52,7 +52,7 @@ class navigation extends settings_navigation_ajax { * Constructs the navigation for use in an AJAX request * * @param \moodle_page $page - * @param int $courseid + * @param int $courseid */ public function __construct(\moodle_page &$page, $courseid = 0) { $this->page = $page; @@ -94,9 +94,17 @@ public function get_menu_for_js() { // TODO Add custom commands actions enrolling, creating course and more. // Convert and output the branch as JSON. + + $courseadminnode = $this->get('courseadmin'); + $courseadminnode->children->remove('users'); + $courseadminlinks = $this->convert($courseadminnode); + $courseadminlinks['children'][] = $this->get_groups_links(); + + $rootlinks = $this->convert($this->get('root')); + return json_encode([ - 'admin' => $this->convert($this->get('root')), - 'courseadmin' => $this->convert($this->get('courseadmin')), + 'admin' => $rootlinks, + 'courseadmin' => $courseadminlinks, ]); } @@ -104,11 +112,11 @@ public function get_menu_for_js() { * Recursively converts a child node and its children to XML for output. * * @param navigation_node $child The child to convert - * @param int $depth Pointlessly used to track the depth of the XML structure + * @param int $depth Pointlessly used to track the depth of the XML structure * * @return array */ - protected function convert($child, int $depth = 1) : array { + protected function convert($child, int $depth = 1): array { $attributes = []; @@ -122,7 +130,7 @@ protected function convert($child, int $depth = 1) : array { } $attributes['id'] = $child->id; - $attributes['name'] = (string)$child->text; // This can be lang_string object so typecast it. + $attributes['name'] = (string) $child->text; // This can be lang_string object so typecast it. $attributes['link'] = '#'; if (is_string($child->action)) { @@ -150,4 +158,66 @@ protected function convert($child, int $depth = 1) : array { return $attributes; } + /** + * Get groups links. + * + * @return array[] + */ + public function get_groups_links(): array { + + $attributes = []; + $attributes['id'] = null; + $attributes['name'] = get_string('users'); + $attributes['haschildren'] = true; + + $firstchild = $this->get_child_node( + null, + get_string('groups', 'group'), + (new moodle_url('/group/index.php', [ + 'id' => $this->courseid, + ]))->out(false), + ); + $firstchild['haschildren'] = true; + + $firstchild['children'][] = $this->get_child_node( + 1, + get_string('overview', 'group'), + (new moodle_url('/group/overview.php', [ + 'id' => $this->courseid, + ]))->out(false), + ); + + $firstchild['children'][] = $this->get_child_node( + 2, + get_string('groupings', 'group'), + (new moodle_url('/group/groupings.php', [ + 'id' => $this->courseid, + ]))->out(false), + ); + + $attributes['children'][] = $firstchild; + + return $attributes; + } + + /** + * Get child node. + * + * @param $id + * @param $name + * @param $link + * + * @return array + */ + private function get_child_node($id, $name, $link): array { + + $node = ['id' => $id]; + $node['name'] = $name; + $node['link'] = $link; + $node['haschildren'] = false; + $node['children'] = []; + + return $node; + } + } diff --git a/db/access.php b/db/access.php index ec26b15..98ecfa8 100644 --- a/db/access.php +++ b/db/access.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Capabilities + * Capabilities. * * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * diff --git a/version.php b/version.php index c4ecc1a..ead0f64 100644 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ **/ defined('MOODLE_INTERNAL') || die(); -$plugin->release = '4.1.0 (2022112800)'; +$plugin->release = '4.1.1 (2024011500)'; $plugin->maturity = MATURITY_STABLE; -$plugin->version = 2023030500; +$plugin->version = 2024011500; $plugin->requires = 2015111602; $plugin->component = 'local_commander';