diff --git a/sigi/apps/mdl/models.py b/sigi/apps/mdl/models.py
index 5a59152..3cf129b 100644
--- a/sigi/apps/mdl/models.py
+++ b/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
diff --git a/sigi/apps/saberes/templates/saberes/detail.html b/sigi/apps/saberes/templates/saberes/detail.html
new file mode 100644
index 0000000..64dedcc
--- /dev/null
+++ b/sigi/apps/saberes/templates/saberes/detail.html
@@ -0,0 +1,50 @@
+{% extends "admin/base_site.html" %}
+
+{% block extrastyle %}
+ {{ block.super }}
+
+{% endblock %}
+
+{% block content %}
+
+
+
+
+
+
+
+ {% for col_title in table_head %}
+ {{ col_title }} |
+ {% endfor %}
+
+
+
+ {% for k, row in table_data.items %}
+
+ {{ row.course_name }} |
+ {{ row.total_matriculas }} |
+ {% if 'N' in flags %}
+ {{ row.N }} |
+ {{ row.efetivos }} |
+ {% endif %}
+ {% if 'C' in flags %}{{ row.C }} | {% endif %}
+ {% if 'L' in flags %}{{ row.L }} | {% endif %}
+ {% if 'R' in flags %}{{ row.R }} | {% endif %}
+ {% if 'A' in flags %}{{ row.A }} | {% endif %}
+ {% if 'MA' in flags %}{{ row.media_aprovados|floatformat:2 }} | {% endif %}
+ {% if 'MR' in flags %}{{ row.media_reprovados|floatformat:2 }} | {% endif %}
+
+ {% endfor %}
+
+
+
+
+{% endblock %}
diff --git a/sigi/apps/saberes/templates/saberes/snippets.html b/sigi/apps/saberes/templates/saberes/snippets.html
index 6a060a0..457f876 100644
--- a/sigi/apps/saberes/templates/saberes/snippets.html
+++ b/sigi/apps/saberes/templates/saberes/snippets.html
@@ -4,7 +4,12 @@
{% for k, painel in paineis.items %}
-
{{ painel.titulo }}
+
+ {{ painel.titulo }}
+ {% if painel.area %}
+
Detalhes
+ {% endif %}
+
{% for linha in painel.dados %}
diff --git a/sigi/apps/saberes/urls.py b/sigi/apps/saberes/urls.py
index c4dc77e..e326a33 100644
--- a/sigi/apps/saberes/urls.py
+++ b/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\w+)/$', 'detail', name="saberes-dashboard-detail"),
)
\ No newline at end of file
diff --git a/sigi/apps/saberes/views.py b/sigi/apps/saberes/views.py
index ff4d40f..2dd1244 100644
--- a/sigi/apps/saberes/views.py
+++ b/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
@@ -15,7 +15,62 @@ def dashboard(request):
if p.painel not in paineis:
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))
\ No newline at end of file
+ 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))
+
\ No newline at end of file