Add GET/LIST API for Quiz Extensions and NQ Accommodations#2640
Add GET/LIST API for Quiz Extensions and NQ Accommodations#2640jasonfill wants to merge 0 commit into
Conversation
|
|
| # } | ||
| # | ||
| def index | ||
| return render_unauthorized_action unless authorized_to_read? |
There was a problem hiding this comment.
I've been thinking, shouldn't the authorized_to_read? belong to before_action? It looks like currently an unauthorized user can probe assignment_type and service configuration. It's not very dangerous, but since we had an incident, perhaps it would be better safe than sorry?
There was a problem hiding this comment.
Auth moved to before_action in NewQuizAccommodationsController — authorize_read now runs before require_assignment and require_new_quizzes_service, preventing unauthorized users from probing assignment type or service configuration.
|
|
||
| private | ||
|
|
||
| def serialize_jsonapi(quiz_extensions) |
There was a problem hiding this comment.
We changed the serialize_jsonapi method. The problem is, it's used by both new index and the pre-existing create actions. Now the method returns raw integers instead of strings. Wouldn't it cause issues for the existing consumers?
There was a problem hiding this comment.
Restored original serializer for create in QuizExtensionsController. Now create uses the original serialize_jsonapi (serializer-based, stringified IDs) and index uses a new serialize_extensions method (raw hashes, integer IDs).
| extra_attempts = participant["extra_attempts"] | ||
| reduce_choices_enabled = participant["reduce_choices_enabled"] | ||
|
|
||
| next unless extra_time.to_i > 0 || extra_attempts.to_i > 0 || reduce_choices_enabled == true |
There was a problem hiding this comment.
A nitpick: we use == true here. That means the service response of "reduce_choices_enabled" => "true" will be considered truthy. Normally we wouldn't care, but, as I can see, in the other places alternate key names are handled (canvas_user_id, time_extension). So we currently have inconsistency here.
There was a problem hiding this comment.
reduce_choices_enabled boolean coercion - replaced == true with Canvas::Plugin.value_to_boolean(...) to consistently handle string "true" from the NQ service, matching the defensive approach used for alternate key names (canvas_user_id, time_extension)
9c84212 to
1c9f0bb
Compare
|
@dbuimistrau I am closing this PR and have opened this one: #2644. The changes requested are in the new PR. We needed to do this to clean up our repos master branch so we could get a few more PRs worked up and submitted off a clean master. |
The Quiz Extensions and New Quizzes Accommodations APIs currently only support creating extensions (POST), but provide no way to read them back. This makes it impossible for integrations to query what extensions have been granted to students, and there is no event-driven notification when extensions are set through the UI.
This change adds:
GET /api/v1/courses/:course_id/quizzes/:quiz_id/extensions
GET /api/v1/courses/:course_id/new_quizzes/:assignment_id/accommodations
GET /api/v1/courses/:course_id/new_quizzes/:assignment_id/accommodations/:user_id
Live Events
Note
This does NOT create live events for NQ as that is a closed system and I could not see a way to do that properly.
flag=none
Test Plan:
bin/rspec spec/apis/v1/quizzes/quiz_extensions_index_api_spec.rb
spec/apis/v1/quizzes/new_quiz_accommodations_api_spec.rb
spec/lib/canvas/live_events_quiz_extensions_spec.rb
spec/apis/v1/quizzes/quiz_extensions_api_spec.rb