Commit 84b4402a authored by bhmeyer's avatar bhmeyer

#209: Update student list page & Add filter option to phase analysis

parent b15e53c2
Pipeline #21155 passed with stage
in 2 minutes and 40 seconds
......@@ -559,7 +559,7 @@ class DegreeGrid:
},
"phases":{
"barreira": ["CI068", "CI055", "CM046", "CM045", "CM201",
"Barreira": ["CI068", "CI055", "CM046", "CM045", "CM201",
"CI210", "CI056", "CI067", "CM005", "CM202",
"CI212", "CI057", "CI064", "CI237", "CI166",]
},
......
......@@ -144,12 +144,21 @@
<td>Período pretendido</td>
<td>
{% if analysis_result.periodo_pretendido %}
<span class="data">{{ analysis_result.periodo_pretendido }}</span>
<span class="data">
{{ analysis_result.periodo_pretendido }}
</span>
{% else %}
<span class="data">Formado</span>
<span class="data">Formado</span>
{% endif %}
</td>
</tr>
{% for phase_name, phase_value in grid_phases %}
<tr>
<td>{{phase_value.description_name}} ({{phase_name}})</td>
<td><span class="data">{{phase_value.description_value}}</span></td>
</tr>
{% endfor %}
</table>
</div>
......
This diff is collapsed.
......@@ -13,7 +13,7 @@ from guardian.decorators import permission_required_or_403
from student.grid import DegreeGrid
from submission.analysis.utils.situations import Situation
from submission.analysis.utils.situations import Situation, EvasionForm
situations_pass = Situation.SITUATION_PASS
situations_pass = [Situation.code_to_str(c) for c in situations_pass]
......@@ -40,6 +40,31 @@ 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
grid_phases_values = []
for phase_name in grid_phases:
list_phase_val = get_list_students(
request.session,
degree,
phase_name,
submission_id
)
# list_phase_val
grid_phase_desc_value = None
for student in list_phase_val["student_list"]:
if student["grr"] == grr:
grid_phase_desc_value = student["description_value"]
break
grid_phases_values.append({
"description_value": grid_phase_desc_value,
"description_name": list_phase_val["description_name"],
})
grid_phases = list(zip(grid_phases.keys(), grid_phases_values))
analysis_result = {
'indice_aprovacao' : cache_j['taxa_aprovacao'],
'periodo_real': cache_j['periodo_real'],
......@@ -51,7 +76,7 @@ def detail(request, submission_id, grr):
'student': cache_j['student'],
'aluno_turmas': hist,
'grid': grid_info,
'grid_extra': grid_info_extra
'grid_extra': grid_info_extra,
}
return render(request, 'student/detail.html', {
......@@ -60,6 +85,7 @@ def detail(request, submission_id, grr):
"submission": submission,
"situations_pass": situations_pass,
"situations_fail": situations_fail,
'grid_phases': grid_phases
})
......@@ -103,6 +129,26 @@ def index(request, submission_id):
submission_id
)
dg = DegreeGrid(DegreeGrid.bcc_grid_2011)
grid_phases = dg.grid_detail.phases # Dictionary
# Parse to list of tuples
grid_phases_names = list(grid_phases.keys())
active_name = EvasionForm.code_to_str(EvasionForm.EF_ATIVO)
# Collect the phases list only for active students (see student analysis)
grid_phases_names+=[p+" - "+active_name for p in grid_phases_names]
grid_phases_values = []
for phase_name in grid_phases_names:
grid_phases_values.append(
get_list_students(
request.session,
degree,
phase_name,
submission_id
)
)
grid_phases = list(zip(grid_phases_names, grid_phases_values))
return render(request, 'student/index.html', {
'degree': degree,
'formatura': formatura,
......@@ -113,5 +159,6 @@ def index(request, submission_id):
"submission": submission,
"situations_pass": situations_pass,
"situations_fail": situations_fail,
"grid_phases": grid_phases,
})
......@@ -57,65 +57,67 @@ class StudentAnalysis:
situations = list(pd.DataFrame(
{'count': situations.size()}).reset_index().groupby(["FORMA_EVASAO"]))
iras = self.ira_alunos(df=df)
list_situations = defaultdict(list)
iras = self.ira_alunos()
list_situations = defaultdict(dict)
for sit in situations:
grrs = list(sit[1]["MATR_ALUNO"])
people_names = list(sit[1]["NOME_PESSOA"])
evasion_form_name = EvasionForm.code_to_str(sit[0])
student_list = []
for i, student in enumerate(grrs):
list_situations[sit[0]].append({
"forma_evasao": evasion_form_name,
student_list.append({
"description_value": evasion_form_name,
"grr": grrs[i],
"ira": iras[grrs[i]],
"nome": people_names[i]
})
list_situations[sit[0]]["student_list"] = student_list
list_situations[sit[0]]["description_name"] = "Forma de evasão"
return list_situations
def list_students_phases(self, df=None):
def list_students_phases(self, df=None, only_actives=False):
df = df if df is not None else self.data_frame
iras = self.ira_alunos()
# iras = self.ira_alunos(df=df)
df_approved = df[df['SITUACAO'].isin(Situation.SITUATION_PASS)]
groups = df_approved.groupby("MATR_ALUNO")
if only_actives:
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
set_phases = {p:set(phases[p]) for p in phases}
students_list = defaultdict(list)
for grr,group in groups:
approved_courses = set(group["COD_ATIV_CURRIC"].values)
for s in set_phases:
list_phases = defaultdict(dict)
for s in set_phases:
phase_name = s
if only_actives:
phase_name+=" - "+EvasionForm.code_to_str(EvasionForm.EF_ATIVO)
student_list = []
for grr,group in groups:
# Each row of sub dataframe have the same "NOME_PESSOA" value
people_name = group["NOME_PESSOA"][0]
group = group[group['SITUACAO'].isin(Situation.SITUATION_PASS)]
approved_courses = set(group["COD_ATIV_CURRIC"].values)
# Total if courses needed fot a student complete a phase
debpt = len(set_phases[s] - approved_courses)
students_list[s].append({"grr":grr, "debpt":debpt})
print(students_list)
exit()
return
# list_situations= defaultdict(list)
# for sit in situations:
# grrs = list(sit[1]["MATR_ALUNO"])
# people_names = list(sit[1]["NOME_PESSOA"])
# evasion_form_name = EvasionForm.code_to_str(sit[0])
# for i, student in enumerate(grrs):
# list_situations[sit[0]].append({
# "forma_evasao": evasion_form_name,
# "grr": grrs[i],
# "ira": iras[grrs[i]],
# "nome": people_names[i]
# })
student_list.append({
"grr":grr,
"nome": people_name,
"ira": iras[grr],
"description_value":debpt,
})
# return list_situations
list_phases[phase_name]["student_list"] = student_list
list_phases[phase_name]["description_name"] = "Disciplinas restantes"
return list_phases
def ira_alunos(self, df=None):
"""
......@@ -134,11 +136,14 @@ class StudentAnalysis:
--------
iras = { GRR: number, ...}
"""
if not (self._ira_alunos_last_result is None):
return self._ira_alunos_last_result
df = df if df is not None else self.data_frame
# Verify if exist cache for default dataframe result
if not (self._ira_alunos_last_result is None) and df.equals(self.data_frame):
return self._ira_alunos_last_result
iras = self.ira_por_quantidade_disciplinas(df=df)
ira_per_student = {}
for i in iras:
......@@ -154,7 +159,9 @@ class StudentAnalysis:
else: # There is no register of courses for this student
ira_per_student[i] = 0
self._ira_alunos_last_result = ira_per_student
# Save the result if the dataframe is default
if df.equals(self.data_frame):
self._ira_alunos_last_result = ira_per_student
return ira_per_student
......
......@@ -40,11 +40,11 @@ def build_cache(dataframe, path, current_year = CURRENT_YEAR,
for cod, df in dataframe.groupby('COD_CURSO'):
path = path + '/'
# generate_degree_data(path, df, student_analysis)
generate_degree_data(path, df, student_analysis)
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, df)
generate_admission_data(path + 'admissions/', df, student_analysis)
generate_course_data(path + 'courses/',current_year, dataframe)
generate_cepe_data(path, df)
def generate_cepe_data(path, df):
......@@ -142,18 +142,27 @@ def generate_student_data(path, dataframe, student_analysis):
EvasionForm.EF_OUTROS
]
list_phases = student_analysis.list_students_phases()
list_situations = student_analysis.list_students_situation()
for fl in files_list:
list_name = EvasionForm.code_to_str(int(fl))
list_content = []
list_content = {"description_name":"", "description_value":""}
if(fl in list_situations):
list_content = list_situations[fl]
print(list_content)
save_json(path + "list/" + list_name + ".json", list_content)
# Falta verificar se alguem nao recebeu algumas analises
# TODO: Check if all students receive analysis
# All students
list_phases = student_analysis.list_students_phases()
for phase_name in list_phases:
list_content = list_phases[phase_name]
save_json(path + "list/" + phase_name + ".json", list_content)
# Only students without evasion
list_phases = student_analysis.list_students_phases(only_actives=True)
for phase_name in list_phases:
list_content = list_phases[phase_name]
save_json(path + "list/" + phase_name + ".json", list_content)
def generate_student_list(path):
pass
......
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