Changeset 1761


Ignore:
Timestamp:
9 May 2007, 19:44:21 (18 years ago)
Author:
Henrik Bettermann
Message:

first part of new statistics

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  
    1212return Student Statistics
    1313"""
    14 try:
    15     from Products.zdb import set_trace
    16 except:
    17     def set_trace():
    18         pass
     14
    1915import logging
    2016logger = logging.getLogger('Skins.getNewStudentStatistics')
    2117
    22 try:
    23     from Products.AdvancedQuery import Eq, Between, Le,In, Ge,MatchRegexp
    24     aq_portal = context.portal_catalog.evalAdvancedQuery
    25     aq_students = context.students_catalog.evalAdvancedQuery
    26 except:
    27     evalAdvancedQuery = None
    28 
    29 def intersect(m,n):
    30     return [i for i in m if i in n]
    31    
    3218logger.info('%s invoked statistics' % context.portal_membership.getAuthenticatedMember())
    3319if not context.isStaff():
    34     return l
    35 total_dict = {}
     20    return 'Not allowed'
    3621
    37 total_dict['id'] = "All Faculties"
    3822
    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',
     23total_new = context.students_catalog(session = '06')
     24
     25new_states =      ('admitted',
    4826                   'clearance_pin_entered',
     27                   'objection_raised',
    4928                   'clearance_requested',
    5029                   'cleared_and_validated',
    51                    'objection_raised',
     30                   'school_fee_paid',
     31                   'courses_registered',
     32                   'courses_validated',
    5233                   )
    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)
     34faculties = context.portal_catalog(portal_type="Faculty")
     35
     36l = []
     37
     38
    6539fac_res = {}
    66 #fac_res['total'] = total_dict
    67 faculties = context.portal_catalog(portal_type="Faculty")
     40
     41dict = {}
     42dict['id'] = 'All Faculties'
     43dict['title'] = 'All Faculties'
     44res = context.students_catalog(entry_session = '06')
     45dict['total'] = len(res)
     46for 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
     55l.append(dict)
     56
    6857for f in faculties:
    6958    dict = {}
    7059    dict['id'] = f.getId
    7160    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'])
    11669        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)
    12473
    12574return l
    12675
     76
  • WAeUP_SRP/trunk/skins/waeup_student/statistics_new_view.pt

    r1621 r1761  
    11<metal:body use-macro="here/main_template/macros/master">
    22  <metal:main fill-slot="main">
    3   <metal:block tal:define="departments context/getNewStudentStatistics;
     3  <metal:block tal:define="faculties context/getNewStudentStatistics;
    44                        mtool here/portal_membership;
    55                        member mtool/getAuthenticatedMember;">       
    66
    7       <span tal:condition="not: departments">
     7      <span tal:condition="not: faculties">
    88        <span tal:content="here/illegal_view" />
    99      </span>
    10       <span tal:condition="departments">
     10      <span tal:condition="faculties">
    1111 
    1212      <strong>
     
    3333            <th align="right">CR</th>
    3434            <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
    3639          </tr>
    37           <tr tal:repeat="d departments"
     40          <tr tal:repeat="d faculties"
    3841              tal:attributes="class python:test(repeat['d'].even(), 'even ajaxtd', 'odd ajaxtd')">
    3942              <td width="80px"> <span tal:content="d/id" /> </td>
    4043              <td width="80px" align="right">
    41                 <span tal:content="d/new" />
     44                <span tal:content="d/total" />
    4245              </td>
    4346              <td width="80px" align="right">
     
    6265              </td>
    6366              <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
    6779          </tr>
    6880        </table>
     
    7486        <tr><td>CR: </td> <td>Clearance requested</td></tr>
    7587        <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>               
    7791        </table>
    7892      </span>
Note: See TracChangeset for help on using the changeset viewer.