Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
adega
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
64
Issues
64
List
Boards
Labels
Service Desk
Milestones
Merge Requests
3
Merge Requests
3
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
adega
adega
Commits
5699d3f6
Commit
5699d3f6
authored
Aug 01, 2019
by
bhmeyer
Committed by
msrr18
Aug 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Identificar barrados"
parent
247798c9
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
272 additions
and
109 deletions
+272
-109
src/student/grid.py
src/student/grid.py
+7
-3
src/student/templates/student/detail.html
src/student/templates/student/detail.html
+11
-2
src/student/templates/student/index.html
src/student/templates/student/index.html
+121
-89
src/student/views.py
src/student/views.py
+49
-2
src/submission/analysis/analysis/student_analysis.py
src/submission/analysis/analysis/student_analysis.py
+63
-7
src/submission/analysis/build_cache.py
src/submission/analysis/build_cache.py
+21
-6
No files found.
src/student/grid.py
View file @
5699d3f6
...
...
@@ -159,6 +159,7 @@ class DegreeGridDescription:
self
.
equiv_codes
=
obj
[
"equiv_codes"
]
self
.
fake_codes
=
obj
[
"fake_codes"
]
self
.
prerequisites
=
obj
[
"prerequisites"
]
self
.
phases
=
obj
[
"phases"
]
# Codes that show more then one time on grid, like OPT
self
.
repeated_codes
=
obj
[
"repeated_codes"
]
...
...
@@ -582,9 +583,12 @@ class DegreeGrid:
"CI064"
,
"CM045"
,
"CM005"
,
"CI237"
,
"CM201"
,
"CM202"
,
"CI166"
],
"TG II"
:
[
"CI068"
,
"CI210"
,
"CI212"
,
"CI055"
,
"CI056"
,
"CI057"
,
"CM046"
,
"CI067"
,
"CI064"
,
"CM045"
,
"CM005"
,
"CI237"
,
"CM201"
,
"CM202"
,
"CI166"
],
}
},
"phases"
:{
"Barreira"
:
[
"CI068"
,
"CI055"
,
"CM046"
,
"CM045"
,
"CM201"
,
"CI210"
,
"CI056"
,
"CI067"
,
"CM005"
,
"CM202"
,
"CI212"
,
"CI057"
,
"CI064"
,
"CI237"
,
"CI166"
,]
},
})
src/student/templates/student/detail.html
View file @
5699d3f6
...
...
@@ -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>
...
...
src/student/templates/student/index.html
View file @
5699d3f6
This diff is collapsed.
Click to expand it.
src/student/views.py
View file @
5699d3f6
...
...
@@ -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
,
})
src/submission/analysis/analysis/student_analysis.py
View file @
5699d3f6
...
...
@@ -11,11 +11,13 @@ from collections import defaultdict
class
StudentAnalysis
:
data_frame
=
None
def
__init__
(
self
,
df
,
current_year
,
current_semester
):
def
__init__
(
self
,
df
,
current_year
,
current_semester
,
dg
):
self
.
data_frame
=
df
self
.
current_year
=
current_year
self
.
current_semester
=
current_semester
self
.
dg
=
dg
self
.
_ira_alunos_last_result
=
None
def
student_info
(
self
,
df
=
None
):
df
=
df
if
df
is
not
None
else
self
.
data_frame
...
...
@@ -49,30 +51,73 @@ class StudentAnalysis:
return
info
def
list_students
(
self
,
df
=
None
):
def
list_students
_situation
(
self
,
df
=
None
):
df
=
df
if
df
is
not
None
else
self
.
data_frame
situations
=
df
.
groupby
([
"MATR_ALUNO"
,
"NOME_PESSOA"
,
"FORMA_EVASAO"
])
situations
=
list
(
pd
.
DataFrame
(
{
'count'
:
situations
.
size
()}).
reset_index
().
groupby
([
"FORMA_EVASAO"
]))
iras
=
self
.
ira_alunos
(
df
=
df
)
list_situations
=
defaultdict
(
lis
t
)
iras
=
self
.
ira_alunos
()
list_situations
=
defaultdict
(
dic
t
)
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
,
only_actives
=
False
):
df
=
df
if
df
is
not
None
else
self
.
data_frame
iras
=
self
.
ira_alunos
()
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
}
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
)
student_list
.
append
({
"grr"
:
grr
,
"nome"
:
people_name
,
"ira"
:
iras
[
grr
],
"description_value"
:
debpt
,
})
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
):
"""
...
...
@@ -91,8 +136,14 @@ class StudentAnalysis:
--------
iras = { GRR: number, ...}
"""
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
:
...
...
@@ -107,6 +158,11 @@ class StudentAnalysis:
ira_per_student
[
i
]
=
ira_total
/
carga_total
else
:
# There is no register of courses for this student
ira_per_student
[
i
]
=
0
# 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
...
...
src/submission/analysis/build_cache.py
View file @
5699d3f6
...
...
@@ -14,6 +14,8 @@ from submission.analysis.analysis.admission_analysis import evasion_per_semester
from
submission.analysis.analysis.cepe9615_analysis
import
*
from
student.grid
import
DegreeGrid
from
collections
import
defaultdict
try
:
...
...
@@ -27,11 +29,14 @@ student_analysis = None
CURRENT_YEAR
=
2016
CURRENT_SEMESTER
=
1
def
build_cache
(
dataframe
,
path
,
current_year
=
CURRENT_YEAR
,
current_semester
=
CURRENT_SEMESTER
):
def
build_cache
(
dataframe
,
path
,
current_year
=
CURRENT_YEAR
,
current_semester
=
CURRENT_SEMESTER
):
# os.chdir("../src")
ensure_path_exists
(
path
)
student_analysis
=
StudentAnalysis
(
dataframe
,
current_year
,
current_semester
)
dg
=
DegreeGrid
(
DegreeGrid
.
bcc_grid_2011
)
student_analysis
=
StudentAnalysis
(
dataframe
,
current_year
,
current_semester
,
dg
)
for
cod
,
df
in
dataframe
.
groupby
(
'COD_CURSO'
):
path
=
path
+
'/'
...
...
@@ -137,17 +142,27 @@ def generate_student_data(path, dataframe, student_analysis):
EvasionForm
.
EF_OUTROS
]
list_situations
=
student_analysis
.
list_students
()
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
]
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment