Changeset 6725 for main/waeup.sirp/trunk/src/waeup/sirp/students
- Timestamp:
- 13 Sep 2011, 07:28:26 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp/students
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py
r6724 r6725 7 7 from waeup.sirp.students.vocabularies import ( 8 8 year_range, lgas_vocab, CertificateSource, GenderSource, 9 entry_session_vocab, study_levels, verdicts,9 entry_session_vocab, verdicts, StudyLevelSource, 10 10 ) 11 11 … … 137 137 current_level = schema.Choice( 138 138 title = u'Current Level', 139 source = study_levels,139 source = StudyLevelSource(), 140 140 default = None, 141 required = True,141 required = False, 142 142 ) 143 143 … … 146 146 source = verdicts, 147 147 default = None, 148 required = True,148 required = False, 149 149 ) 150 150 … … 153 153 source = verdicts, 154 154 default = None, 155 required = True,155 required = False, 156 156 ) 157 157 -
main/waeup.sirp/trunk/src/waeup/sirp/students/vocabularies.py
r6724 r6725 8 8 from waeup.sirp.interfaces import SimpleWAeUPVocabulary 9 9 from waeup.sirp.students.lgas import LGAS 10 from waeup.sirp.university.vocabularies import course_levels 10 11 11 12 def year_range(): … … 23 24 *sorted([(x[1],x[0]) for x in LGAS])) 24 25 25 # This will become a source with probation and 26 # splill-over levels too 27 study_levels = SimpleWAeUPVocabulary( 28 ('Pre-Studies',0), 29 ('100 (Year 1)',100), 30 ('200 (Year 2)',200), 31 ('300 (Year 3)',300), 32 ('400 (Year 4)',400), 33 ('500 (Year 5)',500), 34 ('600 (Year 6)',600), 35 ('700 (Year 7)',700), 36 ('800 (Year 8)',800), 37 ) 26 def study_levels(studycourse): 27 try: 28 start_level = int(studycourse.certificate.start_level) 29 end_level = int(studycourse.certificate.end_level) 30 levels = [level for level in range(start_level,end_level+200,10) 31 if level % 100 < 30 and level < end_level + 120] 32 return levels 33 except AttributeError: 34 return [] 35 36 class StudyLevelSource(BasicContextualSourceFactory): 37 """The StudyLevelSource is based on and extends the 38 course_levels vocabulary defined in the university package. 39 Repeating study levels are denoted by increments of 10, the 40 first spillover level by the certificate's end level plus 100 41 and the second spillover level by the end level plus 110. 42 """ 43 def getValues(self, context): 44 return study_levels(context) 45 46 def getToken(self, context, value): 47 return str(value) 48 49 def getTitle(self, context, value): 50 end_level = int(context.certificate.end_level) 51 level,repeat = divmod(value, 100) 52 level = level * 100 53 repeat = repeat//10 54 title = course_levels.by_value[level].title 55 if level > end_level and repeat: 56 title = course_levels.by_value[level-100].title 57 title = "%s 2nd spillover" % title 58 elif level > end_level: 59 title = course_levels.by_value[level-100].title 60 title = "%s spillover" % title 61 elif repeat: 62 title = "%s on %d. probation" % (title, repeat) 63 return title 38 64 39 65 verdicts = SimpleWAeUPVocabulary(
Note: See TracChangeset for help on using the changeset viewer.