fix(examagent): restore Moodle API compatibility and fix multi-environment template handling#1123
Draft
Copilot wants to merge 4 commits into
Draft
fix(examagent): restore Moodle API compatibility and fix multi-environment template handling#1123Copilot wants to merge 4 commits into
Copilot wants to merge 4 commits into
Conversation
- Add CustomizationUrls struct with ContentOrigin, ContentDestination, StatusCheck fields matching the expected Moodle API format - Update InstanceAdapter to use CustomizationUrls instead of the old ContentUrls field (was clv1alpha2.InstanceContentUrls) - Update InstanceSpecFromAdapter to accept context and client, fetch the referenced Template to get the first environment name (replacing the hardcoded "default" key), set StatusCheckURL, and error if the template has != 1 environment - Update HandlePut to use the new InstanceSpecFromAdapter signature and handle the error it may now return - Update AdapterFromInstance to populate the new CustomizationUrls field from inst.Spec.ContentUrls and inst.Spec.StatusCheckURL Agent-Logs-Url: https://github.com/netgroup-polito/CrownLabs/sessions/22b11e08-78d2-4964-b3e5-17515ca77eb1 Co-authored-by: QcFe <10742159+QcFe@users.noreply.github.com>
Agent-Logs-Url: https://github.com/netgroup-polito/CrownLabs/sessions/22b11e08-78d2-4964-b3e5-17515ca77eb1 Co-authored-by: QcFe <10742159+QcFe@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix exam agent API inconsistency affecting Moodle compatibility
fix(examagent): restore Moodle API compatibility and fix multi-environment template handling
May 15, 2026
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 exam agent
InstanceAdapterbroke Moodle compatibility when multi-environment template support was introduced: the JSON field names changed (contentUrls→ split intocustomizationUrls), andInstanceSpecFromAdapterhardcoded"default"as the environment key inContentUrls, which fails whenever the template's environment isn't named"default".Changes
New
CustomizationUrlsstruct — matches the expected Moodle-facing API:InstanceAdapter— replacesContentUrls clv1alpha2.InstanceContentUrls(json:contentUrls) withCustomizationUrls CustomizationUrls(json:customizationUrls), restoring the expected wire format.InstanceSpecFromAdapter— now acceptscontext.Contextandclient.Client, fetches the referenced Template at call time to resolve the actual first environment name as theContentUrlsmap key, populatesStatusCheckURLfromCustomizationUrls.StatusCheck, and returns an error if the template contains more than one environment (unsupported by the exam agent).HandlePut— callsInstanceSpecFromAdapterbeforectrl.CreateOrUpdateand handles the new error return.AdapterFromInstance— mapsinst.Spec.ContentUrls(first entry) andinst.Spec.StatusCheckURLback into the newCustomizationUrlsfields on the adapter.