diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..652948a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,112 @@ +name: IAGORA CI + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:13 + 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 + + strategy: + fail-fast: false + matrix: + php: ['8.3'] + moodle-branch: ['MOODLE_404_STABLE'] + database: [pgsql] + + steps: + - name: Check out repository code + uses: actions/checkout@v4 + with: + path: plugin + + - name: Setup PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + ini-values: max_input_vars=5000 + coverage: xdebug + + - name: Initialise moodle-plugin-ci + run: | + composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4 + 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 }} + # Uncomment this to run Behat tests using the Moodle App. + # MOODLE_APP: 'true' + + - name: PHP Lint + if: ${{ !cancelled() }} + run: moodle-plugin-ci phplint + + - name: PHP Mess Detector + continue-on-error: true # This step will show errors but will not fail. + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpmd + + - name: Moodle Code Checker + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpcs --max-warnings 0 + + - name: Moodle PHPDoc Checker + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpdoc --max-warnings 0 + + - name: Validating + if: ${{ !cancelled() }} + run: moodle-plugin-ci validate + + - name: Check upgrade savepoints + if: ${{ !cancelled() }} + run: moodle-plugin-ci savepoints + + - name: Mustache Lint + if: ${{ !cancelled() }} + run: moodle-plugin-ci mustache + + - name: Grunt + if: ${{ !cancelled() }} + run: moodle-plugin-ci grunt --max-lint-warnings 0 + + - name: PHPUnit tests + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpunit --fail-on-warning + + - name: Behat features + id: behat + if: ${{ !cancelled() }} + run: moodle-plugin-ci behat --profile chrome + + - name: Upload Behat Faildump + if: ${{ failure() && steps.behat.outcome == 'failure' }} + uses: actions/upload-artifact@v4 + with: + name: Behat Faildump (${{ join(matrix.*, ', ') }}) + path: ${{ github.workspace }}/moodledata/behat_dump + retention-days: 1 + if-no-files-found: ignore + + - name: Mark cancelled jobs as failed. + if: ${{ cancelled() }} + run: exit 1 diff --git a/block_iagora.php b/block_iagora.php new file mode 100644 index 0000000..359bc02 --- /dev/null +++ b/block_iagora.php @@ -0,0 +1,63 @@ +. + +/** + * Block definition class for the block_iagora plugin. + * + * @package block_iagora + * @copyright 2024, Datum Academy + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +class block_iagora extends block_base { + + /** + * Initialises the block. + * + * @return void + */ + public function init() { + $this->title = get_string('pluginname', 'block_iagora'); + } + + /** + * Gets the block contents. + * + * @return string The block HTML. + */ + public function get_content() { + if ($this->content !== null) { + return $this->content; + } + + $this->content = new stdClass(); + $this->content->footer = ''; + $this->content->text = ''; + + return $this->content; + } + + /** + * Defines in which pages this block can be added. + * + * @return array of the pages where the block can be added. + */ + public function applicable_formats() { + return ['all' => true]; + } +} diff --git a/db/access.php b/db/access.php new file mode 100644 index 0000000..dc05516 --- /dev/null +++ b/db/access.php @@ -0,0 +1,46 @@ +. + +/** + * Plugin capabilities for the block_iagora plugin. + * + * @package block_iagora + * @copyright 2024, Datum Academy + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$capabilities = [ + 'block/iagora:myaddinstance' => [ + 'captype' => 'write', + 'contextlevel' => CONTEXT_SYSTEM, + 'archetypes' => [ + 'user' => CAP_ALLOW + ], + 'clonepermissionsfrom' => 'moodle/my:manageblocks' + ], + 'block/iagora:addinstance' => [ + 'riskbitmask' => RISK_SPAM | RISK_XSS, + 'captype' => 'write', + 'contextlevel' => CONTEXT_BLOCK, + 'archetypes' => [ + 'editingteacher' => CAP_ALLOW, + 'manager' => CAP_ALLOW + ], + 'clonepermissionsfrom' => 'moodle/site:manageblocks' + ], +]; diff --git a/lang/en/block_iagora.php b/lang/en/block_iagora.php new file mode 100644 index 0000000..18229d2 --- /dev/null +++ b/lang/en/block_iagora.php @@ -0,0 +1,25 @@ +. + +/** + * Languages configuration for the block_iagora plugin. + * + * @package block_iagora + * @copyright 2024, Datum Academy + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +$string['pluginname'] = 'IAGORA'; diff --git a/version.php b/version.php new file mode 100644 index 0000000..f314b94 --- /dev/null +++ b/version.php @@ -0,0 +1,29 @@ +. + +/** + * @package block_iagora + * @copyright 2024, Datum Academy + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$plugin->component = 'block_iagora'; +$plugin->version = 2024070800; // YYYYMMDDXX (intentionally added long line to see and check whether the moodle linter complains!). +$plugin->requires = 2023100900.00; // Moodle 4.3.0. +$plugin->maturity = MATURITY_ALPHA; +$plugin->release = '0.1.0';