Ejemplo n.º 1
0
    def __init__(self, context, request, view, manager, data):
        self.context = context
        super(Renderer, self).__init__(self.context, request, view, manager, data)
        self.mtool = self.context.portal_membership

        self.assignmentstate = AssignmentState(self.context)
        self.inprogress = len(self.assignmentstate.getInprogress())
        self.submitted = len(self.assignmentstate.getSubmitted())
        self.graded = len(self.assignmentstate.getGraded())
        self.unsubmitted = len(self.assignmentstate.getUnsubmitted())
        self.total = len(self.assignmentstate.getTotal())
Ejemplo n.º 2
0
class Renderer(base.Renderer):
    """Portlet renderer.

    This is registered in configure.zcml. The referenced page template is
    rendered, and the implicit variable 'view' will refer to an instance
    of this class. Other methods can be added and referenced in the template.
    """

    render = ViewPageTemplateFile('assignmentportlet.pt')

    def __init__(self, context, request, view, manager, data):
        self.context = context
        super(Renderer, self).__init__(self.context, request, view, manager, data)
        self.mtool = self.context.portal_membership

        self.assignmentstate = AssignmentState(self.context)
        self.inprogress = len(self.assignmentstate.getInprogress())
        self.submitted = len(self.assignmentstate.getSubmitted())
        self.graded = len(self.assignmentstate.getGraded())
        self.unsubmitted = len(self.assignmentstate.getUnsubmitted())
        self.total = len(self.assignmentstate.getTotal())

    @property
    def available(self):
        return 'CTMParticipant' in self.mtool.getAuthenticatedMember().getGroups() and not self.context.isTemporary()

    def getInprogressCount(self):
        return self.inprogress

    def getSubmittedCount(self):
        return self.submitted

    def getGradedCount(self):
        return self.graded

    def getUnsubmittedCount(self):
        return self.unsubmitted

    def getTotalCount(self):
        return self.total

    def getStatePercent(self, state):
        """ Grab states for each object based on a filter """

        func = getattr(self, 'get%sCount' %state,  None)
        val = func()

        try:
            return str(float(val)/self.getTotalCount() * 100) + '%'
        except ZeroDivisionError:
            return '0%'

    def getCtmUrl(self):
	mtool = self.context.portal_membership.getAuthenticatedMember()
	if mtool.getProperty('ctmbookmark'):
	    return mtool.getProperty('ctmbookmark')
	else:
	    return ''

    def getCtmCohort(self):
	mtool = self.context.portal_membership.getAuthenticatedMember()
	if mtool.getProperty('ctmcohort'):
	    return mtool.getProperty('ctmcohort')
	else:
	    return ''