Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MBS-9820: Improve course edit form hook #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions classes/local/hook_callbacks.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

use context_block;
use context_system;
use local_ai_manager\ai_manager_utils;
use stdClass;

/**
Expand All @@ -30,17 +31,19 @@
*/
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
*/
public static function handle_after_form_definition(\core_course\hook\after_form_definition $hook): void {
$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);
}
}

Expand Down
1 change: 1 addition & 0 deletions db/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lang/de/block_ai_chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions lang/en/block_ai_chat.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
$plugin->component = 'block_ai_chat';
$plugin->maturity = MATURITY_STABLE;
$plugin->dependencies = [
'local_ai_manager' => 2024092700,
'local_ai_manager' => 2024122900,
];
Loading