From d9c20b0a518f74ef27c659e0cd27a01ff2aa734c Mon Sep 17 00:00:00 2001 From: Philipp Memmel Date: Fri, 3 Jan 2025 07:36:06 +0100 Subject: [PATCH 1/2] MBS-9820: Improve course edit form hook --- classes/local/hook_callbacks.php | 9 ++++++--- db/hooks.php | 1 + lang/de/block_ai_chat.php | 4 ++-- lang/en/block_ai_chat.php | 4 ++-- version.php | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/classes/local/hook_callbacks.php b/classes/local/hook_callbacks.php index fd4701f..edc9c02 100644 --- a/classes/local/hook_callbacks.php +++ b/classes/local/hook_callbacks.php @@ -18,6 +18,7 @@ use context_block; use context_system; +use local_ai_manager\ai_manager_utils; use stdClass; /** @@ -30,7 +31,7 @@ */ class hook_callbacks { /** - * Add a checkbox to add a ai-chat block. + * Add a checkbox to add an AI chat block. * * @param \core_course\hook\after_form_definition $hook */ @@ -38,9 +39,11 @@ public static function handle_after_form_definition(\core_course\hook\after_form $tenant = \core\di::get(\local_ai_manager\local\tenant::class); if ($tenant->is_tenant_allowed()) { $mform = $hook->mform; - $mform->addElement('checkbox', 'addaichat', get_string('addblockinstance', 'block_ai_chat'), 'add_block_ai_chat'); + ai_manager_utils::add_ai_tools_category_to_mform($mform); + $mform->addElement('checkbox', 'addaichat', get_string('pluginname', 'block_ai_chat'), + get_string('addblockinstance', 'block_ai_chat')); $mform->addHelpButton('addaichat', 'addblockinstance', 'block_ai_chat'); - $mform->setDefaults('addaichat', 1); + $mform->setDefault('addaichat', 0); } } diff --git a/db/hooks.php b/db/hooks.php index 5255b19..147bbc1 100644 --- a/db/hooks.php +++ b/db/hooks.php @@ -29,6 +29,7 @@ [ 'hook' => \core_course\hook\after_form_definition::class, 'callback' => \block_ai_chat\local\hook_callbacks::class . '::handle_after_form_definition', + 'priority' => 500, ], [ 'hook' => \core_course\hook\after_form_submission::class, diff --git a/lang/de/block_ai_chat.php b/lang/de/block_ai_chat.php index e05dc45..7555861 100644 --- a/lang/de/block_ai_chat.php +++ b/lang/de/block_ai_chat.php @@ -23,8 +23,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['addblockinstance'] = 'KI Chat zum Kurs hinzufügen'; -$string['addblockinstance_help'] = 'Fügt den Block KI Chat zum Kurs hinzu. Dieser wird gegebenenfalls entfernt, falls nicht gesetzt.'; +$string['addblockinstance'] = 'KI-Chat zum Kurs hinzufügen'; +$string['addblockinstance_help'] = 'Durch Setzen des Hakens wird dem Kurs ein KI-Chat hinzugefügt. Wird der Haken entfernt, wird der KI-Chat aus dem Kurs entfernt.'; $string['ai_chat'] = 'KI-Chat'; $string['ai_chat:addinstance'] = 'KI-Chat Block hinzufügen'; $string['ai_chat:myaddinstance'] = 'KI-Chat Block zu meiner Startseite hinzufügen'; diff --git a/lang/en/block_ai_chat.php b/lang/en/block_ai_chat.php index 99c9d36..135906d 100644 --- a/lang/en/block_ai_chat.php +++ b/lang/en/block_ai_chat.php @@ -23,8 +23,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -$string['addblockinstance'] = 'Add a AI Chat to this course'; -$string['addblockinstance_help'] = 'Adds a block instance of AI Chat to this course. Or is removed when unchecked'; +$string['addblockinstance'] = 'Add an AI Chat to this course'; +$string['addblockinstance_help'] = 'Adds an AI Chat to this course. The AI chat will be removed if the checkbox is unchecked.'; $string['ai_chat'] = 'AI Chat'; $string['ai_chat:addinstance'] = 'Add a AI Chat block'; $string['ai_chat:myaddinstance'] = 'Add a AI Chat block to my moodle'; diff --git a/version.php b/version.php index 7bba319..c93f3f7 100644 --- a/version.php +++ b/version.php @@ -31,5 +31,5 @@ $plugin->component = 'block_ai_chat'; $plugin->maturity = MATURITY_STABLE; $plugin->dependencies = [ - 'local_ai_manager' => 2024092700, + 'local_ai_manager' => 2024122900, ]; From 218b7733b878c594bc090cbbdfbad37540106afc Mon Sep 17 00:00:00 2001 From: Philipp Memmel Date: Fri, 3 Jan 2025 13:38:23 +0100 Subject: [PATCH 2/2] MBS-9820: Readd unit tests to GHA --- .github/workflows/ci.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50c3f29..7ac674b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,7 +59,9 @@ jobs: 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 + run: | + moodle-plugin-ci add-plugin mebis-lp/moodle-local_ai_manager + moodle-plugin-ci install --plugin ./plugin --db-host=127.0.0.1 env: DB: ${{ matrix.database }} MOODLE_BRANCH: ${{ matrix.moodle-branch }} @@ -95,10 +97,9 @@ jobs: if: ${{ !cancelled() }} run: moodle-plugin-ci grunt --max-lint-warnings 0 - # Unittest need local_ai_manager to run successfully. - # - name: PHPUnit tests - # if: ${{ !cancelled() }} - # run: moodle-plugin-ci phpunit --fail-on-warning + - name: PHPUnit tests + if: ${{ !cancelled() }} + run: moodle-plugin-ci phpunit --fail-on-warning - name: Behat features id: behat