Skip to content

fix(examagent): restore Moodle API compatibility and fix multi-environment template handling#1123

Draft
Copilot wants to merge 4 commits into
masterfrom
copilot/bugfix-exam-agent-api-inconsistency
Draft

fix(examagent): restore Moodle API compatibility and fix multi-environment template handling#1123
Copilot wants to merge 4 commits into
masterfrom
copilot/bugfix-exam-agent-api-inconsistency

Conversation

Copilot AI commented May 15, 2026

Copy link
Copy Markdown
Contributor

The exam agent InstanceAdapter broke Moodle compatibility when multi-environment template support was introduced: the JSON field names changed (contentUrls → split into customizationUrls), and InstanceSpecFromAdapter hardcoded "default" as the environment key in ContentUrls, which fails whenever the template's environment isn't named "default".

Changes

  • New CustomizationUrls struct — matches the expected Moodle-facing API:

    type CustomizationUrls struct {
        ContentOrigin      string `json:"contentOrigin,omitempty"`
        ContentDestination string `json:"contentDestination,omitempty"`
        StatusCheck        string `json:"statusCheck,omitempty"`
    }
  • InstanceAdapter — replaces ContentUrls clv1alpha2.InstanceContentUrls (json: contentUrls) with CustomizationUrls CustomizationUrls (json: customizationUrls), restoring the expected wire format.

  • InstanceSpecFromAdapter — now accepts context.Context and client.Client, fetches the referenced Template at call time to resolve the actual first environment name as the ContentUrls map key, populates StatusCheckURL from CustomizationUrls.StatusCheck, and returns an error if the template contains more than one environment (unsupported by the exam agent).

  • HandlePut — calls InstanceSpecFromAdapter before ctrl.CreateOrUpdate and handles the new error return.

  • AdapterFromInstance — maps inst.Spec.ContentUrls (first entry) and inst.Spec.StatusCheckURL back into the new CustomizationUrls fields on the adapter.

Copilot AI linked an issue May 15, 2026 that may be closed by this pull request
- 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>
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
Copilot AI requested a review from QcFe May 15, 2026 08:31
Copilot finished work on behalf of QcFe May 15, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Exam agent API inconsistency

3 participants