Index: WAeUP_SRP/trunk/skins/waeup_academics/getCourseInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_academics/getCourseInfo.py	(revision 1380)
+++ WAeUP_SRP/trunk/skins/waeup_academics/getCourseInfo.py	(revision 1380)
@@ -0,0 +1,26 @@
+## Script (Python) "getCourseInfo"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=code
+##title=
+##
+# $Id$
+"""
+return course-data from courses_catalog
+"""
+cat = context.courses_catalog
+d = {}
+res = cat(code=code)
+if res:
+    course = res[0]
+    for field in cat.schema():
+        d[field] = getattr(course,field)
+else:
+    for field in cat.schema():
+        d[field] = "-"
+    d['title'] = "unknown"
+    d['code'] = code
+return d
Index: WAeUP_SRP/trunk/skins/waeup_student/getStudyCourseInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/getStudyCourseInfo.py	(revision 1378)
+++ WAeUP_SRP/trunk/skins/waeup_student/getStudyCourseInfo.py	(revision 1380)
@@ -18,19 +18,45 @@
 
 info = {}
+info['is_so'] = context.isSectionOfficer()
 info['action'] = "%s" % context.campus.absolute_url()
 info['choosen_ids'] = request.get('ids',[])
-info['doc'] = context.getContent()
+course  = info['doc'] = context.getContent()
+student_id = context.getStudentId()
+res = context.students_catalog(id = student_id)
+if not res:
+    return None
+sbrain = res[0]
+cert_id = sbrain.course
+res = context.portal_catalog(portal_type = "Certificate", id = cert_id)
+ci = {}
+if res:
+    info['cert_id'] = cert_id
+    brain = res[0]
+    ci['study_course'] = brain.getId
+    ci['title'] = brain.Title
+    pl = brain.getPath().split('/')
+    ci['faculty'] = pl[-4]
+    ci['department'] = pl[-3]
+    info['course_doc'] = ci
+else:
+    info['course'] = None
 items = []
-levels = context.objectValues()
+current_level = sbrain.level
+levels = context.objectIds()
+if current_level not in levels:
+    context.invokeFactory('StudentStudyLevel',"%s" % current_level)
+    level = getattr(context,"%s" % current_level)
+    level.getContent().edit(mapping={'session': "2006/2007"})
+    context.portal_workflow.doActionFor(level,'open')
+    context.portal_workflow.doActionFor(level,'close_for_edit')
+    levels.append(current_level)
+#from Products.zdb import set_trace;set_trace()
 for l in levels:
     row = {}
-    ld = l.getContent()
-    row['id'] = l.getId()
-    if hasattr(ld,'Title'):
-        row['title'] = ld.Title()
-    else:
-        row['title'] = getattr(ld,'title','no title')
-    row['url'] = l.absolute_url()
+    row['id'] = l
+    row['title'] = "Level %s" % l
+    row['url'] = "%s/%s" % (context.absolute_url(),l)
     items.append(row)
+
 info['items'] = items
 return info
Index: WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py	(revision 1378)
+++ WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py	(revision 1380)
@@ -12,4 +12,10 @@
 return Info about the Studylevel
 """
+from Products.AdvancedQuery import Eq, Between, Le,In
+evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery
+request = context.REQUEST
+session = request.SESSION
+response = request.RESPONSE
+
 def calculateGPA():
     """calculate the gpa"""
@@ -29,68 +35,42 @@
     return 0.0
 
-request = context.REQUEST
+def cmp_semester(a,b):
+    if a['semester'] == b['semester']:
+        return 0
+    if a['semester'] > b['semester']:
+        return 1
+    return -1
+
 
 wf = context.portal_workflow
 mtool = context.portal_membership
-path_info = request.get('PATH_INFO').split('/')
-try:
-    i = int(path_info[-1])
-    p = 0
-except:
-    p = 1
+student_id = context.getStudentId()
+
 info = {}
-pt = request.get('PATH_TRANSLATED').split('/')
-
-student_id = pt[-(3+p)]
-level_id = pt[-(1+p)]
-info['action'] = "%s" % context.absolute_url()
+info['student'] = student = context.students_catalog(id=student_id)[0]
 info['choosen_ids'] = request.get('ids',[])
 info['doc'] = context.getContent()
-study_course = context.aq_parent.getContent()
-cert_id = study_course.study_course
-brain = context.portal_catalog(meta_type="Student",id = student_id)[-1]
-cp = brain.getPath()
-info['container_path'] = cp
+##study_course = context.aq_parent.getContent()
+##cert_id = study_course.study_course
+cert_id = student.course
 info['cert_id'] = cert_id
+normal = []
+carry_overs = []
+for id,obj in context.objectItems():
+    if id.endswith('_co'):
+        d = context.getCourseInfo(id[:-3])
+        d['grade'] = obj.getContent().grade
+        carry_overs.append(d)
+    else:
+        d = context.getCourseInfo(id)
+        coe = obj.getContent().core_or_elective
+        d['coe'] = 'Core'
+        if not coe:
+            d['coe'] = 'Elective'
+        normal.append(d)
 
-res = context.portal_catalog(meta_type="StudentCourseResult",
-                             container_path="%s/study_course/%s" % (cp,level_id))
-first = []
-second = []
-sum = 0
-course_count = 0
-for r in res:
-    row = {}
-    ro = r.getObject()
-    rd = ro.getContent()
-    row['id'] = ro.getId()
-    row['credits'] = rd.credits
-    if row['credits'] and rd.grade:
-        credits = int(rd.credits)
-        sum += credits * ['F','E','D','C','B','A'].index(rd.grade)
-        course_count += credits
-    row['sum'] = sum
-    row['count'] = course_count
-    row['title'] = rd.title
-    #row['core'] = rd.core_or_elective
-    row['semester'] = rd.semester
-    row['score'] = rd.score
-    row['grade'] = rd.grade
-    row['weight'] = rd.weight
-    row['url'] = ro.absolute_url()
-    row['review_state'] = wf.getInfoFor(ro,'review_state','None')
-    row['is_editable'] = mtool.checkPermission('Modify portal content', ro)
-    if rd.semester == 1:
-        first.append(row)
-    else:
-        second.append(row)
-first.sort()
-second.sort()
-gpaf = 0.0
-if course_count:
-    gpaf = (float(sum)/course_count)
-gpa = "%4.2f" % gpaf
-info['doc'].edit(mapping={'gpa': gpaf})
-info['first'] = first
-info['second'] = second
+carry_overs.sort(cmp_semester)
+info['carry_overs'] = carry_overs
+normal.sort(cmp_semester)
+info['normal'] = normal
 return info
Index: WAeUP_SRP/trunk/skins/waeup_student/student_index.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/student_index.py	(revision 1378)
+++ WAeUP_SRP/trunk/skins/waeup_student/student_index.py	(revision 1380)
@@ -12,7 +12,11 @@
 return the current student_index_html
 """
+from Products.AdvancedQuery import Eq, Between, Le,In
+evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery
 
 request = context.REQUEST
-redirect = request.RESPONSE.redirect
+session = request.SESSION
+response = request.RESPONSE
+redirect = response.redirect
 pm = context.portal_membership
 member = pm.getAuthenticatedMember()
@@ -38,4 +42,46 @@
     elif context.portal_type == 'Payment':
         return context.payment_receipt()
+    elif context.portal_type == 'StudentStudyLevel':
+        if context.objectIds():
+            return context.study_level_view()
+        student = context.students_catalog(id=context.getStudentId())[0]
+        cert_id = student.course
+        in_progress =  session.get('in_progress','finished')
+        if in_progress == 'finished':
+            session.set('in_progress','started')
+            view = context.in_progress_view(refresh=3,page='study_level_view')
+            response.setHeader('Content-type','text/html; charset=ISO-8859-15')
+            response.setHeader('Content-length','%d' % (len(view)))
+            response.setStatus('OK')
+            response.write(view)
+            response.write('')
+        elif in_progress == 'started':
+            return
+        #from Products.zdb import set_trace;set_trace()
+        results = context.results_import(matric_no = student.matric_no)
+        carry_overs = [brain for brain in results if brain.GRADE in ('D','E','F')]
+        l = []
+        for co in carry_overs:
+            d = context.getCourseInfo(co.CosCode)
+            d['grade'] = co.GRADE
+            d['carry_level'] = co.CarryLevel
+            cr_id = context.invokeFactory('StudentCourseResult',"%s_co" % co.CosCode)
+            getattr(context,cr_id).getContent().edit(mapping=d)
+        res = context.portal_catalog(portal_type="Certificate", id = cert_id)
+        l = []
+        if res:
+            cert = res[0]
+            path = cert.getPath()
+            query = Eq("path",path) &\
+                    Eq('portal_type','CertificateCourse') &\
+                    Eq('SearchableText', "%s" % student.level)
+            courses = evalAdvancedQuery(query)
+            for c in courses:
+                d = context.getCourseInfo(c.getId)
+                cr_id = context.invokeFactory('StudentCourseResult',c.getId)
+                d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective')
+                getattr(context,cr_id).getContent().edit(mapping=d)
+        session.set('in_progress','finished')
+        return "finished"
     students_url = "%s/campus/students" % (context.portal_url())
     id = str(member)
Index: WAeUP_SRP/trunk/skins/waeup_student/study_course_view.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/study_course_view.pt	(revision 1378)
+++ WAeUP_SRP/trunk/skins/waeup_student/study_course_view.pt	(revision 1380)
@@ -1,12 +1,9 @@
-<metal:html tal:define="is_so context/isSectionOfficer;
-                        s_info context/getStudentInfo;"
-                        >
-  <span tal:condition="not: s_info">
-    <span tal:content="here/illegal_view" />
-  </span>
-  <metal:block tal:condition="s_info">             
-  <span tal:define="info context/getStudyCourseInfo">
+<metal:html>
   <metal:body use-macro="here/waeup_content_master/macros/master">
-    <metal:block fill-slot="header">
+    <metal:block fill-slot="header"  
+                 tal:define="global info context/getStudyCourseInfo;
+                 global is_so info/is_so;
+                 "
+                 >
       <a href=""
          tal:attributes="href string:${here/academicsParent}">
@@ -15,6 +12,6 @@
       </a>
       <h3> 
-         <span tal:condition="python:is_so and s_info">
-           <span tal:content="s_info/student/Title" />:
+         <span tal:condition="python:is_so and info">
+           <span tal:content="info/student/Title" />:
          </span>
         <span tal:content="here/title_or_id" />
@@ -25,5 +22,5 @@
       <span tal:omit-tag="" tal:condition="nothing"
             tal:content="structure python: info['doc'].render(layout_mode='view')" />
-      <table tal:define="sc python: s_info['course_doc']">
+      <table tal:define="sc python: info['course_doc']">
         <tr>
           <td width="180px">Certificate:</td> 
@@ -97,5 +94,3 @@
  
   </metal:body>
-  </span>  
-  </metal:block>
 </metal:html>
Index: WAeUP_SRP/trunk/skins/waeup_student/study_level_view.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/study_level_view.pt	(revision 1378)
+++ WAeUP_SRP/trunk/skins/waeup_student/study_level_view.pt	(revision 1380)
@@ -1,8 +1,8 @@
-<metal:html tal:define="info context/getStudyLevelInfo;
-            is_so context/isSectionOfficer;
-            s_info context/getStudentInfo;"
-            >
+<metal:html>
   <metal:body use-macro="here/waeup_content_master/macros/master">
-    <metal:block fill-slot="header">
+    <metal:block fill-slot="header" 
+                 tal:define="global info context/getStudyLevelInfo;
+                 global is_so context/isSectionOfficer;"
+                 >
       <a href=""
          tal:attributes="href string:${here/academicsParent}">
@@ -11,58 +11,51 @@
       </a>
       <h3> 
-         <span tal:condition="python:is_so and s_info">
-           <span tal:content="s_info/student/Title" />:
-         </span>
-         <span tal:content="here/title_or_id" />
+        <span tal:condition="python:is_so and s_info">
+          <span tal:content="info/student/name" />:
+        </span>
+        <span tal:content="here/title_or_id" />
       </h3>
       <br />
-      <div tal:condition="python:0" tal:content="info/container_path"/>
-      <div tal:condition="python:0" tal:content="info/cert_id"/>
-      <div tal:condition="python:0" tal:content="info/gpa"/>
     </metal:block>
     <metal:main fill-slot="main" tal:condition="python:1">
-      <span tal:omit-tag=""  
-            tal:content="structure python: info['doc'].render(layout_mode='view')" />
-      
-      <form action="" method="post" class="group"
-            tal:attributes="action info/action"
-            >
+      <form action="." method="post" class="group">
+        <h3>Carryover Courses</h3>
         <table tal:condition="python: 1" class="contentListing" width="100%" summary="content layout" id="folder_content">      
-          <span tal:repeat="sem python:('first','second')">
-            <tr><th colspan="3" tal:content="python: test(sem == 'first','First Semester', 'Second Semester')" />
-            <tr tal:repeat="row python: info[sem]"
-                tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')">
-              <td align="left" valign="middle" style="width: 5px;" 
-                  tal:condition="python:1 and is_so">
-                <input type="checkbox" name="ids:list" value="" id="" class="noborder"
-                       tal:condition="is_so"
-                       tal:define="id row/id"
-                       tal:attributes="value id;
-                       id python:'cb_' + id;
-                       checked python:id in info['choosen_ids'];" 
-                       />
-                </td>
-                <td><a href="view" tal:attributes="href string:${row/url}">
-                    <strong tal:content="row/title" /></a> </td>
-                <td tal:content="row/id"></td>
-                <td tal:content="row/semester"></td>
-                <td tal:content="row/credits"></td>
-                <td tal:condition="is_so" tal:content="row/score"></td>
-                <td tal:content="row/grade"></td>
-                <td tal:content="row/weight"></td>
-                <td tal:condition="python:0" tal:content="row/sum"></td>
-                <td tal:condition="python:0" tal:content="row/count"></td>
-                <td tal:condition="row/is_editable" tal:content="row/review_state"> </td>
-                <td> 
-                <a tal:condition="row/is_editable"
-                    href="edit" tal:attributes="href string:${row/url}/external_edit_form"
-                    target="edit"
-                    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')">
-                    [edit]
-                    </a> 
-                </td>
-              </tr>
-            </span>
-          </table>
+          <tr tal:repeat="row info/carry_overs"
+              tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')">
+            <td align="left" valign="middle" style="width: 5px;">
+              <input type="checkbox" name="ids:list" value="" id="" class="noborder"
+                     tal:define="id row/code"
+                     tal:attributes="value id;
+                     id python:'cb_' + id;
+                     checked python:id in info['choosen_ids'];" 
+                     />
+            </td>
+            <td width="80%" tal:content="row/title"></td>
+            <td width="8%" tal:content="row/code"></td>
+            <td width="2%" tal:content="row/semester"></td>
+            <td width="2%" tal:content="row/credits"></td>
+            <td width="8%" tal:content="row/grade|nothing"></td>
+          </tr>
+        </table>
+        <h3>Session Courses</h3>
+        <table tal:condition="python: 1" class="contentListing" width="100%" summary="content layout" id="folder_content">      
+          <tr tal:repeat="row info/normal"
+              tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')">
+            <td align="left" valign="middle" style="width: 5px;">
+              <input type="checkbox" name="ids:list" value="" id="" class="noborder"
+                     tal:define="id row/code"
+                     tal:attributes="value id;
+                     id python:'cb_' + id;
+                     checked python:id in info['choosen_ids'];" 
+                     />
+            </td>
+            <td width="80%" tal:content="row/title"></td>
+            <td width="8%" tal:content="row/code"></td>
+            <td width="2%" tal:content="row/semester"></td>
+            <td width="2%" tal:content="row/credits"></td>
+            <td width="8%" tal:content="row/coe|nothing"></td>
+          </tr>
+        </table>
         <table width="100%" cellspacing="0" cellpadding="2"
                class="folderButtons">
@@ -70,5 +63,5 @@
             <td align="left" valign="top" rowspan="3"></td>
             <td align="left" valign="top">
-              <span tal:condition="python:1 and is_so">
+              <span tal:condition="python:1">
                 <input type="button" value="button_select_all" class="context"
                        onclick="someJavaScriptFunctionThatWillBeReplaced"
@@ -77,6 +70,6 @@
                        % (cpsmcat('button_select_all'), cpsmcat('button_deselect_all'))"
                        />
-                <input tal:condition="python:0" type="submit" name="approve_checked:method"
-                       class="context" value="Approve" />
+                <input tal:condition="python:1" type="submit" name="register_checked:method"
+                       class="context" value="Register" />
                 <input tal:condition="python:0" type="submit" name="retract_checked:method"
                        class="context" value="Retract" />
Index: WAeUP_SRP/trunk/skins/waeup_utilities/getFromData_entry_mode.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_utilities/getFromData_entry_mode.py	(revision 1378)
+++ WAeUP_SRP/trunk/skins/waeup_utilities/getFromData_entry_mode.py	(revision 1380)
@@ -19,4 +19,5 @@
 if app is None:
     return None
+#from Products.zdb import set_trace;set_trace()
 em = app.getContent().entry_mode
 if em:
Index: WAeUP_SRP/trunk/skins/waeup_utilities/reindex_entry_mode.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_utilities/reindex_entry_mode.py	(revision 1378)
+++ WAeUP_SRP/trunk/skins/waeup_utilities/reindex_entry_mode.py	(revision 1380)
@@ -12,20 +12,62 @@
 reindex students_catalog entry_mode index
 """
+request = context.REQUEST
+session = request.SESSION
+response = request.RESPONSE
+students = context.portal_url.getPortalObject().campus.students
+def rwrite(s):
+    response.setHeader('Content-type','text/html; charset=ISO-8859-15')
+    #response.setHeader('Content-length','%d' % (len(s)))
+    #response.setStatus('OK')
+    response.write(s)
+    
 cat = context.students_catalog
-
+ems = cat.uniqueValuesFor('entry_mode')
+rwrite("entry_mode values: %s<br />\n" % (str(ems)))
+for em in ems:
+    res = cat(entry_mode = em)
+    rwrite("entry_mode: %s = %d<br />\n" % (em,len(res)))
+#from Products.zdb import set_trace;set_trace()
 sbrains = cat()
+count = 0
+lc = 1
+rwrite("%3d " % lc)
 for sb in sbrains:
     normalized = False
-    em= context.getFromData_entry_mode(sb.id)
-    if em:
+    em = context.getFromData_entry_mode(sb.id)
+    ec = 'x'
+    if em is None:
+        ec = 'n'
+        em = 'None'
+    if em in ('UME','DE'):
+        ec = 'C'
         normalized = True
     elif sb.entry_mode in ('DIRECT', 'DIRECT ENTRY',):
+        ec = 'D'
         em = 'DE'
         normalized = True
     elif sb.entry_mode in ('U.M.E', 'UNE',):
+        ec = 'U'
         em ="UME"
         normalized = True
+    elif not sb.entry_mode:
+        ec = 'u'
+        em ="UME"
+        normalized = True
+    if ec != "C" and em != sb.entry_mode:
+        #from Products.zdb import set_trace;set_trace()
+        app = getattr(getattr(students,sb.id),'application',None)
+        ec = 'a'
+        if app is not None:
+            ec = 'A'
+            app.getContent().edit(mapping={'entry_mode': sb.entry_mode})
     if normalized:
         cat.modifyRecord(id = sb.id,
                          entry_mode = em)
+    rwrite(ec)
+    count += 1
+    if count > 60:
+        lc += 1
+        rwrite("<br />\n%3d " % lc)
+        count = 0
 
