# -*- coding: utf-8 # Copyright 2005 by Meelis Mets from Products.Archetypes.public import BaseSchema, Schema from Products.Archetypes.public import StringField, LinesField from Products.Archetypes.public import LinesWidget, TextAreaWidget, IdWidget, StringWidget, SelectionWidget from Products.Archetypes.public import BaseContent, registerType from Globals import InitializeClass from Products.CMFCore.utils import getToolByName from Permissions import * from AccessControl import ClassSecurityInfo, Unauthorized from config import PROJECT_NAME schema = BaseSchema + Schema(( )) class GradeBook(BaseContent): """ GradeBook """ meta_type = "GradeBook" archetype_name = "GradeBook" global_allow = 1 allowed_content_types = () security = ClassSecurityInfo() content_icon='gradebook_icon.gif' schema = schema actions = ( { 'id':'view', 'name':'View', 'action':'string:${object_url}/gradebook_view', 'permissions': ('View',), }, ) def getAnswers(self, member): """ gets answers """ answer = [] homefolder = self.portal_membership.getHomeFolder(member.id) for obj in homefolder.getFolderContents(): if obj.meta_type in ['PaperAnswer', 'FillInAnswer']: answerObj = obj.getObject() answer.append({'title':answerObj.title,'grade':answerObj.grade,'comment':answerObj.comment,'url':answerObj.absolute_url(),'type':answerObj.meta_type[:-6]}) return answer registerType(GradeBook, PROJECT_NAME)