Skip to content

Add refresh_autotest_schema API route for course autotester - #8172

Open
Naragod wants to merge 2 commits into
masterfrom
refresh_autotest_schema_api
Open

Naragod wants to merge 2 commits into
masterfrom
refresh_autotest_schema_api

Conversation

@Naragod

@Naragod Naragod commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

This adds an API route. It refreshes a course's autotester schema.

One path updates autotest_settings.schema today. It is the "Refresh autotest schema" button in Admin > Courses > edit (#7828). A markus-autotesting release can change a tester's settings. Each MarkUs instance then takes one click per autotester URL. This route lets a deploy script do that step.

PUT /api/courses/:id/refresh_autotest_schema copies Admin::CoursesController#refresh_autotest_schema. It pulls the schema from the autotester. It saves it. Admin keys pass the policy check.

Response When
200 MarkUs pulled the schema. The row holds it.
422 The course lacks an autotester URL, or the row fails validation
500 The autotester refused the request
403 The key belongs to a plain user

Changes:

  • config/routes.rb adds put 'refresh_autotest_schema' next to reset_autotest_connection.
  • app/controllers/api/courses_controller.rb adds the action.
  • app/policies/api/course_policy.rb puts the new rule under the admin_user? alias.
  • spec/controllers/api/courses_controller_spec.rb covers all four responses.
  • docs/docs/technical-guides/restful-api.md lists the route with the other autotest course routes.
  • Changelog.md gains one line.

Verification:

  • rspec spec/controllers/api/courses_controller_spec.rb passes 98 examples with 0 failures.
  • We called the route on a dev server once per code.
  • A course with a live autotester returned 200. The new schema landed in the row.
  • A course that lacks an autotester URL returned 422.
  • A course whose autotester was down returned 500.
  • A key from a plain user returned 403.

One AutotestSetting row serves every course that shares a URL. One call per URL covers that instance.

Type of Change

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality) X
🐛 Bug fix (non-breaking change that fixes an issue)
🎨 User interface change (change to user interface; provide screenshots)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📦 Dependency update (change that updates a dependency)
📖 Documentation update (change that updates documentation)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have updated the project Changelog (this is required for all changes).
  • I have verified that the pre-commit.ci checks have passed.
  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

One AutotestSetting row serves every course that shares a URL. A deploy script can call this route once per URL per MarkUs instance.

@Naragod
Naragod requested a review from donny-wong September 16, 2026 20:41
@Naragod
Naragod force-pushed the refresh_autotest_schema_api branch from 3d1a2d1 to 3b03700 Compare September 16, 2026 20:41
@coveralls

coveralls commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 35232493781

Coverage increased (+0.006%) to 90.776%

Details

  • Coverage increased (+0.006%) from the base build.
  • Patch coverage: 38 of 38 lines across 3 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 52883
Covered Lines: 49038
Line Coverage: 92.73%
Relevant Branches: 2517
Covered Branches: 1252
Branch Coverage: 49.74%
Branches in Coverage %: Yes
Coverage Strength: 128.15 hits per line

💛 - Coveralls

@Naragod
Naragod force-pushed the refresh_autotest_schema_api branch from 3b03700 to aa4f30a Compare September 17, 2026 14:16
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.

2 participants