Browse Source

Add detail page to saberes dashboard

producao
Sesostris Vieira 10 years ago
parent
commit
e60fd48ed4
  1. 1
      sigi/apps/mdl/models.py
  2. 50
      sigi/apps/saberes/templates/saberes/detail.html
  3. 7
      sigi/apps/saberes/templates/saberes/snippets.html
  4. 1
      sigi/apps/saberes/urls.py
  5. 57
      sigi/apps/saberes/views.py

1
sigi/apps/mdl/models.py

@ -14,6 +14,7 @@ class CourseStats(models.Model):
# CASE
# WHEN e.enrol = 'ilbeadtutorado' AND ue.status = 1 THEN 'N' -- Rejeitada
# WHEN e.enrol = 'ilbead' AND ue.timeend > date_part('epoch', now()) THEN 'C' -- Em curso
# WHEN e.enrol = 'ilbead' and ue.timeend < date_part('epoch', now()) and co.timecompleted is null and gg.finalgrade is null then 'L' -- Abandono
# WHEN (co.timestarted = 0 OR co.timestarted IS NULL) AND gg.finalgrade IS NOT NULL THEN 'R' -- Reprovada
# WHEN co.timestarted = 0 OR co.timestarted IS NULL THEN 'L' -- Abandono
# WHEN co.timestarted > 0 AND co.timecompleted IS NULL THEN 'R' -- Reprovado

50
sigi/apps/saberes/templates/saberes/detail.html

@ -0,0 +1,50 @@
{% extends "admin/base_site.html" %}
{% block extrastyle %}
{{ block.super }}
<style>
td.number {
text-align: right;
}
.panel-body {
max-height: 400px;
overflow: auto;
}
</style>
{% endblock %}
{% block content %}
<div id="content-main">
<div class="page-header"><h1>Detalhes para {{ area.descricao }}</h1></div>
<div class="results">
<table class="table table-striped table-bordered" id="result_list">
<thead>
<tr>
{% for col_title in table_head %}
<th>{{ col_title }}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for k, row in table_data.items %}
<tr class="row1">
<th>{{ row.course_name }}</th>
<td class='number'>{{ row.total_matriculas }}</td>
{% if 'N' in flags %}
<td class='number'>{{ row.N }}</td>
<td class='number'>{{ row.efetivos }}</td>
{% endif %}
{% if 'C' in flags %}<td class='number'>{{ row.C }}</td>{% endif %}
{% if 'L' in flags %}<td class='number'>{{ row.L }}</td>{% endif %}
{% if 'R' in flags %}<td class='number'>{{ row.R }}</td>{% endif %}
{% if 'A' in flags %}<td class='number'>{{ row.A }}</td>{% endif %}
{% if 'MA' in flags %}<td class='number'>{{ row.media_aprovados|floatformat:2 }}</td>{% endif %}
{% if 'MR' in flags %}<td class='number'>{{ row.media_reprovados|floatformat:2 }}</td>{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock %}

7
sigi/apps/saberes/templates/saberes/snippets.html

@ -4,7 +4,12 @@
{% for k, painel in paineis.items %}
<div class="col-md-4">
<div class="panel panel-primary flex-col">
<div class="panel-heading">{{ painel.titulo }}</div>
<div class="panel-heading">
{{ painel.titulo }}
{% if painel.area %}
<span class="badge"><a href="{% url "saberes-dashboard-detail" painel.area.id %}">Detalhes</a></span>
{% endif %}
</div>
<div class="panel-body">
<table class='table'>
{% for linha in painel.dados %}

1
sigi/apps/saberes/urls.py

@ -3,4 +3,5 @@ from django.conf.urls import patterns, url
urlpatterns = patterns('sigi.apps.saberes.views',
url(r'^dashboard/$', 'dashboard', name="saberes-dashboard-view"),
url(r'^dashboard/(?P<area>\w+)/$', 'detail', name="saberes-dashboard-detail"),
)

57
sigi/apps/saberes/views.py

@ -3,7 +3,7 @@
from collections import OrderedDict
from django.utils.translation import ugettext as _
from django.db.models import Sum, Avg
from django.shortcuts import render, render_to_response
from django.shortcuts import render, render_to_response, get_object_or_404
from django.template import RequestContext
from sigi.apps.mdl.models import User, CourseStats
from sigi.apps.saberes.models import CategoriasInteresse, PainelItem
@ -16,6 +16,61 @@ def dashboard(request):
paineis[p.painel] = {'titulo': p.painel, 'dados': []}
paineis[p.painel]['dados'].append(p)
for p in paineis:
try:
paineis[p]['area'] = CategoriasInteresse.objects.get(descricao=paineis[p]['titulo'])
except:
pass
extra_context = {'paineis': paineis}
return render_to_response('saberes/dashboard.html', extra_context, context_instance=RequestContext(request))
def detail(request, area):
ci = get_object_or_404(CategoriasInteresse, pk=area)
head_flags = []
table_data = OrderedDict()
for c in CourseStats.objects.filter(category__in=ci.categorias(subcategorias=True)).order_by('course__fullname'):
if c.course_id not in table_data:
table_data[c.course_id] = {'course_name': c.course.fullname, 'total_matriculas': 0}
table_data[c.course_id]['total_matriculas'] += c.usercount
table_data[c.course_id][c.completionstatus] = c.usercount
head_flags.append(c.completionstatus)
if c.completionstatus == 'A':
table_data[c.course_id]['media_aprovados'] = c.gradeaverage
head_flags.append('MA')
if c.completionstatus == 'R':
table_data[c.course_id]['media_reprovados'] = c.gradeaverage
head_flags.append('MR')
head_flags = set(head_flags)
table_head = [_(u'Curso / turma'), _(u'Total de matrículas')]
if 'N' in head_flags:
table_head.append(_(u'Matrículas rejeitadas'))
table_head.append(_(u'Alunos efetivos'))
for k in table_data:
table_data[k]['efetivos'] = table_data[k]['total_matriculas'] - (table_data[k]['N'] if 'N' in table_data[k] else 0)
if 'C' in head_flags:
table_head.append(_(u'Em curso'))
if 'L' in head_flags:
table_head.append(_(u'Abandono'))
if 'R' in head_flags:
table_head.append(_(u'Reprovação'))
if 'A' in head_flags:
table_head.append(_(u'Aprovação'))
if 'MA' in head_flags:
table_head.append(_(u'Média das notas dos alunos aprovados'))
if 'MR' in head_flags:
table_head.append(_(u'Média das notas dos alunos reprovados'))
extra_context = {'area': ci, 'table_head': table_head, 'table_data': table_data, 'flags': head_flags}
return render_to_response('saberes/detail.html', extra_context, context_instance=RequestContext(request))
Loading…
Cancel
Save