Commit 043e8a8d authored by Bruno Meyer's avatar Bruno Meyer 😢

Merge branch '150-quantidades-de-turma-ingresso' into 'development'

Merge branch '150-quantidades-de-turma-ingresso' into 'development'

Closes #150

See merge request adega/adega!45
parents e4aaee56 a48b2cf1
<div class="sidebar left hidden-sm hidden-xs">
<ul class="list-sidebar">
<li><a class="btn btn-primary text-left" href="{% url 'dashboard' %}">Gerenciar relatórios</a></li>
<li><a class="btn btn-primary text-left" href="{% url 'degree:index' degree_id=degree.code%}">Informações gerais do curso</a></li>
<li><a class="btn btn-primary text-left" href="{% url 'student:index' degree_id=degree.code%}">Alunos</a></li>
<li style="display: block;">
<div>
<a class="btn btn-primary text-left" href="{% url 'course:index' degree_id=degree.code%}">Disciplinas</a>
{% comment %}
<a class="btn btn-primary text-left" href="course" class="drop" data-toggle="collapse" data-target="#side-disciplinas">
<span class="rotate"><i class="fa fa-angle-left"></i></span>
</a>
{% endcomment %}
</div>
{% comment %}
<ul class="sub-menu collapse" id="side-disciplinas">
<li><a class="btn btn-primary text-left disabled" href="compare">Comparar</a></li>
</ul>
{% endcomment %}
</li>
{% comment %}
<li><a class="btn btn-primary disabled text-left" href="#">Professores</a></li>
<li><a class="btn btn-primary disabled text-left" href="#">Turmas</a></li>
{% endcomment %}
<li><a class="btn btn-primary text-left" href="{% url 'admission:index' degree_id=degree.code%}">Turmas de Ingresso</a></li>
{% comment %}
<li style="display: block;" >
<a href="#" data-toggle="collapse" data-target="#side-outros" style="display:flex" class="drop">
<span style="flex-grow:1">Outros</span>
<span style="padding-top:3px" class="rotate"><i class="fa fa-angle-left"></i></span>
</a>
<ul class="sub-menu collapse" id="side-outros">
<li><a class="btn btn-primary disabled text-left" href="#">Cepe 96/15</a></li>
</ul>
</li>
{% endcomment %}
</ul>
</div>
......@@ -9,7 +9,7 @@
<table class="table">
<tr>
<td>Ano/Semestre</td>
<td> NO </td>
<td> {{admission_info.ano}}/{{admission_info.semestre}} </td>
</tr>
<tr>
<td>Quantidade de alunos</td>
......@@ -17,7 +17,7 @@
</tr>
<tr>
<td>Ira Médio</td>
<td> NO </td>
<td> {{admission_info.ira|floatformat:2}} &plusmn {{admission_info.std|floatformat:2}} </td>
</tr>
<tr>
<td>Tempo médio de formatura em anos</td>
......@@ -33,23 +33,23 @@
</tr>
<tr>
<td>Quantidade de Evadidos</td>
<td> NO </td>
<td> {{admission_info.alunos_evadidos}} </td>
</tr>
<tr>
<td>Quantidade de Formados</td>
<td> NO </td>
<td> {{admission_info.formatura}} </td>
</tr>
<tr>
<td>Quantidade de alunos ativos</td>
<td> NO </td>
<td> {{admission_info.ativos}} </td>
</tr>
<tr>
<td>Quantidade de Abandonos</td>
<td> NO </td>
<td> {{admission_info.abandono}} </td>
</tr>
<tr>
<td>Quantidade de outras formas de evasão</td>
<td> NO </td>
<td> {{admission_info.outras_formas_evasao}} </td>
</tr>
</table>
......
......@@ -30,9 +30,9 @@
</td>
<td>{{ti.ira|floatformat:2}} &plusmn {{ti.std|floatformat:2}}</td>
<td> NO </td>
<td> NO </td>
<td> NO </td>
<td> NO </td>
<td> {{ti.alunos_evadidos}} </td>
<td> {{ti.formatura}} </td>
<td> {{ti.ativos}} </td>
</tr>
{% endfor %}
</tbody>
......
......@@ -4,7 +4,7 @@ from django.core.files.storage import FileSystemStorage
from django.contrib import messages
from degree.models import Degree
from report_api.views import get_list_admission
from report_api.views import get_list_admission, get_admission_detail
......@@ -19,6 +19,16 @@ def detail(request, degree_id, ano, semestre):
admission_info = admission
break
admission_detail = get_admission_detail(
request.session,
degree,
ano,
semestre
)
for x in admission_detail:
admission_info[x] = admission_detail[x]
return render(request, 'admission/detail.html',{
"degree": degree,
"admission_info": admission_info
......
......@@ -19,6 +19,9 @@ def get_degree_information(session, degree):
def get_list_admission(session, degree):
return get_data(session,degree,"admissions/lista_turma_ingresso.json")
def get_admission_detail(session, degree, year, semester):
return get_data(session,degree,"admissions/"+year+"/"+semester+".json")
def get_list_courses(session, degree):
return get_data(session,degree,"courses/disciplinas.json")
......
import numpy as np
from script.utils.situations import Situation as sit
from script.utils.situations import EvasionForm as ef
from script.utils.situations import *
from script.analysis.student_analysis import StudentAnalysis
from collections import defaultdict
......@@ -9,6 +11,81 @@ import numpy as np
ANO_ATUAL = 2017
SEMESTRE_ATUAL = 2
class Admission(object):
__dataframes = {}
__groupbys = {}
analysis = {}
def __init__(self, df):
self.__dataframes["df_original"] = df
self.__dataframes["df_filted"] = df.drop_duplicates(["MATR_ALUNO"])
self.__groupbys["groupby_original"] = df.groupby(['ANO_INGRESSO_y', 'SEMESTRE_INGRESSO'])
self.__groupbys["groupby_filted"] = self.__dataframes["df_filted"].groupby(['ANO_INGRESSO_y', 'SEMESTRE_INGRESSO'])
#print(self.__dataframes["df_filted"])
def count_evasion_form(self,g,evasion_form):
return g.apply(lambda x: x.loc[(x.FORMA_EVASAO == evasion_form)].shape[0])
def counts(self):
qtd_alunos_ingresso = self.__groupbys["groupby_filted"].apply(lambda x: x.shape[0])
evasions = [
("qtd_ativos",ef.EF_ATIVO),
("qtd_abandono",ef.EF_ABANDONO),
("qtd_formatura",ef.EF_FORMATURA),
("qtd_ativos",ef.EF_ATIVO)
]
# calcula a quantidade de alunos qtd_ativos, qtd_abandono e qtd_formatura
for i in evasions:
self.analysis[i[0]] = self.count_evasion_form(self.__groupbys["groupby_filted"],i[1])
# calcula a quantidade de alunos evadidos
self.analysis["alunos_evadidos"] = qtd_alunos_ingresso - self.analysis["qtd_ativos"]
self.analysis["outras_formas_evasao"] = self.analysis["alunos_evadidos"] - self.analysis["qtd_formatura"] - self.analysis["qtd_abandono"]
def admission_list(self):
self.analysis["admission_list"] = list(self.__groupbys["groupby_filted"].groups.keys())
def build_analysis(self):
self.counts()
self.admission_list()
def build_cache(self):
admissions = []
for i in self.analysis["admission_list"]:
admission_dict = {}
# This will create an directory when build_cache create the json
# By instance: The files and directories admission/2010/1.json will
# be created
admission_dict["ano"] = i[0]
admission_dict["semestre"] = i[1]
admission_dict["abandono"] = int(self.analysis["qtd_abandono"][i])
admission_dict["ativos"] = int(self.analysis["qtd_ativos"][i])
admission_dict["formatura"] = int(self.analysis["qtd_formatura"][i])
admission_dict["alunos_evadidos"] = int(self.analysis["alunos_evadidos"][i])
admission_dict["outras_formas_evasao"] = int(self.analysis["outras_formas_evasao"][i])
admissions.append(admission_dict)
return admissions
def build_cache_evasion_count(self):
admission_dict = {}
admission_dict["ano"] = {}
admission_dict["semestre"] = {}
admission_dict["abandono"] = {}
admission_dict["ativos"] = {}
admission_dict["formatura"] = {}
admission_dict["alunos_evadidos"] = {}
admission_dict["outras_formas_evasao"] = {}
for i in self.analysis["admission_list"]:
admission_dict["ano"][i] = i[0]
admission_dict["semestre"][i] = i[1]
admission_dict["abandono"][i] = int(self.analysis["qtd_abandono"][i])
admission_dict["ativos"][i] = int(self.analysis["qtd_ativos"][i])
admission_dict["formatura"][i] = int(self.analysis["qtd_formatura"][i])
admission_dict["alunos_evadidos"][i] = int(self.analysis["alunos_evadidos"][i])
admission_dict["outras_formas_evasao"][i] = int(self.analysis["outras_formas_evasao"][i])
return admission_dict
def admission_class_ira_per_semester(df):
"""
......@@ -160,4 +237,4 @@ def students_per_semester(df):
# cada dicionario contido no dicionario e indexado pela tupla (ano, periodo) e contem o numero de linhas de cada grupo do agrupamento
for t_i_s, value in aux.items():
dict_students.setdefault(t_i_s[0], {})[t_i_s[1]] = value
return dict_students
\ No newline at end of file
return dict_students
from script.utils.utils import *
from script.utils.utils import save_json, ensure_path_exists
from script.utils.situations import *
from script.analysis.degree_analysis import *
from script.analysis.student_analysis import *
from script.analysis.course_analysis import Course
from script.analysis.admission_analysis import *
from script.analysis.admission_analysis import Admission
from script.analysis.admission_analysis import media_ira_turma_ingresso
from script.analysis.admission_analysis import desvio_padrao_turma_ingresso
from script.analysis.admission_analysis import students_per_semester
from script.analysis.admission_analysis import admission_class_ira_per_semester
from script.analysis.admission_analysis import evasion_per_semester
from script.analysis.cepe9615_analysis import *
from collections import defaultdict
......@@ -141,19 +149,32 @@ def generate_student_data(path, dataframe, student_analysis):
def generate_student_list(path):
pass
def generate_admission_data(path,df):
def generate_admission_data(path, df):
listagem = []
a = Admission(df)
a.build_analysis()
admissions = a.build_cache()
for i in admissions:
save_json(path+i["ano"]+"/"+i["semestre"]+".json", i)
evasion_count = a.build_cache_evasion_count()
analises = [
("ira", media_ira_turma_ingresso(df)),
("std", desvio_padrao_turma_ingresso(df)),
("ira_per_semester", admission_class_ira_per_semester(df)),
("evasion_per_semester", evasion_per_semester(df)),
("students_per_semester", students_per_semester(df)),
("abandono", evasion_count["abandono"]),
("ativos", evasion_count["ativos"]),
("formatura", evasion_count["formatura"]),
("alunos_evadidos", evasion_count["alunos_evadidos"]),
("outras_formas_evasao", evasion_count["outras_formas_evasao"])
]
# cria um dicionario com as analises para cada turma
print(a.build_cache_evasion_count())
# cria um dicionario com as analises para cada turma
turmas = defaultdict(dict)
for a in analises:
for x in a[1]:
......
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