| 1 | |
| 2 | |
| 3 | from __future__ import annotations |
| 4 | |
| 5 | import config as C |
| 6 | |
| 7 | |
| 8 | class Scale: |
| 9 | |
| 10 | |
| 11 | def __init__(self, name: str, n_students: int): |
| 12 | self.name = name |
| 13 | self.n_students = n_students |
| 14 | self.ratio = n_students / C.N_STUDENTS_FULL |
| 15 | |
| 16 | |
| 17 | SCALES = { |
| 18 | "full": Scale("full", C.N_STUDENTS_FULL), |
| 19 | "smoke": Scale("smoke", 20), |
| 20 | } |
| 21 | |
| 22 | |
| 23 | class Ctx: |
| 24 | def __init__(self, seed: int, scale: Scale, shift_days: int, emitter): |
| 25 | self.seed = seed |
| 26 | self.scale = scale |
| 27 | self.shift_days = shift_days |
| 28 | self.emitter = emitter |
| 29 | |
| 30 | self.users = [] |
| 31 | self.students = [] |
| 32 | self.teachers = [] |
| 33 | self.managers = [] |
| 34 | self.parents = [] |
| 35 | self.parent_links = [] |
| 36 | self.admin = None |
| 37 | |
| 38 | self.courses = [] |
| 39 | self.core_courses = [] |
| 40 | self.extra_courses = [] |
| 41 | self.classes = [] |
| 42 | self.subjects = [] |
| 43 | self.enrolled_courses = {} |
| 44 | |
| 45 | self.exams = [] |
| 46 | self.questions = [] |
| 47 | self.items = {} |
| 48 | self.item_of_question = {} |
| 49 | self.bank_templates = [] |
| 50 | self.homeworks = [] |
| 51 | |
| 52 | |
| 53 | self.stats = {} |
| 54 | self.answer_stats = {"choice_asked": 0, "choice_answered": 0, "choice_correct": 0, |
| 55 | "text_asked": 0, "text_answered": 0} |
| 56 | self.question_stats = {} |
| 57 | self.archetype_stats = {} |
| 58 | self.attendance_stats = {} |
| 59 | self.student_attend = {} |
| 60 | self.hw_stats = {"total": 0, "on_time": 0, "late": 0, "last24": 0, |
| 61 | "on_time_but_updated_late": 0} |
| 62 | self.hw_archetype = {} |
| 63 | self.mark_values = [] |
| 64 | self.kind_ref_counts = {} |
| 65 | self.slot_ref_counts = {} |
| 66 | self.pool_true_subject = [] |
| 67 | self.text_diverged = {} |
| 68 | self.broken_origin = [] |
| 69 | self.answer_key_edits = [] |
| 70 | self.deleted_bank_templates = [] |
| 71 | self.open_pomodoro = {} |
| 72 | self.pomodoro_true_counted = {} |
| 73 | self.appointment_by_student = {} |
| 74 | self.gap_class_stats = {"asked": 0, "correct": 0} |
| 75 | self.all_gap_subjects = set() |
| 76 | self.archetype_counts = {} |
| 77 | self.ungraded_exams = [] |
| 78 | self.expected_question_count = 0 |
| 79 | self.teaching_week_count = 0 |
| 80 | |
| 81 | def bump(self, user, counter: str, amount: int = 1) -> None: |
| 82 | user.counters[counter] = user.counters.get(counter, 0) + amount |