- argparse
- dotenv
- canvasapi
run
pip install -r requirements.txt
to install dependencies
- Make sure you have enough permissions.
- Get your Canvas API key from your Canvas account following steps.
- Copy your API key and paste it in the
.env
file. - Run
python [single_problem_quiz.py| multiple_problem_quiz.py]
. Details are shown below.
Description: Update the total score of a quiz and upload attachments for the quiz
Usage:
python single_problem_quiz.py [-h] -c COURSE_ID -a ASSIGNMENT_ID -e EXCEL_PATH -d DIR_PATH
Optional arguments:
-h, --help
show this help message and exit-c COURSE_ID
,--course_id COURSE_ID
ID of the course-a ASSIGNMENT_ID
,--assignment_id ASSIGNMENT_ID
ID of the assignment-e EXCEL_PATH
,--excel_path EXCEL_PATH
Path to Excel file that must include id and score columns-d DIR_PATH
,--dir_path DIR_PATH
Path to attachment directory. Naming of the files follows the format:sectionId_lastName_firstName_studentId_SISLoginId_id.*
Example:
python single_problem_quiz.py -c 130230 -a 3155457 -e ./test/resources/scores.xlsx -d ./test/resources/attachments
Open speed grader tab in canvas and copy the course ID and assignment ID from the URL. For example, if the URL is https://osu.instructure.com/courses/130230/gradebook/speed_grader?assignment_id=3155457&student_id=1057113
, then the course ID is 130230
the assignment ID is 3155457
and the student_id is 1057113
.
Description: Update the score for a single problem in the quiz and upload attachments for the problem.
usage: python multiple_problems_quiz.py [-h] -c COURSE_ID -q QUIZ_ID -Q QUESTION_ID -a ASSIGNMENT_ID -e EXCEL_PATH -d DIR_PATH
optional arguments:
-h
,--help
show this help message and exit-c COURSE_ID
,--course_id COURSE_ID
ID of the course-q QUIZ_ID
,--quiz_id QUIZ_ID
ID of the quiz-Q QUESTION_ID
,--question_id QUESTION_ID
ID of the first question-a ASSIGNMENT_ID
,--assignment_id ASSIGNMENT_ID
ID of the assignment-e EXCEL_PATH
,--excel_path EXCEL_PATH
Path to Excel file that must include id and score columns-d DIR_PATH
,--dir_path DIR_PATH
Path to attachment directory
Open a quiz tab in Quizzes
and copy quiz_id
from the url. For example, if the URL is https://osu.instructure.com/courses/130230/quizzes/816752
, then the quiz ID is 816752
. To get the question_id, for example, if the URL is https://osu.instructure.com/courses/130230/quizzes/816752/questions/3155458
, then the question_id
is 3155458
.
Unfortunately as a TA, I don't have the permission to access the second url. If you are also a TA, however, there is way around it to get the question_id
.
- Open the speed grader tab.
- Right click on a question to show the developer tool.
- Click inspect and find the
question_id
in thedata-question_id
tag attribute.
- If you have an instructor role, you can get question_id directly from canvas api.
- I tried web-scraping the speed-grader page in order to get
question_id
automatically. However it requires duo authentication. I am afraid there is no way around it using api.