MBS-10651: Use correct context for AI calls#68
Merged
marcusgreen merged 1 commit intomarcusgreen:mainfrom Mar 16, 2026
Merged
Conversation
Owner
|
Thanks Phillip I will look at it after Wednesday, when I am one of the presenters at the Moodle Leeds events (and will be showing some ByCS things). I don't doubt your code, I just want to understand it before I merge. |
Contributor
Author
|
No rush and thanks in advance! Final version will be pushed soon. |
17f8bf8 to
4ce9229
Compare
Contributor
Author
|
I added some more context to the description. I think you got the issue now. It's now also easily testable manually. Unit test coverage should be pretty decent as well :) |
Owner
|
Thanks Phillip, I now understand your block ai_control plugin which I would not have done otherwise. I did a test with the Core AI subsystem and it worked as expected. |
Contributor
Author
|
Thanks for reviewing, testing and merging! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current code uses the wrong context when sending AI requests. The context of the question is being used right now which is for example the context of the question bank the question is living in.
However, submitting an attempt in a quiz you definitely want the context of the quiz to be the one being used in the LLM request (which is being used for permission checks in local_ai_manager for example), because that's actually the context you are operating in.
Steps for testing:
Bonus testing steps:
local_ai_manager_request_log/contexttables.local_ai_manager_request_logtable should have the quiz course module context idlocal_ai_manager_request_logshould be the context of the mod_qbank instancelocal_ai_manager_request_logshould belong to the quiz course module