Commit 222eb7a6 authored by Bruno Meyer's avatar Bruno Meyer 😢

Merge branch '147-padronizar-estilo-de-indentacao' into 'development'

Closes #147

See merge request adega/adega!39
parents 5dff2bc0 eb247779
......@@ -6,7 +6,7 @@
if ! sudo -u postgres psql adega
then
sudo -u postgres psql < postgres/create.sql
sudo -u postgres psql < postgres/create.sql
fi
......
......@@ -44,10 +44,10 @@ INSTALLED_APPS = [
'adega',
'public',
'degree',
'educator',
'admission',
'course',
'student',
'educator',
'admission',
'course',
'student',
'report_api',
'uploads'
]
......
......@@ -4,27 +4,27 @@
</div>
<div class="collapse navbar-collapse" id="navbartoggle">
<span class="navbar-brand mr-auto">
{% if degree != None %}
<a href="{% url 'degree:index' degree_id=degree.code%}">{{degree.name}} </a>
{% endif %}
{% if degree != None %}
<a href="{% url 'degree:index' degree_id=degree.code%}">{{degree.name}} </a>
{% endif %}
</span>
{% comment %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Cursos <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
{% if len(user.educator.degree.all()) > 1 %}
{% for degree in user.educator.degree.all() %}
<li><a href="{% url 'degree:index'
degree_id=degree.code%}">{{degree.name}} </a></li>
{% endfor %}
{% else %}
{% endif %}
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Cursos <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
{% if len(user.educator.degree.all()) > 1 %}
{% for degree in user.educator.degree.all() %}
<li><a href="{% url 'degree:index'
degree_id=degree.code%}">{{degree.name}} </a></li>
{% endfor %}
{% else %}
{% endif %}
</ul>
</li>
{% endcomment %}
<span class="navbar-text">
Relatório 2016/1
......
......@@ -7,9 +7,9 @@
{% block content %}
<div class="row">
<div class="col-md-12">
<h2>Turmas de Ingresso</h2>
<table class="table table-striped table-bordered" id="admission_table">
<div class="col-md-12">
<h2>Turmas de Ingresso</h2>
<table class="table table-striped table-bordered" id="admission_table">
<thead>
<tr>
<th>Ano/Semestre</th>
......@@ -21,30 +21,30 @@
</tr>
</thead>
<tbody>
{% for ti in listage_admissions %}
<tr>
<td>
<a href="{% url 'admission:detail' degree_id=degree.code ano=ti.ano semestre=ti.semestre %}">
{{ ti.ano }}/{{ ti.semestre }}
</a>
</td>
<td>{{ti.ira|floatformat:2}} &plusmn {{ti.desvio_padrao|floatformat:2}}</td>
<td> NO </td>
<td> NO </td>
<td> NO </td>
<td> NO </td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% for ti in listage_admissions %}
<tr>
<td>
<a href="{% url 'admission:detail' degree_id=degree.code ano=ti.ano semestre=ti.semestre %}">
{{ ti.ano }}/{{ ti.semestre }}
</a>
</td>
<td>{{ti.ira|floatformat:2}} &plusmn {{ti.desvio_padrao|floatformat:2}}</td>
<td> NO </td>
<td> NO </td>
<td> NO </td>
<td> NO </td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock content %}
{% block js-foot %}
<script>
$('#admission_table').dataTable({
$('#admission_table').dataTable({
"bPaginate": true,
"bInfo": false,
"aaSorting": [[ 1, "desc" ]],
......
......@@ -7,36 +7,36 @@
{% block content %}
<div class="row">
<div class="col-md-12">
<h2>Disciplinas</h2>
<table id="course_table" class="table table-striped table-bordered">
<thead>
<tr>
<th>Código</th>
<th>Nome</th>
<th>Nota Média</th>
</tr>
</thead>
<tbody>
{% for key, value in courses.items %}
<tr>
<td>
<a href="{% url 'course:detail' degree_id=degree.code codigo_disciplina=key %}">{{key}}</a>
</td>
<td> {{value.name}} </td>
<td> {{value.nota.0 | floatformat:2}} &plusmn {{value.nota.1 | floatformat:2}} </td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="col-md-12">
<h2>Disciplinas</h2>
<table id="course_table" class="table table-striped table-bordered">
<thead>
<tr>
<th>Código</th>
<th>Nome</th>
<th>Nota Média</th>
</tr>
</thead>
<tbody>
{% for key, value in courses.items %}
<tr>
<td>
<a href="{% url 'course:detail' degree_id=degree.code codigo_disciplina=key %}">{{key}}</a>
</td>
<td> {{value.name}} </td>
<td> {{value.nota.0 | floatformat:2}} &plusmn {{value.nota.1 | floatformat:2}} </td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock content %}
{% block js-foot %}
<script>
$('#course_table').dataTable({
$('#course_table').dataTable({
"bPaginate": true,
"bInfo": false,
"aaSorting": [[ 1, "desc" ]],
......
This diff is collapsed.
......@@ -3,7 +3,7 @@ from django.contrib.auth.models import User
from degree.models import Degree
class Educator(models.Model):
user = models.OneToOneField(User)
degree = models.ManyToManyField(Degree)
def __str__(self):
return "{}".format(self.user.username)
user = models.OneToOneField(User)
degree = models.ManyToManyField(Degree)
def __str__(self):
return "{}".format(self.user.username)
......@@ -11,100 +11,118 @@ SEMESTRE_ATUAL = 2
def admission_class_ira_per_semester(df):
"""
Calculate the average IRA in every semester of the admission classes.
This function group the dataframe by admission classes.
Then group each class by semesters.
And finally group each semester by student.
Calculate each student's IRA and then the average IRA for the class.
Parameters
----------
df : DataFrame
Returns
-------
dict of {list:dict}
dict_admission={
(admission_class1):{semester1:ira, semester2:ira, ...},
(admission_class2):{semester1:ira, semester2:ira, ...},
...
}
Examples
--------
{('2005', '1'): {(2012, '1o. Semestre'): 0.485,
(2007, '1o. Semestre'): 0.6186531973412296, ...} ...}
"""
df = df[df['SITUACAO'].isin(Situation.SITUATION_AFFECT_IRA)]
df = df[ df['TOTAL_CARGA_HORARIA'] != 0]
admission_grouped = df.groupby(['ANO_INGRESSO_y','SEMESTRE_INGRESSO'])
dict_admission = {}
for admission in admission_grouped:
#admission_grouped is a tuple of tuples, each tuple contains 0-tuple year/semester & 1-dataframe
dict_ira_semester = {}
semester_grouped = admission[1].groupby(['ANO','PERIODO'])
for semester in semester_grouped:
student_grouped = semester[1].groupby('ID_ALUNO')
ira_class = 0
for student in student_grouped:
#TODO: Verify if this can be calculated without groupby
ira_individual =( (student[1].MEDIA_FINAL*student[1].TOTAL_CARGA_HORARIA).sum() )/(100*student[1].TOTAL_CARGA_HORARIA.sum())
ira_class += ira_individual
ira_class = ira_class / len(student_grouped)
dict_ira_semester.update({semester[0]:ira_class})
dict_admission.update({admission[0]:dict_ira_semester})
return dict_admission
"""
Calculate the average IRA in every semester of the admission classes.
This function group the dataframe by admission classes.
Then group each class by semesters.
And finally group each semester by student.
Calculate each student's IRA and then the average IRA for the class.
Parameters
----------
df : DataFrame
Returns
-------
dict of {list:dict}
dict_admission={
(admission_class1):{semester1:ira, semester2:ira, ...},
(admission_class2):{semester1:ira, semester2:ira, ...},
...
}
Examples
--------
{('2005', '1'): {(2012, '1o. Semestre'): 0.485,
(2007, '1o. Semestre'): 0.6186531973412296, ...} ...}
"""
df = df[df['SITUACAO'].isin(Situation.SITUATION_AFFECT_IRA)]
df = df[ df['TOTAL_CARGA_HORARIA'] != 0]
admission_grouped = df.groupby(['ANO_INGRESSO_y','SEMESTRE_INGRESSO'])
dict_admission = {}
for admission in admission_grouped:
#admission_grouped is a tuple of tuples, each tuple contains 0-tuple year/semester & 1-dataframe
dict_ira_semester = {}
semester_grouped = admission[1].groupby(['ANO','PERIODO'])
for semester in semester_grouped:
student_grouped = semester[1].groupby('ID_ALUNO')
ira_class = 0
for student in student_grouped:
#TODO: Verify if this can be calculated without groupby
ira_individual =( (student[1].MEDIA_FINAL*student[1].TOTAL_CARGA_HORARIA).sum() )/(100*student[1].TOTAL_CARGA_HORARIA.sum())
ira_class += ira_individual
ira_class = ira_class / len(student_grouped)
dict_ira_semester.update({semester[0]:ira_class})
dict_admission.update({admission[0]:dict_ira_semester})
return dict_admission
def iras_alunos_turmas_ingressos(df):
student_analysis = StudentAnalysis(df)
iras = student_analysis.ira_alunos()
student_analysis = StudentAnalysis(df)
iras = student_analysis.ira_alunos()
turmas_ingresso_grr = df.groupby([
"ANO_INGRESSO",
"SEMESTRE_INGRESSO",
"MATR_ALUNO"]
).groups
# Cria um dicionario cujas chaves são GRR
# e valor são tuplas (ano_ingresso,semestre_ingresso)
ano_semestre_do_grr = {}
for ti in turmas_ingresso_grr:
ano_semestre_do_grr[ ti[2] ] = (ti[0],ti[1])
resultados = defaultdict(list)
turmas_ingresso_grr = df.groupby([
"ANO_INGRESSO",
"SEMESTRE_INGRESSO",
"MATR_ALUNO"]
).groups
# Cria um dicionario cujas chaves são GRR
# e valor são tuplas (ano_ingresso,semestre_ingresso)
ano_semestre_do_grr = {}
for ti in turmas_ingresso_grr:
ano_semestre_do_grr[ ti[2] ] = (ti[0],ti[1])
resultados = defaultdict(list)
for grr in iras:
semestre_ano = ano_semestre_do_grr[grr]
resultados[ semestre_ano ].append(iras[grr])
for grr in iras:
semestre_ano = ano_semestre_do_grr[grr]
resultados[ semestre_ano ].append(iras[grr])
return resultados
return resultados
def media_ira_turma_ingresso(df):
iras_alunos_por_turma = iras_alunos_turmas_ingressos(df)
# Calcula a média do ira para cada turma_ingresso
resultados = {}
for r in iras_alunos_por_turma:
aux = np.array(iras_alunos_por_turma[r])
resultados[r] = np.mean(aux)
return resultados
iras_alunos_por_turma = iras_alunos_turmas_ingressos(df)
# Calcula a média do ira para cada turma_ingresso
resultados = {}
for r in iras_alunos_por_turma:
aux = np.array(iras_alunos_por_turma[r])
resultados[r] = np.mean(aux)
return resultados
def desvio_padrao_turma_ingresso(df):
iras_alunos_por_turma = iras_alunos_turmas_ingressos(df)
# Calcula o desvio padrão para cada turma_ingresso
resultados = {}
for r in iras_alunos_por_turma:
aux = np.array(iras_alunos_por_turma[r])
resultados[r] = np.std(aux)
return resultados
iras_alunos_por_turma = iras_alunos_turmas_ingressos(df)
# Calcula o desvio padrão para cada turma_ingresso
resultados = {}
for r in iras_alunos_por_turma:
aux = np.array(iras_alunos_por_turma[r])
resultados[r] = np.std(aux)
return resultados
def evasion_per_semester(df):
turmas_ingresso = df.drop_duplicates(['ANO_INGRESSO_y','SEMESTRE_INGRESSO', 'ANO','PERIODO', 'MATR_ALUNO'], keep='last')
t_i_semestral_size = turmas_ingresso.groupby(['ANO_INGRESSO_y','SEMESTRE_INGRESSO', 'ANO','PERIODO'])['MATR_ALUNO']
t_i_evasions = turmas_ingresso.loc[(turmas_ingresso.FORMA_EVASAO != EvasionForm.EF_ATIVO) & (turmas_ingresso.FORMA_EVASAO != EvasionForm.EF_FORMATURA) & (turmas_ingresso.FORMA_EVASAO != EvasionForm.EF_REINTEGRACAO)]
t_i_evasions_semestral_size = t_i_evasions.groupby(['ANO_INGRESSO_y','SEMESTRE_INGRESSO', 'ANO_EVASAO','SEMESTRE_EVASAO'])['MATR_ALUNO'].nunique().to_dict()
dict_evasion = {}
aux = {}
for t_i_s in t_i_semestral_size:
t_i_s_aux = (t_i_s[0][0], t_i_s[0][1], str(t_i_s[0][2]), t_i_s[0][3].split("o")[0])
if t_i_s_aux in t_i_evasions_semestral_size:
evasions = t_i_evasions_semestral_size[t_i_s_aux]
else:
evasions = 0
aux.update({((t_i_s[0][0], t_i_s[0][1]), (t_i_s[0][2], t_i_s[0][3])):(evasions/t_i_s[1].size)})
for t_i_s, value in aux.items():
dict_evasion.setdefault(t_i_s[0], {})[t_i_s[1]] = value
return dict_evasion
......@@ -33,23 +33,23 @@ def student_fails_course(df):
-------
dict of {int:dict}
quantity={
"3":{aluno1:GRR, aluno2:GRR, ...},
"7":{aluno1:GRR, aluno2:GRR, ...},
...
}
quantity={
"3":{aluno1:GRR, aluno2:GRR, ...},
"7":{aluno1:GRR, aluno2:GRR, ...},
...
}
Examples
--------
"3" : {
"José da Silva Carvalho": 20114027,
"Pedro dos Santos" : 20152678,
"José da Silva Carvalho": 20114027,
"Pedro dos Santos" : 20152678,
...
}
"7" : {
"José da Silva Carvalho": 20114027,
"Pedro dos Santos" : 20152678,
"José da Silva Carvalho": 20114027,
"Pedro dos Santos" : 20152678,
...
}
"""
......@@ -192,12 +192,12 @@ def fails_by_freq(df):
"""
people_studying_df = df[df['FORMA_EVASAO'] == EvasionForm.EF_ATIVO]
// workaround: SIT_REPROVADO_FREQ é o item 1 na tupla SITUATION_FAIL
# workaround: SIT_REPROVADO_FREQ é o item 1 na tupla SITUATION_FAIL
failedbyfreq = people_studying_df.loc[people_studying_df['SITUACAO'] == Situation.SITUATION_FAIL[1]]
coursefailed_bystudent = failedbyfreq.groupby(["NOME_PESSOA", "MATR_ALUNO", "COD_ATIV_CURRIC"])
final_dict = {}
for n in fails_by_freq:
for n in failedbyfreq:
final_dict[n] = []
for fail in coursefailed_bystudent:
if fail[1].shape[0] == n:
......
This diff is collapsed.
......@@ -148,6 +148,7 @@ def generate_admission_data(path,df):
("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)),
]
# cria um dicionario com as analises para cada turma
......
This diff is collapsed.
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