Skip to content

Feature: Change AI course assistance placement button location, resolves #894 #945

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

larsbonczek
Copy link
Contributor

@larsbonczek larsbonczek commented May 13, 2025

  • Added a new "AI" tab on the "Feel" settings page
  • Added a setting theme_boost_union/aiplacementcourseassistlocation to control the location of the AI button
  • Added styles to remove padding and disable text wrapping on the AI button when it's a header action
  • Code is designed to be future-proof (works with upcoming changes to aiplacement_courseassist in Moodle 5.0)
    The styles mentioned above will break in Moodle 5.0 :(
  • Added Behat tests

@abias abias linked an issue May 15, 2025 that may be closed by this pull request
@larsbonczek larsbonczek force-pushed the change-aiplacement-courseassist-btn-location branch 2 times, most recently from 5171911 to 6527f1c Compare May 15, 2025 10:49
@larsbonczek
Copy link
Contributor Author

Note that this uses the function theme_boost_union_manipulate_hooks() to prevent the AI button from being added in the default location when its location has been changed in the Boost Union settings. However, as is mentioned here, this function is executed regardless of whether Boost Union is selected as the current theme or not. This means that if Boost Union is NOT selected as the current theme and the new setting to change the AI button location is set to "headeraction", then the AI button will NOT be added in the default location (because the aiplacement_courseassist hook is overriden in theme_boost_union_manipulate_hooks()) and it will also NOT be added is the new location (because Boost Union is not selected as the current theme). This means that the button disappears completely.

To prevent this, I suggest overriding the aiplacement_courseassist hook with a custom callback (instead of disabling it) which checks whether Boost Union is the current theme and calls the original aiplacement_courseassist callback if it is not. Do you agree with this solution @abias? I'm not sure where to place this new callback. It doesn't make sense to me to put it in the logical place for hook callbacks (i.e., classes/local/hook/output/after_http_headers.php) because it's not a real hook callback registered in the db/hooks.php file. It's only called if the Boost Union setting is set to "headeraction", after all. What about classes/local/hook_override/aiplacement_courseassist/hook_callbacks.php?

@larsbonczek larsbonczek force-pushed the change-aiplacement-courseassist-btn-location branch 2 times, most recently from e0fb8ed to 5018b95 Compare June 5, 2025 13:35
@larsbonczek
Copy link
Contributor Author

I have updated the changes for Moodle 5.0 and fixed the problem outlined above. The solution looks a bit different than proposed initially because it is not actually possible to override a hook with a custom callback using $CFG->hooks_callback_overrides. You can only disable it or change its priority. I therefore added Boost Union's own callback for the after_http_headers hook in classes/local/hook/output/after_http_headers.php, which calls aiplacement_courseassist's hook if Boost Union has disabled that hook but is not currently active.

@larsbonczek larsbonczek force-pushed the change-aiplacement-courseassist-btn-location branch from 5018b95 to c89bd21 Compare June 5, 2025 13:40
@larsbonczek larsbonczek marked this pull request as ready for review June 9, 2025 11:40
@larsbonczek
Copy link
Contributor Author

The failed Behat tests don't seem to be related to my changes, if I'm not mistaken.

@abias
Copy link
Member

abias commented Jun 9, 2025

Thank you @larsbonczek for working on this improvement.
We will review it and consider it for integration soon.

The failed Behat tests don't seem to be related to my changes, if I'm not mistaken.

No, they are not related. I am working on these failures in #973

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Change AI course summarise button placement
2 participants