Browse Source

Adicionado dashboard do ambiente saberes

stable/1.0
root 11 years ago
parent
commit
51cee43480
  1. 25
      sigi/apps/metas/views.py
  2. 41
      sigi/templates/saberes/dashboard.html
  3. 46
      sigi/templates/saberes/snippets.html
  4. 1
      sigi/urls.py

25
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))

41
sigi/templates/saberes/dashboard.html

@ -0,0 +1,41 @@
{% extends "admin/index.html" %}
{% load adminmedia %}
{% block title %}SIGI{% endblock %}
{% block extrahead %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% admin_media_prefix %}css/changelists.css" />
{% endblock %}
{% block content_title %}
<h1>Indicadores do Saberes - EAD</h1>
{% comment %}
<div id="changelist">
<div id="toolbar">
<p></p>
</div>
</div>
{% endcomment %}
{% endblock %}
{% block content %}
<div class="colMS" id="content">
<div id="content-main">
{% include "saberes/snippets.html" %}
</div>
</div>
{% endblock %}
{% block sidebar %}
<div id="content-related">
{% comment %}
<div class="module" id="filters">
<h2>Filtros</h2>
<h3>Filtro 1</h3>
</div>
{% endcomment %}
</div>
{% endblock %}

46
sigi/templates/saberes/snippets.html

@ -0,0 +1,46 @@
{% load charts %}
{# ------------- Totais ------------- #}
<div style="height: 300px;" class="module">
<h2>Totais</h2>
<h3>Uso do Saberes</h3>
<table style="margin: auto;">
<tr>
<th>Total de usuários cadastrados</th>
<td>{{ total_cadastros }}</td>
</tr>
<tr>
<th>Novos usuários cadastrados</th>
<td>{{ novos_cadastros }}</td>
</tr>
<tr>
<th>Total de turmas EAD</th>
<td>{{ total_cursos }}</td>
</tr>
<tr>
<th>Total de alunos matriculados</th>
<td>{{ total_matriculas }}</td>
</tr>
<tr>
<th>Média de alunos por curso</th>
<td>{{ media_alunos_curso }}</td>
</tr>
</table>
</div>
{# ------------- Turmas ------------- #}
<div style="height: 300px;" class="module">
<h2>Turmas</h2>
<h3>Alunos matriculados por turma</h3>
<div style="height: 250px; overflow: auto;">
<table style="margin: auto;">
{% for curso in cursos %}
<tr>
<th>{{ curso.0 }}</th>
<td>{{ curso.1 }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>

1
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),

Loading…
Cancel
Save