canvas-lms icon indicating copy to clipboard operation
canvas-lms copied to clipboard

API: Quiz scoring_policy can't be set when allowed_attempts is set to "unlimited"

Open ToeBee opened this issue 8 years ago • 3 comments

Summary:

It is impossible to create a quiz that has unlimited attempts with a scoring policy of keep_latest

This actually affects both the quiz creating and editing API calls. The parameters for both of these calls are documented under Quiz creation.

The documentation for the scoring_policy parameter says the following:

Required and only valid if allowed_attempts > 1. Scoring policy for a quiz that students can take multiple times. Defaults to “keep_highest”.

While technically this documentation is accurate since "unlimited" is represented by a -1, I would argue that "unlimited" is logically "> 1" even if the value used to represent it is -1.

Steps to reproduce:

  1. Create a quiz with unlimited attempts and a scoring policy of keep_latest:

    curl -H 'Content-Type: application/json' \ 
    -H 'Authorization: Bearer <token>' \
    -X POST \
    -d '{"quiz": {"title": "Quiz creation test", "allowed_attempts": -1, "scoring_policy": "keep_latest"}}' \
    https://institution.test.instructure.com/api/v1/courses/<course_id>/quizzes
    
  2. Inspect the returned JSON and see that the requested scoring policy was not applied: ... "scoring_policy":"keep_highest","allowed_attempts":-1 ...

Additional notes:

The current work-around for this is to create the quiz with an arbitrary large value for allowed_attempts (we use 50) just so we can set the scoring policy and then edit the quiz to set allowed_attempts to -1. But this is one more round-trip to the API that costs us another half a second while the user is waiting on a response from our application.

I'm also kind of curious why this restriction exists in the first place. If allowed attempts is set to 1, why does it matter what the scoring policy is?

ToeBee avatar Feb 15 '17 00:02 ToeBee