Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- replaceafill@system76:~/dev/sandboxes/merge/schooltool.cando$ bzr diff
- === modified file 'src/schooltool/cando/gradebook.py'
- --- src/schooltool/cando/gradebook.py 2013-09-25 18:30:52 +0000
- +++ src/schooltool/cando/gradebook.py 2013-11-12 21:38:43 +0000
- @@ -18,6 +18,7 @@
- """CanDo Gradebook."""
- from zope.annotation.interfaces import IAnnotations
- +from zope.cachedescriptors.property import Lazy
- from zope.component import adapts, adapter, queryMultiAdapter
- from zope.component import getMultiAdapter
- from zope.interface import implements, implementer, implementsOnly
- @@ -152,41 +153,30 @@
- score = super(SkillsGradebook, self).getScore(student, activity)
- if score is not None:
- return score
- - return self.getPreviousScore(student, activity)
- -
- - def getPreviousScore(self, student, activity):
- - equivalent = activity.findAllEquivalent()
- - previous = self.getPreviousSections(self.section)
- - for section in previous:
- - filtered = self.filterEquivalent(equivalent, section)
- - if filtered:
- - # XXX: could there be more than one equivalent
- - # in a linked section?
- - skill = proxy.removeSecurityProxy(filtered[0])
- - worksheet = skill.__parent__
- - gradebook = ISkillsGradebook(worksheet, None)
- - if gradebook is not None:
- - try:
- - score = gradebook.getScore(student, skill)
- - except (ValueError,):
- - score = None
- - if score is not None:
- - return score
- -
- - def getPreviousSections(self, section):
- - result = []
- - previous = section.previous
- - while previous:
- - result.append(previous)
- - previous = previous.previous
- - return result
- -
- - def filterEquivalent(self, equivalent, section):
- - # select only equivalent skills that belong to this section
- - equivalent = [proxy.removeSecurityProxy(e) for e in equivalent]
- - return filter(
- - lambda e: ISection(e.__parent__, None) is section,
- - equivalent)
- + if self.section.previous is not None:
- + return self.getPreviousScore(student, activity, self.section.previous)
- +
- + def getPreviousScore(self, student, activity, section):
- + equivalent = self.findEquivalent(activity, section)
- + if equivalent is not None:
- + skill = proxy.removeSecurityProxy(equivalent)
- + worksheet = skill.__parent__
- + gradebook = ISkillsGradebook(worksheet, None)
- + if gradebook is not None:
- + try:
- + score = gradebook.getScore(student, skill)
- + except (ValueError,):
- + score = None
- + if score is not None:
- + return score
- +
- + def findEquivalent(self, activity, section):
- + equivalent = set(activity.equivalent)
- + skillsets = ISectionSkills(section)
- + for skillset in skillsets.values():
- + for skill in skillset.values():
- + if set(skill.equivalent).intersection(equivalent):
- + return skill
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement