Index: WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py	(revision 726)
+++ WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py	(revision 727)
@@ -1,3 +1,3 @@
-## Script (Python) "cpsdocument_edit"
+# Script (Python) "cpsdocument_edit"
 ##bind container=container
 ##bind context=context
@@ -12,13 +12,4 @@
 return Info about the Studylevel
 """
-def findCourse(cid):
-    ''' find the course'''
-    res = context.portal_catalog({'meta_type': 'Course',
-                                  'id': cid})
-    if len(res) < 1:
-        return None
-    course = res[0].getObject().getContent()
-    return course
-
 def calculateGPA():
     """calculate the gpa"""
@@ -76,15 +67,12 @@
     rd = ro.getContent()
     row['id'] = ro.getId()
-    course = findCourse(ro.getId())
-    row['credits'] = 0
-    if course:
-        row['credits'] = course.credits
+    row['credits'] = rd.credits
     if row['credits'] and rd.grade:
-        credits = int(course.credits)
+        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['title'] = rd.title
     #row['core'] = rd.core_or_elective
     row['semester'] = rd.semester
Index: WAeUP_SRP/trunk/skins/waeup_student/searchStudents.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/searchStudents.py	(revision 726)
+++ WAeUP_SRP/trunk/skins/waeup_student/searchStudents.py	(revision 727)
@@ -12,5 +12,10 @@
 return Info about the current Student
 """
-#from Products.ZCTextIndex.QueryParser import ParseError,QueryError
+try:
+    from Products.AdvancedQuery import Eq, Between, Le
+    evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery
+except:
+    evalAdvancedQuery = None
+    
 request = context.REQUEST
 form = request.form
@@ -53,4 +58,7 @@
 err = False
 with_review = state != "all"
+onlyreview = with_review and not term
+with_level_results = state.startswith("category") and evalAdvancedQuery is not None
+bools = "with_review = %s<br\> onlyreview = %s<br\> with_level_results = %s" % (with_review,onlyreview,with_level_results)
 if not term and not with_review:
     psm = "You must specify a search string when searching 'all states'."
@@ -66,29 +74,40 @@
                              is_manager = is_manager,
                              )
-with_review = state != "all"
 items = []
 res = []
 portal_type_query = {'query':['Student','StudentApplication','StudentPersonal']}
 st_queries = ('jamb_reg_no','matric_no','name')
-onlyreview = with_review and not term
-if onlyreview:
-    res = catalog(portal_type='Student',
-                  review_state=state)
+query_step = 0
+if onlyreview and not with_level_results:
+    query_step = 1
+    query =  Eq('portal_type','Student') & Eq('review_state',state) 
+    res = evalAdvancedQuery(query)
+##    res = catalog(portal_type='Student',
+##                  review_state=state)
+elif onlyreview and with_level_results:
+    query_step = 2
+    query =  Eq('portal_type','StudentStudyLevel') & Eq('review_state',state) 
+    res = evalAdvancedQuery(query)
 elif what == "student_id":
     if with_review:
+        query_step = 3
         res = catalog(portal_type='Student',
                       id = term.strip(),
                       review_state=state)
     else:
+        query_step = 4
         res = catalog(portal_type='Student',
                       id = term.strip())
-elif what in st_queries:
+elif what in st_queries and not with_level_results:
     if what == "jamb_reg_no":
+        query_step = 5
         pt = 'StudentApplication'
         st = "%s*" % term.strip().lower()
     elif what == "matric_no":
+        query_step = 6
         pt = 'StudentClearance'
         st = "%s*" % term.strip().lower()
     elif what == "name":
+        query_step = 7
         pt = portal_type_query
         st = "%s*" % term.strip()
@@ -102,9 +121,36 @@
                              is_manager = is_manager,
                              )
+elif what in st_queries and with_level_results and evalAdvancedQuery:
+    if what == "jamb_reg_no":
+        query_step = 8
+        pt = 'StudentApplication'
+        st = "%s*" % term.strip().lower()
+    elif what == "matric_no":
+        query_step = 9
+        pt = 'StudentClearance'
+        st = "%s*" % term.strip().lower()
+    elif what == "name":
+        query_step = 10
+        pt = portal_type_query
+        st = "%s*" % term.strip()
+    query = Eq('portal_type',pt) & Eq('SearchableText',"%s*" % term.strip().lower())\
+                | Eq('portal_type','StudentStudyLevel') & Eq('review_state',state) 
+    try:
+        res = evalAdvancedQuery(query)
+    except:
+        return context.students_manager_view(rendered = rend,
+                             psm = 'Advanced Query failed' % term,
+                             #psm = "%s, %s" % (psm,ds),
+                             students = items,
+                             is_manager = is_manager,
+                             )
 students = []
+raw_res = len(res)
 if res:
     for r in res:
-        if r.portal_type in ("StudentApplication","StudentPersonal"):
+        if r.portal_type in ("StudentApplication","StudentPersonal",):
             student = r.getObject().aq_parent
+        elif r.portal_type in ("StudentStudyLevel",):
+            student = r.getObject().aq_parent.aq_parent
 ##            pp = '/'.join(r.getPath().split('/')[:-1])
 ##            student_cat = catalog(pathindex=pp,portal_type='Student')[0]
@@ -114,5 +160,5 @@
             student = r.getObject()
         student_rs = wf.getInfoFor(student,'review_state','keiner')
-        if (with_review and student_rs != state) or student in items:
+        if (with_review and student_rs != state and not with_level_results) or student in items:
             continue
         items.append(student)
@@ -126,5 +172,5 @@
                              )
 return context.students_manager_view(rendered = rend,
-                             psm = """Your search for "%s" in %s with state %s failed.""" % (st,what,state),
+                             psm = """Step: %s found: %s Your search for "%s" in %s with state %s failed.<br\>%s""" % (query_step,raw_res,st,what,state,bools),
                              students = students,
                              is_manager = is_manager,
