80 lines
2.1 KiB
Python
80 lines
2.1 KiB
Python
|
from random import choice, randint
|
||
|
|
||
|
from faker import Faker
|
||
|
|
||
|
from backend.model.assessment import Assessment, Domain, Exercise, Question, Skill
|
||
|
from backend.model.student import Tribe
|
||
|
|
||
|
faker = Faker()
|
||
|
|
||
|
|
||
|
def build_tribes(quantity=1):
|
||
|
return [Tribe(name=faker.words(5), level=faker.words(5)) for _ in range(quantity)]
|
||
|
|
||
|
|
||
|
def build_tribe_assessment(tribe_qty=1, assessment_per_tribe=1):
|
||
|
tribes = build_tribes(tribe_qty)
|
||
|
|
||
|
assessments = []
|
||
|
for t in tribes:
|
||
|
assessments += [
|
||
|
Assessment("faker.words(5)", t, randint(1, 3))
|
||
|
for _ in range(assessment_per_tribe)
|
||
|
]
|
||
|
|
||
|
return tribes, assessments
|
||
|
|
||
|
|
||
|
def build_tribe_assessment_exercise(
|
||
|
tribe_qty=1, assessment_per_tribe=1, exercise_per_assessment=1
|
||
|
):
|
||
|
tribes, assessments = build_tribe_assessment(tribe_qty, assessment_per_tribe)
|
||
|
|
||
|
exercises = []
|
||
|
for assessment in assessments:
|
||
|
exercises += [
|
||
|
Exercise("faker.words(4)", assessment, "today")
|
||
|
for _ in range(exercise_per_assessment)
|
||
|
]
|
||
|
|
||
|
return tribes, assessments, exercises
|
||
|
|
||
|
|
||
|
def build_skills(quantity=1):
|
||
|
return [Skill(faker.words(6), faker.text()) for _ in range(quantity)]
|
||
|
|
||
|
|
||
|
def build_domains(quantity=1):
|
||
|
return [Domain(faker.words(6), faker.text()) for _ in range(quantity)]
|
||
|
|
||
|
|
||
|
def build_tribe_assessment_exercise_question(
|
||
|
tribe_qty=1,
|
||
|
assessment_per_tribe=1,
|
||
|
exercise_per_assessment=1,
|
||
|
question_per_exercise=1,
|
||
|
):
|
||
|
tribes, assessments, exercises = build_tribe_assessment_exercise(
|
||
|
tribe_qty, assessment_per_tribe, exercise_per_assessment
|
||
|
)
|
||
|
|
||
|
skills = build_skills()
|
||
|
domains = build_domains()
|
||
|
|
||
|
questions = []
|
||
|
for exercise in exercises:
|
||
|
questions += [
|
||
|
Question(
|
||
|
faker.words(2),
|
||
|
exercise,
|
||
|
description="desc",
|
||
|
skill=choice(skills),
|
||
|
domain=choice(domains),
|
||
|
is_leveled=choice([True, False]),
|
||
|
scale=randint(1, 20),
|
||
|
)
|
||
|
for _ in range(question_per_exercise)
|
||
|
]
|
||
|
|
||
|
return tribes, assessments, exercises, questions
|