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

Canvas Quiz create_report generate exceptions #671

Open
scott-yj-yang opened this issue Oct 18, 2024 · 0 comments
Open

Canvas Quiz create_report generate exceptions #671

scott-yj-yang opened this issue Oct 18, 2024 · 0 comments
Labels

Comments

@scott-yj-yang
Copy link

Describe the bug

When the quiz does not have a new entries, and a new student report is requested, canvasapi throws exception.

To Reproduce

Steps to reproduce the behavior:

  • Generate quiz report when there is no new entries.
{
	"name": "Conflict",
	"message": "{\"status\":\"conflict\",\"message\":\"report is already being generated\"}",
	"stack": "---------------------------------------------------------------------------
Conflict                                  Traceback (most recent call last)
Input In [6], in <cell line: 1>()
----> 1 github_usernames = cg.fetch_username_from_quiz(quiz_id=185628)

File ~/anaconda3/envs/CanvasGroupy/lib/python3.10/site-packages/CanvasGroupy/canvas.py:237, in CanvasGroup.fetch_username_from_quiz(self, quiz_id, col_index)
    233 if self.verbosity != 0:
    234     print(f\"Quiz: {bcolors.OKGREEN+quiz.title+bcolors.ENDC} \"
    235           f\"fetch! \
Generating Student Analaysis...\"
    236          )
--> 237 report = quiz.create_report(\"student_analysis\")
    238 progress_url = report.progress_url
    239 completed = False

File ~/anaconda3/envs/CanvasGroupy/lib/python3.10/site-packages/canvasapi/quiz.py:141, in Quiz.create_report(self, report_type, **kwargs)
    135     raise ValueError(
    136         \"Param `report_type` must be a either 'student_analysis' or 'item_analysis'\"
    137     )
    139 kwargs[\"quiz_report\"] = {\"report_type\": report_type}
--> 141 response = self._requester.request(
    142     \"POST\",
    143     \"courses/{}/quizzes/{}/reports\".format(self.course_id, self.id),
    144     _kwargs=combine_kwargs(**kwargs),
    145 )
    147 response_json = response.json()
    148 response_json.update({\"course_id\": self.course_id})

File ~/anaconda3/envs/CanvasGroupy/lib/python3.10/site-packages/canvasapi/requester.py:257, in Requester.request(self, method, endpoint, headers, use_auth, _url, _kwargs, json, **kwargs)
    255     raise ResourceDoesNotExist(\"Not Found\")
    256 elif response.status_code == 409:
--> 257     raise Conflict(response.text)
    258 elif response.status_code == 422:
    259     raise UnprocessableEntity(response.text)

Conflict: {\"status\":\"conflict\",\"message\":\"report is already being generated\"}"

Expected behavior

From the doc:

Create and return a new report for this quiz. If a previously generated report matches the arguments and is still current (i.e. there have been no new submissions), it will be returned.

Environment information

  • Python version (python --3.10.9)
  • CanvasAPI version (pip show canvasapi) 3.1.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant