Documentation¶
Usage: myst2canvas [OPTIONS] NOTEBOOK_FILE
Parse file into quiz and upload to Canvas.
Options: * -u, –url TEXT
URL of Canvas course.
-t, –token TEXT
Token string generated by Canvas.
-f, –token-file TEXT
File containing token string generated by Canvas.
-c, –course-id TEXT
ID of the course.
-s, –save-settings
Set flag to save settings for future use.
-q, –quiz-id TEXT
ID of the quiz, use if updating existing quiz.
-d, –dump TEXT
File to dump JSON string to.
-n, –no-upload
Set flag to stop uploading of quiz.
-h, –hush
Set flag to stop printing other than warnings and errors.
–help
Show this message and exit.
Example¶
The quiz in the examples folder is fully functional on the latest version of myst2canvas. If your settings are already saved in the config file, this quiz can be uploaded with the following command:
myst2canvas .\examples\simpleQuiz.md
API¶
For using the API, refer to the Documentation page.
The following files are documented here:
myst2json.py¶
-
myst2canvas.myst2json.
parse_answerless_question
(q_name, options)¶ Function for dict, takes place for question types with no answers.
- Parameters
q_name (str) – name of the question
options (str) – metadata and answer list
- Returns
[obj] – parsed answers
obj – extra attributes to add to the question
-
myst2canvas.myst2json.
parse_attrs
(text, title_name='title', desc_name='description')¶ Parse metadata.
- Parameters
text (str) – metadata
title_name (str) – dict key for title
desc_name (str) – dict key for description
- Returns
obj – parsed metadata
[str] – list of paths to images linked from this text
-
myst2canvas.myst2json.
parse_group
(text, group_arr)¶ Parse Question Group.
- Parameters
text (str) – metadata for the group
group_arr ([obj]) – list of the following objects in the quiz
- Returns
parsed group
- Return type
obj
-
myst2canvas.myst2json.
parse_matching_question
(q_name, options)¶ Parse matching question answers.
- Parameters
q_name (str) – name of the question
options (str) – metadata and answer list
- Returns
[obj] – parsed answers
obj – extra attributes to add to the question
-
myst2canvas.myst2json.
parse_md_text
(text)¶ Parse markdown into HTML, also check for latex.
- Parameters
text (str) – text to parse
- Returns
str – parsed text with Canvas latex
[str] – list of paths to images linked from this text
-
myst2canvas.myst2json.
parse_multiple_answers_question
(q_name, options)¶ Parse multiple answers question answers.
- Parameters
q_name (str) – name of the question
options (str) – metadata and answer list
- Returns
[obj] – parsed answers
obj – extra attributes to add to the question
-
myst2canvas.myst2json.
parse_multiple_choice_question
(q_name, options)¶ Parse multiple choice question answers.
- Parameters
q_name (str) – name of the question
options (str) – metadata and answer list
- Returns
[obj] – parsed answers
obj – extra attributes to add to the question
-
myst2canvas.myst2json.
parse_numerical_question
(q_name, options)¶ Parse numerical question answers.
- Parameters
q_name (str) – name of the question
options (str) – metadata and answer list
- Returns
[obj] – parsed answers
obj – extra attributes to add to the question
-
myst2canvas.myst2json.
parse_question
(text, question_arr)¶ Parse Question.
- Parameters
text (str) – metadata for the question
question_arr ([obj]) – list of the following objects in the quiz
- Returns
parsed question
- Return type
obj
-
myst2canvas.myst2json.
parse_quiz
(nb_file)¶ Parse quiz at given file path.
- Parameters
nb_file (str) – path to quiz file to parse
- Returns
parsed quiz
- Return type
obj
-
myst2canvas.myst2json.
parse_short_answer_question
(q_name, options)¶ Parse short answer question answers.
- Parameters
q_name (str) – name of the question
options (str) – metadata and answer list
- Returns
[obj] – parsed answers
obj – extra attributes to add to the question
-
myst2canvas.myst2json.
parse_true_false_question
(q_name, options)¶ Parse true/false question answers.
- Parameters
q_name (str) – name of the question
options (str) – metadata and answer list
- Returns
[obj] – parsed answers
obj – extra attributes to add to the question
-
myst2canvas.myst2json.
parse_value
(val)¶ Parse value.
- Parameters
val (str) – value to parse
- Returns
parsed value
- Return type
int/bool/datetime/str
-
myst2canvas.myst2json.
parse_weight
(weight)¶ Convert weight to int.
- Parameters
weight (bool/int) – weight to convert
- Returns
converted weight
- Return type
int
-
myst2canvas.myst2json.
to_canvas
(latex, inline=False)¶ Convert latex to Canvas format.
- Parameters
latex (str) – latex string
inline (bool) – True if latex is inline
- Returns
converted latex
- Return type
str
json2canvas.py¶
-
myst2canvas.json2canvas.
edit_quiz
(url, quiz, canvas_quiz, canvas_quiz_folder)¶ Update an existing quiz.
- Parameters
url (str) – Canvas URL
quiz (obj) – parsed quiz data
canvas_quiz (Quiz) – Quiz object to modify
canvas_quiz_folder (obj) – Canvas course to get folder from
- Returns
- Return type
None
-
myst2canvas.json2canvas.
get_course
(url, token, course_id)¶ Retrieve Course from Canvas
- Parameters
url (str) – Canvas URL
token (str) – access token
course_id (str) – numerical ID of course
- Returns
Course object that hosts quiz
- Return type
Course
-
myst2canvas.json2canvas.
get_quiz_folder
(course, quiz_id)¶ Get media folder for this quiz.
- Parameters
course (obj) – Canvas course to get folder from
quiz_id (str) – numerical ID of quiz
- Returns
ID of folder for given quiz
- Return type
int
-
myst2canvas.json2canvas.
update_media
(url, folder, media)¶ Add media to folder if it doesn’t already exist.
- Parameters
url (str) – Canvas URL
folder (obj) – Canvas course to get folder from
quiz_id (str) – numerical ID of quiz
- Returns
ID of folder for given quiz
- Return type
int
-
myst2canvas.json2canvas.
update_quiz
(quiz, url, token, course_id, quiz_id)¶ Update an existing quiz.
- Parameters
quiz (obj) – parsed quiz data
url (str) – Canvas URL
token (str) – access token
course_id (str) – numerical ID of course
quiz_id (str) – numerical ID of quiz
- Returns
- Return type
None
-
myst2canvas.json2canvas.
upload_quiz
(quiz, url, token, course_id)¶ Upload a new quiz.
- Parameters
quiz (obj) – parsed quiz data
url (str) – Canvas URL
token (str) – access token
course_id (str) – numerical ID of course
- Returns
- Return type
None