Changeset 13870 for main/waeup.aaue/trunk
- Timestamp:
- 30 May 2016, 14:32:21 (9 years ago)
- Location:
- main/waeup.aaue/trunk/src/waeup/aaue
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/browser_templates/studentlevelstatisticsreportgeneratorpage.pt
r13857 r13870 10 10 <select name="breakdown" class="form-control half"> 11 11 <span tal:repeat="items view/breakdowns" tal:omit-tag=""> 12 <option 13 tal:define="name python: items[1]; title python: items[0]" 14 tal:attributes="value name"> 15 <span tal:replace="title">TITLE</span> 16 </option> 17 </span> 18 </select> 19 <br /> 20 <label for="session" i18n:translate="">Study Modes Group</label> 21 <select name="mode" class="form-control half"> 22 <span tal:repeat="items view/modes" tal:omit-tag=""> 12 23 <option 13 24 tal:define="name python: items[1]; title python: items[0]" -
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/student_level_statistics.py
r13860 r13870 34 34 session = Attribute('Session to report') 35 35 creation_dt_string = Attribute('Human readable report creation datetime') 36 37 def get_student_stats(session, breakdown): 38 """Get students in a certain session. 36 mode = Attribute('Study modes group to report') 37 38 def get_student_stats(session, mode, breakdown): 39 """Get students in a certain session and study mode. 39 40 40 41 Returns a table ordered by code (faculty or department, one per row) and … … 74 75 result = cat.searchResults(current_session=(session, session)) 75 76 table = [[0 for x in xrange(2 * len(levels) + 2)] for y in xrange(len(paths)+1)] 77 mode_groups = getUtility(IKofaUtils).MODE_GROUPS 76 78 for stud in result: 79 if mode != 'All' and stud.current_mode not in mode_groups[mode]: 80 continue 77 81 if getattr(stud, breakdown) is None: 78 82 continue … … 155 159 data = None 156 160 session = None 157 158 def __init__(self, session, breakdown, author='System'): 161 mode = None 162 163 def __init__(self, session, mode, breakdown, author='System'): 159 164 super(StudentLevelStatisticsReport, self).__init__( 160 args=[session, breakdown], kwargs={'author':author})165 args=[session, mode, breakdown], kwargs={'author':author}) 161 166 self.studylevelsource = StudyLevelSource().factory 162 167 self.portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE … … 164 169 self.breakdown = breakdown 165 170 self.author = author 171 self.mode = mode 166 172 self.creation_dt_string = self.creation_dt.astimezone( 167 173 getUtility(IKofaUtils).tzinfo).strftime("%Y-%m-%d %H:%M:%S %Z") 168 self.data = get_student_stats(session, breakdown)174 self.data = get_student_stats(session, mode, breakdown) 169 175 170 176 def create_pdf(self): … … 178 184 Table(table_data, style=TABLE_STYLE, colWidths=col_widths)] 179 185 doc_title = translate( 180 _(' Students - ${c}',181 mapping = {' c':self.session}))186 _('${a} Students - ${c}', 187 mapping = {'a':self.mode, 'c':self.session})) 182 188 pdf = creator.create_pdf( 183 189 pdf_data, None, doc_title, self.author, doc_title + '-' … … 192 198 193 199 def generate( 194 self, site, session=None, 200 self, site, session=None, mode=None, 195 201 breakdown=None, author=None): 196 202 result = StudentLevelStatisticsReport( 197 session=session, 203 session=session, mode=mode, 198 204 breakdown=breakdown, author=author) 199 205 return result … … 224 230 225 231 def update( 226 self, CREATE=None, session=None, breakdown=None):232 self, CREATE=None, session=None, mode=None, breakdown=None): 227 233 self.parent_url = self.url(self.context.__parent__) 228 234 self._set_session_values() 235 self._set_mode_values() 229 236 self._set_breakdown_values() 230 237 if CREATE and session: … … 234 241 kw = dict( 235 242 session=int(session), 243 mode=mode, 236 244 breakdown=breakdown) 237 245 self.flash(_('New report is being created in background')) … … 240 248 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 241 249 grok.getSite().logger.info( 242 '%s - report %s created: %s (session=%s, breakdown=%s)' % (250 '%s - report %s created: %s (session=%s, mode=%s, breakdown=%s)' % ( 243 251 ob_class, job_id, self.context.title, 244 session, breakdown))252 session, mode, breakdown)) 245 253 self.redirect(self.parent_url) 246 254 return … … 250 258 vocab_terms = academic_sessions_vocab.by_value.values() 251 259 self.sessions = [(x.title, x.token) for x in vocab_terms] 260 return 261 262 def _set_mode_values(self): 263 mode_groups = getUtility(IKofaUtils).MODE_GROUPS 264 self.modes = sorted([(key, key) for key in mode_groups.keys()]) 252 265 return 253 266 … … 264 277 265 278 def _filename(self): 266 return 'StudentLevelStatisticsReport_%s_%s .pdf' % (267 self.context.session, 279 return 'StudentLevelStatisticsReport_%s_%s_%s.pdf' % ( 280 self.context.session, self.context.mode, 268 281 self.context.creation_dt_string) 269 282 -
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_student_level_statistics.py
r13860 r13870 23 23 def test_iface(self): 24 24 # ensure we fullfill interface contracts 25 obj = StudentLevelStatisticsReport(2010, ' faccode')25 obj = StudentLevelStatisticsReport(2010, 'Undergraduate Full-Time', 'faccode') 26 26 verifyClass(IStudentLevelStatisticsReport, StudentLevelStatisticsReport) 27 27 verifyObject(IStudentLevelStatisticsReport, obj) … … 32 32 self.student.sex = 'm' 33 33 # we can get a table with one student 34 result1 = get_student_stats(2010, ' faccode')35 result2 = get_student_stats(2009, ' faccode')34 result1 = get_student_stats(2010, 'Undergraduate Full-Time', 'faccode') 35 result2 = get_student_stats(2009, 'Undergraduate Full-Time', 'faccode') 36 36 self.assertEqual( 37 37 result1, … … 54 54 self.create_cert(u'fac2', u'dep2', u'CERT2') 55 55 self.student.sex = 'm' 56 result1 = get_student_stats(2010, ' faccode')57 result2 = get_student_stats(2009, ' faccode')56 result1 = get_student_stats(2010, 'Undergraduate Full-Time', 'faccode') 57 result2 = get_student_stats(2009, 'Undergraduate Full-Time', 'faccode') 58 58 self.assertEqual( 59 59 result1, … … 78 78 self.create_cert(u'fac2', u'dep2', u'CERT2') 79 79 self.student.sex = 'm' 80 result1 = get_student_stats(2010, ' depcode')81 result2 = get_student_stats(2009, ' depcode')80 result1 = get_student_stats(2010, 'Undergraduate Full-Time', 'depcode') 81 result2 = get_student_stats(2009, 'Undergraduate Full-Time', 'depcode') 82 82 self.assertEqual( 83 83 result1, … … 102 102 self.create_cert(u'FAC2', u'dept2', u'CERT2') 103 103 self.student['studycourse'].current_level = 220 104 report = StudentLevelStatisticsReport(2010, ' depcode')104 report = StudentLevelStatisticsReport(2010, 'Undergraduate Full-Time', 'depcode') 105 105 result = report.create_pdf() 106 106 self.assertTrue(result.startswith('%PDF-')) -
main/waeup.aaue/trunk/src/waeup/aaue/utils/utils.py
r13794 r13870 152 152 'cl_regular': 'Acceptance Fee - Regular Students', 153 153 } 154 155 MODE_GROUPS = { 156 'All': ('all',), 157 'Undergraduate Full-Time': ('ug_ft', 'mde_ft', 'mug_ft', 'de_ft'), 158 'Undergraduate Part-Time': ('ug_pt', 'de_pt'), 159 'Postgraduate': ('pg_ft','special_pg_ft', 'special_pg_pt'), 160 'Foundation Programme': ('found',), 161 'Institute of Education': ('dp_ft'), 162 }
Note: See TracChangeset for help on using the changeset viewer.