Changeset 1673 for WAeUP_SRP/branches/joachim-event-branch/skins
- Timestamp:
- 9 Apr 2007, 16:01:51 (18 years ago)
- Location:
- WAeUP_SRP/branches/joachim-event-branch/skins
- Files:
-
- 2 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/getNewStudentStatistics.py
r1596 r1673 12 12 return Student Statistics 13 13 """ 14 try: 15 from Products.zdb import set_trace 16 except: 17 def set_trace(): 18 pass 14 19 import logging 15 20 logger = logging.getLogger('Skins.getNewStudentStatistics') 16 21 17 22 try: 18 from Products.AdvancedQuery import Eq, Between, Le,In, Ge 23 from Products.AdvancedQuery import Eq, Between, Le,In, Ge,MatchRegexp 19 24 aq_portal = context.portal_catalog.evalAdvancedQuery 20 25 aq_students = context.students_catalog.evalAdvancedQuery 21 26 except: 22 27 evalAdvancedQuery = None 28 29 def intersect(m,n): 30 return [i for i in m if i in n] 31 23 32 logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember()) 24 l = []25 33 if not context.isStaff(): 26 34 return l 27 dep= {}35 total_dict = {} 28 36 29 dep['id'] = "All Faculties"37 total_dict['id'] = "All Faculties" 30 38 31 freshquery = Eq('level','100') | (Eq('level','200') & Eq('entry_mode','DE')) 32 total_new = aq_students(freshquery) 33 total_new = float(len(total_new)) 34 dep['new'] = "%.0f" % total_new 35 36 37 #from Products.zdb import set_trace;set_trace() 38 39 adm_res = context.portal_catalog(review_state ='admitted') 40 adm_ids = [r.getId for r in adm_res] 41 adm = len(adm_res) 42 dep['admitted'] = adm 43 dep['admitted_percent'] = "%.0f" % round(adm*100/total_new) 44 45 cpe_res = context.portal_catalog(review_state ='clearance_pin_entered') 46 cpe_ids = [r.getId for r in cpe_res] 47 cpe = len(cpe_res) 48 dep['clearance_pin_entered'] = cpe 49 dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total_new) 50 51 cr_res = context.portal_catalog(review_state='clearance_requested') 52 cr_ids = [r.getId for r in cr_res] 53 cr = len(cr_res) 54 dep['clearance_requested'] = cr 55 dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total_new) 56 57 cav_res = context.portal_catalog(review_state ='cleared_and_validated') 58 cav_ids = [r.getId for r in cav_res] 59 cav = len(cav_res) 60 dep['cleared_and_validated'] = cav 61 dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total_new) 62 63 or_res = context.portal_catalog(review_state='objection_raised') 64 or_ids = [r.getId for r in or_res] 65 ora = len(or_res) 66 dep['objection_raised'] = ora 67 dep['objection_raised_percent'] = "%.0f" % round(ora*100/total_new) 68 69 total_sfp = total_new - (cav + cr + cpe + adm + ora) 70 dep['rest'] = int(total_sfp) 71 dep['rest_percent'] = "%.0f" % round(total_sfp*100/total_new) 72 73 74 l.append(dep) 75 fs = context.portal_catalog(portal_type="Faculty") 76 for fid in [f.getId for f in fs]: 77 dep = {} 78 dep['id'] = fid 79 fquery = Eq('faculty',fid) 80 fac_res = aq_students(fquery & freshquery) 81 fac_ids = [r.id for r in fac_res] 82 total = float(len(fac_res)) 83 84 if total == 0: 85 continue 86 87 dep['new'] = "%.0f" % total 88 89 adm = len([s for s in fac_ids if s in adm_ids]) 90 dep['admitted'] = adm 91 dep['admitted_percent'] = 0 92 if total: 93 dep['admitted_percent'] = "%.0f" % round(adm*100/total) 94 95 cpe = len([s for s in fac_ids if s in cpe_ids]) 96 dep['clearance_pin_entered'] = cpe 97 dep['clearance_pin_entered_percent'] = 0 98 if total: 99 dep['clearance_pin_entered_percent'] = "%.0f" % round(cpe*100/total) 100 cr = len([s for s in fac_ids if s in cr_ids]) 101 dep['clearance_requested'] = cr 102 dep['clearance_requested_percent'] = 0 103 if total: 104 dep['clearance_requested_percent'] = "%.0f" % round(cr*100/total) 105 cav = len([s for s in fac_ids if s in cav_ids]) 106 dep['cleared_and_validated'] = cav 107 dep['cleared_and_validated_percent'] = 0 108 if total: 109 dep['cleared_and_validated_percent'] = "%.0f" % round(cav*100/total) 110 111 ora = len([s for s in fac_ids if s in or_ids]) 112 dep['objection_raised'] = ora 113 dep['objection_raised_percent'] = 0 114 if total: 115 dep['objection_raised_percent'] = "%.0f" % round(ora*100/total) 116 117 rest = int(total - (cav + cr + cpe + adm + ora)) 118 dep['rest'] = rest 119 dep['rest_percent'] = "%.0f" % round(rest*100/total) 120 121 l.append(dep) 39 ##freshquery = Eq('level','100') | (Eq('level','200') & Eq('entry_mode','DE')) 40 ##total_new = aq_students(freshquery) 41 ##total_new = float(len(total_new)) 42 newquery = Eq('portal_type','StudentApplication') & MatchRegexp('SearchableText',r'^6*') 43 total_res = aq_portal(newquery) 44 new_ids = [r.getPath().split('/')[-2] for r in total_res] 45 total_new = float(len(total_res)) 46 total_dict['new'] = "%.0f" % total_new 47 special_states = ('admitted', 48 'clearance_pin_entered', 49 'clearance_requested', 50 'cleared_and_validated', 51 'objection_raised', 52 ) 53 state_count = 0 54 state_ids = {} 55 for state in special_states: 56 res = context.portal_catalog(review_state = state) 57 ids = [r.getId for r in res] 58 state_ids[state] = ids 59 count = len(res) 60 state_count += count 61 total_dict[state] = count 62 total_dict['%s_percent' % state] = "%.0f" % round(count*100/total_new) 63 total_dict['rest'] = "%.0f" % (total_new - state_count) 64 total_dict['rest_percent'] = "%.0f" % round((total_new - state_count)*100/total_new) 65 fac_res = {} 66 #fac_res['total'] = total_dict 67 faculties = context.portal_catalog(portal_type="Faculty") 68 for f in faculties: 69 dict = {} 70 dict['id'] = f.getId 71 dict['title'] = f.Title 72 sid_in_faculty = [s.id for s in context.students_catalog(faculty=f.getId)] 73 new_in_faculty = intersect(new_ids,sid_in_faculty) 74 dict['new'] = rest = len(new_in_faculty) 75 for state in special_states: 76 state_count = len(intersect(state_ids[state], new_in_faculty)) 77 rest -= state_count 78 dict[state] = state_count 79 dict['rest'] = rest 80 fac_res[f.getId] = dict 81 #set_trace() 82 ##for sid,review_state in new_ids: 83 ## scat_res = context.students_catalog(id = sid) 84 ## if not scat_res: 85 ## continue 86 ## student = scat_res[0] 87 ## faculty = student.faculty 88 ## if not fac_res.has_key(faculty): 89 ## continue 90 ## if review_state in special_states: 91 ## fac_res[faculty][review_state] = fac_res[faculty][review_state] + 1 92 ## else: 93 ## fac_res[faculty]['rest'] = fac_res[faculty]['rest'] + 1 94 l = [] 95 l.append(total_dict) 96 fac_ids = [f.getId for f in faculties] 97 fac_ids.sort() 98 check_dict = {} 99 check_dict['id'] = 'Check' 100 check_dict['new'] = 0 101 check_dict['new_percent'] = 0 102 check_dict['rest'] = 0 103 check_dict['rest_percent'] = 0 104 for state in special_states: 105 check_dict[state] = 0 106 check_dict["%s_percent" % state] = 0 107 108 for f in fac_ids: 109 total_fac = fac_res[f]['new'] 110 check_dict['new'] = check_dict['new'] + total_fac 111 check_dict['rest'] = check_dict['rest'] + fac_res[f]['rest'] 112 for state in special_states: 113 check_dict[state] = check_dict[state] + fac_res[f][state] 114 if total_fac != 0: 115 fac_res[f]['%s_percent' % state] = "%.0f" % round(fac_res[f][state]*100/total_fac) 116 else: 117 fac_res[f]['%s_percent' % state] = "%.0f" % 0.0 118 if total_fac != 0: 119 fac_res[f]['rest_percent'] = "%.0f" % round(fac_res[f]['rest']*100/total_fac) 120 else: 121 fac_res[f]['rest_percent'] = "%.0f" % 0.0 122 l.append(fac_res[f]) 123 l.append(check_dict) 122 124 123 125 return l -
WAeUP_SRP/branches/joachim-event-branch/skins/waeup_student/list_students.py
r1312 r1673 12 12 export student_list 13 13 """ 14 try: 15 from Products.zdb import set_trace 16 except: 17 def set_trace(): 18 pass 19 from Products.AdvancedQuery import Eq, Between, Le,In,MatchRegexp 20 aq_portal = context.portal_catalog.evalAdvancedQuery 21 aq_students = context.students_catalog.evalAdvancedQuery 14 22 request = context.REQUEST 15 23 setheader = request.RESPONSE.setHeader … … 33 41 lines.append(','.join(fields)) 34 42 format = '"%(' + ')s","%('.join(fields) + ')s"' 35 cleared = context.portal_catalog(review_state = "cleared_and_validated") 43 #cleared = context.portal_catalog(review_state = "cleared_and_validated") 44 query = In('review_state',('cleared_and_validated', 45 'school_fee_paid', 46 'courses_registered', 47 'courses_validated')) 48 cleared = aq_portal(query) 49 newquery = Eq('portal_type','StudentApplication') & MatchRegexp('SearchableText',r'^6*') 50 #newquery = MatchRegexp('SearchableText','^5*') 51 new_students = aq_portal(newquery) 52 new_sids = [] 53 for ns in new_students: 54 new_sids.append(ns.getPath().split('/')[-2]) 36 55 for student in cleared: 56 if student.getId not in new_sids: 57 continue 37 58 erg = scat(id=student.getId) 38 59 if not erg:
Note: See TracChangeset for help on using the changeset viewer.