Code for Canvas:
# Import the Canvas API library
from canvasapi import Canvas
# Set API URL and API key
API_URL = "https://yourinstitution.instructure.com"
API_KEY = "your_api_key"
# Initialize a new Canvas object
canvas = Canvas(API_URL, API_KEY)
# Set the quiz id
quiz_id = 12345
# Create multiple choice questions
question1 = {
"question_name": "Who conceptualized Python in the late 1980s?",
"question_text": "Who conceptualized Python in the late 1980s?",
"question_type": "multiple_choice_question",
"answers": [
{"answer_text": "Guido van Rossum", "weight": 100},
{"answer_text": "Alice Packer", "weight": 0},
{"answer_text": "Monty Python", "weight": 0},
{"answer_text": "The National Research Institute for Scientific Research", "weight": 0}
]
}
question2 = {
"question_name": "What was the original target system for Python?",
"question_text": "What was the original target system for Python?",
"question_type": "multiple_choice_question",
"answers": [
{"answer_text": "Mobile", "weight": 0},
{"answer_text": "Time-sharing", "weight": 100},
{"answer_text": "Systems programming", "weight": 0},
{"answer_text": "The Internet", "weight": 0}
]
}
question3 = {
"question_name": "What was the name of the initiative launched by Guido van Rossum to make programming more accessible to the masses?",
"question_text": "What was the name of the initiative launched by Guido van Rossum to make programming more accessible to the masses?",
"question_type": "multiple_choice_question",
"answers": [
{"answer_text": "Python for Everyone", "weight": 0},
{"answer_text": "Computer Programming for Everyone", "weight": 100},
{"answer_text": "Easy Programming for All", "weight": 0},
{"answer_text": "The Python Initiative", "weight": 0}
]
}
# Add questions to quiz
quiz = canvas.get_quiz(quiz_id)
quiz.create_question(question1)
quiz.create_question(question2)
quiz.create