Commit 35e144b2 authored by tsv19's avatar tsv19

Merge branch '200-identificar-provaveis-formandos' into 'development'

Resolve "Identificar prováveis formandos"

Closes #200

See merge request !112
parents 4d612607 17f12751
Pipeline #22303 passed with stage
in 5 minutes and 39 seconds
......@@ -209,7 +209,7 @@ class DegreeGridDescription:
if(code1 == code2):
return True
return False
class DegreeGrid:
def __init__(self, grid_detail):
self.grid_detail = grid_detail
......
......@@ -31,6 +31,7 @@
<a class="nav-item nav-link" href="#abandono" aria-controls="abandono" data-toggle="tab">Abandono</a>
<a class="nav-item nav-link" href="#desistencia" aria-controls="desistencia" data-toggle="tab">Desistência</a>
<a class="nav-item nav-link" href="#outras" aria-controls="outras" data-toggle="tab">Outras Formas de Evasão</a>
<a class="nav-item nav-link" href="#formandos" aria-controls="formandos" data-toggle="tab">Possíveis Formandos</a>
{% for phase_name, phase_value in grid_phases %}
<a class="nav-item nav-link" href="#phase_{{phase_name|remove_spaces}}" aria-controls="{{phase_name}}" data-toggle="tab">{{phase_name}}</a>
{% endfor %}
......@@ -148,7 +149,28 @@
</tbody>
</table>
</div>
<div role="tabpanel" class="tab-pane" id="formandos">
<table class="table table-striped table-bordered" id="formandos_table">
<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">{{formandos.description_name}}</th>
</tr>
</thead>
<tbody>
{% for l in formandos.student_list %}
<tr>
<td class="col-md-2"><a href="{% url 'student:detail' grr=l.grr submission_id=submission.id %}">{{ 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.description_value }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% for phase_name, phase_value in grid_phases %}
<div role="tabpanel" class="tab-pane" id="phase_{{phase_name|remove_spaces}}">
......@@ -188,6 +210,7 @@
$("#abandono_table"),
$("#desistencia_table"),
$("#outros_table"),
$("#formandos_table"),
{% for phase_name, phase_value in grid_phases %}
$("#phase_{{phase_name|remove_spaces}}_table"),
{% endfor %}
......
......@@ -41,8 +41,8 @@ def detail(request, submission_id, grr):
grid_info, grid_info_extra = dg.get_situation(hist)
grid_phases = dg.grid_detail.phases # Dictionary
# Parse to list of tuples
# Parse to list of tuple
grid_phases_values = []
for phase_name in grid_phases:
list_phase_val = get_list_students(
......@@ -128,6 +128,13 @@ def index(request, submission_id):
"Outro",
submission_id
)
formandos = get_list_students(
request.session,
degree,
"Formandos",
submission_id
)
dg = DegreeGrid(DegreeGrid.bcc_grid_2011)
......@@ -156,6 +163,7 @@ def index(request, submission_id):
'abandono': abandono,
'desistencia': desistencia,
'outros': outros,
'formandos': formandos,
"submission": submission,
"situations_pass": situations_pass,
"situations_fail": situations_fail,
......
import numpy as np
from submission.analysis.utils.situations import *
......@@ -118,6 +119,76 @@ class StudentAnalysis:
list_phases[phase_name]["description_name"] = "Disciplinas restantes"
return list_phases
def list_students_trainees(self, df=None):
df = df if df is not None else self.data_frame
iras = self.ira_alunos()
df = df[df["FORMA_EVASAO"] == EvasionForm.EF_ATIVO]
groups = df.groupby("MATR_ALUNO")
# Parse phases lists to sets before start the checkage
phases = self.dg.grid_detail.phases
# Transforme grid matrix into list
flatten = lambda l: [item for sublist in l for item in sublist]
list_phases = defaultdict(dict)
intended_semester = self.periodo_pretendido(df)
SITUATION_PASS_OR_MATR = (
Situation.SIT_APROVADO,
Situation.SIT_CONHECIMENTO_APROVADO,
Situation.SIT_DISPENSA_COM_NOTA,
Situation.SIT_APROV_ADIANTAMENTO,
Situation.SIT_EQUIVALENCIA,
Situation.SIT_MATRICULA
)
student_list = []
for grr,group in groups:
to_do = flatten(self.dg.grid_detail.grid)
# Each row of sub dataframe have the same "NOME_PESSOA" value
people_name = group["NOME_PESSOA"][0]
group = group[ group['SITUACAO'].isin(SITUATION_PASS_OR_MATR) ]
approved_matr_courses = group["COD_ATIV_CURRIC"].values
# Replace real codes for "fake codes" from grid e.g.: CI204 -> OPT
for fake_code in self.dg.grid_detail.fake_codes:
approved_matr_courses = [fake_code if self.dg.grid_detail.is_equivalence(code,fake_code)
else code for code in approved_matr_courses ]
# Total if courses needed fot a student complete a phase
for code1 in approved_matr_courses:
# If the student did the course then remove it from to do list
if (code1 in to_do):
i = to_do.index(code1)
del to_do[i]
# Total courses that is left to do to graduate
debpt = len(to_do)
if (not debpt):
student_list.append({
"grr":grr,
"nome": people_name,
"ira": iras[grr],
"description_value":intended_semester[grr]
})
return {
"student_list": student_list,
"description_name": "Semestres de curso"
}
def ira_alunos(self, df=None):
......@@ -271,7 +342,6 @@ class StudentAnalysis:
fake_codes = DegreeGrid.get_degree_grid("21A").fake_codes
opts_tgs = list(DegreeGrid.get_degree_grid("21A").equiv_codes)
else:
# print ('sem grade irmão')
continue
max_period = len(grid)-1
......
......@@ -152,6 +152,8 @@ def generate_student_data(path, dataframe, student_analysis):
save_json(path + "list/" + list_name + ".json", list_content)
# TODO: Check if all students receive analysis
list_students_trainees = student_analysis.list_students_trainees()
save_json(path + "list/Formandos.json", list_students_trainees)
# All students
list_phases = student_analysis.list_students_phases()
......
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