- Timestamp:
- 9 May 2007, 19:44:21 (18 years ago)
- Location:
- WAeUP_SRP/trunk/skins/waeup_student
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/skins/waeup_student/getNewStudentStatistics.py
r1671 r1761 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 15 import logging 20 16 logger = logging.getLogger('Skins.getNewStudentStatistics') 21 17 22 try:23 from Products.AdvancedQuery import Eq, Between, Le,In, Ge,MatchRegexp24 aq_portal = context.portal_catalog.evalAdvancedQuery25 aq_students = context.students_catalog.evalAdvancedQuery26 except:27 evalAdvancedQuery = None28 29 def intersect(m,n):30 return [i for i in m if i in n]31 32 18 logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember()) 33 19 if not context.isStaff(): 34 return l 35 total_dict = {} 20 return 'Not allowed' 36 21 37 total_dict['id'] = "All Faculties"38 22 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', 23 total_new = context.students_catalog(session = '06') 24 25 new_states = ('admitted', 48 26 'clearance_pin_entered', 27 'objection_raised', 49 28 'clearance_requested', 50 29 'cleared_and_validated', 51 'objection_raised', 30 'school_fee_paid', 31 'courses_registered', 32 'courses_validated', 52 33 ) 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) 34 faculties = context.portal_catalog(portal_type="Faculty") 35 36 l = [] 37 38 65 39 fac_res = {} 66 #fac_res['total'] = total_dict 67 faculties = context.portal_catalog(portal_type="Faculty") 40 41 dict = {} 42 dict['id'] = 'All Faculties' 43 dict['title'] = 'All Faculties' 44 res = context.students_catalog(entry_session = '06') 45 dict['total'] = len(res) 46 for state in new_states: 47 res = context.students_catalog(entry_session = '06', review_state = state) 48 dict[state] = len(res) 49 statepercent = state+'_percent' 50 if dict['total'] > 0: 51 dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total']) 52 else: 53 dict[statepercent] = 0 54 #fac_res['all'] = dict 55 l.append(dict) 56 68 57 for f in faculties: 69 58 dict = {} 70 59 dict['id'] = f.getId 71 60 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) 61 res = context.students_catalog(entry_session = '06', faculty = f.getId) 62 dict['total'] = len(res) 63 for state in new_states: 64 res = context.students_catalog(entry_session = '06', faculty = f.getId, review_state = state) 65 dict[state] = len(res) 66 statepercent = state+'_percent' 67 if dict['total'] > 0: 68 dict[statepercent] = "%.0f" % round(dict[state]*100.0/dict['total']) 116 69 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) 70 dict[statepercent] = 0 71 #fac_res[f.getId] = dict 72 l.append(dict) 124 73 125 74 return l 126 75 76 -
WAeUP_SRP/trunk/skins/waeup_student/statistics_new_view.pt
r1621 r1761 1 1 <metal:body use-macro="here/main_template/macros/master"> 2 2 <metal:main fill-slot="main"> 3 <metal:block tal:define=" departments context/getNewStudentStatistics;3 <metal:block tal:define="faculties context/getNewStudentStatistics; 4 4 mtool here/portal_membership; 5 5 member mtool/getAuthenticatedMember;"> 6 6 7 <span tal:condition="not: departments">7 <span tal:condition="not: faculties"> 8 8 <span tal:content="here/illegal_view" /> 9 9 </span> 10 <span tal:condition=" departments">10 <span tal:condition="faculties"> 11 11 12 12 <strong> … … 33 33 <th align="right">CR</th> 34 34 <th align="right">VC</th> 35 <th align="right">SFP+</th> 35 <th align="right">SFP</th> 36 <th align="right">CR</th> 37 <th align="right">CV</th> 38 36 39 </tr> 37 <tr tal:repeat="d departments"40 <tr tal:repeat="d faculties" 38 41 tal:attributes="class python:test(repeat['d'].even(), 'even ajaxtd', 'odd ajaxtd')"> 39 42 <td width="80px"> <span tal:content="d/id" /> </td> 40 43 <td width="80px" align="right"> 41 <span tal:content="d/ new" />44 <span tal:content="d/total" /> 42 45 </td> 43 46 <td width="80px" align="right"> … … 62 65 </td> 63 66 <td width="80px" align="right"> 64 <span tal:content="d/rest" /> 65 (<span tal:content="d/rest_percent" />%) 66 </td> 67 <span tal:content="d/school_fee_paid" /> 68 (<span tal:content="d/school_fee_paid_percent" />%) 69 </td> 70 <td width="80px" align="right"> 71 <span tal:content="d/courses_registered" /> 72 (<span tal:content="d/courses_registered_percent" />%) 73 </td> 74 <td width="80px" align="right"> 75 <span tal:content="d/courses_validated" /> 76 (<span tal:content="d/courses_validated_percent" />%) 77 </td> 78 67 79 </tr> 68 80 </table> … … 74 86 <tr><td>CR: </td> <td>Clearance requested</td></tr> 75 87 <tr><td>VC: </td> <td>Validated and cleared</td></tr> 76 <tr><td>SFP+: </td> <td>School fee paid and further</td></tr> 88 <tr><td>SFP: </td> <td>School fee paid</td></tr> 89 <tr><td>CR: </td> <td>Course list registered</td></tr> 90 <tr><td>CV: </td> <td>Course list validated</td></tr> 77 91 </table> 78 92 </span>
Note: See TracChangeset for help on using the changeset viewer.