mirror of https://github.com/interlegis/sigi.git
Marcio Mazza
10 years ago
23 changed files with 5671 additions and 5 deletions
@ -0,0 +1,22 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
class MoodleRouter(object): |
||||
|
def db_for_read(self, model, **hints): |
||||
|
if model._meta.app_label == 'mdl': |
||||
|
return 'moodle' |
||||
|
return None |
||||
|
|
||||
|
def db_for_write(self, model, **hints): |
||||
|
if model._meta.app_label == 'mdl': |
||||
|
return 'moodle' |
||||
|
return None |
||||
|
|
||||
|
def allow_relation(self, obj1, obj2, **hints): |
||||
|
if obj1._meta.app_label == 'mdl' and obj2._meta.app_label == 'mdl': |
||||
|
return True |
||||
|
return None |
||||
|
|
||||
|
def allow_migrate(self, db, model): |
||||
|
if model._meta.app_label == 'mdl': |
||||
|
return False |
||||
|
return None |
@ -0,0 +1,3 @@ |
|||||
|
from django.contrib import admin |
||||
|
|
||||
|
# Register your models here. |
File diff suppressed because it is too large
@ -0,0 +1,327 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
from __future__ import unicode_literals |
||||
|
from django.db import models |
||||
|
|
||||
|
class CourseStatus(models.Model): |
||||
|
# databaseview: (postgresql dialect): |
||||
|
# |
||||
|
# CREATE OR REPLACE VIEW ilb_course_status AS |
||||
|
# SELECT DISTINCT u.id AS userid, c.id AS courseid, c.category, |
||||
|
# CASE |
||||
|
# WHEN e.enrol::text = 'ilbeadtutorado'::text AND ue.status = 1::bigint THEN 'Matrícula rejeitada'::text |
||||
|
# WHEN e.enrol::text = 'ilbead'::text AND ue.timeend < date_part('epoch'::text, now())::integer THEN 'Em curso'::text |
||||
|
# WHEN co.timestarted = 0 OR co.timestarted IS NULL THEN 'Abandono'::text |
||||
|
# WHEN co.timestarted > 0 AND co.timecompleted IS NULL THEN 'Reprovado'::text |
||||
|
# WHEN co.timecompleted IS NOT NULL THEN 'Aprovado'::text |
||||
|
# WHEN e.enrol::text <> 'ilbeadtutorado'::text THEN '?'::text |
||||
|
# ELSE ''::text |
||||
|
# END AS status |
||||
|
# FROM mdl_user u |
||||
|
# JOIN mdl_user_enrolments ue ON ue.userid = u.id |
||||
|
# JOIN mdl_enrol e ON e.id = ue.enrolid |
||||
|
# JOIN mdl_course c ON c.id = e.courseid |
||||
|
# LEFT JOIN mdl_course_completions co ON co.userid = u.id AND co.course = c.id; |
||||
|
|
||||
|
userid = models.IntegerField(primary_key=True) |
||||
|
courseid = models.IntegerField() |
||||
|
category = models.IntegerField() |
||||
|
status = models.CharField(max_length=100) |
||||
|
|
||||
|
class Meta: |
||||
|
managed = False |
||||
|
db_table = 'ilb_course_status' |
||||
|
|
||||
|
class Cohort(models.Model): |
||||
|
id = models.BigIntegerField(primary_key=True) |
||||
|
context = models.ForeignKey('Context', db_column='contextid') |
||||
|
name = models.CharField(max_length=254) |
||||
|
idnumber = models.CharField(max_length=100, blank=True) |
||||
|
description = models.TextField(blank=True) |
||||
|
descriptionformat = models.SmallIntegerField() |
||||
|
component = models.CharField(max_length=100) |
||||
|
timecreated = models.BigIntegerField() |
||||
|
timemodified = models.BigIntegerField() |
||||
|
# Manytomany |
||||
|
members = models.ManyToManyField('User', through='CohortMembers') |
||||
|
|
||||
|
class Meta: |
||||
|
managed = False |
||||
|
db_table = 'mdl_cohort' |
||||
|
|
||||
|
def __unicode__(self): |
||||
|
return self.name |
||||
|
|
||||
|
class CohortMembers(models.Model): |
||||
|
id = models.BigIntegerField(primary_key=True) |
||||
|
cohort = models.ForeignKey('Cohort', db_column='cohortid') |
||||
|
user = models.ForeignKey('User', db_column='userid') |
||||
|
timeadded = models.BigIntegerField() |
||||
|
|
||||
|
class Meta: |
||||
|
managed = False |
||||
|
db_table = 'mdl_cohort_members' |
||||
|
|
||||
|
class Context(models.Model): |
||||
|
CONTEXT_SYSTEM = 10 # System context level - only one instance in every system |
||||
|
CONTEXT_USER = 30 # User context level - one instance for each user describing what others can do to user |
||||
|
CONTEXT_COURSECAT = 40 # Course category context level - one instance for each category |
||||
|
CONTEXT_COURSE = 50 # Course context level - one instances for each course |
||||
|
CONTEXT_MODULE = 70 # Course module context level - one instance for each course module |
||||
|
CONTEXT_BLOCK = 80 # Block context level - one instance for each block, sticky blocks are tricky |
||||
|
# because ppl think they should be able to override them at lower contexts. |
||||
|
# Any other context level instance can be parent of block context. |
||||
|
|
||||
|
id = models.BigIntegerField(primary_key=True) |
||||
|
contextlevel = models.BigIntegerField() |
||||
|
instanceid = models.BigIntegerField() |
||||
|
path = models.CharField(max_length=255, blank=True) |
||||
|
depth = models.SmallIntegerField() |
||||
|
|
||||
|
class Meta: |
||||
|
managed = False |
||||
|
db_table = 'mdl_context' |
||||
|
|
||||
|
def __unicode__(self): |
||||
|
return self.path |
||||
|
|
||||
|
class Course(models.Model): |
||||
|
id = models.BigIntegerField(primary_key=True) |
||||
|
category = models.ForeignKey('CourseCategories', db_column='category', related_name='courses') |
||||
|
sortorder = models.BigIntegerField() |
||||
|
fullname = models.CharField(max_length=254) |
||||
|
shortname = models.CharField(max_length=255) |
||||
|
idnumber = models.CharField(max_length=100) |
||||
|
summary = models.TextField(blank=True) |
||||
|
format = models.CharField(max_length=21) |
||||
|
showgrades = models.SmallIntegerField() |
||||
|
modinfo = models.TextField(blank=True) |
||||
|
newsitems = models.IntegerField() |
||||
|
startdate = models.BigIntegerField() |
||||
|
marker = models.BigIntegerField() |
||||
|
maxbytes = models.BigIntegerField() |
||||
|
showreports = models.SmallIntegerField() |
||||
|
visible = models.SmallIntegerField() |
||||
|
groupmode = models.SmallIntegerField() |
||||
|
groupmodeforce = models.SmallIntegerField() |
||||
|
lang = models.CharField(max_length=30) |
||||
|
theme = models.CharField(max_length=50) |
||||
|
timecreated = models.BigIntegerField() |
||||
|
timemodified = models.BigIntegerField() |
||||
|
requested = models.SmallIntegerField() |
||||
|
defaultgroupingid = models.BigIntegerField() |
||||
|
enrolmax = models.BigIntegerField() |
||||
|
enablecompletion = models.SmallIntegerField() |
||||
|
legacyfiles = models.SmallIntegerField() |
||||
|
summaryformat = models.SmallIntegerField() |
||||
|
completionnotify = models.SmallIntegerField() |
||||
|
visibleold = models.SmallIntegerField() |
||||
|
sectioncache = models.TextField(blank=True) |
||||
|
|
||||
|
class Meta: |
||||
|
managed = False |
||||
|
db_table = 'mdl_course' |
||||
|
ordering = ['sortorder',] |
||||
|
|
||||
|
def __unicode__(self): |
||||
|
return self.fullname |
||||
|
|
||||
|
def total_alunos(self): |
||||
|
return sum(e.user_enrolments.count() for e in self.enrols.all()) |
||||
|
|
||||
|
def total_ativos(self): |
||||
|
return sum(e.user_enrolments.filter(status=0).count() for e in self.enrols.all()) |
||||
|
|
||||
|
def get_matriculas(self): |
||||
|
q = UserEnrolments.objects.none() |
||||
|
for e in self.enrols.all(): |
||||
|
q = q | e.user_enrolments.all() |
||||
|
return q |
||||
|
|
||||
|
class CourseCategories(models.Model): |
||||
|
id = models.BigIntegerField(primary_key=True) |
||||
|
name = models.CharField(max_length=255) |
||||
|
description = models.TextField(blank=True) |
||||
|
parent = models.ForeignKey('CourseCategories', db_column='parent', related_name='children') |
||||
|
sortorder = models.BigIntegerField() |
||||
|
coursecount = models.BigIntegerField() |
||||
|
visible = models.SmallIntegerField() |
||||
|
timemodified = models.BigIntegerField() |
||||
|
depth = models.BigIntegerField() |
||||
|
path = models.CharField(max_length=255) |
||||
|
theme = models.CharField(max_length=50, blank=True) |
||||
|
descriptionformat = models.SmallIntegerField() |
||||
|
visibleold = models.SmallIntegerField() |
||||
|
idnumber = models.CharField(max_length=100, blank=True) |
||||
|
|
||||
|
class Meta: |
||||
|
managed = False |
||||
|
db_table = 'mdl_course_categories' |
||||
|
ordering = ['sortorder',] |
||||
|
|
||||
|
def __unicode__(self): |
||||
|
return self.name |
||||
|
|
||||
|
def context(self): |
||||
|
return Context.objects.get(instanceid=self.id, contextlevel=Context.CONTEXT_COURSECAT) |
||||
|
|
||||
|
def total_turmas(self): |
||||
|
return self.coursecount + sum([c.coursecount for c in self.children.all()]) |
||||
|
|
||||
|
def total_alunos(self): |
||||
|
total = 0 |
||||
|
total = total + sum(c.total_alunos() for c in self.courses.all()) |
||||
|
total = total + sum(c.total_alunos() for c in self.children.all()) |
||||
|
return total |
||||
|
|
||||
|
def cohortids(self): |
||||
|
cids = [c.pk for c in self.context().cohort_set.all()] |
||||
|
for c in self.children.all(): |
||||
|
cids = cids + c.cohortids() |
||||
|
return cids |
||||
|
|
||||
|
def total_alunos_cohort(self): |
||||
|
return sum([c.members.distinct().count() for c in Cohort.objects.filter(pk__in=self.cohortids())]) |
||||
|
|
||||
|
def get_all_courses(self, only_visible=False): |
||||
|
if only_visible: |
||||
|
q = self.courses.filter(visible=1) |
||||
|
else: |
||||
|
q = self.courses.all() |
||||
|
for c in self.children.all(): |
||||
|
q = q | c.get_all_courses(only_visible=only_visible) |
||||
|
return q |
||||
|
|
||||
|
class CourseCompletions(models.Model): |
||||
|
id = models.BigIntegerField(primary_key=True) |
||||
|
user = models.ForeignKey('User', db_column='userid') |
||||
|
course = models.ForeignKey('Course', db_column='course') |
||||
|
timeenrolled = models.BigIntegerField() |
||||
|
timestarted = models.BigIntegerField() |
||||
|
timecompleted = models.BigIntegerField(blank=True, null=True) |
||||
|
reaggregate = models.BigIntegerField() |
||||
|
|
||||
|
class Meta: |
||||
|
managed = False |
||||
|
db_table = 'mdl_course_completions' |
||||
|
|
||||
|
class Enrol(models.Model): |
||||
|
id = models.BigIntegerField(primary_key=True) |
||||
|
enrol = models.CharField(max_length=20) |
||||
|
status = models.BigIntegerField() |
||||
|
course = models.ForeignKey('Course', db_column='courseid', related_name='enrols') |
||||
|
sortorder = models.BigIntegerField() |
||||
|
name = models.CharField(max_length=255, blank=True) |
||||
|
enrolperiod = models.BigIntegerField(blank=True, null=True) |
||||
|
enrolstartdate = models.BigIntegerField(blank=True, null=True) |
||||
|
enrolenddate = models.BigIntegerField(blank=True, null=True) |
||||
|
expirynotify = models.SmallIntegerField(blank=True, null=True) |
||||
|
expirythreshold = models.BigIntegerField(blank=True, null=True) |
||||
|
notifyall = models.SmallIntegerField(blank=True, null=True) |
||||
|
password = models.CharField(max_length=50, blank=True) |
||||
|
cost = models.CharField(max_length=20, blank=True) |
||||
|
currency = models.CharField(max_length=3, blank=True) |
||||
|
roleid = models.BigIntegerField(blank=True, null=True) |
||||
|
customint1 = models.BigIntegerField(blank=True, null=True) |
||||
|
customint2 = models.BigIntegerField(blank=True, null=True) |
||||
|
customint3 = models.BigIntegerField(blank=True, null=True) |
||||
|
customint4 = models.BigIntegerField(blank=True, null=True) |
||||
|
customchar1 = models.CharField(max_length=255, blank=True) |
||||
|
customchar2 = models.CharField(max_length=255, blank=True) |
||||
|
customdec1 = models.DecimalField(max_digits=12, decimal_places=7, blank=True, null=True) |
||||
|
customdec2 = models.DecimalField(max_digits=12, decimal_places=7, blank=True, null=True) |
||||
|
customtext1 = models.TextField(blank=True) |
||||
|
customtext2 = models.TextField(blank=True) |
||||
|
timecreated = models.BigIntegerField() |
||||
|
timemodified = models.BigIntegerField() |
||||
|
customint5 = models.BigIntegerField(blank=True, null=True) |
||||
|
customint6 = models.BigIntegerField(blank=True, null=True) |
||||
|
customint7 = models.BigIntegerField(blank=True, null=True) |
||||
|
customint8 = models.BigIntegerField(blank=True, null=True) |
||||
|
customchar3 = models.CharField(max_length=1333, blank=True) |
||||
|
customtext3 = models.TextField(blank=True) |
||||
|
customtext4 = models.TextField(blank=True) |
||||
|
|
||||
|
class Meta: |
||||
|
managed = False |
||||
|
db_table = 'mdl_enrol' |
||||
|
ordering = ['sortorder',] |
||||
|
|
||||
|
def __unicode__(self): |
||||
|
if not self.name: |
||||
|
return self.enrol |
||||
|
return self.name |
||||
|
|
||||
|
class User(models.Model): |
||||
|
id = models.BigIntegerField(primary_key=True) |
||||
|
auth = models.CharField(max_length=20) |
||||
|
confirmed = models.SmallIntegerField() |
||||
|
policyagreed = models.SmallIntegerField() |
||||
|
deleted = models.SmallIntegerField() |
||||
|
mnethostid = models.BigIntegerField() |
||||
|
username = models.CharField(max_length=100) |
||||
|
password = models.CharField(max_length=255) |
||||
|
firstname = models.CharField(max_length=100) |
||||
|
lastname = models.CharField(max_length=100) |
||||
|
email = models.CharField(max_length=100) |
||||
|
emailstop = models.SmallIntegerField() |
||||
|
icq = models.CharField(max_length=15) |
||||
|
skype = models.CharField(max_length=50) |
||||
|
yahoo = models.CharField(max_length=50) |
||||
|
aim = models.CharField(max_length=50) |
||||
|
msn = models.CharField(max_length=50) |
||||
|
phone1 = models.CharField(max_length=20) |
||||
|
phone2 = models.CharField(max_length=20) |
||||
|
institution = models.CharField(max_length=40) |
||||
|
department = models.CharField(max_length=30) |
||||
|
address = models.CharField(max_length=70) |
||||
|
city = models.CharField(max_length=120) |
||||
|
country = models.CharField(max_length=2) |
||||
|
lang = models.CharField(max_length=30) |
||||
|
theme = models.CharField(max_length=50) |
||||
|
timezone = models.CharField(max_length=100) |
||||
|
firstaccess = models.BigIntegerField() |
||||
|
lastaccess = models.BigIntegerField() |
||||
|
lastlogin = models.BigIntegerField() |
||||
|
currentlogin = models.BigIntegerField() |
||||
|
lastip = models.CharField(max_length=45) |
||||
|
secret = models.CharField(max_length=15) |
||||
|
picture = models.BigIntegerField() |
||||
|
url = models.CharField(max_length=255) |
||||
|
description = models.TextField(blank=True) |
||||
|
mailformat = models.SmallIntegerField() |
||||
|
maildigest = models.SmallIntegerField() |
||||
|
maildisplay = models.SmallIntegerField() |
||||
|
htmleditor = models.SmallIntegerField() |
||||
|
autosubscribe = models.SmallIntegerField() |
||||
|
trackforums = models.SmallIntegerField() |
||||
|
timemodified = models.BigIntegerField() |
||||
|
trustbitmask = models.BigIntegerField() |
||||
|
imagealt = models.CharField(max_length=255, blank=True) |
||||
|
idnumber = models.CharField(max_length=255) |
||||
|
descriptionformat = models.SmallIntegerField() |
||||
|
timecreated = models.BigIntegerField() |
||||
|
suspended = models.SmallIntegerField() |
||||
|
|
||||
|
class Meta: |
||||
|
managed = False |
||||
|
db_table = 'mdl_user' |
||||
|
|
||||
|
def __unicode__(self): |
||||
|
return u'%s %s' % (self.firstname, self.lastname) |
||||
|
|
||||
|
|
||||
|
class UserEnrolments(models.Model): |
||||
|
id = models.BigIntegerField(primary_key=True) |
||||
|
status = models.BigIntegerField() |
||||
|
enrol = models.ForeignKey('Enrol', db_column='enrolid', related_name='user_enrolments') |
||||
|
user = models.ForeignKey('User', db_column='userid', related_name='Enrolments') |
||||
|
timestart = models.BigIntegerField() |
||||
|
timeend = models.BigIntegerField() |
||||
|
modifierid = models.BigIntegerField() |
||||
|
timecreated = models.BigIntegerField() |
||||
|
timemodified = models.BigIntegerField() |
||||
|
|
||||
|
class Meta: |
||||
|
managed = False |
||||
|
db_table = 'mdl_user_enrolments' |
@ -0,0 +1,3 @@ |
|||||
|
from django.test import TestCase |
||||
|
|
||||
|
# Create your tests here. |
@ -0,0 +1,3 @@ |
|||||
|
from django.shortcuts import render |
||||
|
|
||||
|
# Create your views here. |
@ -0,0 +1,12 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
from django.utils.translation import ugettext as _ |
||||
|
from django.contrib import admin |
||||
|
from sigi.apps.saberes.models import CategoriasInteresse |
||||
|
|
||||
|
class CategoriasInteresseAdmin(admin.ModelAdmin): |
||||
|
list_display = ('prefixo', 'descricao', 'count_categorias',) |
||||
|
|
||||
|
def count_categorias(self, obj): |
||||
|
return obj.categorias().count() |
||||
|
count_categorias.short_description = _("Categorias que casam") |
||||
|
admin.site.register(CategoriasInteresse, CategoriasInteresseAdmin) |
@ -0,0 +1,51 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
from __future__ import unicode_literals |
||||
|
from django.utils.translation import ugettext as _ |
||||
|
from django.db import models |
||||
|
from django.db.models import Q |
||||
|
from sigi.apps.mdl.models import Course, CourseCategories, CourseCompletions, UserEnrolments |
||||
|
|
||||
|
class CategoriasInteresse(models.Model): |
||||
|
prefixo = models.CharField(_(u"Prefixo das categorias no Moodle"), max_length=100, |
||||
|
help_text=_(u"Identifica as categorias no Moodle (campo idnumber) relacionadas a este interesse")) |
||||
|
descricao = models.CharField(_(u"Descrição"), max_length=100) |
||||
|
sigla = models.CharField(_(u"Sigla"), max_length=20) |
||||
|
coorte = models.BooleanField(_(u"Usa Cohorte"), default=False, help_text=_(u"Usa cohorte para calcular o número de matrículas/alunos")) |
||||
|
apurar_alunos = models.BooleanField(_(u"Apurar alunos"), default=False, help_text=_(u"Indica que deve-se verificar o perfil da"\ |
||||
|
+ " inscrição para saber se é um aluno ou se a matrícula foi rejeitada")) |
||||
|
apurar_conclusao = models.BooleanField(_(u"Apurar conclusão"), default=False, help_text=_(u"Indica se o dashboard mostrará o "\ |
||||
|
+ "número de alunos aprovados, reprovados e desistentes")) |
||||
|
|
||||
|
class Meta: |
||||
|
verbose_name = _(u'Categorias de interesse') |
||||
|
|
||||
|
def __unicode__(self): |
||||
|
return self.descricao |
||||
|
|
||||
|
def categorias(self): |
||||
|
return CourseCategories.objects.filter(idnumber__startswith=self.prefixo) |
||||
|
|
||||
|
def get_all_courses(self, only_visible=False): |
||||
|
q = Course.objects.none() |
||||
|
for categoria in self.categorias(): |
||||
|
q = q | categoria.get_all_courses(only_visible=only_visible) |
||||
|
return q |
||||
|
|
||||
|
def get_all_completions(self): |
||||
|
q = CourseCompletions.objects.none() |
||||
|
for c in self.get_all_courses(): |
||||
|
q = q | c.coursecompletions_set.all() |
||||
|
return q |
||||
|
|
||||
|
def get_all_enrolments(self): |
||||
|
q = UserEnrolments.objects.none() |
||||
|
for c in self.get_all_courses(): |
||||
|
q = q | c.get_matriculas() |
||||
|
return q |
||||
|
|
||||
|
def total_alunos(self): |
||||
|
if self.coorte: |
||||
|
return sum(c.total_alunos_cohort() for c in self.categorias()) |
||||
|
else: |
||||
|
return sum([c.total_alunos() for c in self.categorias()]) |
@ -0,0 +1,20 @@ |
|||||
|
{% 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"> |
||||
|
{% include "saberes/snippets.html" %} |
||||
|
</div> |
||||
|
{% endblock %} |
@ -0,0 +1,22 @@ |
|||||
|
{% load charts %} |
||||
|
|
||||
|
<div class="row row-flex row-flex-wrap"> |
||||
|
{% for painel in paineis %} |
||||
|
<div class="col-md-4"> |
||||
|
<div class="panel panel-primary flex-col"> |
||||
|
<div class="panel-heading">{{ painel.titulo }}</div> |
||||
|
<div class="panel-body"> |
||||
|
<table class='table'> |
||||
|
{% for linha in painel.dados %} |
||||
|
<tr> |
||||
|
<th>{{ linha.descricao }}</th> |
||||
|
<td class='number'>{{ linha.valor }}</td> |
||||
|
</tr> |
||||
|
{% endfor %} |
||||
|
</table> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
{% cycle '' '' '</div><div class="row">' %} |
||||
|
{% endfor %} |
||||
|
</div> |
@ -0,0 +1,3 @@ |
|||||
|
from django.test import TestCase |
||||
|
|
||||
|
# Create your tests here. |
@ -0,0 +1,6 @@ |
|||||
|
# coding: utf-8 |
||||
|
from django.conf.urls import patterns, url |
||||
|
|
||||
|
urlpatterns = patterns('sigi.apps.saberes.views', |
||||
|
url(r'^dashboard/$', 'dashboard', name="saberes-dashboard-view"), |
||||
|
) |
@ -0,0 +1,54 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
|
||||
|
from django.utils.translation import ugettext as _ |
||||
|
from django.db.models import Count |
||||
|
from django.shortcuts import render, render_to_response |
||||
|
from django.template import RequestContext |
||||
|
from sigi.apps.mdl.models import User, CourseStatus |
||||
|
from sigi.apps.saberes.models import CategoriasInteresse |
||||
|
|
||||
|
def dashboard(request): |
||||
|
areas = [] |
||||
|
numeros = [ |
||||
|
{'descricao': _(u'Total de usuários cadastrados'), 'valor': User.objects.count()}, |
||||
|
{'descricao': _(u'Novos usuários cadastrados') , 'valor': User.objects.filter(firstaccess__gte=1392326052).count()} |
||||
|
] |
||||
|
|
||||
|
for ci in CategoriasInteresse.objects.all(): |
||||
|
matriculas = ci.total_alunos() |
||||
|
numeros.append({'descricao': _(u'Total de matrículas em %s' % ci.descricao.lower()), 'valor': matriculas}) |
||||
|
area = {'titulo': ci.descricao, 'dados': [{'descricao': _(u'Total de matrículas'), 'valor': matriculas}]} |
||||
|
for course in ci.get_all_courses(only_visible=True): |
||||
|
area['dados'].append({'descricao': course.fullname, 'valor': course.total_alunos()}) |
||||
|
# if ci.apurar_alunos: # Apurar número de alunos |
||||
|
# valor = sum([curso.total_ativos() for curso in ci.get_all_courses()]) |
||||
|
# area['dados'].append({'descricao': _(u'Total de alunos aceitos'), 'valor': valor}) |
||||
|
# if ci.apurar_conclusao: |
||||
|
# cl = [curso.id for curso in ci.get_all_courses()] |
||||
|
# for cs in CourseStatus.objects.filter(courseid__in=cl).values('status').annotate(valor=Count('userid')): |
||||
|
# area['dados'].append({'descricao': cs['status'], 'valor': cs['valor']}) |
||||
|
# |
||||
|
areas.append(area) |
||||
|
|
||||
|
paineis = [{'titulo': _(u'Saberes em números'), 'dados': numeros}] + areas |
||||
|
|
||||
|
|
||||
|
totais = [] |
||||
|
|
||||
|
# for i in MapaCategorias.INTERESSE_CHOICES: |
||||
|
# totais.append({'nome': i[1], 'total_turmas': '', 'total_alunos': '', 'padding': 0}) |
||||
|
# for mapa in MapaCategorias.objects.filter(area_interesse=i[0]): |
||||
|
# totais.append({'nome': mapa.categoria.name, 'total_turmas': mapa.total_turmas(), 'total_alunos': mapa.total_alunos(), 'padding': 1}) |
||||
|
# for c in mapa.categoria.children.all(): |
||||
|
# totais.append({'nome': c.name, 'total_turmas': c.total_turmas(), 'total_alunos': c.total_alunos(), 'padding': 2}) |
||||
|
|
||||
|
tutorias = [] |
||||
|
|
||||
|
# for mapa in MapaCategorias.objects.filter(area_interesse='CT'): |
||||
|
# tutorias.append({'nome': mapa.categoria.name, 'inscritos': mapa.total_alunos(), 'padding': 0}) |
||||
|
# for c in mapa.categoria.courses.all(): |
||||
|
# tutorias.append({'nome': c.fullname, 'inscritos': c.total_alunos(), 'padding': 1}) |
||||
|
|
||||
|
extra_context = {'numeros': numeros, 'paineis': paineis, 'totais': totais, 'tutorias': tutorias} |
||||
|
|
||||
|
return render_to_response('saberes/dashboard.html', extra_context, context_instance=RequestContext(request)) |
Loading…
Reference in new issue