- Timestamp:
- 3 Feb 2021, 21:26:18 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/students/webservices.py
r16391 r16392 155 155 156 156 @grok.require('waeup.xmlrpc') 157 def get_students_by_department(self, faccode=None, depcode=None, session=None): 158 """A webservice to pull student's registered courses in a department. 157 def get_students_by_department(self, faccode=None, depcode=None, 158 session=None, level=None): 159 """A webservice to pull student's registered courses in a 160 department 159 161 """ 160 162 try: 161 163 session = int(session) 164 level = int(level) 162 165 except (TypeError, ValueError): 163 166 pass 164 sessionsearch = True165 167 if session in (None, ''): 166 sessionsearch = False 168 session= None 169 if level in (None, ''): 170 level= None 167 171 try: 168 172 department =self.context['faculties'][faccode][depcode] … … 171 175 courses = department.courses.keys() 172 176 cat = queryUtility(ICatalog, name='coursetickets_catalog') 173 hit list = []177 hitdict = {} 174 178 for course in courses: 175 if sessionsearch: 176 coursetickets = cat.searchResults( 177 session=(session, session), 178 code=(course, course)) 179 else: 180 coursetickets = cat.searchResults( 181 code=(course, course)) 179 coursetickets = cat.searchResults( 180 session=(session, session), 181 level=(level, level), 182 code=(course, course)) 182 183 for c_ticket in coursetickets: 183 hitlist.append((184 c_ticket.code,185 c_ticket.level,186 c_ticket.level_session,187 c_ticket.student.student_id,188 c_ticket.student.matric_number,189 c_ticket.student.display_fullname,190 ))191 return list(set(hitlist))184 if not c_ticket.student.student_id in hitdict.keys(): 185 hitdict[c_ticket.student.student_id] = ( 186 c_ticket.student.matric_number, 187 c_ticket.student.display_fullname, 188 [c_ticket.code,]) 189 else: 190 hitdict[c_ticket.student.student_id][2].append( 191 c_ticket.code,) 192 return hitdict 192 193 193 194 @grok.require('waeup.xmlrpc')
Note: See TracChangeset for help on using the changeset viewer.