Commit 9f28b166 authored by bhm15's avatar bhm15

adega#115: Create class StudentAnalysis & Create student app

parent 80af568b
Pipeline #16280 failed with stage
in 1 minute and 36 seconds
......@@ -47,6 +47,7 @@ INSTALLED_APPS = [
'educator',
'admission',
'course',
'student',
'report_api',
'uploads'
]
......
......@@ -63,7 +63,7 @@
<ul class="nav navbar-nav hidden-md hidden-lg">
<li><a href="#">Alunos</a></li>
<li><a href="{% url 'student:index' degree_id=degree.code%}">Alunos</a></li>
<li><a href="{% url 'course:index' degree_id=degree.code%}">Turmas de Ingresso</a></li>
<li class="dropdown">
<a href="{% url 'course:index' degree_id=degree.code%}" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
......
<div class="sidebar left hidden-sm hidden-xs">
<ul class="list-sidebar">
<li><a href="#">Alunos</a></li>
<li><a href="{% url 'student:index' degree_id=degree.code%}">Alunos</a></li>
<li style="display: block;">
<div>
<a href="{% url 'course:index' degree_id=degree.code%}">Disciplinas</a>
......
......@@ -13,6 +13,8 @@ urlpatterns = [
url(r'^course/(?P<degree_id>\w*)/', include('course.urls', namespace='course')),
url(r'^student/(?P<degree_id>\w*)/', include('student.urls', namespace='student')),
url(r'^degree/(?P<degree_id>\w*)/', include('degree.urls', namespace='degree')),
url(r'^public/', include('public.urls', namespace='public')),
......
......@@ -23,4 +23,7 @@ def get_list_courses(session,degree):
return get_data(session,degree,"disciplina/disciplinas.json")
def get_course_detail(session,degree, course_id):
return get_data(session,degree,"disciplina/"+course_id+".json")
\ No newline at end of file
return get_data(session,degree,"disciplina/"+course_id+".json")
def get_list_students(session, degree, list_name):
return get_data(session,degree,"students/list/"+list_name+".json")
\ No newline at end of file
import numpy as np
from script.utils.situations import *
from script.analysis.student_analysis import ira_alunos
from script.analysis.student_analysis import StudentAnalysis
from collections import defaultdict
import numpy as np
......@@ -10,8 +10,9 @@ ANO_ATUAL = 2017
SEMESTRE_ATUAL = 2
def iras_alunos_turmas_ingressos(df):
iras = ira_alunos(df)
student_analysis = StudentAnalysis(df)
iras = student_analysis.ira_alunos()
turmas_ingresso_grr = df.groupby([
"ANO_INGRESSO",
"SEMESTRE_INGRESSO",
......
This diff is collapsed.
from script.utils.utils import *
from script.utils.situations import *
from script.analysis.degree_analysis import *
from script.analysis.student_analysis import *
from script.analysis.student_analysis import StudentAnalysis
from script.analysis.course_analysis import *
from script.analysis.admission_analysis import *
......@@ -13,16 +13,21 @@ except NameError:
to_unicode = str
student_analysis = None
def build_cache(dataframe,path):
# os.chdir("../src")
ensure_path_exists(path)
student_analysis = StudentAnalysis(dataframe)
for cod, df in dataframe.groupby('COD_CURSO'):
path = path + '/'
# generate_degree_data(path, df)
generate_student_data(path+'students/',df)
# generate_admission_data(path+'/admission/',df)
# generate_course_data(path+'disciplina/' ,dataframe)
generate_degree_data(path, df)
generate_student_data(path+'students/', dataframe, student_analysis)
generate_admission_data(path+'/admission/',df)
generate_course_data(path+'disciplina/' ,dataframe)
def generate_degree_data(path, dataframe):
ensure_path_exists(path)
......@@ -57,7 +62,7 @@ def process_semestre(per, df):
def generate_student_data(path, dataframe):
def generate_student_data(path, dataframe, student_analysis):
student_data = dict()
all_grrs = list(dataframe["MATR_ALUNO"].drop_duplicates())
for x in all_grrs:
......@@ -68,29 +73,29 @@ def generate_student_data(path, dataframe):
# 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"),
(student_analysis.posicao_turmaIngresso_semestral(),
"posicao_turmaIngresso_semestral"),
# (periodo_real(dataframe),
# "periodo_real"),
(student_analysis.periodo_real(),
"periodo_real"),
# (periodo_pretendido(dataframe),
# "periodo_pretendido"),
(student_analysis.periodo_pretendido(),
"periodo_pretendido"),
# (ira_semestral(dataframe),
# "ira_semestral"),
(student_analysis.ira_semestral(),
"ira_semestral"),
# (ira_por_quantidade_disciplinas(dataframe),
# "ira_por_quantidade_disciplinas"),
(student_analysis.ira_por_quantidade_disciplinas(),
"ira_por_quantidade_disciplinas"),
# (indice_aprovacao_semestral(dataframe),
# "indice_aprovacao_semestral"),
(student_analysis.indice_aprovacao_semestral(),
"indice_aprovacao_semestral"),
# (aluno_turmas(dataframe),
# "aluno_turmas"),
(student_analysis.aluno_turmas(),
"aluno_turmas"),
# (taxa_aprovacao(dataframe),
# "taxa_aprovacao"),
(student_analysis.taxa_aprovacao(),
"taxa_aprovacao"),
]
for x in student_data:
......@@ -103,14 +108,18 @@ def generate_student_data(path, dataframe):
EvasionForm.EF_ABANDONO,
EvasionForm.EF_DESISTENCIA,
EvasionForm.EF_FORMATURA,
EvasionForm.EF_ATIVO
EvasionForm.EF_ATIVO,
EvasionForm.EF_OUTROS
]
list_situations = list_students(dataframe)
for l in list_situations:
if(l in files_list):
list_name = EvasionForm.code_to_str(int(l))
save_json(path+"list/"+list_name+".json", list_situations[l])
list_situations = student_analysis.list_students()
for fl in files_list:
list_name = EvasionForm.code_to_str(int(fl))
list_content = []
if(fl in list_situations):
list_content = list_situations[fl]
save_json(path+"list/"+list_name+".json", list_content)
......
import os
import copy
import ujson as json
......@@ -10,6 +11,18 @@ except:
DEBUG = True
# Use this class as decorator to save functions returns
def memoize(f):
memo = {}
def helper(x):
if str(x) not in memo:
memo[str(x)] = f(x)
return copy.deepcopy(memo[str(x)])
return helper
def invert_dict(d):
return {v: k for k, v in d}
......
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class StudentConfig(AppConfig):
name = 'student'
from django.db import models
# Create your models here.
{% extends 'base.html' %}
{% load static %}
{% block content %}
<div class="row">
<div class="col-md-12">
<h1>{{ nome_disciplina }}
<small>{{ codigo_disciplina }}</small>
</h1>
<br>
<h2>Informações Gerais</h2>
<table class="table">
<tr>
<td>Quantidade de matrículas</td>
<td>{% if analysis_result.qtd_alunos >= 0%}
{{ analysis_result.qtd_alunos }}
{% else %}
Desconhecido
{% endif %}</td>
</tr>
<tr>
<td>Nota Média</td>
<td>{% if analysis_result.nota.0 >= 0%}
{{analysis_result.nota.0|floatformat:2}} &plusmn {{analysis_result.nota.1|floatformat:2}}
{% else %}
Desconhecido
{% endif %}</td>
</tr>
<tr>
<td>Nota Média/ Último ano</td>
<td>{% if analysis_result.nota_ultimo_ano.0 >= 0%}
{{analysis_result.nota_ultimo_ano.0|floatformat:2}} &plusmn {{analysis_result.nota_ultimo_ano.1|floatformat:2}}
{% else %}
Desconhecido
{% endif %}</td>
</tr>
</table>
<h1>Taxas</h1>
<table class="table">
<tr>
<td>Taxa Reprovação</td>
<td>{% if analysis_result.taxa_reprovacao_absoluta >= 0%}
{{ analysis_result.taxa_reprovacao_absoluta|floatformat:2 }}%
{% else %}
Desconhecido
{% endif %}</td>
</tr>
<tr>
<td>Taxa Reprovação Frequência </td>
<td>{% if analysis_result.taxa_reprovacao_frequencia >= 0%}
{{ analysis_result.taxa_reprovacao_frequencia|floatformat:2 }}%
{% else %}
Desconhecido
{% endif %}</td>
</tr>
<tr>
<td>Taxa Reprovação/Último ano</td>
<td>{% if analysis_result.taxa_reprovacao_ultimo_absoluto >= 0%}
{{ analysis_result.taxa_reprovacao_ultimo_absoluto|floatformat:2 }}%
{% else %}
Desconhecido
{% endif %}</td>
</tr>
<tr>
<td>Taxa Reprovação/Último ano Frequência</td>
<td>{% if analysis_result.taxa_reprovacao_ultimo_frequencia >= 0%}
{{ analysis_result.taxa_reprovacao_ultimo_frequencia|floatformat:2 }}%
{% else %}
Desconhecido
{% endif %}</td>
</tr>
<tr>
<td>Quantidade de Aproveitamento de Conhecimento</td>
<td>
{% if analysis_result.qtd_conhecimento >= 0 %}
{{ analysis_result.qtd_conhecimento }}
{% else %}
Desconhecido
{% endif %}
</td>
</tr>
<tr>
<td>Taxa Aprovação/Aproveitamento de Conhecimento</td>
<td>{% if analysis_result.taxa_aproveitamento_conhecimento >= 0%}
{{ analysis_result.taxa_aproveitamento_conhecimento|floatformat:2 }}%
{% else %}
Desconhecido
{% endif %}</td>
</tr>
<tr>
<td>Quantidade Trancamento</td>
<td>{% if analysis_result.qtd_trancamento >= 0%}
{{ analysis_result.qtd_trancamento }}
{% else %}
Desconhecido
{% endif %}</td>
</tr>
<tr>
<td>Taxa Trancamento</td>
<td>{% if analysis_result.taxa_trancamento >= 0%}
{{ analysis_result.taxa_trancamento|floatformat:2 }}%
{% else %}
Desconhecido
{% endif %}</td>
</tr>
<tr>
<td>Quantidade Média de Vezes Cursada até Aprovação</td>
<td>{% if analysis_result.qtd_cursada_aprov >= 0 %}
{{ analysis_result.qtd_cursada_aprov|floatformat:2 }}
{% else %}
Desconhecido
{% endif %}</td>
</td>
</table>
<div id="aprovacao_semestre"></div>
<div id="myChart2"></div>
{% endblock content %}
{% block js-foot %}
<script>
var chart1 = new AdegaChart({
data: {{analysis_result.aprovacao_semestral|safe}},
div_target: "aprovacao_semestre",
//type: "bar",
title: "Índice de aprovação/Semestre",
fill: "none",
legend: ["Aprovação %","Quantidade de alunos"]
});
var chart1 = new AdegaChart({
data_x: [0,1,2],
data_y: [[6,10,2], [7,9,2.5]],
div_target: "myChart2",
error_y: [[1,2,3], [1.5,0.1,0.5]],
type:["bar", "scatter"],
title: "Exemplo 2",
legend: ["linha 1", "linha 2"]
});
</script>
{% endblock js-foot %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block content %}
<div class="row">
<div class="col-md-12">
<h1>Listagem dos Alunos</h1>
<div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#sem_evasao" aria-controls="sem_evasao" role="tab" data-toggle="tab">Sem Evasão</a></li>
<li role="presentation"><a href="#formados" aria-controls="formados" role="tab" data-toggle="tab">Formados</a></li>
<li role="presentation"><a href="#abandono" aria-controls="abandono" role="tab" data-toggle="tab">Abandono</a></li>
<li role="presentation"><a href="#desistencia" aria-controls="desistencia" role="tab" data-toggle="tab">Desistência</a></li>
<li role="presentation"><a href="#outras" aria-controls="outras" role="tab" data-toggle="tab">Outras Formas de Evasão</a></li>
</ul>
</div>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="sem_evasao">
<table class="table datatable">
<thead>
<tr>
<th class="col-md-2">GRR</th>
<th class="col-md-4">Nome</th>
<th class="col-md-2">ira</th>
<th class="col-md-2">Forma evasão</th>
</tr>
</thead>
<tbody>
{% for l in sem_evasao %}
<tr>
<td class="col-md-2"><a href="{% url 'student:detail' grr=l.grr degree_id=degree.code %}">{{ l.grr }}</a></td>
<td class="col-md-4">{{ l.nome }}</td>
<td class="col-md-2">{{ l.ira|floatformat:2 }}</td>
<td class="col-md-2">{{ l.forma_evasao }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="formados">
<table class="table datatable">
<thead>
<tr>
<th class="col-md-2">GRR</th>
<th class="col-md-4">Nome</th>
<th class="col-md-2">ira</th>
<th class="col-md-2">Forma evasão</th>
</tr>
</thead>
<tbody>
{% for l in formatura %}
<tr>
<td class="col-md-2"><a href="{% url 'student:detail' grr=l.grr degree_id=degree.code %}">{{ l.grr }}</a></td>
<td class="col-md-4">{{ l.nome }}</td>
<td class="col-md-2">{{ l.ira|floatformat:2 }}</td>
<td class="col-md-2">{{ l.forma_evasao }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="abandono">
<table class="table datatable">
<thead>
<tr>
<th class="col-md-2">GRR</th>
<th class="col-md-4">Nome</th>
<th class="col-md-2">ira</th>
<th class="col-md-2">Forma evasão</th>
</tr>
</thead>
<tbody>
{% for l in abandono %}
<tr>
<td class="col-md-2"><a href="{% url 'student:detail' grr=l.grr degree_id=degree.code %}">{{ l.grr }}</a></td>
<td class="col-md-4">{{ l.nome }}</td>
<td class="col-md-2">{{ l.ira|floatformat:2 }}</td>
<td class="col-md-2">{{ l.forma_evasao }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="desistencia">
<table class="table datatable">
<thead>
<tr>
<th class="col-md-2">GRR</th>
<th class="col-md-4">Nome</th>
<th class="col-md-2">ira</th>
<th class="col-md-2">Forma evasão</th>
</tr>
</thead>
<tbody>
{% for l in desistencia %}
<tr>
<td class="col-md-2"><a href="{% url 'student:detail' grr=l.grr degree_id=degree.code %}">{{ l.grr }}</a></td>
<td class="col-md-4">{{ l.nome }}</td>
<td class="col-md-2">{{ l.ira|floatformat:2 }}</td>
<td class="col-md-2">{{ l.forma_evasao }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="outras">
<table class="table datatable">
<thead>
<tr>
<th class="col-md-2">GRR</th>
<th class="col-md-4">Nome</th>
<th class="col-md-2">ira</th>
<th class="col-md-2">Forma evasão</th>
</tr>
</thead>
<tbody>
{% for l in outros %}
<tr>
<td class="col-md-2"><a href="{% url 'student:detail' grr=l.grr degree_id=degree.code %}">{{ l.grr }}</a></td>
<td class="col-md-4">{{ l.nome }}</td>
<td class="col-md-2">{{ l.ira|floatformat:2 }}</td>
<td class="col-md-2">{{ l.forma_evasao }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
{% endblock content %}
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from django.conf import settings
from django.conf.urls.static import static
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^(?P<grr>\w+)/$', views.detail, name='detail'),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.shortcuts import render, redirect
from django.core.files.storage import FileSystemStorage
from django.contrib import messages
from degree.models import Degree
from report_api.views import get_list_students, get_course_detail
def detail(request, degree_id, codigo_disciplina):
degree = Degree.objects.get(code=degree_id)
if not (degree in request.user.educator.degree.all()):
return redirect("adega:dashboard")
course_detail = get_course_detail(request.session, degree, codigo_disciplina)
return render(request, 'student/detail.html',{
"analysis_result": course_detail,
"degree": degree,
"codigo_disciplina": codigo_disciplina,
"nome_disciplina": course_detail["disciplina_nome"]
})
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")
sem_evasao = get_list_students(request.session, degree, "Sem evasão")
formatura = get_list_students(request.session, degree, "Formatura")
abandono = get_list_students(request.session, degree, "Abandono")
desistencia = get_list_students(request.session, degree, "Desistência")
outros = get_list_students(request.session, degree, "Outro")
return render(request, 'student/index.html', {
'degree': degree,
'formatura': formatura,
'sem_evasao': sem_evasao,
'abandono': abandono,
'desistencia': desistencia,
'outros': outros
})
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