コード例 #1
0
def getSourceObj(source):
    if source is None:
        return None

    items = source.split('_')
    scid = items[0]
    ws_hash = items[-2]
    act_hash = items[-1]
    sid = '_'.join(items[1:-2])

    app = ISchoolToolApplication(None)
    sectionContainer = app['schooltool.course.section'].get(scid, None)
    if sectionContainer is None:
        return None

    section = sectionContainer.get(sid, None)
    if section is None:
        return None

    for worksheet in interfaces.IActivities(section).values():
        if ws_hash == unicode(hash(IKeyReference(worksheet))):
            break
    else:
        return None

    if act_hash == 'ave':
        return worksheet
    for key, activity in worksheet.items():
        if act_hash == unicode(hash(IKeyReference(activity))):
            return activity
    return None
コード例 #2
0
 def __init__(self, context):
     self.context = context
     # To make URL creation happy
     self.__parent__ = context
     self.section = self.context.__parent__.__parent__
     # Establish worksheets and all activities
     worksheets = interfaces.IActivities(self.section)
     ensureAtLeastOneWorksheet(worksheets)
     self.worksheets = list(worksheets.values())
     self.activities = []
     for activity in context.values():
         self.activities.append(activity)
     self.students = self.section.members.all()
コード例 #3
0
def getCurrentSectionAttended(person):
    person = proxy.removeSecurityProxy(person)
    ann = annotation.interfaces.IAnnotations(person)
    if CURRENT_SECTION_ATTENDED_KEY not in ann:
        ann[CURRENT_SECTION_ATTENDED_KEY] = None
    else:
        section = ann[CURRENT_SECTION_ATTENDED_KEY]
        if section not in getLearnerSections(person):
            return None
        try:
            interfaces.IActivities(section)
        except:
            ann[CURRENT_SECTION_ATTENDED_KEY] = None
    return ann[CURRENT_SECTION_ATTENDED_KEY]
コード例 #4
0
def getCurrentSectionTaught(person):
    person = proxy.removeSecurityProxy(person)
    ann = annotation.interfaces.IAnnotations(person)
    if CURRENT_SECTION_TAUGHT_KEY not in ann:
        ann[CURRENT_SECTION_TAUGHT_KEY] = None
    else:
        section = ann[CURRENT_SECTION_TAUGHT_KEY]
        if section not in getInstructorSections(person):
            return None
        try:
            interfaces.IActivities(section)
        except:
            ann[CURRENT_SECTION_TAUGHT_KEY] = None
    return ann[CURRENT_SECTION_TAUGHT_KEY]
コード例 #5
0
 def setCurrentWorksheet(self, person, worksheet):
     section = self.section
     worksheets = interfaces.IActivities(section)
     worksheet = proxy.removeSecurityProxy(worksheet)
     worksheets.setCurrentWorksheet(person, worksheet)
コード例 #6
0
 def getCurrentWorksheet(self, person):
     section = self.section
     worksheets = interfaces.IActivities(section)
     current = worksheets.getCurrentWorksheet(person)
     return current