Index: /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/browser_templates/levelreportgeneratorpage.pt
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/browser_templates/levelreportgeneratorpage.pt	(revision 14424)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/browser_templates/levelreportgeneratorpage.pt	(revision 14425)
@@ -7,7 +7,13 @@
   </p>
   <br />
-  <label for="session" i18n:translate="">Department</label>
-  <select name="faccode_depcode" class="form-control half">
-    <span tal:repeat="items view/faccode_depcodes" tal:omit-tag="">
+  <label for="session" i18n:translate="">Certificate</label>
+  <input id="filterbox" class="kofa-filterbox form-control half"
+         placeholder="Enter search text, then select item below."
+         type="text" i18n:translate=""/>
+  <br />
+  <select id="filteredselect" name="faccode_depcode_certcode"
+          class="form-control half" size=5>
+      <span tal:repeat="items view/faccode_depcode_certcode"
+          tal:omit-tag="">
       <option
           tal:define="name python: items[1]; title python: items[0]"
@@ -19,15 +25,13 @@
   <br />
   <label for="session">Academic Session</label>
-  <div class="input">
-    <select name="session" class="form-control half">
-      <span tal:repeat="items view/sessions" tal:omit-tag="">
-        <option
-            tal:define="name python: items[1]; title python: items[0]"
-            tal:attributes="value name">
-          <span tal:replace="title">TITLE</span>
-        </option>
-      </span>
-    </select>
-  </div>
+  <select name="session" class="form-control half">
+    <span tal:repeat="items view/sessions" tal:omit-tag="">
+      <option
+          tal:define="name python: items[1]; title python: items[0]"
+          tal:attributes="value name">
+        <span tal:replace="title">TITLE</span>
+      </option>
+    </span>
+  </select>
   <br />
   <label for="session">Level</label>
Index: /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/level_report.py
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/level_report.py	(revision 14424)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/level_report.py	(revision 14425)
@@ -33,8 +33,8 @@
 class LevelReportGenerator(LevelReportGenerator):
 
-    def generate(self, site, faccode=None, depcode=None,
+    def generate(self, site, faccode=None, depcode=None, certcode=None,
                  session=None, level=None, author=None):
         result = CustomLevelReport(faccode=faccode, depcode=depcode,
-                             session=session, level=level, author=author)
+            certcode=certcode, session=session, level=level, author=author)
         return result
 
Index: /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/raw_score_report.py
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/raw_score_report.py	(revision 14424)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/raw_score_report.py	(revision 14425)
@@ -39,41 +39,28 @@
     faccode = Attribute('Faculty to report')
     depcode = Attribute('Department to report')
+    certcode = Attribute('Certzificate to report')
     creation_dt_string = Attribute('Human readable report creation datetime')
 
-def get_courses_1(faccode, depcode, session, level):
+def get_courses(faccode, depcode, certcode, session, level):
     """Method 1: Get certificate courses of a
-    certain department at a certain level.
+    certain department/certificate at a certain level.
     """
     site = grok.getSite()
     course_codes = []
     department = site['faculties'][faccode][depcode]
-    for cert in department.certificates.values():
-        for certcourse in cert.values():
+    if certcode == 'all':
+        for cert in department.certificates.values():
+            for certcourse in cert.values():
+                if certcourse.level == level:
+                    course_codes.append(certcourse.getCourseCode())
+    else:
+        certificate = site['faculties'][faccode][depcode].certificates[certcode]
+        for certcourse in certificate.values():
             if certcourse.level == level:
                 course_codes.append(certcourse.getCourseCode())
     return course_codes
 
-def get_courses_2(faccode, depcode, session, level):
-    """Method 2 (not used): Get all courses students of a certain
-    department have registered at a certain level.
-    """
-    cat = queryUtility(ICatalog, name="students_catalog")
-    result = cat.searchResults(
-        depcode = (depcode, depcode), faccode = (faccode, faccode)
-        )
-    course_codes = []
-    for stud in result:
-        if not stud['studycourse'].has_key(str(level)):
-            continue
-        level_obj = stud['studycourse'][str(level)]
-        if level_obj.level_session != session:
-            continue
-        for ticket in level_obj.values():
-            course_codes.append(ticket.code)
-    course_codes = sorted(list(set(course_codes)))
-    return course_codes
-
-def get_students(faccode, depcode, session, level, course_codes):
-    """Get students in a certain department who registered courses
+def get_students(faccode, depcode, certcode, session, level, course_codes):
+    """Get students in a certain department/certificate who registered courses
     in a certain session at a certain level.
 
@@ -81,6 +68,9 @@
     """
     cat = queryUtility(ICatalog, name="students_catalog")
+    if certcode == 'all':
+        certcode = None
     result = cat.searchResults(
-        depcode = (depcode, depcode), faccode = (faccode, faccode)
+        depcode = (depcode, depcode), faccode = (faccode, faccode),
+        certcode = (certcode, certcode)
         )
     table = []
@@ -183,4 +173,5 @@
     faccode = None
     depcode = None
+    certcode = None
 
     note = ""
@@ -193,7 +184,9 @@
 #"""
 
-    def __init__(self, faccode, depcode, session, level, author='System'):
+    def __init__(self, faccode, depcode, certcode, session, level,
+                 author='System'):
         super(RawScoreReport, self).__init__(
-            args=[faccode, depcode, session, level], kwargs={'author':author})
+            args=[faccode, depcode, certcode, session, level],
+                  kwargs={'author':author})
         site = grok.getSite()
         self.studylevelsource = StudyLevelSource().factory
@@ -206,6 +199,14 @@
         self.faccode = faccode
         self.depcode = depcode
+        self.certcode = certcode
         self.factitle = site['faculties'][faccode].longtitle
         self.deptitle = site['faculties'][faccode][depcode].longtitle
+        if self.certcode == 'all':
+            self.certtitle = translate(
+                _('All Certificates'), 'waeup.kofa',
+                target_language=self.portal_language)
+        else:
+            self.certtitle = site['faculties'][faccode][
+                depcode].certificates[certcode].longtitle
         self.author = author
         self.creation_dt_string = self.creation_dt.astimezone(
@@ -215,8 +216,9 @@
         self.data = dict()
         for level in self.past_levels:
-            course_codes = get_courses_1(faccode, depcode, session, level)
+            course_codes = get_courses(
+                faccode, depcode, certcode, session, level)
             self.course_codes[level] = course_codes
             self.data[level] = get_students(
-                faccode, depcode, session, self.levelcode, course_codes)
+                faccode, depcode, certcode, session, self.levelcode, course_codes)
 
     def create_pdf(self, job_id):
@@ -233,9 +235,10 @@
         pdf_data += [Paragraph(
                     translate(
-                        '${a}<br />${b}<br />Session: ${c}<br />Level: ${d}',
-                        mapping = {'a':self.factitle,
+                        '${a}<br />${b}<br />${c}<br /><br />Session: ${d}<br />Level: ${e}',
+                        mapping = {'a':self.certtitle,
                                    'b':self.deptitle,
-                                   'c':self.session,
-                                   'd':self.level,
+                                   'c':self.factitle,
+                                   'd':self.session,
+                                   'e':self.level,
                                    }),
                     STYLE["Normal"]),
@@ -260,6 +263,7 @@
         pdf = creator.create_pdf(
             pdf_data, None, doc_title, self.author,
-            doc_title + ' - %s/%s - %s - %s -' % (
-            self.faccode, self.depcode, self.levelcode, self.sessioncode),
+            doc_title + ' - %s/%s/%s - %s - %s -' % (
+            self.faccode, self.depcode, self.certcode,
+            self.levelcode, self.sessioncode),
             note=self.note
             )
@@ -272,8 +276,8 @@
     grok.name('raw_score_report')
 
-    def generate(self, site, faccode=None, depcode=None,
+    def generate(self, site, faccode=None, depcode=None, certcode=None,
                  session=None, level=None, author=None):
         result = RawScoreReport(faccode=faccode, depcode=depcode,
-                             session=session, level=level, author=author)
+            certcode=certcode, session=session, level=level, author=author)
         return result
 
@@ -302,6 +306,6 @@
 
     def _filename(self):
-        return 'RawScoreReport_%s_%s_%s_%s_%s.pdf' % (
-            self.context.faccode, self.context.depcode,
+        return 'RawScoreReport_%s_%s_%s_%s_%s_%s.pdf' % (
+            self.context.faccode, self.context.depcode, self.context.certcode,
             self.context.sessioncode, self.context.levelcode,
             self.context.creation_dt_string)
Index: /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/session_results_presentation.py
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/session_results_presentation.py	(revision 14424)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/session_results_presentation.py	(revision 14425)
@@ -33,7 +33,8 @@
 class CustomSessionResultsPresentationGenerator(SessionResultsPresentationGenerator):
 
-    def generate(self, site, faccode=None, depcode=None,
+    def generate(self, site, faccode=None, depcode=None, certcode=None,
                  session=None, level=None, author=None):
-        result = CustomSessionResultsPresentation(faccode=faccode, depcode=depcode,
-                             session=session, level=level, author=author)
+        result = CustomSessionResultsPresentation(faccode=faccode,
+            depcode=depcode, certcode=certcode, session=session,
+            level=level, author=author)
         return result
Index: /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_level_report.py
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_level_report.py	(revision 14424)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_level_report.py	(revision 14425)
@@ -20,5 +20,5 @@
     def test_iface(self):
         # ensure we fullfill interface contracts
-        obj = CustomLevelReport('fac1', 'dep1', 2010, 100)
+        obj = CustomLevelReport('fac1', 'dep1', 'CERT1', 2010, 100)
         verifyClass(ILevelReport, CustomLevelReport)
         verifyObject(ILevelReport, obj)
@@ -28,5 +28,5 @@
         # we can get a table with one student
         self.student['studycourse']['100']['Course1'].ca = 0
-        result = get_students('fac1', 'dep1', 2010, 100)
+        result = get_students('fac1', 'dep1', 'CERT1', 2010, 100)
         self.assertEqual(result,
             [(u'1234', u'TESTER, Bob', 30, 30, '5.000', 'NIL', '', 30, 30, '5.000', 'Proceed')])
@@ -35,5 +35,5 @@
     def test_create_pdf(self):
         self.student['studycourse']['100']['Course1'].ca = 0
-        report = CustomLevelReport('fac1', 'dep1', 2010, 100)
+        report = CustomLevelReport('fac1', 'dep1', 'CERT1', 2010, 100)
         result = report.create_pdf('JOB_ID')
         self.assertTrue(result.startswith('%PDF-'))
Index: /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_raw_score_report.py
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_raw_score_report.py	(revision 14424)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_raw_score_report.py	(revision 14425)
@@ -11,5 +11,5 @@
 from waeup.aaue.students.reports.raw_score_report import (
     get_students, RawScoreReport, IRawScoreReport,
-    get_courses_1 as get_courses)
+    get_courses)
 from waeup.aaue.testing import FunctionalLayer
 
@@ -29,5 +29,5 @@
     def test_iface(self):
         # ensure we fullfill interface contracts
-        obj = RawScoreReport('fac1', 'dep1', 2010, 100)
+        obj = RawScoreReport('fac1', 'dep1', 'CERT1', 2010, 100)
         verifyClass(IRawScoreReport, RawScoreReport)
         verifyObject(IRawScoreReport, obj)
@@ -36,5 +36,5 @@
     def test_get_courses(self):
         # we can get a list with one course code
-        result = get_courses('fac1', 'dep1', 2010, 100)
+        result = get_courses('fac1', 'dep1', 'CERT1', 2010, 100)
         self.assertEqual(result, [(u'Course1')])
         return
@@ -43,6 +43,6 @@
         # we can get a table with one student
         self.student['studycourse']['100']['Course1'].ca = 0
-        course_codes = get_courses('fac1', 'dep1', 2010, 100)
-        result = get_students('fac1', 'dep1', 2010, 100, course_codes)
+        course_codes = get_courses('fac1', 'dep1', 'CERT1', 2010, 100)
+        result = get_students('fac1', 'dep1', 'CERT1', 2010, 100, course_codes)
         self.assertEqual(result,
             [(u'1234', u'TESTER, Bob', {'Course1': (70, 'A')})])
@@ -68,5 +68,5 @@
         self.student.firstname = u'Osahenokese Tessy'
         self.student.lastname = u'Emwinyomwanru'
-        report = RawScoreReport('fac1', 'dep1', 2011, 200)
+        report = RawScoreReport('fac1', 'dep1', 'CERT1', 2011, 200)
         result = report.create_pdf('JOB_ID')
         self.assertTrue(result.startswith('%PDF-'))
Index: /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_session_results_presentation.py
===================================================================
--- /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_session_results_presentation.py	(revision 14424)
+++ /main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_session_results_presentation.py	(revision 14425)
@@ -23,5 +23,5 @@
     def test_iface(self):
         # ensure we fullfill interface contracts
-        obj = CustomSessionResultsPresentation('fac1', 'dep1', 2010, 100)
+        obj = CustomSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100)
         verifyClass(ISessionResultsPresentation, CustomSessionResultsPresentation)
         verifyObject(ISessionResultsPresentation, obj)
@@ -29,10 +29,10 @@
 
     def test_get_students(self):
-        result = get_students('fac1', 'dep1', 2010, 100)
+        result = get_students('fac1', 'dep1', 'CERT1', 2010, 100)
         self.assertEqual(result,
             [[(u'E1000000', u'1234', u'TESTER, Bob')], [], [], [], [], [], []])
         self.student['studycourse']['100']['Course1'].score = 60
         self.student['studycourse']['100']['Course1'].ca = 10
-        result = get_students('fac1', 'dep1', 2010, 100)
+        result = get_students('fac1', 'dep1', 'CERT1', 2010, 100)
         self.assertEqual(result,
             [[], [], [], [], [], [(u'E1000000', u'1234', u'TESTER, Bob')], []])
@@ -41,5 +41,5 @@
 
     def test_create_pdf(self):
-        report = CustomSessionResultsPresentation('fac1', 'dep1', 2010, 100)
+        report = CustomSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100)
         result = report.create_pdf('JOB_ID')
         self.assertTrue(result.startswith('%PDF-'))
