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

Resolve "Fazer grade para o degree"

parent 3bae5606
......@@ -287,6 +287,23 @@ span.data {
.grade .name {
display: block; }
.materia_selected {
outline-style:solid;
outline-color:rgb(138, 64, 207);
outline-width:1px;
}
.materia_prerequisite {
outline-style:solid;
outline-color:#FFD700;
outline-width:1px;
}
.materia_posrequisite {
outline-style:solid;
outline-color:#6B8E23;
outline-width:1px;
}
/* ============================================== 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):
try:
return value.replace(' ', '')
except:
return value
\ No newline at end of file
return value
@register.filter
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 -->
</div>
<br>
<!-- 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>
</h3>
<div class="row" id="grid">
<br>
<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="{{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>
</span>
{% else %}
<span class="name">{{ course.code }}</span>
{% endif %}
</div>
<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>
<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}}
</span>
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
<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>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock content %}
{% block js-foot %}
<script>
<script>
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
$(".materia").hover(function(){
var code = $(this).attr("code");
for(var i in prerequisites[code]){
var code2 = prerequisites[code][i];
$("#grid_course_course_"+code2).addClass('materia_prerequisite');
}
for(var i in prerequisites_rev[code]){
var code2 = prerequisites_rev[code][i];
$("#grid_course_course_"+code2).addClass('materia_posrequisite');
}
$(this).addClass('materia_selected');
},
// Mouse Leave event
function(){
var code = $(this).attr("code");
for(var i in prerequisites[code]){
var code2 = prerequisites[code][i];
$("#grid_course_course_"+code2).removeClass('materia_prerequisite');
}
for(var i in prerequisites_rev[code]){
var code2 = prerequisites_rev[code][i];
$("#grid_course_course_"+code2).removeClass('materia_posrequisite');
}
$(this).removeClass('materia_selected');
}
);
});
// 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 = submission.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] = []
prerequisites_rev[c2].append(c1)
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.
Parameters:
courses_hist: Cache object with each course description. Same instance
used into index course page.
Returns:
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