Changeset 1380


Ignore:
Timestamp:
31 Jan 2007, 16:24:18 (18 years ago)
Author:
joachim
Message:

course registration

M waeup_student/student_index.py
M waeup_student/study_level_view.pt
M waeup_student/getStudyLevelInfo.py
M waeup_student/study_course_view.pt
M waeup_student/getStudyCourseInfo.py
AM waeup_academics/getCourseInfo.py

reindex entry_mode

M waeup_utilities/getFromData_entry_mode.py
M waeup_utilities/reindex_entry_mode.py

Location:
WAeUP_SRP/trunk/skins
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/skins/waeup_student/getStudyCourseInfo.py

    r913 r1380  
    1818
    1919info = {}
     20info['is_so'] = context.isSectionOfficer()
    2021info['action'] = "%s" % context.campus.absolute_url()
    2122info['choosen_ids'] = request.get('ids',[])
    22 info['doc'] = context.getContent()
     23course  = info['doc'] = context.getContent()
     24student_id = context.getStudentId()
     25res = context.students_catalog(id = student_id)
     26if not res:
     27    return None
     28sbrain = res[0]
     29cert_id = sbrain.course
     30res = context.portal_catalog(portal_type = "Certificate", id = cert_id)
     31ci = {}
     32if res:
     33    info['cert_id'] = cert_id
     34    brain = res[0]
     35    ci['study_course'] = brain.getId
     36    ci['title'] = brain.Title
     37    pl = brain.getPath().split('/')
     38    ci['faculty'] = pl[-4]
     39    ci['department'] = pl[-3]
     40    info['course_doc'] = ci
     41else:
     42    info['course'] = None
    2343items = []
    24 levels = context.objectValues()
     44current_level = sbrain.level
     45levels = context.objectIds()
     46if current_level not in levels:
     47    context.invokeFactory('StudentStudyLevel',"%s" % current_level)
     48    level = getattr(context,"%s" % current_level)
     49    level.getContent().edit(mapping={'session': "2006/2007"})
     50    context.portal_workflow.doActionFor(level,'open')
     51    context.portal_workflow.doActionFor(level,'close_for_edit')
     52    levels.append(current_level)
     53#from Products.zdb import set_trace;set_trace()
    2554for l in levels:
    2655    row = {}
    27     ld = l.getContent()
    28     row['id'] = l.getId()
    29     if hasattr(ld,'Title'):
    30         row['title'] = ld.Title()
    31     else:
    32         row['title'] = getattr(ld,'title','no title')
    33     row['url'] = l.absolute_url()
     56    row['id'] = l
     57    row['title'] = "Level %s" % l
     58    row['url'] = "%s/%s" % (context.absolute_url(),l)
    3459    items.append(row)
     60
    3561info['items'] = items
    3662return info
  • WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py

    r913 r1380  
    1212return Info about the Studylevel
    1313"""
     14from Products.AdvancedQuery import Eq, Between, Le,In
     15evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery
     16request = context.REQUEST
     17session = request.SESSION
     18response = request.RESPONSE
     19
    1420def calculateGPA():
    1521    """calculate the gpa"""
     
    2935    return 0.0
    3036
    31 request = context.REQUEST
     37def cmp_semester(a,b):
     38    if a['semester'] == b['semester']:
     39        return 0
     40    if a['semester'] > b['semester']:
     41        return 1
     42    return -1
     43
    3244
    3345wf = context.portal_workflow
    3446mtool = context.portal_membership
    35 path_info = request.get('PATH_INFO').split('/')
    36 try:
    37     i = int(path_info[-1])
    38     p = 0
    39 except:
    40     p = 1
     47student_id = context.getStudentId()
     48
    4149info = {}
    42 pt = request.get('PATH_TRANSLATED').split('/')
    43 
    44 student_id = pt[-(3+p)]
    45 level_id = pt[-(1+p)]
    46 info['action'] = "%s" % context.absolute_url()
     50info['student'] = student = context.students_catalog(id=student_id)[0]
    4751info['choosen_ids'] = request.get('ids',[])
    4852info['doc'] = context.getContent()
    49 study_course = context.aq_parent.getContent()
    50 cert_id = study_course.study_course
    51 brain = context.portal_catalog(meta_type="Student",id = student_id)[-1]
    52 cp = brain.getPath()
    53 info['container_path'] = cp
     53##study_course = context.aq_parent.getContent()
     54##cert_id = study_course.study_course
     55cert_id = student.course
    5456info['cert_id'] = cert_id
     57normal = []
     58carry_overs = []
     59for id,obj in context.objectItems():
     60    if id.endswith('_co'):
     61        d = context.getCourseInfo(id[:-3])
     62        d['grade'] = obj.getContent().grade
     63        carry_overs.append(d)
     64    else:
     65        d = context.getCourseInfo(id)
     66        coe = obj.getContent().core_or_elective
     67        d['coe'] = 'Core'
     68        if not coe:
     69            d['coe'] = 'Elective'
     70        normal.append(d)
    5571
    56 res = context.portal_catalog(meta_type="StudentCourseResult",
    57                              container_path="%s/study_course/%s" % (cp,level_id))
    58 first = []
    59 second = []
    60 sum = 0
    61 course_count = 0
    62 for r in res:
    63     row = {}
    64     ro = r.getObject()
    65     rd = ro.getContent()
    66     row['id'] = ro.getId()
    67     row['credits'] = rd.credits
    68     if row['credits'] and rd.grade:
    69         credits = int(rd.credits)
    70         sum += credits * ['F','E','D','C','B','A'].index(rd.grade)
    71         course_count += credits
    72     row['sum'] = sum
    73     row['count'] = course_count
    74     row['title'] = rd.title
    75     #row['core'] = rd.core_or_elective
    76     row['semester'] = rd.semester
    77     row['score'] = rd.score
    78     row['grade'] = rd.grade
    79     row['weight'] = rd.weight
    80     row['url'] = ro.absolute_url()
    81     row['review_state'] = wf.getInfoFor(ro,'review_state','None')
    82     row['is_editable'] = mtool.checkPermission('Modify portal content', ro)
    83     if rd.semester == 1:
    84         first.append(row)
    85     else:
    86         second.append(row)
    87 first.sort()
    88 second.sort()
    89 gpaf = 0.0
    90 if course_count:
    91     gpaf = (float(sum)/course_count)
    92 gpa = "%4.2f" % gpaf
    93 info['doc'].edit(mapping={'gpa': gpaf})
    94 info['first'] = first
    95 info['second'] = second
     72carry_overs.sort(cmp_semester)
     73info['carry_overs'] = carry_overs
     74normal.sort(cmp_semester)
     75info['normal'] = normal
    9676return info
  • WAeUP_SRP/trunk/skins/waeup_student/student_index.py

    r1368 r1380  
    1212return the current student_index_html
    1313"""
     14from Products.AdvancedQuery import Eq, Between, Le,In
     15evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery
    1416
    1517request = context.REQUEST
    16 redirect = request.RESPONSE.redirect
     18session = request.SESSION
     19response = request.RESPONSE
     20redirect = response.redirect
    1721pm = context.portal_membership
    1822member = pm.getAuthenticatedMember()
     
    3842    elif context.portal_type == 'Payment':
    3943        return context.payment_receipt()
     44    elif context.portal_type == 'StudentStudyLevel':
     45        if context.objectIds():
     46            return context.study_level_view()
     47        student = context.students_catalog(id=context.getStudentId())[0]
     48        cert_id = student.course
     49        in_progress =  session.get('in_progress','finished')
     50        if in_progress == 'finished':
     51            session.set('in_progress','started')
     52            view = context.in_progress_view(refresh=3,page='study_level_view')
     53            response.setHeader('Content-type','text/html; charset=ISO-8859-15')
     54            response.setHeader('Content-length','%d' % (len(view)))
     55            response.setStatus('OK')
     56            response.write(view)
     57            response.write('')
     58        elif in_progress == 'started':
     59            return
     60        #from Products.zdb import set_trace;set_trace()
     61        results = context.results_import(matric_no = student.matric_no)
     62        carry_overs = [brain for brain in results if brain.GRADE in ('D','E','F')]
     63        l = []
     64        for co in carry_overs:
     65            d = context.getCourseInfo(co.CosCode)
     66            d['grade'] = co.GRADE
     67            d['carry_level'] = co.CarryLevel
     68            cr_id = context.invokeFactory('StudentCourseResult',"%s_co" % co.CosCode)
     69            getattr(context,cr_id).getContent().edit(mapping=d)
     70        res = context.portal_catalog(portal_type="Certificate", id = cert_id)
     71        l = []
     72        if res:
     73            cert = res[0]
     74            path = cert.getPath()
     75            query = Eq("path",path) &\
     76                    Eq('portal_type','CertificateCourse') &\
     77                    Eq('SearchableText', "%s" % student.level)
     78            courses = evalAdvancedQuery(query)
     79            for c in courses:
     80                d = context.getCourseInfo(c.getId)
     81                cr_id = context.invokeFactory('StudentCourseResult',c.getId)
     82                d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective')
     83                getattr(context,cr_id).getContent().edit(mapping=d)
     84        session.set('in_progress','finished')
     85        return "finished"
    4086    students_url = "%s/campus/students" % (context.portal_url())
    4187    id = str(member)
  • WAeUP_SRP/trunk/skins/waeup_student/study_course_view.pt

    r1096 r1380  
    1 <metal:html tal:define="is_so context/isSectionOfficer;
    2                         s_info context/getStudentInfo;"
    3                         >
    4   <span tal:condition="not: s_info">
    5     <span tal:content="here/illegal_view" />
    6   </span>
    7   <metal:block tal:condition="s_info">             
    8   <span tal:define="info context/getStudyCourseInfo">
     1<metal:html>
    92  <metal:body use-macro="here/waeup_content_master/macros/master">
    10     <metal:block fill-slot="header">
     3    <metal:block fill-slot="header" 
     4                 tal:define="global info context/getStudyCourseInfo;
     5                 global is_so info/is_so;
     6                 "
     7                 >
    118      <a href=""
    129         tal:attributes="href string:${here/academicsParent}">
     
    1512      </a>
    1613      <h3>
    17          <span tal:condition="python:is_so and s_info">
    18            <span tal:content="s_info/student/Title" />:
     14         <span tal:condition="python:is_so and info">
     15           <span tal:content="info/student/Title" />:
    1916         </span>
    2017        <span tal:content="here/title_or_id" />
     
    2522      <span tal:omit-tag="" tal:condition="nothing"
    2623            tal:content="structure python: info['doc'].render(layout_mode='view')" />
    27       <table tal:define="sc python: s_info['course_doc']">
     24      <table tal:define="sc python: info['course_doc']">
    2825        <tr>
    2926          <td width="180px">Certificate:</td>
     
    9794 
    9895  </metal:body>
    99   </span> 
    100   </metal:block>
    10196</metal:html>
  • WAeUP_SRP/trunk/skins/waeup_student/study_level_view.pt

    r913 r1380  
    1 <metal:html tal:define="info context/getStudyLevelInfo;
    2             is_so context/isSectionOfficer;
    3             s_info context/getStudentInfo;"
    4             >
     1<metal:html>
    52  <metal:body use-macro="here/waeup_content_master/macros/master">
    6     <metal:block fill-slot="header">
     3    <metal:block fill-slot="header"
     4                 tal:define="global info context/getStudyLevelInfo;
     5                 global is_so context/isSectionOfficer;"
     6                 >
    77      <a href=""
    88         tal:attributes="href string:${here/academicsParent}">
     
    1111      </a>
    1212      <h3>
    13          <span tal:condition="python:is_so and s_info">
    14            <span tal:content="s_info/student/Title" />:
    15          </span>
    16          <span tal:content="here/title_or_id" />
     13        <span tal:condition="python:is_so and s_info">
     14          <span tal:content="info/student/name" />:
     15        </span>
     16        <span tal:content="here/title_or_id" />
    1717      </h3>
    1818      <br />
    19       <div tal:condition="python:0" tal:content="info/container_path"/>
    20       <div tal:condition="python:0" tal:content="info/cert_id"/>
    21       <div tal:condition="python:0" tal:content="info/gpa"/>
    2219    </metal:block>
    2320    <metal:main fill-slot="main" tal:condition="python:1">
    24       <span tal:omit-tag="" 
    25             tal:content="structure python: info['doc'].render(layout_mode='view')" />
    26      
    27       <form action="" method="post" class="group"
    28             tal:attributes="action info/action"
    29             >
     21      <form action="." method="post" class="group">
     22        <h3>Carryover Courses</h3>
    3023        <table tal:condition="python: 1" class="contentListing" width="100%" summary="content layout" id="folder_content">     
    31           <span tal:repeat="sem python:('first','second')">
    32             <tr><th colspan="3" tal:content="python: test(sem == 'first','First Semester', 'Second Semester')" />
    33             <tr tal:repeat="row python: info[sem]"
    34                 tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')">
    35               <td align="left" valign="middle" style="width: 5px;"
    36                   tal:condition="python:1 and is_so">
    37                 <input type="checkbox" name="ids:list" value="" id="" class="noborder"
    38                        tal:condition="is_so"
    39                        tal:define="id row/id"
    40                        tal:attributes="value id;
    41                        id python:'cb_' + id;
    42                        checked python:id in info['choosen_ids'];"
    43                        />
    44                 </td>
    45                 <td><a href="view" tal:attributes="href string:${row/url}">
    46                     <strong tal:content="row/title" /></a> </td>
    47                 <td tal:content="row/id"></td>
    48                 <td tal:content="row/semester"></td>
    49                 <td tal:content="row/credits"></td>
    50                 <td tal:condition="is_so" tal:content="row/score"></td>
    51                 <td tal:content="row/grade"></td>
    52                 <td tal:content="row/weight"></td>
    53                 <td tal:condition="python:0" tal:content="row/sum"></td>
    54                 <td tal:condition="python:0" tal:content="row/count"></td>
    55                 <td tal:condition="row/is_editable" tal:content="row/review_state"> </td>
    56                 <td>
    57                 <a tal:condition="row/is_editable"
    58                     href="edit" tal:attributes="href string:${row/url}/external_edit_form"
    59                     target="edit"
    60                     onclick="javascript:window.open('','edit','width=600, height=700, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')">
    61                     [edit]
    62                     </a>
    63                 </td>
    64               </tr>
    65             </span>
    66           </table>
     24          <tr tal:repeat="row info/carry_overs"
     25              tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')">
     26            <td align="left" valign="middle" style="width: 5px;">
     27              <input type="checkbox" name="ids:list" value="" id="" class="noborder"
     28                     tal:define="id row/code"
     29                     tal:attributes="value id;
     30                     id python:'cb_' + id;
     31                     checked python:id in info['choosen_ids'];"
     32                     />
     33            </td>
     34            <td width="80%" tal:content="row/title"></td>
     35            <td width="8%" tal:content="row/code"></td>
     36            <td width="2%" tal:content="row/semester"></td>
     37            <td width="2%" tal:content="row/credits"></td>
     38            <td width="8%" tal:content="row/grade|nothing"></td>
     39          </tr>
     40        </table>
     41        <h3>Session Courses</h3>
     42        <table tal:condition="python: 1" class="contentListing" width="100%" summary="content layout" id="folder_content">     
     43          <tr tal:repeat="row info/normal"
     44              tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')">
     45            <td align="left" valign="middle" style="width: 5px;">
     46              <input type="checkbox" name="ids:list" value="" id="" class="noborder"
     47                     tal:define="id row/code"
     48                     tal:attributes="value id;
     49                     id python:'cb_' + id;
     50                     checked python:id in info['choosen_ids'];"
     51                     />
     52            </td>
     53            <td width="80%" tal:content="row/title"></td>
     54            <td width="8%" tal:content="row/code"></td>
     55            <td width="2%" tal:content="row/semester"></td>
     56            <td width="2%" tal:content="row/credits"></td>
     57            <td width="8%" tal:content="row/coe|nothing"></td>
     58          </tr>
     59        </table>
    6760        <table width="100%" cellspacing="0" cellpadding="2"
    6861               class="folderButtons">
     
    7063            <td align="left" valign="top" rowspan="3"></td>
    7164            <td align="left" valign="top">
    72               <span tal:condition="python:1 and is_so">
     65              <span tal:condition="python:1">
    7366                <input type="button" value="button_select_all" class="context"
    7467                       onclick="someJavaScriptFunctionThatWillBeReplaced"
     
    7770                       % (cpsmcat('button_select_all'), cpsmcat('button_deselect_all'))"
    7871                       />
    79                 <input tal:condition="python:0" type="submit" name="approve_checked:method"
    80                        class="context" value="Approve" />
     72                <input tal:condition="python:1" type="submit" name="register_checked:method"
     73                       class="context" value="Register" />
    8174                <input tal:condition="python:0" type="submit" name="retract_checked:method"
    8275                       class="context" value="Retract" />
  • WAeUP_SRP/trunk/skins/waeup_utilities/getFromData_entry_mode.py

    r1334 r1380  
    1919if app is None:
    2020    return None
     21#from Products.zdb import set_trace;set_trace()
    2122em = app.getContent().entry_mode
    2223if em:
  • WAeUP_SRP/trunk/skins/waeup_utilities/reindex_entry_mode.py

    r1363 r1380  
    1212reindex students_catalog entry_mode index
    1313"""
     14request = context.REQUEST
     15session = request.SESSION
     16response = request.RESPONSE
     17students = context.portal_url.getPortalObject().campus.students
     18def rwrite(s):
     19    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
     20    #response.setHeader('Content-length','%d' % (len(s)))
     21    #response.setStatus('OK')
     22    response.write(s)
     23   
    1424cat = context.students_catalog
    15 
     25ems = cat.uniqueValuesFor('entry_mode')
     26rwrite("entry_mode values: %s<br />\n" % (str(ems)))
     27for em in ems:
     28    res = cat(entry_mode = em)
     29    rwrite("entry_mode: %s = %d<br />\n" % (em,len(res)))
     30#from Products.zdb import set_trace;set_trace()
    1631sbrains = cat()
     32count = 0
     33lc = 1
     34rwrite("%3d " % lc)
    1735for sb in sbrains:
    1836    normalized = False
    19     em= context.getFromData_entry_mode(sb.id)
    20     if em:
     37    em = context.getFromData_entry_mode(sb.id)
     38    ec = 'x'
     39    if em is None:
     40        ec = 'n'
     41        em = 'None'
     42    if em in ('UME','DE'):
     43        ec = 'C'
    2144        normalized = True
    2245    elif sb.entry_mode in ('DIRECT', 'DIRECT ENTRY',):
     46        ec = 'D'
    2347        em = 'DE'
    2448        normalized = True
    2549    elif sb.entry_mode in ('U.M.E', 'UNE',):
     50        ec = 'U'
    2651        em ="UME"
    2752        normalized = True
     53    elif not sb.entry_mode:
     54        ec = 'u'
     55        em ="UME"
     56        normalized = True
     57    if ec != "C" and em != sb.entry_mode:
     58        #from Products.zdb import set_trace;set_trace()
     59        app = getattr(getattr(students,sb.id),'application',None)
     60        ec = 'a'
     61        if app is not None:
     62            ec = 'A'
     63            app.getContent().edit(mapping={'entry_mode': sb.entry_mode})
    2864    if normalized:
    2965        cat.modifyRecord(id = sb.id,
    3066                         entry_mode = em)
     67    rwrite(ec)
     68    count += 1
     69    if count > 60:
     70        lc += 1
     71        rwrite("<br />\n%3d " % lc)
     72        count = 0
    3173
Note: See TracChangeset for help on using the changeset viewer.