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

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" ]],
......
......@@ -2,78 +2,78 @@
{% block content%}
<div class="row">
<div class="col-md-12">
<h1>Informações Gerais</h1>
<table class="table">
<tr>
<td>Quantidade de alunos ativos</td>
<td>{{degree_data.qtd_alunos_atuais}}</td>
</tr>
<tr>
<td>I.R.A. médio desde o inicio do curso</td>
<td>{{degree_data.ira_medio.0|floatformat:2}} &#177;
{{degree_data.ira_medio.1|floatformat:2}}</td>
</tr>
<tr>
<td> I.R.A. médio dos alunos atualmente no curso</td>
<td>{{degree_data.ira_atual.0|floatformat:2}} &#177; {{degree_data.ira_atual.1|floatformat:2}}</td>
</tr>
<tr>
<td>Taxa de reprovação desde o inicio do curso</td>
<td>{{ degree_data.taxa_reprovacao.0|floatformat:2 }}%
&#177; {{degree_data.taxa_reprovacao.1|floatformat:2 }}%</td>
</tr>
<tr>
<td>Taxa de reprovação dos alunos atualmente no curso</td>
<div class="col-md-12">
<h1>Informações Gerais</h1>
<table class="table">
<tr>
<td>Quantidade de alunos ativos</td>
<td>{{degree_data.qtd_alunos_atuais}}</td>
</tr>
<tr>
<td>I.R.A. médio desde o inicio do curso</td>
<td>{{degree_data.ira_medio.0|floatformat:2}} &#177;
{{degree_data.ira_medio.1|floatformat:2}}</td>
</tr>
<tr>
<td> I.R.A. médio dos alunos atualmente no curso</td>
<td>{{degree_data.ira_atual.0|floatformat:2}} &#177; {{degree_data.ira_atual.1|floatformat:2}}</td>
</tr>
<tr>
<td>Taxa de reprovação desde o inicio do curso</td>
<td>{{ degree_data.taxa_reprovacao.0|floatformat:2 }}%
&#177; {{degree_data.taxa_reprovacao.1|floatformat:2 }}%</td>
</tr>
<tr>
<td>Taxa de reprovação dos alunos atualmente no curso</td>
<td>{{ degree_data.taxa_reprovacao_atual.0|floatformat:2 }}% &#177; {{degree_data.taxa_reprovacao_atual.1|floatformat:2}}%</td>
</tr>
<tr>
{% comment %}
<td>Média de formandos (de {{ degree_data.total_alunos }} alunos)</td>
<td>{{ degree_data.media_formandos|floatformat:2 }}%</td>
</tr>
<tr>
<td>Taxa de evasão desde o inicio do curso</td>
<td>{{degree_data.evasao_geral|percentage}}</td>
</tr>
<tr>
<td>Tempo médio para formatura</td>
<td>{{degree_data.tempo_medio_formatura|floatformat:2}} anos</td>
</tr>
<tr>
<td>Possíveis jubilandos nesse semestre</td>
<td>{{degree_data.jubilamento}}</td>
</tr>
{% endcomment %}
</table>
<td>{{ degree_data.taxa_reprovacao_atual.0|floatformat:2 }}% &#177; {{degree_data.taxa_reprovacao_atual.1|floatformat:2}}%</td>
</tr>
<tr>
{% comment %}
<td>Média de formandos (de {{ degree_data.total_alunos }} alunos)</td>
<td>{{ degree_data.media_formandos|floatformat:2 }}%</td>
</tr>
<tr>
<td>Taxa de evasão desde o inicio do curso</td>
<td>{{degree_data.evasao_geral|percentage}}</td>
</tr>
<tr>
<td>Tempo médio para formatura</td>
<td>{{degree_data.tempo_medio_formatura|floatformat:2}} anos</td>
</tr>
<tr>
<td>Possíveis jubilandos nesse semestre</td>
<td>{{degree_data.jubilamento}}</td>
</tr>
{% endcomment %}
</table>
{% comment %}
<div>
<div class="panel-container">
<div class="data-panel">
<h3>Nota Média</h3>
<span class="data">{{ degree_data.nota_media.0|floatformat:2 }} &#177; {{degree_data.nota_media.1|floatformat:2 }}</span>
</div>
<div class="data-panel">
<h3>Taxa Média de Reprovação</h3>
<span class="data">{{ degree_data.taxa_reprovacao.0|floatformat:2 }}% &#177; {{degree_data.taxa_reprovacao.1|floatformat:2 }}%</span>
</div>
</div>
<div class="panel-container">
<div class="data-panel">
<h3>Aprovação Aproveitamento de Conhecimento</h3>
<span class="data">{{ degree_data.taxa_conhecimento.0|floatformat:2 }}% &#177; {{degree_data.taxa_conhecimento.1|floatformat:2 }}%</span>
</div>
<div class="data-panel">
<h3>Taxa de Trancamento</h3>
<span class="data">{{ degree_data.taxa_trancamento.0|floatformat:2 }}% &#177;{{degree_data.taxa_trancamento.1|floatformat:2}}%</span>
</div>
</div>
</div>
{% endcomment %}
<div id="graficos">
<div class="row">
{% comment %}
<div>
<div class="panel-container">
<div class="data-panel">
<h3>Nota Média</h3>
<span class="data">{{ degree_data.nota_media.0|floatformat:2 }} &#177; {{degree_data.nota_media.1|floatformat:2 }}</span>
</div>
<div class="data-panel">
<h3>Taxa Média de Reprovação</h3>
<span class="data">{{ degree_data.taxa_reprovacao.0|floatformat:2 }}% &#177; {{degree_data.taxa_reprovacao.1|floatformat:2 }}%</span>
</div>
</div>
<div class="panel-container">
<div class="data-panel">
<h3>Aprovação Aproveitamento de Conhecimento</h3>
<span class="data">{{ degree_data.taxa_conhecimento.0|floatformat:2 }}% &#177; {{degree_data.taxa_conhecimento.1|floatformat:2 }}%</span>
</div>
<div class="data-panel">
<h3>Taxa de Trancamento</h3>
<span class="data">{{ degree_data.taxa_trancamento.0|floatformat:2 }}% &#177;{{degree_data.taxa_trancamento.1|floatformat:2}}%</span>
</div>
</div>
</div>
{% endcomment %}
<div id="graficos">
<div class="row">
<div class="col-md-6">
<!-- <h3>Quantidade alunos/IRA</h3> -->
<div id="ira_semestral"></div>
......@@ -82,76 +82,76 @@
<!-- <h3>Quantidade evasão/período</h3> -->
<div id="evasao_semestre"></div>
</div>
<!--
<div class="col-md-6">
<h3>Nota Média/Periodo</h3>
<canvas id="nota_media_semestre"
data-data='{{ degree_data.media_disc|safe }}'></canvas>
</div> essa analise foi feita de uma maneira ruim no adega
antigo -->
<!-- analises sa02 -->
{% comment %}
<div class="col-md-6">
<h3>Alunos/Periodo</h3>
<canvas id="aluno_periodo"
data-data='{{ degree_data.aluno_periodo|safe }}'></canvas>
</div>
<!--
<div class="col-md-6">
<h3>Nota Média/Periodo</h3>
<canvas id="nota_media_semestre"
data-data='{{ degree_data.media_disc|safe }}'></canvas>
</div> essa analise foi feita de uma maneira ruim no adega
antigo -->
<!-- analises sa02 -->
{% comment %}
<div class="col-md-6">
<h3>Alunos/Periodo</h3>
<canvas id="aluno_periodo"
data-data='{{ degree_data.aluno_periodo|safe }}'></canvas>
</div>
<div class="col-md-6">
<h3>Nota Média/Periodo</h3>
<canvas id="nota_media_periodo"
data-data='{{ degree_data.nota_media_periodo|safe }}'></canvas>
</div>
<div class="col-md-6">
<h3>Nota Média/Periodo</h3>
<canvas id="nota_media_periodo"
data-data='{{ degree_data.nota_media_periodo|safe }}'></canvas>
</div>
<div class="col-md-6">
<h3>Taxa Aprovação/Periodo</h3>
<canvas id="taxa_aprovacao_periodo"
data-data='{{ degree_data.taxa_aprovacao_periodo|safe }}'></canvas>
</div>
{% endcomment %}
<!-- fim analise sa02 -->
</div>
</div>
</div>
<div class="col-md-6">
<h3>Taxa Aprovação/Periodo</h3>
<canvas id="taxa_aprovacao_periodo"
data-data='{{ degree_data.taxa_aprovacao_periodo|safe }}'></canvas>
</div>
{% endcomment %}
<!-- fim analise sa02 -->
</div>
</div>
</div>
</div>
{% endblock content %}
{% block js-foot %}
<script>
// TODO: Refactor the analyzes to avoid this pretreatment
// Assure that the keys is in order and convert the data
// to a format that AdegaChart will accept
function convert_degree_chart_data(data){
var new_data = {};
var dict_order_keys = Object.keys(data[0][1]);
// TODO: Refactor the analyzes to avoid this pretreatment
// Assure that the keys is in order and convert the data
// to a format that AdegaChart will accept
function convert_degree_chart_data(data){
var new_data = {};
var dict_order_keys = Object.keys(data[0][1]);
data.map(function(x){
var elements_tick = [];
for(var i in dict_order_keys) elements_tick.push(0);
for(var y in x[1]){
var index = dict_order_keys.indexOf(y);
elements_tick[index] = x[1][y];
}
var index = x[0];
new_data[index] = elements_tick;
});
return new_data;
}
var ira_semestral = {{degree_data.ira_medio_grafico|safe}};
var ira_semestral_data = convert_degree_chart_data(ira_semestral);
data.map(function(x){
var elements_tick = [];
for(var i in dict_order_keys) elements_tick.push(0);
for(var y in x[1]){
var index = dict_order_keys.indexOf(y);
elements_tick[index] = x[1][y];
}
var index = x[0];
new_data[index] = elements_tick;
});
return new_data;
}
var ira_semestral = {{degree_data.ira_medio_grafico|safe}};
var ira_semestral_data = convert_degree_chart_data(ira_semestral);
var evasao_semestre = {{degree_data.evasao_grafico|safe}};
var evasao_semestre_data = convert_degree_chart_data(evasao_semestre);
// ira_semestral_data will be in format of:
// {"00-4.9": [10,20,30], "05-9.9": [11,21,31], ...}
console.log(evasao_semestre_data);
var evasao_semestre = {{degree_data.evasao_grafico|safe}};
var evasao_semestre_data = convert_degree_chart_data(evasao_semestre);
// ira_semestral_data will be in format of:
// {"00-4.9": [10,20,30], "05-9.9": [11,21,31], ...}
console.log(evasao_semestre_data);
var chart1 = new AdegaChart({
data: ira_semestral_data,
......
......@@ -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