Skip to content

Commit

Permalink
Merge pull request #17 from LdesignMedia/15-groupings-and-group-overv…
Browse files Browse the repository at this point in the history
…iew-pages-not-reachable-by-the-commander

15 groupings and group overview pages not reachable by the commander
  • Loading branch information
hamzatamyachte authored Jan 16, 2024
2 parents 6132329 + e6da0f4 commit f430679
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 130 deletions.
130 changes: 9 additions & 121 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
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
82 changes: 76 additions & 6 deletions classes/navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -94,21 +94,29 @@ 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,
]);
}

/**
* 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 = [];

Expand All @@ -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)) {
Expand Down Expand Up @@ -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;
}

}
2 changes: 1 addition & 1 deletion db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Capabilities
* Capabilities.
*
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit f430679

Please sign in to comment.