Changeset 14425 for main/waeup.aaue/trunk/src/waeup/aaue/students
- Timestamp:
- 21 Jan 2017, 16:07:07 (8 years ago)
- Location:
- main/waeup.aaue/trunk/src/waeup/aaue/students/reports
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/browser_templates/levelreportgeneratorpage.pt
r14041 r14425 7 7 </p> 8 8 <br /> 9 <label for="session" i18n:translate="">Department</label> 10 <select name="faccode_depcode" class="form-control half"> 11 <span tal:repeat="items view/faccode_depcodes" tal:omit-tag=""> 9 <label for="session" i18n:translate="">Certificate</label> 10 <input id="filterbox" class="kofa-filterbox form-control half" 11 placeholder="Enter search text, then select item below." 12 type="text" i18n:translate=""/> 13 <br /> 14 <select id="filteredselect" name="faccode_depcode_certcode" 15 class="form-control half" size=5> 16 <span tal:repeat="items view/faccode_depcode_certcode" 17 tal:omit-tag=""> 12 18 <option 13 19 tal:define="name python: items[1]; title python: items[0]" … … 19 25 <br /> 20 26 <label for="session">Academic Session</label> 21 <div class="input"> 22 <select name="session" class="form-control half"> 23 <span tal:repeat="items view/sessions" tal:omit-tag=""> 24 <option 25 tal:define="name python: items[1]; title python: items[0]" 26 tal:attributes="value name"> 27 <span tal:replace="title">TITLE</span> 28 </option> 29 </span> 30 </select> 31 </div> 27 <select name="session" class="form-control half"> 28 <span tal:repeat="items view/sessions" tal:omit-tag=""> 29 <option 30 tal:define="name python: items[1]; title python: items[0]" 31 tal:attributes="value name"> 32 <span tal:replace="title">TITLE</span> 33 </option> 34 </span> 35 </select> 32 36 <br /> 33 37 <label for="session">Level</label> -
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/level_report.py
r14419 r14425 33 33 class LevelReportGenerator(LevelReportGenerator): 34 34 35 def generate(self, site, faccode=None, depcode=None, 35 def generate(self, site, faccode=None, depcode=None, certcode=None, 36 36 session=None, level=None, author=None): 37 37 result = CustomLevelReport(faccode=faccode, depcode=depcode, 38 38 certcode=certcode, session=session, level=level, author=author) 39 39 return result 40 40 -
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/raw_score_report.py
r14419 r14425 39 39 faccode = Attribute('Faculty to report') 40 40 depcode = Attribute('Department to report') 41 certcode = Attribute('Certzificate to report') 41 42 creation_dt_string = Attribute('Human readable report creation datetime') 42 43 43 def get_courses _1(faccode, depcode, session, level):44 def get_courses(faccode, depcode, certcode, session, level): 44 45 """Method 1: Get certificate courses of a 45 certain department at a certain level.46 certain department/certificate at a certain level. 46 47 """ 47 48 site = grok.getSite() 48 49 course_codes = [] 49 50 department = site['faculties'][faccode][depcode] 50 for cert in department.certificates.values(): 51 for certcourse in cert.values(): 51 if certcode == 'all': 52 for cert in department.certificates.values(): 53 for certcourse in cert.values(): 54 if certcourse.level == level: 55 course_codes.append(certcourse.getCourseCode()) 56 else: 57 certificate = site['faculties'][faccode][depcode].certificates[certcode] 58 for certcourse in certificate.values(): 52 59 if certcourse.level == level: 53 60 course_codes.append(certcourse.getCourseCode()) 54 61 return course_codes 55 62 56 def get_courses_2(faccode, depcode, session, level): 57 """Method 2 (not used): Get all courses students of a certain 58 department have registered at a certain level. 59 """ 60 cat = queryUtility(ICatalog, name="students_catalog") 61 result = cat.searchResults( 62 depcode = (depcode, depcode), faccode = (faccode, faccode) 63 ) 64 course_codes = [] 65 for stud in result: 66 if not stud['studycourse'].has_key(str(level)): 67 continue 68 level_obj = stud['studycourse'][str(level)] 69 if level_obj.level_session != session: 70 continue 71 for ticket in level_obj.values(): 72 course_codes.append(ticket.code) 73 course_codes = sorted(list(set(course_codes))) 74 return course_codes 75 76 def get_students(faccode, depcode, session, level, course_codes): 77 """Get students in a certain department who registered courses 63 def get_students(faccode, depcode, certcode, session, level, course_codes): 64 """Get students in a certain department/certificate who registered courses 78 65 in a certain session at a certain level. 79 66 … … 81 68 """ 82 69 cat = queryUtility(ICatalog, name="students_catalog") 70 if certcode == 'all': 71 certcode = None 83 72 result = cat.searchResults( 84 depcode = (depcode, depcode), faccode = (faccode, faccode) 73 depcode = (depcode, depcode), faccode = (faccode, faccode), 74 certcode = (certcode, certcode) 85 75 ) 86 76 table = [] … … 183 173 faccode = None 184 174 depcode = None 175 certcode = None 185 176 186 177 note = "" … … 193 184 #""" 194 185 195 def __init__(self, faccode, depcode, session, level, author='System'): 186 def __init__(self, faccode, depcode, certcode, session, level, 187 author='System'): 196 188 super(RawScoreReport, self).__init__( 197 args=[faccode, depcode, session, level], kwargs={'author':author}) 189 args=[faccode, depcode, certcode, session, level], 190 kwargs={'author':author}) 198 191 site = grok.getSite() 199 192 self.studylevelsource = StudyLevelSource().factory … … 206 199 self.faccode = faccode 207 200 self.depcode = depcode 201 self.certcode = certcode 208 202 self.factitle = site['faculties'][faccode].longtitle 209 203 self.deptitle = site['faculties'][faccode][depcode].longtitle 204 if self.certcode == 'all': 205 self.certtitle = translate( 206 _('All Certificates'), 'waeup.kofa', 207 target_language=self.portal_language) 208 else: 209 self.certtitle = site['faculties'][faccode][ 210 depcode].certificates[certcode].longtitle 210 211 self.author = author 211 212 self.creation_dt_string = self.creation_dt.astimezone( … … 215 216 self.data = dict() 216 217 for level in self.past_levels: 217 course_codes = get_courses_1(faccode, depcode, session, level) 218 course_codes = get_courses( 219 faccode, depcode, certcode, session, level) 218 220 self.course_codes[level] = course_codes 219 221 self.data[level] = get_students( 220 faccode, depcode, session, self.levelcode, course_codes)222 faccode, depcode, certcode, session, self.levelcode, course_codes) 221 223 222 224 def create_pdf(self, job_id): … … 233 235 pdf_data += [Paragraph( 234 236 translate( 235 '${a}<br />${b}<br /> Session: ${c}<br />Level: ${d}',236 mapping = {'a':self. factitle,237 '${a}<br />${b}<br />${c}<br /><br />Session: ${d}<br />Level: ${e}', 238 mapping = {'a':self.certtitle, 237 239 'b':self.deptitle, 238 'c':self.session, 239 'd':self.level, 240 'c':self.factitle, 241 'd':self.session, 242 'e':self.level, 240 243 }), 241 244 STYLE["Normal"]), … … 260 263 pdf = creator.create_pdf( 261 264 pdf_data, None, doc_title, self.author, 262 doc_title + ' - %s/%s - %s - %s -' % ( 263 self.faccode, self.depcode, self.levelcode, self.sessioncode), 265 doc_title + ' - %s/%s/%s - %s - %s -' % ( 266 self.faccode, self.depcode, self.certcode, 267 self.levelcode, self.sessioncode), 264 268 note=self.note 265 269 ) … … 272 276 grok.name('raw_score_report') 273 277 274 def generate(self, site, faccode=None, depcode=None, 278 def generate(self, site, faccode=None, depcode=None, certcode=None, 275 279 session=None, level=None, author=None): 276 280 result = RawScoreReport(faccode=faccode, depcode=depcode, 277 281 certcode=certcode, session=session, level=level, author=author) 278 282 return result 279 283 … … 302 306 303 307 def _filename(self): 304 return 'RawScoreReport_%s_%s_%s_%s_%s .pdf' % (305 self.context.faccode, self.context.depcode, 308 return 'RawScoreReport_%s_%s_%s_%s_%s_%s.pdf' % ( 309 self.context.faccode, self.context.depcode, self.context.certcode, 306 310 self.context.sessioncode, self.context.levelcode, 307 311 self.context.creation_dt_string) -
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/session_results_presentation.py
r14419 r14425 33 33 class CustomSessionResultsPresentationGenerator(SessionResultsPresentationGenerator): 34 34 35 def generate(self, site, faccode=None, depcode=None, 35 def generate(self, site, faccode=None, depcode=None, certcode=None, 36 36 session=None, level=None, author=None): 37 result = CustomSessionResultsPresentation(faccode=faccode, depcode=depcode, 38 session=session, level=level, author=author) 37 result = CustomSessionResultsPresentation(faccode=faccode, 38 depcode=depcode, certcode=certcode, session=session, 39 level=level, author=author) 39 40 return result -
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_level_report.py
r14419 r14425 20 20 def test_iface(self): 21 21 # ensure we fullfill interface contracts 22 obj = CustomLevelReport('fac1', 'dep1', 2010, 100)22 obj = CustomLevelReport('fac1', 'dep1', 'CERT1', 2010, 100) 23 23 verifyClass(ILevelReport, CustomLevelReport) 24 24 verifyObject(ILevelReport, obj) … … 28 28 # we can get a table with one student 29 29 self.student['studycourse']['100']['Course1'].ca = 0 30 result = get_students('fac1', 'dep1', 2010, 100)30 result = get_students('fac1', 'dep1', 'CERT1', 2010, 100) 31 31 self.assertEqual(result, 32 32 [(u'1234', u'TESTER, Bob', 30, 30, '5.000', 'NIL', '', 30, 30, '5.000', 'Proceed')]) … … 35 35 def test_create_pdf(self): 36 36 self.student['studycourse']['100']['Course1'].ca = 0 37 report = CustomLevelReport('fac1', 'dep1', 2010, 100)37 report = CustomLevelReport('fac1', 'dep1', 'CERT1', 2010, 100) 38 38 result = report.create_pdf('JOB_ID') 39 39 self.assertTrue(result.startswith('%PDF-')) -
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_raw_score_report.py
r14399 r14425 11 11 from waeup.aaue.students.reports.raw_score_report import ( 12 12 get_students, RawScoreReport, IRawScoreReport, 13 get_courses _1 as get_courses)13 get_courses) 14 14 from waeup.aaue.testing import FunctionalLayer 15 15 … … 29 29 def test_iface(self): 30 30 # ensure we fullfill interface contracts 31 obj = RawScoreReport('fac1', 'dep1', 2010, 100)31 obj = RawScoreReport('fac1', 'dep1', 'CERT1', 2010, 100) 32 32 verifyClass(IRawScoreReport, RawScoreReport) 33 33 verifyObject(IRawScoreReport, obj) … … 36 36 def test_get_courses(self): 37 37 # we can get a list with one course code 38 result = get_courses('fac1', 'dep1', 2010, 100)38 result = get_courses('fac1', 'dep1', 'CERT1', 2010, 100) 39 39 self.assertEqual(result, [(u'Course1')]) 40 40 return … … 43 43 # we can get a table with one student 44 44 self.student['studycourse']['100']['Course1'].ca = 0 45 course_codes = get_courses('fac1', 'dep1', 2010, 100)46 result = get_students('fac1', 'dep1', 2010, 100, course_codes)45 course_codes = get_courses('fac1', 'dep1', 'CERT1', 2010, 100) 46 result = get_students('fac1', 'dep1', 'CERT1', 2010, 100, course_codes) 47 47 self.assertEqual(result, 48 48 [(u'1234', u'TESTER, Bob', {'Course1': (70, 'A')})]) … … 68 68 self.student.firstname = u'Osahenokese Tessy' 69 69 self.student.lastname = u'Emwinyomwanru' 70 report = RawScoreReport('fac1', 'dep1', 2011, 200)70 report = RawScoreReport('fac1', 'dep1', 'CERT1', 2011, 200) 71 71 result = report.create_pdf('JOB_ID') 72 72 self.assertTrue(result.startswith('%PDF-')) -
main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_session_results_presentation.py
r14393 r14425 23 23 def test_iface(self): 24 24 # ensure we fullfill interface contracts 25 obj = CustomSessionResultsPresentation('fac1', 'dep1', 2010, 100)25 obj = CustomSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100) 26 26 verifyClass(ISessionResultsPresentation, CustomSessionResultsPresentation) 27 27 verifyObject(ISessionResultsPresentation, obj) … … 29 29 30 30 def test_get_students(self): 31 result = get_students('fac1', 'dep1', 2010, 100)31 result = get_students('fac1', 'dep1', 'CERT1', 2010, 100) 32 32 self.assertEqual(result, 33 33 [[(u'E1000000', u'1234', u'TESTER, Bob')], [], [], [], [], [], []]) 34 34 self.student['studycourse']['100']['Course1'].score = 60 35 35 self.student['studycourse']['100']['Course1'].ca = 10 36 result = get_students('fac1', 'dep1', 2010, 100)36 result = get_students('fac1', 'dep1', 'CERT1', 2010, 100) 37 37 self.assertEqual(result, 38 38 [[], [], [], [], [], [(u'E1000000', u'1234', u'TESTER, Bob')], []]) … … 41 41 42 42 def test_create_pdf(self): 43 report = CustomSessionResultsPresentation('fac1', 'dep1', 2010, 100)43 report = CustomSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100) 44 44 result = report.create_pdf('JOB_ID') 45 45 self.assertTrue(result.startswith('%PDF-'))
Note: See TracChangeset for help on using the changeset viewer.