Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
adega
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Odair M.
adega
Commits
7af12cdf
Commit
7af12cdf
authored
7 years ago
by
João Denis Rodrigues
Browse files
Options
Downloads
Patches
Plain Diff
Fix cache student + funcoes disciplinas
parent
033c6b82
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/course/analysis.py
+103
-0
103 additions, 0 deletions
src/course/analysis.py
src/script.py
+1
-1
1 addition, 1 deletion
src/script.py
src/student/models.py
+2
-0
2 additions, 0 deletions
src/student/models.py
src/utils/data.py
+35
-0
35 additions, 0 deletions
src/utils/data.py
with
141 additions
and
1 deletion
src/course/analysis.py
+
103
−
0
View file @
7af12cdf
from
__future__
import
division
from
student.models
import
Student
from
klass.models
import
*
from
admission.models
import
Admission
from
course.models
import
*
from
degree.models
import
*
from
datetime
import
datetime
from
student.analysis
import
*
import
math
def
average_grade
(
klasses
):
# calcular_nota_media(turmas)
grade
=
0
amount_student
=
0
for
klass
in
klasses
:
student_klasses
=
StudentKlass
.
objects
.
filter
(
klass
=
klass
,
situation__in
=
SITUATION_COURSE_VALID_GRADE
)
for
student_klass
in
student_klasses
:
if
student_klass
.
grade
is
not
None
:
grade
+=
student_klass
.
grade
amount_student
+=
1
if
amount_student
==
0
:
return
-
1
else
:
return
grade
/
amount_student
def
average_grade_standard_deviation
(
klasses
):
# calcular_nota_media_desvio_padrao
average_grade
=
average_grade
(
klasses
)
amount_student
=
0
variance
=
0
for
klass
in
klasses
:
student_klasses
=
StudentKlass
.
objects
.
filter
(
klass
=
klass
,
situation__in
=
SITUATION_COURSE_VALID_GRADE
)
for
student_klass
in
student_klasses
:
if
student_klass
.
grade
is
not
None
:
variance
+=
math
.
pow
(
student_klass
.
grade
-
average_grade
,
2
)
amount_student
+=
1
if
amount_student
==
0
:
return
-
1
standard_deviation
=
math
.
sqrt
(
variance
/
amount_student
)
return
(
average_grade
,
standard_deviation
)
def
average_grade_last_year
(
klasses
):
# calcular_nota_media_ultimo_ano
grades
=
0
amount_student
=
0
now
=
datetime
.
now
()
for
klass
in
klasses
:
if
klass
.
year
==
(
now
.
year
-
1
):
student_klasses
=
StudentKlass
.
objects
.
filter
(
klass
=
klass
)
for
student_klass
in
student_klasses
:
if
student_klass
.
grade
is
not
None
:
grades
+=
student_klass
.
grade
amount_student
+=
1
if
amount_student
==
0
:
return
-
1
return
grades
/
student_amount
def
average_grade_last_year_standard_deviation
(
klasses
):
# calcular_nota_media_ultimo_ano_desvio_padrao
average_grade
=
average_grade_last_year
(
klasses
)
if
average_gradde
==
-
1
:
return
(
-
1
,
-
1
)
amount_student
=
0
variance
=
0
now
=
datetime
.
now
()
for
klass
in
klasses
:
if
klass
.
year
==
(
now
.
year
-
1
):
student_klasses
=
StudentKlass
.
objects
.
filter
(
klass
=
klass
)
for
student_klass
in
student_klasses
:
if
student_klass
.
grade
is
not
None
:
variance
+=
math
.
pow
(
student_klass
.
grade
-
average_grade
,
2
)
amount_student
+=
1
if
amount_student
==
0
:
return
(
-
1
,
-
1
)
standard_deviation
=
math
.
sqrt
(
variance
/
amount_student
)
return
(
average_grade
,
standard_deviation
)
#def absolute_pass_rate(klasses): # calcular_taxa_reprovacao_absoluta
def
frequency_failure
(
klasses
):
# calcular_taxa_reprovacao_frequencia
amount_failure
=
0
amounte_student
=
0
for
klass
in
klasses
:
student_klasses
=
StudentKlass
.
objects
.
filter
(
klass
=
klass
)
for
student_klass
in
student_klasses
:
if
student_klass
.
situation
is
not
None
:
if
student
.
situation
==
"
Reprovado por Frequência
"
:
amount_failure
+=
1
amount_student
+=
1
if
amount_student
==
0
:
return
-
1
amount_failure
*=
100
return
amount_failure
/
amount_student
This diff is collapsed.
Click to expand it.
src/script.py
+
1
−
1
View file @
7af12cdf
...
...
@@ -108,7 +108,7 @@ def generate_student_data(degree, path):
for
student
in
students
:
student_klasses
=
StudentKlass
.
objects
.
filter
(
student
=
student
)
amount_courses_semester
=
get_
stude
nt_courses_completed
(
student
_klasses
)
amount_courses_semester
=
get_
amou
nt_courses_completed
(
student
)
failures_semester
=
semester_pass_rate
(
student
)
failures_amount_courses_semester
=
merge_dicts
(
[
'
reprovacoes
'
,
'
cursadas
'
],
...
...
This diff is collapsed.
Click to expand it.
src/student/models.py
+
2
−
0
View file @
7af12cdf
...
...
@@ -17,6 +17,8 @@ class Student(models.Model):
klasses
=
models
.
ManyToManyField
(
'
klass.Klass
'
,
through
=
'
klass.StudentKlass
'
)
def
get_time_in_degree
(
self
):
year_end
=
self
.
admission
.
degree
.
report_year
semester_end
=
self
.
admission
.
degree
.
report_semester
if
self
.
evasion_year
is
not
None
:
year_end
=
self
.
evasion_year
if
self
.
evasion_semester
is
None
:
...
...
This diff is collapsed.
Click to expand it.
src/utils/data.py
+
35
−
0
View file @
7af12cdf
...
...
@@ -87,6 +87,41 @@ SITUATION_FAILURE_COMPLETED = ( # Situacoes reprovacao cursada ate o fim
u
'
Reprovado sem nota
'
,
)
SITUATION_COURSES_VALID
=
(
u
'
Reprovado por nota
'
,
u
'
Aprovado
'
,
u
'
Reprovado por Frequência
'
,
u
'
Reprovado sem nota
'
,
u
'
Equivalência de Disciplina
'
,
u
'
Aprovado Conhecimento
'
,
u
'
Reprovado Conhecimento
'
,
u
'
Aprovado Adiantamento
'
,
u
'
Horas
'
,
u
'
Dispensa de Disciplinas (com nota)
'
,
u
'
Dispensa de Disciplinas (sem nota))
'
,
u
'
Matrícula
'
,
)
SITUATION_COURSES_LOCKED
=
(
u
'
Cancelado
'
,
u
'
Trancamento Total
'
,
u
'
Trancamento Administrativo
'
,
)
SITUATION_COURSES_VALID_GRADE
=
(
u
'
Reprovado por nota
'
,
u
'
Aprovado
'
,
u
'
Reprovado por Frequência
'
,
u
'
Reprovado sem nota
'
,
u
'
Equivalência de Disciplina
'
,
u
'
Aprovado Conhecimento
'
,
u
'
Reprovado Conhecimento
'
,
u
'
Aprovado Adiantamento
'
,
u
'
Horas
'
,
u
'
Dispensa de Disciplinas (com nota)
'
,
u
'
Dispensa de Disciplinas (sem nota))
'
,
)
def
difference_between_semesters
(
year_start
,
semester_start
,
year_end
,
semester_end
):
return
2
*
(
year_end
-
year_start
)
+
(
semester_end
-
semester_start
)
+
1
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment