Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuizSubmission update_score_and_comments doesn't seem to work #601

Open
breed opened this issue Apr 4, 2023 · 3 comments · May be fixed by #602
Open

QuizSubmission update_score_and_comments doesn't seem to work #601

breed opened this issue Apr 4, 2023 · 3 comments · May be fixed by #602
Labels

Comments

@breed
Copy link
Contributor

breed commented Apr 4, 2023

Describe the bug

when i call update_score_and_comments(fudge_points=points) on a quiz submission, i get the error "missing required key :quiz_submissions" back. looking through the code it doesn't seem like the data being sent to the canvas server matches the required format: https://canvas.instructure.com/doc/api/quiz_submissions.html#method.quizzes/quiz_submissions_api.update

To Reproduce

     for s in quiz.get_submissions():
         s.update_score_and_comments(fudge_points=9)

Expected behavior

the fudge_points get set to 9

Environment information

  • Python version (python --version) Python 3.10.6
  • CanvasAPI version (pip show canvasapi) Name: canvasapi Version: 3.0.0

Additional context

Add any other context about the problem here.

@breed breed added the bug label Apr 4, 2023
@bennettscience
Copy link
Contributor

Two things: the endpoint expects a list of objects and you also need to include the required attempt param to apply the fudge score to. This will work:

for s in quiz.get_submissions():
    updated = [
        {
            'attempt': 1,
            'fudge_points': 9
        }
    ]
    s.update_score_and_comments(quiz_submissions=updated)

@breed
Copy link
Contributor Author

breed commented Apr 4, 2023

dang, i though i had tried that! thank you for the super quick response. that works thank you!

it seems a little off to have to do the wrapping in the quiz_submissions, since that is always needed, and to add the attempt, since that is in s (the QuizSubmission object). i've put up #602 to make this a little nicer while still preserving legacy behavior.

@bennettscience
Copy link
Contributor

Yeah, there's a few places the API expects a list or dict without really being specific - the only way you can tell is based on how they note the parameters in the docs. It bit me in the but a lot when I first started.

I like the idea of wrapping for people as the default in the library...curious what @Thetwam will say.

Glad I could help 👍

@Thetwam Thetwam linked a pull request Apr 17, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants