From 51cee43480a9de873a5ac509d3df23e9eff617b0 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 20 Feb 2014 17:57:39 +0000 Subject: [PATCH] Adicionado dashboard do ambiente saberes --- sigi/apps/metas/views.py | 25 +++++++++++++++ sigi/templates/saberes/dashboard.html | 41 ++++++++++++++++++++++++ sigi/templates/saberes/snippets.html | 46 +++++++++++++++++++++++++++ sigi/urls.py | 1 + 4 files changed, 113 insertions(+) create mode 100644 sigi/templates/saberes/dashboard.html create mode 100644 sigi/templates/saberes/snippets.html diff --git a/sigi/apps/metas/views.py b/sigi/apps/metas/views.py index 231bad1..0ea3873 100644 --- a/sigi/apps/metas/views.py +++ b/sigi/apps/metas/views.py @@ -343,3 +343,28 @@ def gera_map_data_file(cronjob=False): return "Arquivo %s gerado em %d segundos" % (JSON_FILE_NAME, time.time() - start) return json_data + +def saberes(request): + extra_context = {'total_cadastros': 0, 'novos_cadastros': 0, 'total_cursos': 0, 'total_matriculas': 0, + 'media_alunos_curso': 0, 'cursos': {}} + + try: + import psycopg2 + cd = {'host': 'bdinterlegis.interlegis.leg.br', 'dbname': 'moodle', 'user': 'saberes', 'password': 'Goo!gu1a'} + cs = "host='%(host)s' dbname='%(dbname)s' user='%(user)s' password='%(password)s'" % cd + con = psycopg2.connect(cs) + cursor = con.cursor() + cursor.execute('select count(*) from mdl_user;') + extra_context['total_cadastros'] = cursor.fetchone()[0] + cursor.execute('select count(*) from mdl_user where firstaccess >= 1392326052') + extra_context['novos_cadastros'] = cursor.fetchone()[0] + cursor.execute("select c.fullname, count(*) from mdl_user_enrolments ue inner join mdl_enrol e on e.id = ue.enrolid inner join mdl_course c on c.id = e.courseid where e.enrol = 'ilbead' and c.visible = 1 group by c.fullname") + extra_context['cursos'] = cursor.fetchall() + extra_context['total_cursos'] = len(extra_context['cursos']) + extra_context['total_matriculas'] = reduce(lambda x,y: x+y[1], extra_context['cursos'], 0) + extra_context['media_alunos_curso'] = extra_context['total_matriculas'] / extra_context['total_cursos'] + + except: + pass + + return render_to_response('saberes/dashboard.html', extra_context, context_instance=RequestContext(request)) diff --git a/sigi/templates/saberes/dashboard.html b/sigi/templates/saberes/dashboard.html new file mode 100644 index 0000000..c149af9 --- /dev/null +++ b/sigi/templates/saberes/dashboard.html @@ -0,0 +1,41 @@ +{% extends "admin/index.html" %} +{% load adminmedia %} + +{% block title %}SIGI{% endblock %} + +{% block extrahead %} + {{ block.super }} + +{% endblock %} + +{% block content_title %} +

Indicadores do Saberes - EAD

+{% comment %} +
+
+

+
+
+{% endcomment %} +{% endblock %} + +{% block content %} +
+
+ + {% include "saberes/snippets.html" %} + +
+
+{% endblock %} + +{% block sidebar %} + +{% endblock %} diff --git a/sigi/templates/saberes/snippets.html b/sigi/templates/saberes/snippets.html new file mode 100644 index 0000000..48eff2d --- /dev/null +++ b/sigi/templates/saberes/snippets.html @@ -0,0 +1,46 @@ +{% load charts %} + +{# ------------- Totais ------------- #} +
+

Totais

+

Uso do Saberes

+ + + + + + + + + + + + + + + + + + + + + +
Total de usuários cadastrados{{ total_cadastros }}
Novos usuários cadastrados{{ novos_cadastros }}
Total de turmas EAD{{ total_cursos }}
Total de alunos matriculados{{ total_matriculas }}
Média de alunos por curso{{ media_alunos_curso }}
+
+{# ------------- Turmas ------------- #} +
+

Turmas

+

Alunos matriculados por turma

+
+ + {% for curso in cursos %} + + + + + {% endfor %} +
{{ curso.0 }}{{ curso.1 }}
+
+
+ + diff --git a/sigi/urls.py b/sigi/urls.py index df84086..3c67cc5 100644 --- a/sigi/urls.py +++ b/sigi/urls.py @@ -122,6 +122,7 @@ urlpatterns = patterns( (r'^sigi/dashboard/mapsearch/$', 'sigi.apps.metas.views.map_search'), (r'^sigi/dashboard/mapsum/$', 'sigi.apps.metas.views.map_sum'), (r'^sigi/dashboard/maplist/$', 'sigi.apps.metas.views.map_list'), + (r'^sigi/dashboard/saberes/', 'sigi.apps.metas.views.saberes'), (r'^sigi/dashboard/$', 'sigi.apps.metas.views.dashboard'), # automatic interface based on admin #(r'^sigi/(.*)', sites.default.root),