diff --git a/Changelog.md b/Changelog.md
index 7a61feb561..73136cb9ae 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -14,6 +14,7 @@
- Update autotest settings form UI (#7777)
- Store start and end date for courses (#7783)
- Split courses into Current and Past sections for all users (#7801)
+- Add an administrator action on the course settings page to refresh autotest schema (#7828)
### 🐛 Bug fixes
- Prevent "No rows found" message from displaying in tables when data is loading (#7790)
diff --git a/app/controllers/admin/courses_controller.rb b/app/controllers/admin/courses_controller.rb
index 4ded4cb437..c03101f2dd 100644
--- a/app/controllers/admin/courses_controller.rb
+++ b/app/controllers/admin/courses_controller.rb
@@ -60,6 +60,23 @@ def reset_autotest_connection
respond_with current_course, location: -> { edit_admin_course_path(current_course) }
end
+ def refresh_autotest_schema
+ settings = current_course.autotest_setting
+ if settings.nil?
+ flash_message(:error, I18n.t('automated_tests.no_autotest_settings'))
+ return respond_with current_course, location: -> { edit_admin_course_path(current_course) }
+ end
+
+ begin
+ schema_json = get_schema(settings)
+ settings.update!(schema: schema_json)
+ flash_message(:success, I18n.t('automated_tests.manage_connection.refresh_schema_success'))
+ rescue StandardError => e
+ flash_message(:error, I18n.t('automated_tests.manage_connection.refresh_schema_failure', error: e.message))
+ end
+ respond_with current_course, location: -> { edit_admin_course_path(current_course) }
+ end
+
def destroy_lti_deployment
deployment = LtiDeployment.find(params[:lti_deployment_id])
deployment.destroy!
diff --git a/app/views/courses/_form.html.erb b/app/views/courses/_form.html.erb
index b166473b59..8f3e37fec7 100644
--- a/app/views/courses/_form.html.erb
+++ b/app/views/courses/_form.html.erb
@@ -56,6 +56,20 @@
<% if @current_course.persisted? && allowed_to?(:edit?, with: Admin::CoursePolicy) %>