2022-12-20 06:58:50 +00:00
|
|
|
from random import choice, randint
|
|
|
|
|
|
|
|
from faker import Faker
|
|
|
|
|
2022-12-20 06:18:48 +00:00
|
|
|
from backend.model.assessment import Assessment, Domain, Exercise, Question, Skill
|
|
|
|
from backend.model.student import Tribe
|
|
|
|
|
2022-12-20 06:58:50 +00:00
|
|
|
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)
|
|
|
|
]
|
2022-12-20 06:18:48 +00:00
|
|
|
|
2022-12-20 06:58:50 +00:00
|
|
|
return tribes, assessments
|
2022-12-20 06:18:48 +00:00
|
|
|
|
|
|
|
|
2022-12-20 06:58:50 +00:00
|
|
|
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)
|
2022-12-20 06:18:48 +00:00
|
|
|
|
2022-12-20 06:58:50 +00:00
|
|
|
exercises = []
|
|
|
|
for assessment in assessments:
|
|
|
|
exercises += [
|
|
|
|
Exercise("faker.words(4)", assessment, "today")
|
|
|
|
for _ in range(exercise_per_assessment)
|
|
|
|
]
|
2022-12-20 06:18:48 +00:00
|
|
|
|
2022-12-20 06:58:50 +00:00
|
|
|
return tribes, assessments, exercises
|
2022-12-20 06:18:48 +00:00
|
|
|
|
|
|
|
|
2022-12-20 06:58:50 +00:00
|
|
|
def build_skills(quantity=1):
|
|
|
|
return [Skill(faker.words(6), faker.text()) for _ in range(quantity)]
|
2022-12-20 06:18:48 +00:00
|
|
|
|
|
|
|
|
2022-12-20 06:58:50 +00:00
|
|
|
def build_domains(quantity=1):
|
|
|
|
return [Domain(faker.words(6), faker.text()) for _ in range(quantity)]
|
2022-12-20 06:18:48 +00:00
|
|
|
|
|
|
|
|
2022-12-20 06:58:50 +00:00
|
|
|
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
|
|
|
|
)
|
|
|
|
|
2022-12-20 06:18:48 +00:00
|
|
|
skills = build_skills()
|
|
|
|
domains = build_domains()
|
2022-12-20 06:58:50 +00:00
|
|
|
|
|
|
|
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
|
2022-12-20 06:18:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_assessement_register_exercise():
|
2022-12-20 06:58:50 +00:00
|
|
|
exercise_qty = randint(1, 10)
|
|
|
|
tribes, assessments, exercises = build_tribe_assessment_exercise(
|
|
|
|
exercise_per_assessment=exercise_qty
|
|
|
|
)
|
2022-12-20 06:18:48 +00:00
|
|
|
|
2022-12-20 06:58:50 +00:00
|
|
|
assert len(assessments[0].exercises) == exercise_qty
|
|
|
|
assert assessments[0].exercises == exercises
|
2022-12-20 06:18:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
def test_exercise_register_question():
|
2022-12-20 06:58:50 +00:00
|
|
|
question_qty = randint(1, 10)
|
|
|
|
(
|
|
|
|
tribes,
|
|
|
|
assessments,
|
|
|
|
exercises,
|
|
|
|
questions,
|
|
|
|
) = build_tribe_assessment_exercise_question(question_per_exercise=question_qty)
|
|
|
|
|
|
|
|
assert len(exercises[0].questions) == question_qty
|
|
|
|
assert exercises[0].questions == questions
|