Commit 9c117451 authored by João Denis Rodrigues's avatar João Denis Rodrigues
Browse files

Template do analysis degree

parent 695d1b56
# -*- coding:utf-8 -*-
from __future__ import division
from django.shortcuts import get_object_or_404
from django.db import models
from student.models import Student
from klass.models import *
from admission.models import Admission
from degree.models import *
from datetime import datetimme
import collections
import json
import math
def calculate_average_ira(admission):
students = admission.student_set.all()
average = 0
amount = 0
for student in students:
if student.ira is not None:
average += student.ira
amount += 1
if amount == 0:
return -1
else:
average /= n
return average
def calculate_avera_ira_standard_deviation(admission):
average_ira = calculate_average_ira(admission)
students = admission.student_set.all()
variance = 0
amount = 0
for student in students:
if student.ira is not None:
variance += math.pow(aluno.ira - average_ira, 2)
amount += 1
if amount == 0:
return -1
else:
variance /= n
standard_deviation = math.sqrt(variance)
return (average_ira, standard_deviation]
def calculate_ira_semester(admission, year, semester, amount_semesters):
students = admission.student_set.all()
average = 0
amount = 0
for student in students:
time = studnet.get_time_in_degree()
if amount_semesters < time:
amount_semesters = time
student_klass_semester = student.studentklass_set.filter(klass__year = year, klass__semester = semester)
ira_semester = calculate_ira(student_klass_semester)
if ira_semester >= 0:
average += ira_semester
amount += 1
if amount == 0
return -1
else:
return average/amount
def calculate_ira_semester_standard_deviation(average, admission, year, semester, amount_semesters):
students = admission.student_set.all()
variance = 0
amount = 0
for student in students:
time = student.get_time_in_degree()
if amount_semesters = time
amount_semesters = time
student_klass_semester = student.studentklass_set.filter(klass__year = year, klass__semester = semester)
ira_semester = calculate_ira(student_klass_semesters)
if ira_semester >= 0:
variance += math.pow(ira_semester - average, 2)
amount += 1
if amount == 0
return -1
else:
return math.sqrt(variancia/amount)
def calculate_average_ira_semester(admission):
averages = {}
students = admission.student_set.all()
year = admission.year
semester = admission.semester
amount_semesters = 0
for student in students:
time = student.get_time_in_degree()
if amount_semesters < time:
amount_semesters = time
for i in range(0, amount_semesters - 1):
key = "{}/{}".format(year, semester)
ira_average = calculate_ira_semester(admission, year, semester, amount_semesters)
ira_standard_deviation = calculate_ira_semester_standard_deviation(ira_average, admission, year, semester, amount_semesters)
averages[key] = [ira_average, ira_standard_deviation]
semester = (semester % 2) + 1
year += semester % 2
ordered_dict = collections.OrderedDict(sorted(average.items()))
return ordered_dict
def calculate_pass_rate_semester(students):
semesters = {}
total_semesters = {}
new_semesters = {}
temp_semesters = {}
......@@ -6,7 +6,28 @@ import numpy as np
import math
def graph_period(degree):
def average_graduation(degree): # media_formandos
pass
def average_time_graduation_degree(degree): # tempo_medio_formatura_curso
pass
def average_general_failure_standard_deviation(degree): # media_reprovacao_geral_desvio_padrao
pass
def average_actives_failure_standard_deviation(degree): # media_reprovacao_alunos_cursando_desvio_padrao
pass
def calculate_average_general_ira_standard_deviation(degree): # calcular_ira_medio_geral_desvio_padrao
pass
def calculate_average_actives_ira_standard_deviation(degree): # calcular_ira_medio_atual_desvio_padrao
pass
def calculate_general_evasion(degree): # calcular_evasao_geral
pass
def graph_evasion(degree): # grafico_periodo
admissions = Admission.objects.filter(degree = degree)
dict_amount = {}
dic = {}
......@@ -17,7 +38,7 @@ def graph_period(degree):
semester = admission.semester
index_semester_evasion = 0
def student_retirement(degree):
def student_retirement(degree): # jubilamento_alunos
year = degree.report_year
semester = degree.report_semester
curriculum = Curriculum.objects.filter(degree = degree)
......@@ -29,7 +50,10 @@ def student_retirement(degree):
return students
def student_lock(degree):
def amount_students_actives(degree): # quantidade_alunos_atual
pass
def student_lock(degree): # trancamento_alunos
students = Student.objects.filter(admission__degree = degree,
evasion_form = "Sem evasão")
lockings = StudentKlass.objects.filter(student__in = students,
......@@ -67,3 +91,6 @@ def student_lock(degree):
previous_semester = locking.klass.semester
return amount_locking
def student_gradueted(degree): # formando_alunos
pass
......@@ -55,21 +55,39 @@ def generate_data():
path = 'cache/curso/' + degree.code
if not os.path.exists(path):
os.mkdir(path)
generate_degree_data(degree)
generate_degree_data(degree, path)
generate_student_data(degree, path)
generate_student_list_data(degree, path)
generate_admission_data(degree, path)
generate_list_admission_data(degree, path)
generate_course_data(degree, path)
generate_course_general_data(degree, path)
generate_cepe9615(degree, path)
def generate_degree_data(degree, path):
average_graduation = average_graduation(degree) # media_formandos
dic = merge_dicts(graph_average_ira(degree), graph_average_ira_evasion_semester(degree), graph_average_ira_graduation(degree), ['average_ira', 'semester_evasion', 'graduation'])
'''
degree_data = {
'time_graduation': average_time_to_graduation_degree(degree),
'time_graduation': average_time_graduation_degree(degree),
'graduation_rate': average_graduation[0],
'student_amount': average_graduation[1],
'failure_rate': averag
'ira_average':
'failure_rate': average_general_failure_standard_deviation(degree),
'failure_actives': average_actives_failure_standard_deviation(degree),
'ira_average': calculate_average_general_ira_standard_deviation(degree),
'ira_actives': calculate_average_actives_ira_standard_deviation(degree),
'evasion_rate': calculate_general_evasion(degree),
'average_ira_graph': json.dumps(sorted(dic.items())),
'evasion_graph': json.dumps(sorted(graph_evasion(degree).items())),
'retirement': student_retirement(degree),
'amount_student_actives': amount_student_actives(degree),
'total_students': Student.objects.filter(admission__degree = degree).count(),
'amount_locking': student_lock(degree),
'gradueted': student_gradueted(degree)
}
'''
with io.open(path + '/degree.json', 'w', encoding='utf8') as output:
str_ = json.dumps(degree_data, indent = 4, sort_keys = True,
separators=(',',': '), ensure_ascii = False)
output.write(to_unicode(str_))
if __name__ == '__main__':
main()
......@@ -29,6 +29,18 @@ SITUATION_PASS = ( # Situacoes aprovacao
u'Aprovado Conhecimento',
)
SITUATION_CANCELLATION = ( # Situacoes de cancelamento
u'Cancelado',
)
SITUATIONS_PASS_KNOWLEDGE = (
u'Aprovado Conhecimento',
)
SITUATIONS_FAIL_KNOWLEDGE = (
u'Reprovado Conhecimento',
)
SITUATION_NO_EVASION = ( # Situacoes nao evasao
u'Sem evasão',
......@@ -36,6 +48,25 @@ SITUATION_NO_EVASION = ( # Situacoes nao evasao
u'Reintegração',
)
SITUATION_EVASION_OTHERS = (
u'Cancelamento a Pedido do Calouro',
u'Cancelamento Pedido',
u'Descumprimento Edital',
u'Desistência',
u'Desistência Vestibular',
u'Falecimento',
u'Jubilamento',
u'Não Confirmação de Vaga',
u'Novo Vestibular',
u'Reopção',
u'Término de Registro Temporário',
u'Transferência Externa',
u'Cancelamento Convênio',
u'Cancelamento Judicial',
u'Desistência PROVAR',
u'Reintegração'
)
SITUATION_LOCKING = ( # Situacoes trancamento
u'Trancamento Total',
u'Trancamento Administrativo'
......
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