Commit 4935adea authored by bhmeyer's avatar bhmeyer Committed by msrr18
Browse files

Resolve "Fazer grade para o degree"

parent 3bae5606
......@@ -287,6 +287,23 @@ {
.grade .name {
display: block; }
.materia_selected {
outline-color:rgb(138, 64, 207);
.materia_prerequisite {
.materia_posrequisite {
/* ============================================== MATERIA */
.materia {
background-color: #FFF;
from django import template
from django.utils.safestring import mark_safe
from django.template import Library
import json
import numpy as np
register = template.Library()
......@@ -21,4 +26,10 @@ def remove_spaces(value):
return value.replace(' ', '')
return value
\ No newline at end of file
return value
def safe_js(value):
if type(value) is np.ndarray:
return mark_safe(json.dumps(value.tolist()))
return mark_safe(json.dumps(value))
\ No newline at end of file
......@@ -168,17 +168,111 @@
{% endcomment %}
<!-- fim analise sa02 -->
<!-- TODO: Add dynamic grid for each degree -->
<div class="col-md-12">
<h3>Grade curricular
<a tabindex="0" class="fa fa-info-circle" data-toggler="popover" data-html="true"
data-content="Informações gerais sobres as disciplinas do curso de graduação.<br>
Passe o mouse sobre os códigos para verificar os nomes completos
e os pré-requisitos associados.<br>
Também é possível verificar o desvio padrão das notas médias
passando o mouse sobre o valor da nota."></a>
<div class="row" id="grid">
<div class="grade col-md-10">
{% for semester in grid_info %}
<div class="semestre">
<div class="grade-head">{{forloop.counter}}º</div>
{% for course in semester %}
<div id="grid_course_course_{{course.code}}" code={{course.code}}
data-toggle="tooltip" data-placement="top" title="{{}}" class="materia {{ course.situation }}">
<div class="info">
{% if course.is_real_code %}
<span class="name">
<a href="{% url 'course:detail' codigo_disciplina=course.code|remove_spaces %}">
{{ course.code }}</a>
{% else %}
<span class="name">{{ course.code }}</span>
{% endif %}
<div class="details">
{% if course.detail %}
<div class="detail">
<span class="detail-name">Taxa de aprovação</span>
<span class="detail-value">{{course.detail.taxa_aprovacao|fix_2digit}}</span>
<div class="detail"
data-toggle="tooltip" data-placement="top" title="Desvio Padrão: &#177 {{course.detail.nota.1|fix_2digit}}">
<span class="detail-name">Nota média</span>
<span class="detail-value">{{course.detail.nota.0|fix_2digit}}
{% endif %}
{% endfor %}
{% endfor %}
<div class="col-md-2">
<div class="text-center materia_prerequisite">Disciplina Pré-Requisitada</div><br>
<div class="text-center materia_posrequisite">Disciplina que possui a matéria como Pré-Requisito</div><br>
<div class="text-center materia_selected">Disciplina selecionada</div>
{% endblock content %}
{% block js-foot %}
var grid_info = {{grid_info|safe_js}};
var prerequisites = {{prerequisites|safe_js}};
var prerequisites_rev = {{prerequisites_rev|safe_js}};
// TODO: Refactor the analyzes to avoid this pretreatment
// Add mouseenter and mouseleave events to grid cells
// The style are defined in the static styles.css file
// OBS: The grid cells must have the id name started with grid_course_course_
$( document ).ready(function() {
// Mouse Enter event
var code = $(this).attr("code");
for(var i in prerequisites[code]){
var code2 = prerequisites[code][i];
for(var i in prerequisites_rev[code]){
var code2 = prerequisites_rev[code][i];
// Mouse Leave event
var code = $(this).attr("code");
for(var i in prerequisites[code]){
var code2 = prerequisites[code][i];
for(var i in prerequisites_rev[code]){
var code2 = prerequisites_rev[code][i];
// TODO: Refactor the analyzes to avoid this pretreatment
// Assure that the keys is in order and convert the data
// to a format that AdegaChart will accept
function convert_degree_chart_data(data, y_keys_sorted){
from django.shortcuts import render, redirect
from django.views.generic import View
from django.contrib.auth import logout as process_logout
from report_api.views import get_degree_information
from report_api.views import get_degree_information, get_list_students, get_student_detail, get_list_courses
from degree.models import Degree
from submission.models import Submission
import json
from student.grid import DegreeGrid
from guardian.decorators import permission_required_or_403
from submission.analysis.utils.situations import Situation
......@@ -21,8 +23,20 @@ def index(request, submission_id):
submission = Submission.objects.get(id=submission_id)
degree =
analysis_result = get_list_courses(request.session, degree, submission_id)
courses_list = analysis_result["cache"]
dg = DegreeGrid(DegreeGrid.bcc_grid_2011)
grid_info = dg.get_degree_situation(courses_list)
prerequisites = dg.grid_detail.prerequisites
prerequisites_rev = {}
for c1 in prerequisites:
for c2 in prerequisites[c1]:
if not (c2 in prerequisites_rev):
prerequisites_rev[c2] = []
degree_data = get_degree_information(request.session, degree, submission_id=submission_id)
return render(request, "degree/index.html", {
......@@ -31,5 +45,8 @@ def index(request, submission_id):
"degree_data": degree_data,
"situations_pass": situations_pass,
"situations_fail": situations_fail,
"grid_info": grid_info,
"prerequisites": prerequisites,
"prerequisites_rev": prerequisites_rev,
......@@ -244,6 +244,33 @@ class DegreeGrid:
cgc = self.compute_cgc(hist)
return self.get_grid(cgc), self.get_repeated_course_info(cgc)
def get_degree_situation(self, courses_hist):
Computes the degree grid with courses analysis summaries.
The informations are the same that index course page.
courses_hist: Cache object with each course description. Same instance
used into index course page.
A matrix of objects. Each row represents a semester.
# Create an empty grid with instances of Grid Collection
cgc = self.compute_cgc([])
grid = self.get_grid(cgc)
# Uses courses analysis summary to populate details
for code in courses_hist:
for semester in grid:
for course in semester:
if code == course["code"]:
course["detail"] = courses_hist[code]
return grid
bcc_grid_2011 = DegreeGridDescription({
"year": 2011,
"grid": [
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