Skip to content

Commit

Permalink
MBS-9811: Add utility function to add a header to an course edit form
Browse files Browse the repository at this point in the history
  • Loading branch information
PhMemmel committed Jan 16, 2025
1 parent d587fcb commit 6b3c320
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions classes/ai_manager_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,19 @@ public static function find_closest_parent_course_context(context $context): ?co
}
return self::find_closest_parent_course_context($context->get_parent_context());
}

/**
* Helper function to add a category to a (course edit) form.
*
* This can be called by other AI plugins using the {@see \core_course\hook\after_form_definition} hook to extend
* the course edit form. Calling this function will add an AI tools category below which the plugins can add their
* mform elements. This function will only add a category if there does not exist one yet.
*
* @param \MoodleQuickForm $mform the mform object to add the heading to
*/
public static function add_ai_tools_category_to_mform(\MoodleQuickForm $mform): void {
if (!$mform->elementExists('aitoolsheader')) {
$mform->addElement('header', 'aitoolsheader', get_string('aicourseeditheader', 'local_ai_manager'));
}
}
}
1 change: 1 addition & 0 deletions lang/en/local_ai_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
$string['ai_manager:viewusernames'] = 'View non anonymized usernames in statistics';
$string['ai_manager:viewuserstatistics'] = 'View statistics of single users';
$string['aiadministrationlink'] = 'AI tools administration';
$string['aicourseeditheader'] = 'AI functionalities';
$string['aiinfotitle'] = 'AI tools in your tenant';
$string['aiisbeingused'] = 'You are using an AI tool. The entered data will be sent to an external AI tool.';
$string['aitool'] = 'AI tool';
Expand Down

0 comments on commit 6b3c320

Please sign in to comment.