|
| 1 | +from __future__ import print_function, unicode_literals |
| 2 | + |
1 | 3 | from faker import Faker
|
2 | 4 | from canvasapi import Canvas
|
3 | 5 |
|
@@ -93,3 +95,22 @@ def generate_enrollments(account_id, min_students=1, max_students=5):
|
93 | 95 | already_enrolled.append(enroll_user.id)
|
94 | 96 |
|
95 | 97 | # TODO: Add support for enrolling Teachers/ TAs
|
| 98 | + |
| 99 | + |
| 100 | +def generate_quizzes(course_id, min_quizzes=1, max_quizzes=5): |
| 101 | + course = canvas.get_course(course_id) |
| 102 | + num_quizzes = fake.random_int(min_quizzes, max_quizzes) |
| 103 | + |
| 104 | + QUIZ_TYPES = ['practice_quiz', 'assignment', 'graded_survey', 'survey'] |
| 105 | + |
| 106 | + for i in range(num_quizzes): |
| 107 | + course.create_quiz(quiz={ |
| 108 | + 'title': fake.bs().title(), |
| 109 | + 'description': fake.text(max_nb_chars=fake.random_int(100, 500)), |
| 110 | + 'quiz_type': fake.random_element(QUIZ_TYPES), |
| 111 | + 'time_limit': fake.random_int(1, 30) * 5 if fake.boolean(50) else None, |
| 112 | + 'published': fake.boolean(75), |
| 113 | + 'allowed_attempts': fake.random_int(1, 3) if fake.boolean(75) else -1 |
| 114 | + }) |
| 115 | + |
| 116 | + # TODO: add quiz questions |
0 commit comments