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 3, 2025
1 parent 9c1d5bf commit b41023b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions classes/ai_manager_utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,20 @@ 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')) {
// If block_ai_chat is installed we just use the heading created by it.
$mform->addElement('header', 'aitoolsheader', get_string('aicourseeditheader', 'local_ai_manager'));
}
}
}

0 comments on commit b41023b

Please sign in to comment.