Changeset 14425 for main/waeup.aaue


Ignore:
Timestamp:
21 Jan 2017, 16:07:07 (8 years ago)
Author:
Henrik Bettermann
Message:

Confine Level Reports and Session Results Presentations to certificates.

Location:
main/waeup.aaue/trunk/src/waeup/aaue/students/reports
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/browser_templates/levelreportgeneratorpage.pt

    r14041 r14425  
    77  </p>
    88  <br />
    9   <label for="session" i18n:translate="">Department</label>
    10   <select name="faccode_depcode" class="form-control half">
    11     <span tal:repeat="items view/faccode_depcodes" tal:omit-tag="">
     9  <label for="session" i18n:translate="">Certificate</label>
     10  <input id="filterbox" class="kofa-filterbox form-control half"
     11         placeholder="Enter search text, then select item below."
     12         type="text" i18n:translate=""/>
     13  <br />
     14  <select id="filteredselect" name="faccode_depcode_certcode"
     15          class="form-control half" size=5>
     16      <span tal:repeat="items view/faccode_depcode_certcode"
     17          tal:omit-tag="">
    1218      <option
    1319          tal:define="name python: items[1]; title python: items[0]"
     
    1925  <br />
    2026  <label for="session">Academic Session</label>
    21   <div class="input">
    22     <select name="session" class="form-control half">
    23       <span tal:repeat="items view/sessions" tal:omit-tag="">
    24         <option
    25             tal:define="name python: items[1]; title python: items[0]"
    26             tal:attributes="value name">
    27           <span tal:replace="title">TITLE</span>
    28         </option>
    29       </span>
    30     </select>
    31   </div>
     27  <select name="session" class="form-control half">
     28    <span tal:repeat="items view/sessions" tal:omit-tag="">
     29      <option
     30          tal:define="name python: items[1]; title python: items[0]"
     31          tal:attributes="value name">
     32        <span tal:replace="title">TITLE</span>
     33      </option>
     34    </span>
     35  </select>
    3236  <br />
    3337  <label for="session">Level</label>
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/level_report.py

    r14419 r14425  
    3333class LevelReportGenerator(LevelReportGenerator):
    3434
    35     def generate(self, site, faccode=None, depcode=None,
     35    def generate(self, site, faccode=None, depcode=None, certcode=None,
    3636                 session=None, level=None, author=None):
    3737        result = CustomLevelReport(faccode=faccode, depcode=depcode,
    38                             session=session, level=level, author=author)
     38            certcode=certcode, session=session, level=level, author=author)
    3939        return result
    4040
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/raw_score_report.py

    r14419 r14425  
    3939    faccode = Attribute('Faculty to report')
    4040    depcode = Attribute('Department to report')
     41    certcode = Attribute('Certzificate to report')
    4142    creation_dt_string = Attribute('Human readable report creation datetime')
    4243
    43 def get_courses_1(faccode, depcode, session, level):
     44def get_courses(faccode, depcode, certcode, session, level):
    4445    """Method 1: Get certificate courses of a
    45     certain department at a certain level.
     46    certain department/certificate at a certain level.
    4647    """
    4748    site = grok.getSite()
    4849    course_codes = []
    4950    department = site['faculties'][faccode][depcode]
    50     for cert in department.certificates.values():
    51         for certcourse in cert.values():
     51    if certcode == 'all':
     52        for cert in department.certificates.values():
     53            for certcourse in cert.values():
     54                if certcourse.level == level:
     55                    course_codes.append(certcourse.getCourseCode())
     56    else:
     57        certificate = site['faculties'][faccode][depcode].certificates[certcode]
     58        for certcourse in certificate.values():
    5259            if certcourse.level == level:
    5360                course_codes.append(certcourse.getCourseCode())
    5461    return course_codes
    5562
    56 def get_courses_2(faccode, depcode, session, level):
    57     """Method 2 (not used): Get all courses students of a certain
    58     department have registered at a certain level.
    59     """
    60     cat = queryUtility(ICatalog, name="students_catalog")
    61     result = cat.searchResults(
    62         depcode = (depcode, depcode), faccode = (faccode, faccode)
    63         )
    64     course_codes = []
    65     for stud in result:
    66         if not stud['studycourse'].has_key(str(level)):
    67             continue
    68         level_obj = stud['studycourse'][str(level)]
    69         if level_obj.level_session != session:
    70             continue
    71         for ticket in level_obj.values():
    72             course_codes.append(ticket.code)
    73     course_codes = sorted(list(set(course_codes)))
    74     return course_codes
    75 
    76 def get_students(faccode, depcode, session, level, course_codes):
    77     """Get students in a certain department who registered courses
     63def get_students(faccode, depcode, certcode, session, level, course_codes):
     64    """Get students in a certain department/certificate who registered courses
    7865    in a certain session at a certain level.
    7966
     
    8168    """
    8269    cat = queryUtility(ICatalog, name="students_catalog")
     70    if certcode == 'all':
     71        certcode = None
    8372    result = cat.searchResults(
    84         depcode = (depcode, depcode), faccode = (faccode, faccode)
     73        depcode = (depcode, depcode), faccode = (faccode, faccode),
     74        certcode = (certcode, certcode)
    8575        )
    8676    table = []
     
    183173    faccode = None
    184174    depcode = None
     175    certcode = None
    185176
    186177    note = ""
     
    193184#"""
    194185
    195     def __init__(self, faccode, depcode, session, level, author='System'):
     186    def __init__(self, faccode, depcode, certcode, session, level,
     187                 author='System'):
    196188        super(RawScoreReport, self).__init__(
    197             args=[faccode, depcode, session, level], kwargs={'author':author})
     189            args=[faccode, depcode, certcode, session, level],
     190                  kwargs={'author':author})
    198191        site = grok.getSite()
    199192        self.studylevelsource = StudyLevelSource().factory
     
    206199        self.faccode = faccode
    207200        self.depcode = depcode
     201        self.certcode = certcode
    208202        self.factitle = site['faculties'][faccode].longtitle
    209203        self.deptitle = site['faculties'][faccode][depcode].longtitle
     204        if self.certcode == 'all':
     205            self.certtitle = translate(
     206                _('All Certificates'), 'waeup.kofa',
     207                target_language=self.portal_language)
     208        else:
     209            self.certtitle = site['faculties'][faccode][
     210                depcode].certificates[certcode].longtitle
    210211        self.author = author
    211212        self.creation_dt_string = self.creation_dt.astimezone(
     
    215216        self.data = dict()
    216217        for level in self.past_levels:
    217             course_codes = get_courses_1(faccode, depcode, session, level)
     218            course_codes = get_courses(
     219                faccode, depcode, certcode, session, level)
    218220            self.course_codes[level] = course_codes
    219221            self.data[level] = get_students(
    220                 faccode, depcode, session, self.levelcode, course_codes)
     222                faccode, depcode, certcode, session, self.levelcode, course_codes)
    221223
    222224    def create_pdf(self, job_id):
     
    233235        pdf_data += [Paragraph(
    234236                    translate(
    235                         '${a}<br />${b}<br />Session: ${c}<br />Level: ${d}',
    236                         mapping = {'a':self.factitle,
     237                        '${a}<br />${b}<br />${c}<br /><br />Session: ${d}<br />Level: ${e}',
     238                        mapping = {'a':self.certtitle,
    237239                                   'b':self.deptitle,
    238                                    'c':self.session,
    239                                    'd':self.level,
     240                                   'c':self.factitle,
     241                                   'd':self.session,
     242                                   'e':self.level,
    240243                                   }),
    241244                    STYLE["Normal"]),
     
    260263        pdf = creator.create_pdf(
    261264            pdf_data, None, doc_title, self.author,
    262             doc_title + ' - %s/%s - %s - %s -' % (
    263             self.faccode, self.depcode, self.levelcode, self.sessioncode),
     265            doc_title + ' - %s/%s/%s - %s - %s -' % (
     266            self.faccode, self.depcode, self.certcode,
     267            self.levelcode, self.sessioncode),
    264268            note=self.note
    265269            )
     
    272276    grok.name('raw_score_report')
    273277
    274     def generate(self, site, faccode=None, depcode=None,
     278    def generate(self, site, faccode=None, depcode=None, certcode=None,
    275279                 session=None, level=None, author=None):
    276280        result = RawScoreReport(faccode=faccode, depcode=depcode,
    277                             session=session, level=level, author=author)
     281            certcode=certcode, session=session, level=level, author=author)
    278282        return result
    279283
     
    302306
    303307    def _filename(self):
    304         return 'RawScoreReport_%s_%s_%s_%s_%s.pdf' % (
    305             self.context.faccode, self.context.depcode,
     308        return 'RawScoreReport_%s_%s_%s_%s_%s_%s.pdf' % (
     309            self.context.faccode, self.context.depcode, self.context.certcode,
    306310            self.context.sessioncode, self.context.levelcode,
    307311            self.context.creation_dt_string)
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/session_results_presentation.py

    r14419 r14425  
    3333class CustomSessionResultsPresentationGenerator(SessionResultsPresentationGenerator):
    3434
    35     def generate(self, site, faccode=None, depcode=None,
     35    def generate(self, site, faccode=None, depcode=None, certcode=None,
    3636                 session=None, level=None, author=None):
    37         result = CustomSessionResultsPresentation(faccode=faccode, depcode=depcode,
    38                              session=session, level=level, author=author)
     37        result = CustomSessionResultsPresentation(faccode=faccode,
     38            depcode=depcode, certcode=certcode, session=session,
     39            level=level, author=author)
    3940        return result
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_level_report.py

    r14419 r14425  
    2020    def test_iface(self):
    2121        # ensure we fullfill interface contracts
    22         obj = CustomLevelReport('fac1', 'dep1', 2010, 100)
     22        obj = CustomLevelReport('fac1', 'dep1', 'CERT1', 2010, 100)
    2323        verifyClass(ILevelReport, CustomLevelReport)
    2424        verifyObject(ILevelReport, obj)
     
    2828        # we can get a table with one student
    2929        self.student['studycourse']['100']['Course1'].ca = 0
    30         result = get_students('fac1', 'dep1', 2010, 100)
     30        result = get_students('fac1', 'dep1', 'CERT1', 2010, 100)
    3131        self.assertEqual(result,
    3232            [(u'1234', u'TESTER, Bob', 30, 30, '5.000', 'NIL', '', 30, 30, '5.000', 'Proceed')])
     
    3535    def test_create_pdf(self):
    3636        self.student['studycourse']['100']['Course1'].ca = 0
    37         report = CustomLevelReport('fac1', 'dep1', 2010, 100)
     37        report = CustomLevelReport('fac1', 'dep1', 'CERT1', 2010, 100)
    3838        result = report.create_pdf('JOB_ID')
    3939        self.assertTrue(result.startswith('%PDF-'))
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_raw_score_report.py

    r14399 r14425  
    1111from waeup.aaue.students.reports.raw_score_report import (
    1212    get_students, RawScoreReport, IRawScoreReport,
    13     get_courses_1 as get_courses)
     13    get_courses)
    1414from waeup.aaue.testing import FunctionalLayer
    1515
     
    2929    def test_iface(self):
    3030        # ensure we fullfill interface contracts
    31         obj = RawScoreReport('fac1', 'dep1', 2010, 100)
     31        obj = RawScoreReport('fac1', 'dep1', 'CERT1', 2010, 100)
    3232        verifyClass(IRawScoreReport, RawScoreReport)
    3333        verifyObject(IRawScoreReport, obj)
     
    3636    def test_get_courses(self):
    3737        # we can get a list with one course code
    38         result = get_courses('fac1', 'dep1', 2010, 100)
     38        result = get_courses('fac1', 'dep1', 'CERT1', 2010, 100)
    3939        self.assertEqual(result, [(u'Course1')])
    4040        return
     
    4343        # we can get a table with one student
    4444        self.student['studycourse']['100']['Course1'].ca = 0
    45         course_codes = get_courses('fac1', 'dep1', 2010, 100)
    46         result = get_students('fac1', 'dep1', 2010, 100, course_codes)
     45        course_codes = get_courses('fac1', 'dep1', 'CERT1', 2010, 100)
     46        result = get_students('fac1', 'dep1', 'CERT1', 2010, 100, course_codes)
    4747        self.assertEqual(result,
    4848            [(u'1234', u'TESTER, Bob', {'Course1': (70, 'A')})])
     
    6868        self.student.firstname = u'Osahenokese Tessy'
    6969        self.student.lastname = u'Emwinyomwanru'
    70         report = RawScoreReport('fac1', 'dep1', 2011, 200)
     70        report = RawScoreReport('fac1', 'dep1', 'CERT1', 2011, 200)
    7171        result = report.create_pdf('JOB_ID')
    7272        self.assertTrue(result.startswith('%PDF-'))
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_session_results_presentation.py

    r14393 r14425  
    2323    def test_iface(self):
    2424        # ensure we fullfill interface contracts
    25         obj = CustomSessionResultsPresentation('fac1', 'dep1', 2010, 100)
     25        obj = CustomSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100)
    2626        verifyClass(ISessionResultsPresentation, CustomSessionResultsPresentation)
    2727        verifyObject(ISessionResultsPresentation, obj)
     
    2929
    3030    def test_get_students(self):
    31         result = get_students('fac1', 'dep1', 2010, 100)
     31        result = get_students('fac1', 'dep1', 'CERT1', 2010, 100)
    3232        self.assertEqual(result,
    3333            [[(u'E1000000', u'1234', u'TESTER, Bob')], [], [], [], [], [], []])
    3434        self.student['studycourse']['100']['Course1'].score = 60
    3535        self.student['studycourse']['100']['Course1'].ca = 10
    36         result = get_students('fac1', 'dep1', 2010, 100)
     36        result = get_students('fac1', 'dep1', 'CERT1', 2010, 100)
    3737        self.assertEqual(result,
    3838            [[], [], [], [], [], [(u'E1000000', u'1234', u'TESTER, Bob')], []])
     
    4141
    4242    def test_create_pdf(self):
    43         report = CustomSessionResultsPresentation('fac1', 'dep1', 2010, 100)
     43        report = CustomSessionResultsPresentation('fac1', 'dep1', 'CERT1', 2010, 100)
    4444        result = report.create_pdf('JOB_ID')
    4545        self.assertTrue(result.startswith('%PDF-'))
Note: See TracChangeset for help on using the changeset viewer.