Commit a1494df5 authored by bhm15's avatar bhm15
Browse files

Merge with development

parents 3c02e289 86b61d76
...@@ -46,6 +46,7 @@ INSTALLED_APPS = [ ...@@ -46,6 +46,7 @@ INSTALLED_APPS = [
'degree', 'degree',
'educator', 'educator',
'admission', 'admission',
'report_api',
'uploads' 'uploads'
] ]
......
...@@ -4,5 +4,8 @@ ...@@ -4,5 +4,8 @@
{% block content%} {% block content%}
<h2>Dashboard</h2> <h2>Dashboard</h2>
{% for degree in degrees %}
<a href="{% url 'degree:index' degree_id=degree.code %}">{{degree}} </a>
{% endfor %}
{% endblock content %} {% endblock content %}
\ No newline at end of file
...@@ -4,10 +4,28 @@ ...@@ -4,10 +4,28 @@
</div> </div>
<div class="collapse navbar-collapse" id="navbartoggle"> <div class="collapse navbar-collapse" id="navbartoggle">
<span class="navbar-brand mr-auto"> <span class="navbar-brand mr-auto">
Ciência da Computação {% if degree != None %}
<a href="{% url 'degree:index' degree_id=degree.code%}">{{degree.name}} </a>
{% endif %}
</span> </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>
{% endcomment %}
<span class="navbar-text"> <span class="navbar-text">
Relatório 2016/1 Relatório 2016/1
</span> </span>
......
from django.conf.urls import include, url from django.conf.urls import include, url
from django.contrib import admin from django.contrib import admin
...@@ -9,6 +10,8 @@ urlpatterns = [ ...@@ -9,6 +10,8 @@ urlpatterns = [
url(r'^uploads/', include('uploads.urls', namespace='uploads')), url(r'^uploads/', include('uploads.urls', namespace='uploads')),
url(r'^admission/', include('admission.urls', namespace='admission')), url(r'^admission/', include('admission.urls', namespace='admission')),
url(r'^degree/(?P<degree_id>\w*)/', include('degree.urls', namespace='degree')),
url(r'^public/', include('public.urls', namespace='public')), url(r'^public/', include('public.urls', namespace='public')),
......
...@@ -8,8 +8,10 @@ from django.contrib.auth import logout as process_logout ...@@ -8,8 +8,10 @@ from django.contrib.auth import logout as process_logout
@login_required @login_required
def dashboard(request): def dashboard(request):
degree = request.user.educator.degree.all()
return render(request, 'adega/dashboard.html', {'title': 'Dashboard'}) return render(request, 'adega/dashboard.html', {'title': 'Dashboard',
"degrees":degree
})
@login_required @login_required
......
...@@ -6,7 +6,7 @@ from admission import views ...@@ -6,7 +6,7 @@ from admission import views
urlpatterns = [ urlpatterns = [
url(r'^$', views.upload, name='upload'), url(r'^$', views.upload, name='admission'),
] ]
if settings.DEBUG: if settings.DEBUG:
......
...@@ -8,7 +8,7 @@ class Degree(models.Model): ...@@ -8,7 +8,7 @@ class Degree(models.Model):
manager = models.ForeignKey(User) manager = models.ForeignKey(User)
def __str__(self): def __str__(self):
return self.code return self.name
def clean_code(self): def clean_code(self):
if '/' in self.code: if '/' in self.code:
raise ValidationError('Valor inválido: O código não pode conter "/"') raise ValidationError('Valor inválido: O código não pode conter "/"')
......
{% extends 'base.html' %}
{% 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.active_students}}</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.media_reprovacao_alunos_cursando.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 %}
{% comment %}
<div id="graficos">
<div class="row">
<div class="col-md-6">
<h3>Quantidade alunos/IRA</h3>
<canvas id="ira_semestral" data-data='{{ degree_data.ira_medio_grafico|safe }}'></canvas>
</div>
<div class="col-md-6">
<h3>Quantidade evasão/período</h3>
<canvas id="evasao_semestre" data-data='{{ degree_data.evasao_grafico|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 -->
<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>Taxa Aprovação/Periodo</h3>
<canvas id="taxa_aprovacao_periodo"
data-data='{{ degree_data.taxa_aprovacao_periodo|safe }}'></canvas>
</div>
<!-- fim analise sa02 -->
</div>
</div>
{% endcomment %}
</div>
</div>
{% endblock content %}
from django.conf.urls import url
from degree import views
urlpatterns = [url(r'^$',views.index, name='index')
]
from django.shortcuts import render from django.shortcuts import render, redirect
from django.views.generic import View
from django.contrib.auth.decorators import login_required
from django.contrib.auth import logout as process_logout
from report_api.views import get_degree_information
from degree.models import Degree
from uploads.models import Submission
import json
# Create your views here.
@login_required
def index(request,degree_id):
degree = Degree.objects.get(code=degree_id)
if not (degree in request.user.educator.degree.all()):
return redirect("adega:dashboard")
degree_data = get_degree_information(request.session,degree)
return render(request,"degree/index.html",{"degree":degree,"degree_data":degree_data})
#class Views(View):
# template_name = "index.html"
# @login_required
# def setDegree(self,request,degree_id):
# request.session["degree"] = degree_id
# return redirect('degree:index' )
# def index(self,request):
# if("degree" in request.session):
# degree = Degree.objects.get(code = request.session["degree"])
# else:
# return redirect("adega:dashboard")
# submission = degree.submission
# return render(request,"degree/index",{"degree":degree})
#
#
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class ReportApiConfig(AppConfig):
name = 'report_api'
from django.db import models
# Create your models here.
from django.test import TestCase
# Create your tests here.
from degree.models import Degree
from uploads.models import Submission
import json
def get_data(session,degree,data_name):
if "submission" in session:
submission = session["submission"]
else:
submission = Submission.objects.filter(degree=degree).last()
path_data = submission.path() + "/" + data_name
with open(path_data) as data_f:
data = json.load(data_f)
return data
def get_degree_information(session,degree):
return get_data(session,degree,"degree.json")
...@@ -181,7 +181,7 @@ def build_dict_ira_medio(alunos): ...@@ -181,7 +181,7 @@ def build_dict_ira_medio(alunos):
return dic return dic
def build_degree_json(df): def build_degree_json(path,df):
def merge_dicts(dict1, dict2, dict3): def merge_dicts(dict1, dict2, dict3):
dict_out = {} dict_out = {}
for key, value in dict1.items(): for key, value in dict1.items():
...@@ -203,5 +203,5 @@ def build_degree_json(df): ...@@ -203,5 +203,5 @@ def build_degree_json(df):
"taxa_reprovacao_atual": current_students_failure(df), "taxa_reprovacao_atual": current_students_failure(df),
"tempo_formatura": average_graduation_time(df), "tempo_formatura": average_graduation_time(df),
} }
with open("cache/curso/curso.json",'w') as f: with open(path+"/degree.json",'w') as f:
f.write(json.dumps(degree_json,indent=4)) f.write(json.dumps(degree_json,indent=4))
...@@ -8,146 +8,127 @@ from script.analysis.admission_analysis import * ...@@ -8,146 +8,127 @@ from script.analysis.admission_analysis import *
from collections import defaultdict from collections import defaultdict
try: try:
to_unicode = unicode to_unicode = unicode
except NameError: except NameError:
to_unicode = str to_unicode = str
def build_cache(dataframe): def build_cache(dataframe,path):
# os.chdir("../src") # os.chdir("../src")
path = 'cache/curso' ensure_path_exists(path)
ensure_path_exists(path)
for cod, df in dataframe.groupby('COD_CURSO'): for cod, df in dataframe.groupby('COD_CURSO'):
path = path + '/' + cod + '/' path = path + '/'
# generate_degree_data(path, df) generate_degree_data(path, df)
# generate_student_data(path+'students/',df) generate_student_data(path+'students/',df)
generate_admission_data(path+'/admission/',df) generate_admission_data(path+'/admission/',df)
#generate_student_list(path) generate_course_data(path+'disciplina/' ,dataframe)
# generate_admission_data(path, dataframe)
# generate_admission_list(path, dataframe)
# generate_course_data(path+'disciplina/' ,dataframe)
def generate_degree_data(path, dataframe): def generate_degree_data(path, dataframe):
ensure_path_exists(path) ensure_path_exists(path)
ensure_path_exists(path+'students') ensure_path_exists(path+'students')
students = dataframe[['MATR_ALUNO', 'FORMA_EVASAO']].drop_duplicates() students = dataframe[['MATR_ALUNO', 'FORMA_EVASAO']].drop_duplicates()
build_degree_json(path,dataframe)
data = { def historico(dataframe):
'average_graduation': average_graduation(dataframe), res = []
'general_failure': general_failure(dataframe),
'general_ira': general_ira(dataframe),
'active_students': students[students.FORMA_EVASAO == EvasionForm.EF_ATIVO].shape[0],
'graduated_students': students[students.FORMA_EVASAO == EvasionForm.EF_FORMATURA].shape[0],
}
save_json(path+'/degree.json', data) for _, row in dataframe.iterrows():
res.append(dict(row[['ANO', 'MEDIA_FINAL', 'PERIODO', 'SITUACAO', 'COD_ATIV_CURRIC', 'NOME_ATIV_CURRIC',
#~ for ind, hist in dataframe.groupby('MATR_ALUNO'): 'CREDITOS', 'CH_TOTAL', 'DESCR_ESTRUTURA', 'FREQUENCIA']]))
#~ generate_student_data_old(path+'students/{}.json'.format(ind), dataframe)
return res
def historico(dataframe): def process_semestre(per, df):
res = [] ira = df[df.SITUACAO.isin(Situation.SITUATION_AFFECT_IRA)].MEDIA_FINAL.mean()
completas = df[df.SITUACAO.isin(Situation.SITUATION_PASS)].shape[0]
tentativas = df[df.SITUACAO.isin(Situation.SITUATION_COURSED)].shape[0]
for _, row in dataframe.iterrows(): return {
res.append(dict(row[['ANO', 'MEDIA_FINAL', 'PERIODO', 'SITUACAO', 'COD_ATIV_CURRIC', 'NOME_ATIV_CURRIC', 'semestre': per,
'CREDITOS', 'CH_TOTAL', 'DESCR_ESTRUTURA', 'FREQUENCIA']])) 'ira': ira,
'completas': completas,
'tentativas': tentativas,
'aprovacao': completas/tentativas if tentativas else 0,
'ira_por_quantidade_disciplinas': ira/tentativas if tentativas else 0
}
return res
def process_semestre(per, df): def generate_student_data(path, dataframe):
ira = df[df.SITUACAO.isin(Situation.SITUATION_AFFECT_IRA)].MEDIA_FINAL.mean() student_data = dict()
completas = df[df.SITUACAO.isin(Situation.SITUATION_PASS)].shape[0] all_grrs = list(dataframe["MATR_ALUNO"].drop_duplicates())
tentativas = df[df.SITUACAO.isin(Situation.SITUATION_COURSED)].shape[0] for x in all_grrs:
student_data[x] = dict()
return {
'semestre': per,
'ira': ira,
'completas': completas,
'tentativas': tentativas,
'aprovacao': completas/tentativas if tentativas else 0,
'ira_por_quantidade_disciplinas': ira/tentativas if tentativas else 0
}
analises = [
# tupla que contem no primeiro elemento a funcao que retorna um dicionario com {"GRR": valor}
# e na segunda posicao o nome que esta analise tera no json
(posicao_turmaIngresso_semestral(dataframe),
"posicao_turmaIngresso_semestral"),
(periodo_real(dataframe),
"periodo_real"),
(periodo_pretendido(dataframe),
"periodo_pretendido"),
(ira_semestral(dataframe),
"ira_semestral"),
(ira_por_quantidade_disciplinas(dataframe),
"ira_por_quantidade_disciplinas"),
(indice_aprovacao_semestral(dataframe),
"indice_aprovacao_semestral"),
(aluno_turmas(dataframe),
"aluno_turmas"),
(taxa_aprovacao(dataframe),
"taxa_aprovacao"),
]
for x in student_data:
for a in analises: # Usar para fazer a verificacao de
student_data[x][a[1]] = a[0][x] # analises nulas para um GRR
save_json(path+x+".json", student_data[x])
listagens_arquivos = [
EvasionForm.EF_ABANDONO,
EvasionForm.EF_DESISTENCIA,
EvasionForm.EF_FORMATURA,
EvasionForm.EF_ATIVO
]
listagens = listagem_alunos(dataframe)
for l in listagens:
if(l in listagens_arquivos):
save_json(path+"listagem/"+str(l)+".json", listagens[l])
#Falta verificar se alguem nao recebeu algumas analises
def generate_student_data(path, dataframe):
student_data = dict()
all_grrs = list(dataframe["MATR_ALUNO"].drop_duplicates())
for x in all_grrs:
student_data[x] = dict()
analises = [
# tupla que contem no primeiro elemento a funcao que retorna um dicionario com {"GRR": valor}
# e na segunda posicao o nome que esta analise tera no json
(posicao_turmaIngresso_semestral(dataframe),
"posicao_turmaIngresso_semestral"),
(periodo_real(dataframe),
"periodo_real"),
(periodo_pretendido(dataframe),
"periodo_pretendido"),
(ira_semestral(dataframe),
"ira_semestral"),
(ira_por_quantidade_disciplinas(dataframe),
"ira_por_quantidade_disciplinas"),
(indice_aprovacao_semestral(dataframe),
"indice_aprovacao_semestral"),
(aluno_turmas(dataframe),
"aluno_turmas"),
(taxa_aprovacao(dataframe),
"taxa_aprovacao"),
]
for x in student_data:
for a in analises: # Usar para fazer a verificacao de
student_data[x][a[1]] = a[0][x] # analises nulas para um GRR
save_json(path+x+".json", student_data[x])
listagens_arquivos = [
EvasionForm.EF_ABANDONO,
EvasionForm.EF_DESISTENCIA,
EvasionForm.EF_FORMATURA,
EvasionForm.EF_ATIVO
]
listagens = listagem_alunos(dataframe)
for l in listagens:
if(l in listagens_arquivos):
save_json(path+"listagem/"+str(l)+".json", listagens[l])
#Falta verificar se alguem nao recebeu algumas analises
def generate_student_list(path): def generate_student_list(path):
pass pass
def generate_admission_data(path,df): def generate_admission_data(path,df):
listagem = [] listagem = []
analises = [ analises = [
("ira", media_ira_turma_ingresso(df)), ("ira", media_ira_turma_ingresso(df)),
("desvio_padrao", desvio_padrao_turma_ingresso(df)), ("desvio_padrao", desvio_padrao_turma_ingresso(df)),
] ]
# cria um dicionario com as analises para cada turma