Commit 5036903d authored by bhmeyer's avatar bhmeyer

Merge branch '191-ajustes-na-grade-do-aluno' into 'development'

Resolve "Ajustes na grade do aluno"

Closes #191

See merge request !107
parents 6ebb6bfc 9500ca5d
Pipeline #21558 failed with stage
in 4 minutes and 52 seconds
from submission.analysis.utils.situations import Situation
from submission.analysis.utils.situations import Situation, PeriodType
import numpy as np
......@@ -7,8 +7,9 @@ class CourseGrid:
self.situation = obj["situacao"]
self.code = obj["codigo"]
self.name = obj["nome"]
self.year = obj["ano"]
self.semester = obj["semestre"]
self.year = int(obj["ano"])
# the code that subtitutes the strings are sorting the period types by time (look situations.py)
self.semester_code = PeriodType.str_to_code(obj["semestre"])
self.grade = obj["nota"]
def is_approved(self):
......@@ -36,6 +37,22 @@ class CourseGrid:
def is_coursed(self):
return self.is_approved() or self.is_failed()
def __gt__(self, other):
if self.year == other.year:
return self.semester_code > other.semester_code
else:
return self.year > other.year
def __lt__(self, other):
if self.year == other.year:
return self.semester_code < other.semester_code
else:
return self.year < other.year
def __eq__(self, other):
return (self.year == other.year) and (self.semester_code == other.semester_code)
class CourseGridCollection:
def __init__(self, code, grid):
......@@ -102,7 +119,11 @@ class CourseGridCollection:
def mean_grade(self):
grades = [x.grade for x in self.get_coursed_historic()]
return np.mean(grades)
def last_grade(self):
courses = self.get_coursed_historic()
courses = sorted(courses)
return courses[-1].grade
def get_prevalent_situation(self):
# If this is an course that repeat on grid, then this doesnt have any
......@@ -140,12 +161,12 @@ class CourseGridCollection:
"name": self.name,
"code": self.code,
"situation": p_sit,
"is_real_code": self.is_real_code
"is_real_code": self.is_real_code,
}
if self.has_detail():
info["detail"] = {
"count": self.count_coursed(),
"mean_grade": self.mean_grade(),
"last_grade": self.last_grade(),
}
return info
......@@ -176,7 +197,7 @@ class DegreeGridDescription:
def is_repeated_code(self, code):
return code in self.repeated_codes
def is_real_code(self, code):
return not code in self.fake_codes
......@@ -193,7 +214,7 @@ class DegreeGrid:
def __init__(self, grid_detail):
self.grid_detail = grid_detail
self.cgc = {}
def compute_cgc(self, hist):
# Create an instance for each cell in grid
cgc = {}
......@@ -217,12 +238,47 @@ class DegreeGrid:
return cgc
def get_prerequisites(self, code):
if code in self.bcc_grid_2011.prerequisites.keys():
return [x for x in self.bcc_grid_2011.prerequisites[code]]
else:
return ['none']
def get_list_approvations(self, grid):
approvations=[]
for period in grid:
for course in period:
if course['situation'] == "approved" or course['situation'] == "equivalence":
approvations.append(course['code'])
return approvations
def is_blocked(self, code, prerequisites, approvations):
if code in approvations:
return False
prerequisites_completed = True
for prerequisite in prerequisites:
if prerequisite == 'none':
return False
if prerequisite not in approvations:
prerequisites_completed = False
return not prerequisites_completed
def get_blocked_courses(self, grid):
approvations = self.get_list_approvations(grid)
for i, period in enumerate(grid):
for j, course in enumerate(period):
code = course['code']
prerequisites = self.get_prerequisites(code)
grid[i][j]["is_blocked"] = self.is_blocked(code, prerequisites, approvations);
return grid
def get_grid(self, cgc):
new_grid = np.array(self.grid_detail.grid, dtype=np.dtype(object))
for i, line in enumerate(self.grid_detail.grid):
for j, course_code in enumerate(line):
# TODO: Add possibility to insert others grids
new_grid[i, j] = cgc[course_code].get_info()
new_grid = self.get_blocked_courses(new_grid)
return new_grid
def get_repeated_course_info(self, cgc):
......@@ -543,7 +599,7 @@ class DegreeGrid:
"CI064": ["CI055"],
"CI067": ["CI055"],
"CI237": ["CM046"],
"CM005": ["CI045"],
"CM005": ["CM045"],
"CM202": ["CM201"],
##
......
......@@ -40,17 +40,20 @@
{% for semester in analysis_result.grid%}
<div class="semestre">
<div class="grade-head">{{forloop.counter}}º</div>
{% for course in semester %}
<div data-toggle="tooltip" data-placement="top" title="{{course.name}}" class="materia {{ course.situation}}">
<div class="info">
{% if course.is_real_code %}
<span class="name">
<a href="{% url 'course:detail' submission_id=submission.id codigo_disciplina=course.code|remove_spaces %}">
{{ course.code }}</a>
{% for course in semester %}
<div data-toggle="tooltip" data-placement="top" title="{{course.name}}" class="materia {{ course.situation}}">
<div class="info">
<span class="name">
{% if course.is_real_code %}
<a href="{% url 'course:detail' submission_id=submission.id codigo_disciplina=course.code|remove_spaces %}">
{{ course.code }}</a>
{% else %}
{{ course.code }}
{% endif %}
{% if course.is_blocked %}
<i class="fa fa-lock pl-3" title="Faltando pré-requisitos. Disciplina bloqueada."></i>
{% endif %}
</span>
{% else %}
<span class="name">{{ course.code }}</span>
{% endif %}
</div>
<div class="details">
{% if course.detail %}
......@@ -59,16 +62,16 @@
<span class="detail-value">{{course.detail.count}}</span>
</div>
<div class="detail">
<span class="detail-name">Nota média</span>
<span class="detail-value">{{course.detail.mean_grade|fix_2digit}}</span>
<span class="detail-name">Última nota</span>
<span class="detail-value">{{course.detail.last_grade|fix_2digit}}</span>
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
{% endfor %}
</div>
<br>
......
# -*- coding: utf-8 -*-
# == Admission Form == #
class PeriodType:
# The numbers are supposedly sorting by time
# the earlier period type
PT_1S = 0
PT_1T = 1
PT_2S = 2
PT_A = 3
PT_SE = 4
PT_E = 5
# the later period type
PERIODS = (
(PT_1S, "1o. Semestre"),
(PT_1T, "1. Trimestre"),
(PT_2S, "2o. Semestre"),
(PT_A,"Anual"),
(PT_SE,"Semestral"),
(PT_E,"Período Especial (1)"),
)
@staticmethod
def str_to_code(name):
for pt in PeriodType.PERIODS:
if(pt[1] == name):
return pt[0]
return -1
class AdmissionType:
AT_DESCONHECIDO = 0
AT_VESTIBULAR = 1
......@@ -25,6 +54,7 @@ class AdmissionType:
(AT_OUTROS, 'Outro'),
)
# == Evasion Form == #
class EvasionForm:
EF_DESCONHECIDO = 0
......
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