def add_exams(dbn, num_takers, reading_score, math_score, writing_score) -> Schools: Schools.objects(dbn=dbn).update(num_takers=num_takers, reading_score=reading_score, math_score=math_score, writing_score=writing_score)
def get_rated_forms_for_school(school_dbn, count) -> List[Form]: my_school = Schools.objects(dbn=school_dbn).first() print(my_school) forms = Form.objects( id__in=my_school.Form_ids).all().order_by("-" + "avg_score").limit(count) return list(forms)
def add_form(school_dbn, name) -> Form: form = Form() form.name = name form.save() school = Schools.objects(dbn=school_dbn).first() school.Form_ids.append(form.id) school.save() return form
def update_aver_score_school(school_dbn) -> Schools: Schools.objects(dbn=school_dbn).update( avg_score=get_average_score_for_school(school_dbn))
def find_School_by_dbn(dbn: str) -> Schools: school = Schools.objects(dbn=dbn).first() return school
def get_schools() -> List[Schools]: schools = Schools.objects().all() return list(schools)
def get_schools_for_user(user_id: bson.ObjectId) -> List[Schools]: owner = Owner.objects(id=user_id).first() schools = Schools.objects(id__in=owner.School_ids).all() return list(schools)
def add_school(dbn, name, num_takers, reading_score, math_score, writing_score, num_takers2, exam_taken2, exam_good2) -> Schools: school = Schools() school.dbn = dbn school.name = name school.num_takers = num_takers school.reading_score = reading_score school.math_score = math_score school.writing_score = writing_score school.num_takers2 = num_takers2 school.exam_taken2 = exam_taken2 school.exam_good2 = exam_good2 school.save()
def add_school_custom(account, dbn, name, num_takers, reading_score, math_score, writing_score, num_takers2, exam_taken2, exam_good2) -> Schools: school = Schools() school.dbn = dbn school.name = name school.num_takers = num_takers school.reading_score = reading_score school.math_score = math_score school.writing_score = writing_score school.num_takers2 = num_takers2 school.exam_taken2 = exam_taken2 school.exam_good2 = exam_good2 school.save() owner = find_account_by_email(account.email) owner.School_ids.append(school.id) owner.save() return school
def get_forms_for_school(school_dbn: bson.ObjectId) -> List[Form]: my_school = Schools.objects(dbn=school_dbn).first() forms = Form.objects(id__in=my_school.Form_ids).all() return forms
def get_average_score_for_school(school_dbn: bson.ObjectId): my_school = Schools.objects(dbn=school_dbn).first() avg = Form.objects(id__in=my_school.Form_ids).average('avg_score') return avg