Commit 62c80578 authored by bhmeyer's avatar bhmeyer

Merge branch '163-criar-pagina-para-a-cepe' into 'development'

Resolve "Criar página para a CEPE"

Closes #163

See merge request !84
parents a4dd3e2b 42f355ef
Pipeline #20204 passed with stage
in 2 minutes and 54 seconds
......@@ -50,6 +50,7 @@ INSTALLED_APPS = [
'admission',
'course',
'student',
'cepe9615',
'report_api',
'submission'
]
......
......@@ -76,6 +76,7 @@
<ul class="nav navbar-nav hidden-md hidden-lg">
<li><a href="{% url 'student:index' submission_id=submission.id%}">Alunos</a></li>
<li><a href="{% url 'course:index' submission_id=submission.id%}">Turmas de Ingresso</a></li>
<li><a href="{% url 'cepe9615:index' submission_id=submission.id%}">Cepe 96/15</a></li>
<li class="dropdown">
<a href="{% url 'course:index' submission_id=submission.id%}" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Disciplinas <span class="caret"></span></a>
......
......@@ -2,6 +2,7 @@
<!-- <li class="nav-item"><a class="btn-primary text-left" href="{% url 'submission:SubmissionListView' %}">Gerenciar relatórios</a></li class="nav-item"> -->
<li class="nav-item"><a class="btn-primary text-left" href="{% url 'degree:index' submission_id=submission.id%}">Informações gerais do curso</a></li class="nav-item">
<li class="nav-item"><a class="btn-primary text-left" href="{% url 'student:index' submission_id=submission.id%}">Alunos</a></li class="nav-item">
<li class="nav-item"><a class="btn-primary text-left" href="{% url 'cepe9615:index' submission_id=submission.id%}">Cepe 96/15</a></li class="nav-item">
<li class="nav-item dropdown dropright">
<a type="button" class="btn-primary" href="{% url 'course:index' submission_id=submission.id%}">Disciplinas</a>
......
......@@ -21,6 +21,8 @@ urlpatterns = [
url(r'^degree/(?P<submission_id>\w*)/', include('degree.urls', namespace='degree')),
url(r'^cepe9615/(?P<submission_id>\w*)/', include('cepe9615.urls', namespace='cepe9615')),
url(r'^public/', include('public.urls', namespace='public')),
url(r'^logout/$', views.logout, name='logout'),
......
......@@ -46,7 +46,6 @@
<script>
$('#admission_table').dataTable({
"bPaginate": true,
"bInfo": false,
"aaSorting": [[ 1, "desc" ]],
"responsive": true
});
......
from django.apps import AppConfig
class Cepe9615Config(AppConfig):
name = 'cepe9615'
from django.db import models
# Create your models here.
{% extends 'base.html' %}
{% block content %}
<div class="row">
<div class="col-md-12">
<div class="col-md-12 row">
{% for numero_disciplinas, alunos in analysys_result.alunos_mais_que_x_reprovacoes_na_mesma_disciplina.items %}
<div class="col-md-4 p-md-2">
<div class="list-group">
<span class="list-group-item "><h3>Alunos com {{numero_disciplinas}} ou mais reprovações na mesma disciplina</h3></span>
{% for s, v in alunos.items %}
<a href="{%url 'student:detail' grr=v submission_id=submission.id %}" class="list-group-item ">{{s}}</a>
{% empty %}
<span class="list-group-item">
<center>
<span ><center>Nenhum aluno</center></span>
</center>
{% endfor %}
</div>
</div>
{% endfor %}
{% for numero_disciplinas, alunos in analysys_result.alunos_mais_que_x_reprovacoes_em_duas_ou_mais_disciplinas_distintas.items %}
<div class="col-md-4 p-md-2">
<div class="list-group">
<span class="list-group-item "><h3>Alunos com {{numero_disciplinas}} ou mais reprovações em duas disciplinas distintas</h3></span>
{% for s, v in alunos.items %}
<a href="{%url 'student:detail' grr=v submission_id=submission.id %}" class="list-group-item ">{{s}}</a>
{% empty %}
<span class="list-group-item">
<center>
<span ><center>Nenhum aluno</center></span>
</center>
{% endfor %}
</div>
</div>
{% endfor %}
{% for numero_disciplinas, alunos in analysys_result.alunos_mais_que_x_reprovacoes_na_mesma_disciplina_por_freq.items %}
<div class="col-md-4 p-md-2">
<div class="list-group">
<span class="list-group-item "><h3>Alunos com {{numero_disciplinas}} ou mais reprovações na mesma disciplina por frequência </h3></span>
{% for s, v in alunos.items %}
<a href="{%url 'student:detail' grr=v submission_id=submission.id %}" class="list-group-item ">{{s}}</a>
{% empty %}
<span class="list-group-item">
<center>
<span ><center>Nenhum aluno</center></span>
</center>
{% endfor %}
</div>
</div>
{% endfor %}
{% for numero_disciplinas, anos_semestres in analysys_result.alunos_que_reprovaram_em_x_materias_no_semestre.items %}
{% for ano_semestre, alunos in anos_semestres.items %}
{% if ano_semestre == year_semester %}
<div class="col-md-4 p-md-2">
<div class="list-group">
<span class="list-group-item "><h3>Alunos que reprovaram em {{numero_disciplinas}} ou mais materias no semestre anterior</h3></span>
{% for s, v in alunos %}
<a href="{%url 'student:detail' grr=v submission_id=submission.id %}" class="list-group-item ">{{s}}</a>
{% empty %}
<span class="list-group-item">
<center>
<span ><center>Nenhum aluno</center></span>
</center>
{% endfor %}
</div>
</div>
{% endif %}
{% endfor %}
{% endfor %}
{% for ano_semestre, alunos in analysys_result.alunos_que_reprovaram_por_falta_em_todas_as_materias_do_semestre.items %}
{% if ano_semestre == year_semester %}
<div class="col-md-4 p-md-2">
<div class="list-group">
<span class="list-group-item "><h3>Alunos que reprovaram por falta em todas as materias do semestre anterior</h3></span>
{% for s, v in alunos %}
<a href="{%url 'student:detail' grr=v submission_id=submission.id %}" class="list-group-item ">{{s}}</a>
{% empty %}
<span class="list-group-item">
<center>
<span ><center>Nenhum aluno</center></span>
</center>
{% endfor %}
</div>
</div>
{% endif %}
{% endfor %}
</div>
</div>
</div>
{% endblock content %}
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from cepe9615 import views
urlpatterns = [
url(r'^$', views.index, name='index')
]
from django.shortcuts import render, redirect
from django.views.generic import View
from django.contrib.auth import logout as process_logout
from report_api.views import get_degree_information
from degree.models import Degree
from submission.models import Submission
import json
from guardian.decorators import permission_required_or_403
@permission_required_or_403('view_cepe9615', (Submission, 'id', 'submission_id'))
def index(request, submission_id):
submission_id = int(submission_id)
submission = Submission.objects.get(id=submission_id)
degree = submission.degree
if not (degree in request.user.educator.degree.all()):
return redirect("adega:dashboard")
cepe9615_data = get_cepe9615_information(request.session,degree, submission_id=submission_id)
last_semester = (submission.relative_semester - 1)
if (last_semester == 0):
year = str(submission.relative_year - 1)
semester = "2"
else:
year = str(submission.relative_year)
semester = str(last_semester)
year_semester = "(" + year + ", '" + semester + "o. Semestre')"
analysys_result = {'alunos_mais_que_x_reprovacoes_na_mesma_disciplina': cepe9615_data['student_fails_course'],
'alunos_mais_que_x_reprovacoes_em_duas_ou_mais_disciplinas_distintas': cepe9615_data['student_fails_2_courses'],
'alunos_mais_que_x_reprovacoes_na_mesma_disciplina_por_freq': cepe9615_data['fails_by_freq'],
'alunos_que_reprovaram_em_x_materias_no_semestre': cepe9615_data['fails_semester'],
'alunos_que_reprovaram_por_falta_em_todas_as_materias_do_semestre': cepe9615_data['fails_by_freq_semester'],
}
return render(request,"cepe9615/index.html",{
"submission":submission,
'analysys_result': analysys_result,
'year_semester': year_semester
})
\ No newline at end of file
......@@ -38,7 +38,6 @@
<script>
$('#course_table').dataTable({
"bPaginate": true,
"bInfo": false,
"aaSorting": [[ 1, "desc" ]],
"responsive": true
});
......
......@@ -131,30 +131,36 @@
// Assure that the keys is in order and convert the data
// to a format that AdegaChart will accept
function convert_degree_chart_data(data){
function convert_degree_chart_data(data, y_keys_sorted){
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];
}
// Ensure the fixed size of array
var elements_tick = y_keys_sorted.map(i => {
return null;
});
y_keys_sorted.map((y,i) => {
elements_tick[i] = x[1][y];
});
// For add a new line in the plot data
var index = x[0];
new_data[index] = elements_tick;
});
return new_data;
}
var y_keys_sorted;
var ira_medio = {{degree_data.ira_medio_grafico|safe}};
var ira_medio_data = convert_degree_chart_data(ira_medio);
y_keys_sorted = ["total","sem_evasao","formatura"];
var ira_medio_data = convert_degree_chart_data(ira_medio,y_keys_sorted);
var evasao_semestre = {{degree_data.evasao_grafico|safe}};
var evasao_semestre_data = convert_degree_chart_data(evasao_semestre);
y_keys_sorted = ["qtd","taxa"];
var evasao_semestre_data = convert_degree_chart_data(evasao_semestre,
y_keys_sorted);
// ira_semestral_data will be in format of:
// {"00-4.9": [10,20,30], "05-9.9": [11,21,31], ...}
......@@ -177,7 +183,7 @@
div_target: "evasao_semestre",
title: "Quantidade de evasão em cada período",
fill: "none",
type: ["scatter","bar"],
type: ["bar","scatter"],
legend: ["Quantidade", "Taxa"],
xaxis_title: "Período",
yaxis_title: "Quantidade de evasões",
......
......@@ -35,3 +35,6 @@ def get_list_students(session, degree, list_name, submission_id=None):
def get_student_detail(session, degree, student_id, submission_id=None):
return get_data(session,degree,"students/"+student_id+".json", submission_id=submission_id)
def get_cepe9615_information(session, degree, submission_id=None):
return get_data(session,degree,"cepe9615.json", submission_id=submission_id)
......@@ -40,7 +40,7 @@
</tr>
{% endfor %}
</tbody>
</table>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="formados">
<table class="table table-striped table-bordered" id="formados_table">
......@@ -146,9 +146,8 @@
$("#outros_table")
];
$(table_names).each(function(i,x){
x.dataTable({
var t = x.dataTable({
"bPaginate": true,
"bInfo": false,
"aaSorting": [[ 1, "desc" ]],
"responsive": true
});
......
......@@ -6,9 +6,9 @@ import pprint
from submission.analysis.utils.situations import *
fails_by_course = [10] # used at: student_three_fails_course
fails_by_semester = [6, 10] # used at: n_fails_semester
fails_by_freq = [3, 5, 7] # used at: n_fails_by_freq
n_fails_by_course = [10] # used at: student_fails_course
n_fails_by_semester = [6, 10] # used at: fails_semester
n_fails_by_freq = [3, 5, 7] # used at: fails_by_freq
pp = pprint.PrettyPrinter(indent=4)
......@@ -20,7 +20,7 @@ pp = pprint.PrettyPrinter(indent=4)
def student_fails_course(df):
"""
Lists of students that failed X, Y, Z ... times in the same course.
X, Y, Z ... are declared in the list "fails_by_course" at the top of analysis.
X, Y, Z ... are declared in the list "n_fails_by_course" at the top of analysis.
This function is inspired by CEPE 96/15 ART.9:
Students with 3 fails in the same course would have their registration suspended.
......@@ -60,7 +60,7 @@ def student_fails_course(df):
# Creates a tuple with (specified informations, dataframe)
students = df.groupby(["NOME_PESSOA", "MATR_ALUNO"])
quantity = {}
for times in fails_by_course:
for times in n_fails_by_course:
names = {}
for student in students:
# For each student that have failed, we will have a dataframe of
......@@ -79,7 +79,7 @@ def student_fails_course(df):
def student_fails_2_courses(df):
"""
Lists of students that failed X, Y, Z ... times in the 2 different courses.
X, Y, Z ... are declared in the list "fails_by_course" at the top of analysis.
X, Y, Z ... are declared in the list "n_fails_by_course" at the top of analysis.
This function is inspired by CEPE 96/15 ART.9:
Students with 3 fails in two different courses would have their registration suspended.
......@@ -121,7 +121,7 @@ def student_fails_2_courses(df):
# Creates a tuple with (specified informations, dataframe)
students = df.groupby(["NOME_PESSOA", "MATR_ALUNO"])
quantity = {}
for times in fails_by_course:
for times in n_fails_by_course:
names = {}
for student in students:
# For each student that have failed, we will have a dataframe of
......@@ -146,7 +146,7 @@ def student_fails_2_courses(df):
def fails_semester (df):
"""
Lists of students that failed X, Y, Z ... courses in the same semester.
X, Y, Z ... are declared in the list "fails_by_semester" at the top.
X, Y, Z ... are declared in the list "n_fails_by_semester" at the top.
This function is inspired by CEPE 96/15 ART.9:
Students with 3 fails in the semester would have their registration suspended.
......@@ -155,7 +155,7 @@ def fails_semester (df):
and have failed courses.
Then it creates a dictionary of semesters.
Inside each semester there is a second dictionary of names and df with the failed courses
This second dictionary will be turned into a list of names according to each N in fails_by_semester
This second dictionary will be turned into a list of names according to each N in n_fails_by_semester
Parameters
----------
......@@ -202,7 +202,7 @@ def fails_semester (df):
# final_dict = { N: semester_finaldict, ...}
# semester_finaldict = { semester: list of students tha failed N courses in that semester}
final_dict = {}
for n in fails_by_semester:
for n in n_fails_by_semester:
semester_finaldict = {}
for semester in semester_dict:
name_list = []
......@@ -217,17 +217,12 @@ def fails_semester (df):
def fails_by_freq_semester (df):
"""
Lists of students that failed X, Y, Z ... courses in the same semester.
X, Y, Z ... are declared in the list "fails_by_semester" at the top.
This function is inspired by CEPE 96/15 ART.9:
Students with 3 fails in the semester would have their registration suspended.
Lists of students that failed all courses in the same semester by lack of frequency.
First this function filters students who are still registrered in the University
and have failed courses.
Then it creates a dictionary of semesters.
Inside each semester there is a second dictionary of names and df with the failed courses
This second dictionary will be turned into a list of names according to each N in fails_by_semester
Parameters
----------
......@@ -237,26 +232,26 @@ def fails_by_freq_semester (df):
-------
dict of {int:dict}
final_dict={
"X":{semester1: list_of_students1, ...},
"Y":{semester1: list_of_students1, ...},
semester_finaldict={
{semester1: list_of_students1, ...},
{semester1: list_of_students1, ...},
...
}
Examples
--------
'4': { (2001, '2o. Semestre'): [],
(2002, '1o. Semestre'): [],
(2002, '2o. Semestre'): [],
(2003, '1o. Semestre'): [],
(2004, '2o. Semestre'): [],
(2007, '1o. Semestre'): [],
(2007, '2o. Semestre'): [ ( 'Carlos das Neves Vieira',
'GRR20073713'),
( 'Adriano Dias Barbosa',
'GRR20075214')],
(2008, '1o. Semestre'): [ ( 'Anderson Silveira Alves',
'GRR20075297')],
(2001, '2o. Semestre'): [],
(2002, '1o. Semestre'): [],
(2002, '2o. Semestre'): [],
(2003, '1o. Semestre'): [],
(2004, '2o. Semestre'): [],
(2007, '1o. Semestre'): [],
(2007, '2o. Semestre'): [ ( 'Carlos das Neves Vieira',
'GRR20073713'),
( 'Adriano Dias Barbosa',
'GRR20075214')],
(2008, '1o. Semestre'): [ ( 'Anderson Silveira Alves',
'GRR20075297')],
"""
people_studying_df = df[df['FORMA_EVASAO'] == EvasionForm.EF_ATIVO]
failed_people_df = people_studying_df.loc[people_studying_df['SITUACAO'] == Situation.SITUATION_FAIL[1]]
......@@ -288,7 +283,7 @@ def fails_by_freq_semester (df):
def fails_by_freq(df):
"""
Lists of students that failed a course X, Y, Z ... times, all of them by lack of frequency!
X, Y, Z ... are declared in the list "fails_by_freq" at the top.
X, Y, Z ... are declared in the list "n_fails_by_freq" at the top.
This function is inspired by CEPE 96/15 ART.4:
Students will be categorize with insuficient academic rendimento
......@@ -296,7 +291,7 @@ def fails_by_freq(df):
First this function filters students who are still registrered in the University
and have failed courses by lack of frequenecy.
Then for each n in fails_by_freq, filters if a course repeat n times for a student
Then for each n in n_fails_by_freq, filters if a course repeat n times for a student
Parameters
----------
......@@ -333,10 +328,12 @@ def fails_by_freq(df):
coursefailed_bystudent = failedbyfreq.groupby(["NOME_PESSOA", "MATR_ALUNO", "COD_ATIV_CURRIC"])
final_dict = {}
for n in failedbyfreq:
final_dict[n] = []
for n in n_fails_by_freq:
names = {}
for fail in coursefailed_bystudent:
if fail[1].shape[0] == n:
final_dict[n].append((fail[0][0], fail[0][2]))
names[fail[0][0]] = fail[0][1]
final_dict[str(n)] = names
# pp.pprint (final_dict)
return final_dict
......@@ -300,7 +300,7 @@ def merge_dicts(dict1, dict2, dict3):
v2 = dict2[key] if key in dict2 else None
v3 = dict3[key] if key in dict3 else None
dict_out[key] = {
'ira_medio': value,
'total': value,
'sem_evasao': v2,
'formatura': v3
}
......
......@@ -39,12 +39,13 @@ def build_cache(dataframe, path, current_year = CURRENT_YEAR, current_semester =
generate_student_data(path + 'students/', df, student_analysis)
generate_admission_data(path + 'admissions/', df, student_analysis)
generate_course_data(path + 'courses/',current_year, dataframe)
generate_cepe_data(path + '/others/', df)
generate_cepe_data(path, df)
def generate_cepe_data(path, df):
cepe_dict = {}
cepe_dict["student_fails_course"] = student_fails_course(df)
cepe_dict["student_fails_2_courses"] = student_fails_2_courses(df)
cepe_dict["fails_semester"] = fails_semester(df)
cepe_dict["fails_by_freq_semester"] = fails_by_freq_semester(df)
cepe_dict["fails_by_freq"] = fails_by_freq(df)
......
......@@ -4,7 +4,7 @@
{% block content %}
<div class="alert alert-warning" role="alert">
<div class="alert alert-light" role="alert">
Selecione as planilhas adquiridas a partir dos relatórios providos pelo
sistema SIE.<br><br>
......
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