Commit 8c119d4c authored by João Denis Rodrigues's avatar João Denis Rodrigues
Browse files

Finalizando cache aluno

parent 9a81c461
......@@ -25,7 +25,6 @@ def average_time_graduation_degree(degree): # tempo_medio_formatura_curso
average_time = 0
for g in graduated:
print(g.get_time_in_degree())
average_time += g.get_time_in_degree()
average_time /= graduated_amount
......
......@@ -93,7 +93,78 @@ def generate_degree_data(degree, path):
def generate_student_data(degree, path):
print("\t- Fazendo analises dos alunos")
return
students = Student.objects.filter(admission__degree = degree)
students_amount = students.count()
counter = 0
student_path = path + '/student'
if not os.path.exists(student_path):
os.mkdir(student_path)
for student in students:
student_klasses = StudentKlass.objects.filter(student=student)
amount_courses_semester = get_student_courses_completed(student_klasses)
failures_semester = semester_pass_rate(student)
# failures_amount_courses_semester = merge_dicts(failures_semester, amount_courses_semester)
ira_courses = sorted(ira_amount_courses(student).items())
pass_rate = pass_rate(student_klasses)
pass_rate_semester = sorted(failures_semester.items())
position = sorted(get_student_position(student).items())
real_period = get_real_period(student)
intended_period = get_intended_period(student)
dict_ira_semester = {}
dict_ira_amount_courses = {}
dict_position = {}
dict_pass = {}
for item, course_pass, pos in zip(ira_courses, pass_rate_semester, position):
ca = list(course_pass)
i = list(item)
p = list(pos)
d_pass, d_done = ap[1]
date = ap[0].split('/')
semester_data = {}
data = '{}/{}'.format(date[0], date[1])
dict_ira_semester[data] = i[1][0]
dict_ira_amount_courses[data] = [i[1][0], d_done]
dict_position[data] = pos[1]
dict_pass[data] = [d_pass, d_done]
student_klasses = StudentKlass.objects.filter(student=student)
student_klass = []
for sk in student_klasses:
sk_dict = {
'grade': sk.grade,
'name': sk.klass.course.name,
'code': sk.klass.course.code,
'situation': sk.situation,
'year': sk.klass.year,
'semester': sk.klass.semester
}
student_klass.append(sk_dict)
student_data = {
'ira_semester': dict_ira_semester,
'semester_pass_rate': dict_pass,
'position': dict_position,
'ira_amount_courses': dict_ira_amount_courses,
'pass_rate': pass_rate,
'intended_period': intended_period,
'real_period': real_period,
'student_klass': student_klass
}
counter += 1
with io.open(student_path + '/' + student.grr + '.json', 'w', encondig = 'utf8') as output:
str_ = json.dumps(student_data, indent = 3, sort_keys = True,
separators=(',', ': '), ensure_ascii = False)
output.write(to_unicode(str_))
if counter % 100 == 0:
print("\t\t- %d alunos processados de %d" % (counter, students_amount))
return
def generate_student_list_data(degree, path):
print("\t- Criando lista de alunos")
......
......@@ -11,7 +11,7 @@ def pass_amount(student_klasses): # calcular_indice_aprovacao
amount_pass = 0
amount_courses = 0
for student_klass in student_klasses:
if student_klass.situation in SITUATION_COURSE_COMPLETED:
if student_klass.situation in SITUATIONS_COURSE_COMPLETED:
amount_courses += 1
if student_klass.situation in SITUATION_PASS:
amount_pass += 1
......@@ -21,7 +21,13 @@ def pass_amount(student_klasses): # calcular_indice_aprovacao
def pass_rate(student_klasses): # indice_aprovacao
amount_pass = 0
pass
amout_courses = 0
for sk in student_klasses:
if sk.situation in SITUATIONS_COURSE_COMPLETED:
amount_courses += 1
if sk.situation in SITUATION_PASS:
amount_pass += 1
return -1 if amount_courses == 0 else amount_pass / amount_courses
def semester_pass_rate(student): # calcular_indice_aprovacao_semestral
index = {}
......@@ -29,7 +35,7 @@ def semester_pass_rate(student): # calcular_indice_aprovacao_semestral
year = student.admission.year
semester = student.admission.semester
for i in range(0, amoun_semesters):
for i in range(0, amount_semesters):
#semester_student_klass = student.studentklass_set.filter(klass__year = year, klass__semester = semester
#semester_index = pass_amount
semester_index = student.studentklass_set.filter(klass__year = year, klass__semester = semester, situation__in = SITUATION_PASS).count()
......@@ -47,7 +53,8 @@ def get_student_courses_completed(student_klasses):
student_courses_completed = []
for student_klass in student_klasses:
if student_klass.situation in SITUATION_COURSE_COMPLETED:
if student_klass.situation in SITUATIONS_COURSE_COMPLETED:
student_courses_completed.append(student_klass)
return student_courses_completed
......@@ -126,13 +133,13 @@ def get_student_position(student):
def ira_amount_courses(student):
ira_semesters = get_ira_semester(student)
amount_courses = get_student_courses_completed(student)
amount_courses = get_amount_courses_completed(student)
ira_amount_course = {}
ira_amount_course = ira_amount_course.fromkeys(ira_semesters.keys())
for ira_semester in ira_semesters:
ira_amount_course[ira_semester] = [ira_semesters[ira_semester], amount_course[ira_semester]]
ira_amount_course[ira_semester] = [ira_semesters[ira_semester], amount_courses[ira_semester]]
return ira_amount_course
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment