Example #1
0
 def set_attribute(self, payload):
     cols = [
         'attempt_id', 'student_id', 'subject_id', 'category_id',
         'skill_id', 'period_id', 'year', 'month', 'day', 'session',
         'score', 'full_score', 'grade', 'creation_date', 'modified_date',
         'modified_by'
     ]
     for col in cols:
         if col in payload.keys():
             setattr(self, col, payload[col])
     if 'subject_name' in payload.keys():
         subjects = SubjectModel.find_by_subject_name(
             payload["subject_name"])
         if subjects:
             self.subject_id = subjects[0].id
     if 'category_name' in payload.keys():
         data = {'category_name': payload["category_name"]}
         assessment_categories = AssessmentCategoryModel.find_assessment_category_by_any(
             **data)
         if assessment_categories:
             self.category_id = assessment_categories[0].id
     if 'skill_name' in payload.keys():
         # data = {'skill_name': payload["skill_name"]}
         assessment_skill = AssessmentSkillModel.find_by_skill_name(
             payload["skill_name"])
         if assessment_skill:
             self.skill_id = assessment_skill.id
     if 'subject_name' in payload.keys():
         data = {'category_name': payload["subject_name"]}
         subject = StudentModel.find_by_student_name(
             payload["subject_name"])
         if subject:
             self.subject_id = subject.id
Example #2
0
 def find_by_subject_name(cls, subject_name):
     subject = SubjectModel.find_by_subject_name(subject_name)
     if subject:
         subject_id = subject.id
         return cls.query.filter_by(subject_id=subject_id).first()
     else:
         return None
Example #3
0
 def find_assessment_skill_by_any(cls, **kwargs):
     cols = ['skill_name', 'skill_code', 'subject_id', 'subject_name'
             'category_id', 'isactive']
     filter_str = 'cls.query'
     if 'skill_name' in kwargs.keys():
         filter_str = filter_str + '.filter_by(skill_name="' + str(
             kwargs['skill_name']) + '")'
     if 'skill_code' in kwargs.keys():
         filter_str = filter_str + '.filter_by(skill_code="' + str(
             kwargs['skill_code']) + '")'
     if 'subject_id' in kwargs.keys():
         filter_str = filter_str + '.filter_by(subject_id="' + str(
             kwargs['subject_id']) + '")'
     if 'category_id' in kwargs.keys():
         filter_str = filter_str + '.filter_by(category_id="' + str(
             kwargs['category_id']) + '")'
     if 'isactive' in kwargs.keys():
         filter_str = filter_str + '.filter_by(isactive="' + str(
             kwargs['isactive']) + '")'
     if 'subject_name' in kwargs.keys():
         subject = SubjectModel.find_by_subject_name(kwargs["subject_name"])
         if subject:
             subject_id = subject.id
             filter_str = filter_str + '.filter_by(subject_id="'\
                          + str(subject_id) + '")'
     if 'category_name' in kwargs.keys():
         assessment_category = AssessmentCategoryModel.find_by_category_name(
             kwargs['category_name'])
         if assessment_category:
             assessment_category_id = assessment_category.id
             filter_str = filter_str + '.filter_by(category_id="' + str(category_id) + '")'
     filter_str = filter_str + '.all()'
     return eval(filter_str)
Example #4
0
 def set_attribute(self, payload):
     cols = ['category_name', 'category_code', 'subject_id', 'isactive']
     for col in cols:
         if col in payload.keys():
             setattr(self, col, payload[col])
     if 'subject_name' in payload.keys():
         subject = SubjectModel.find_by_subject_name(payload["subject_name"])
         if subject:
             self.subject_id = subject.id
Example #5
0
 def set_attribute(self, payload):
     cols = ['skill_name', 'skill_code', 'subject_id', 'category_id','isactive']
     for col in cols:
         if col in payload.keys():
             setattr(self, col, payload[col])
     if 'subject_name' in payload.keys():
         subjects = SubjectModel.find_by_subject_name(payload["subject_name"])
         if subjects:
             self.subject_id = subjects[0].id
     if 'category_name' in payload.keys():
         data = {'category_name': payload["category_name"]}
         assessment_categories = AssessmentCategoryModel.find_assessment_category_by_any(
             **data)
         if assessment_categories:
             self.assessment_category_id = assessment_categories[0].id
Example #6
0
 def get(self):
     data = request.args
     subject_id = data.get("subject_id")
     subject_name = data.get("subject_name")
     subject_code = data.get("subject_code")
     print(data)
     subjects = None
     if subject_name:
         subject = SubjectModel.find_by_subject_name(subject_name)
     elif subject_id:
         subject = SubjectModel.find_by_subject_id(subject_id)
     elif subject_code:
         subject = SubjectModel.find_by_subject_code(subject_code)
     if subject:
         return subject.json()
     return {'message': 'Subject not found'}, 404
Example #7
0
 def find_assessment_result_by_any(cls, **kwargs):
     cols = [
         'attempt_id', 'student_id', 'subject_id', 'assessment_category_id',
         'assessment_skill_id', 'assessment_period_id', 'assessment_year',
         'assessment_month', 'assessment_day', 'assessment_session',
         'assessment_score', 'assessment_full_score', 'assessment_grade',
         'creation_date', 'modified_date', 'modified_by'
     ]
     filter_str = 'cls.query'
     if 'result_id' in kwargs.keys():
         filter_str = filter_str + '.filter_by(id="' + str(
             kwargs['result_id']) + '")'
     if 'attempt_id' in kwargs.keys():
         filter_str = filter_str + '.filter_by(attempt_id="' + str(
             kwargs['attempt_id']) + '")'
     if 'student_id' in kwargs.keys():
         filter_str = filter_str + '.filter_by(student_id="' + str(
             kwargs['student_id']) + '")'
     if 'subject_id' in kwargs.keys():
         filter_str = filter_str + '.filter_by(subject_id="' + str(
             kwargs['subject_id']) + '")'
     if 'category_id' in kwargs.keys():
         filter_str = filter_str + '.filter_by(category_id="' + str(
             kwargs['category_id']) + '")'
     if 'skill_id' in kwargs.keys():
         filter_str = filter_str + '.filter_by(skill_id="' + str(
             kwargs['skill_id']) + '")'
     if 'period_id' in kwargs.keys():
         filter_str = filter_str + '.filter_by(period_id="' + str(
             kwargs['period_id']) + '")'
     if 'year' in kwargs.keys():
         filter_str = filter_str + '.filter_by(year="' + str(
             kwargs['year']) + '")'
     if 'month' in kwargs.keys():
         filter_str = filter_str + '.filter_by(month="' + str(
             kwargs['month']) + '")'
     if 'day' in kwargs.keys():
         filter_str = filter_str + '.filter_by(day="' + str(
             kwargs['day']) + '")'
     if 'session' in kwargs.keys():
         filter_str = filter_str + '.filter_by(session="' + str(
             kwargs['session']) + '")'
     if 'score' in kwargs.keys():
         filter_str = filter_str + '.filter_by(score="' + str(
             kwargs['score']) + '")'
     if 'full_score' in kwargs.keys():
         filter_str = filter_str + '.filter_by(full_score="' + str(
             kwargs['full_score']) + '")'
     if 'grade' in kwargs.keys():
         filter_str = filter_str + '.filter_by(grade="' + str(
             kwargs['grade']) + '")'
     if 'creation_date' in kwargs.keys():
         filter_str = filter_str + '.filter_by(creation_date="' + str(
             kwargs['creation_date']) + '")'
     if 'modified_date' in kwargs.keys():
         filter_str = filter_str + '.filter_by(modified_date="' + str(
             kwargs['modified_date']) + '")'
     if 'modified_by' in kwargs.keys():
         filter_str = filter_str + '.filter_by(modified_by="' + str(
             kwargs['modified_by']) + '")'
     if 'subject_name' in kwargs.keys():
         subject = SubjectModel.find_by_subject_name(kwargs['subject_name'])
         if subject:
             subject_id = subject.id
             filter_str = filter_str + '.filter_by(subject_id="'\
                          + str(subject_id) + '")'
     if 'category_name' in kwargs.keys():
         assessment_category = AssessmentCategoryModel.find_by_category_name(
             kwargs['category_name'])
         if assessment_category:
             category_id = assessment_category.id
             filter_str = filter_str + '.filter_by(category_id="' + str(
                 category_id) + '")'
     if 'student_name' in kwargs.keys():
         student = StudentModel.find_by_student_name(kwargs['student_name'])
         if student:
             student_id = student.id
             filter_str = filter_str + '.filter_by(student_id="' + str(
                 student_id) + '")'
     if 'skill_name' in kwargs.keys():
         skill = AssessmentSkillModel.find_by_skill_name(
             kwargs['skill_name'])
         if skill:
             skill_id = skill.id
             filter_str = filter_str + '.filter_by(skill_id="' + str(
                 skill_id) + '")'
     if 'cluster_id' in kwargs.keys():
         payload = {"cluster_id": kwargs["cluster_id"]}
         students = StudentModel.find_by_student_by_any(**payload)
         if students:
             student_ids = [s.id for s in students]
             # print(student_ids)
             filter_str = filter_str + '.filter(cls.student_id.in_(' + str(
                 student_ids) + '))'
     if 'kalika_kendra_id' in kwargs.keys():
         payload = {"kalika_kendra_id": kwargs["kalika_kendra_id"]}
         students = StudentModel.find_by_student_by_any(**payload)
         if students:
             student_ids = [s.id for s in students]
             filter_str = filter_str + '.filter(cls.student_id.in_(' + str(
                 student_ids) + '))'
     if 'cluster_name' in kwargs.keys():
         payload = {"cluster_name": kwargs["cluster_name"]}
         students = StudentModel.find_by_student_by_any(**payload)
         if students:
             student_ids = [s.id for s in students]
             filter_str = filter_str + '.filter(cls.student_id.in_(' + str(
                 student_ids) + '))'
     if 'kalika_kendra_name' in kwargs.keys():
         payload = {"kalika_kendra_name": kwargs["kalika_kendra_name"]}
         students = StudentModel.find_by_student_by_any(**payload)
         if students:
             student_ids = [s.id for s in students]
             filter_str = filter_str + '.filter(cls.student_id.in_(' + str(
                 student_ids) + '))'
     filter_str = filter_str + '.all()'
     return eval(filter_str)