Ignore:
Timestamp:
15 Mar 2017, 12:08:03 (8 years ago)
Author:
Henrik Bettermann
Message:

Add GradRawScoreReport?.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/raw_score_report.py

    r14528 r14630  
    1818
    1919import grok
     20from zope.interface import implementer, Interface, Attribute
    2021from waeup.kofa.students.reports.raw_score_report import (
    21     RawScoreReport, RawScoreReportGenerator)
     22    RawScoreReport, RawScoreReportGenerator,
     23    IRawScoreReport, RawScoreReportGeneratorPage,
     24    RawScoreReportPDFView)
    2225
    2326
     
    3841
    3942
    40 class RawScoreReportGenerator(RawScoreReportGenerator):
     43class CustomRawScoreReportGenerator(RawScoreReportGenerator):
    4144
    4245    def generate(self, site, faccode=None, depcode=None, certcode=None,
     
    4548            certcode=certcode, session=session, level=level, author=author)
    4649        return result
     50
     51# Raw Score Report for graduating students only
     52
     53class IGradRawScoreReport(IRawScoreReport):
     54    """Marker interface to distuingish graduating students raw score reports
     55    from ordinary raw score reports.
     56    """
     57
     58@implementer(IGradRawScoreReport)
     59class GradRawScoreReport(CustomRawScoreReport):
     60    """
     61    """
     62
     63    title = 'RAW Score Report'
     64
     65    @property
     66    def right_footer(self):
     67        return self.title + ' (graduating students only) - %s -' % self.session
     68
     69    def _excluded(self, level_obj):
     70        """
     71        """
     72        final_level = max(level_obj.student['studycourse'].keys())
     73        final_level_obj = level_obj.student['studycourse'][final_level]
     74        if final_level_obj.remark not in (
     75            'Pass', '3s_rd_s', '2s_2_s', '2s_1_s', '1s_st_s'):
     76            return True
     77        return False
     78
     79class GradRawScoreReportGenerator(RawScoreReportGenerator):
     80
     81    title = 'Graduating Students RAW Score Report'
     82    grok.name('grad_raw_score_report')
     83
     84    def generate(self, site, faccode=None, depcode=None, certcode=None,
     85                 session=None, level=None, author=None):
     86        result = GradRawScoreReport(faccode=faccode, depcode=depcode,
     87            certcode=certcode, session=session, level=level, author=author)
     88        return result
     89
     90class GradRawScoreReportGeneratorPage(RawScoreReportGeneratorPage):
     91
     92    grok.context(GradRawScoreReportGenerator)
     93
     94class GradRawScoreReportPDFView(RawScoreReportPDFView):
     95
     96    grok.context(IGradRawScoreReport)
     97    grok.name('pdf')
     98    grok.require('waeup.handleReports')
     99
     100    def _filename(self):
     101        return 'GradRawScoreReport_rno%s_%s.pdf' % (
     102            self.context.__name__,
     103            self.context.creation_dt_string)
     104
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_raw_score_report.py

    r14608 r14630  
    99from waeup.kofa.browser.tests.test_pdf import samples_dir
    1010from waeup.kofa.students.reports.raw_score_report import IRawScoreReport
    11 from waeup.aaue.students.reports.raw_score_report import CustomRawScoreReport
     11from waeup.aaue.students.reports.raw_score_report import (
     12    CustomRawScoreReport, GradRawScoreReport, IGradRawScoreReport)
    1213from waeup.aaue.testing import FunctionalLayer
    1314
     
    9899        print "Sample raw_score_report.pdf written to %s" % path
    99100        return
     101
     102
     103class GradRawScoreReportTests(CatalogTestSetup):
     104
     105    layer = FunctionalLayer
     106
     107    def setUp(self):
     108        super(GradRawScoreReportTests, self).setUp()
     109        self.course = createObject('waeup.Course')
     110        self.course.code = 'Course1'
     111        self.course.credits = 25
     112        self.app['faculties']['fac1']['dep1'].courses.addCourse(
     113            self.course)
     114        self.app['faculties']['fac1']['dep1'].certificates[
     115            'CERT1'].addCertCourse(self.course, level=100)
     116
     117    def test_iface(self):
     118        # ensure we fullfill interface contracts
     119        obj = GradRawScoreReport('fac1', 'dep1', 'CERT1', 2010, 100)
     120        verifyClass(IGradRawScoreReport, GradRawScoreReport)
     121        verifyObject(IGradRawScoreReport, obj)
     122        return
     123
     124    def test_get_courses(self):
     125        # we can get a list with one course code
     126        rsr =  GradRawScoreReport('fac1', 'dep1', 'CERT1', 2010, 100)
     127        result = rsr._get_courses('fac1', 'dep1', 'CERT1', 2010, 100)
     128        self.assertEqual(result, [u'Course1'])
     129        return
     130
     131    def test_get_students(self):
     132        # we can get a table with one student
     133        self.student['studycourse']['100']['Course1'].ca = 0
     134        rsr =  GradRawScoreReport('fac1', 'dep1', 'CERT1', 2010, 100)
     135        course_codes = rsr._get_courses('fac1', 'dep1', 'CERT1', 2010, 100)
     136        result = rsr._get_students('fac1', 'dep1', 'CERT1', 2010, 100, course_codes)
     137        self.assertEqual(result, [])
     138        # if end level is 100, the student seems graduating and
     139        # we can get a table with one student
     140        self.certificate.end_level = 100
     141        self.student['studycourse']['100']['Course1'].credits = 91
     142        result = rsr._get_students('fac1', 'dep1', 'CERT1', 2010, 100, course_codes)
     143        self.assertEqual(result,
     144            [(u'1234', u'TESTER, Bob', {'Course1': (70, 'A')})])
     145        self.student['studycourse']['100']['Course1'].ca = None
     146        result = rsr._get_students('fac1', 'dep1', 'CERT1', 2010, 100, course_codes)
     147        # NER
     148        self.assertEqual(result, [])
     149        return
     150
     151    def test_create_pdf(self):
     152        self.certificate.end_level = 200
     153        self.course2 = createObject('waeup.Course')
     154        self.course2.code = 'Course2'
     155        self.course2.credits = 30
     156        self.app['faculties']['fac1']['dep1'].courses.addCourse(
     157            self.course2)
     158        self.app['faculties']['fac1']['dep1'].certificates[
     159            'CERT1'].addCertCourse(self.course2, level=100)
     160        self.course3 = createObject('waeup.Course')
     161        self.course3.code = 'Course3'
     162        self.course3.credits = 30
     163        self.app['faculties']['fac1']['dep1'].courses.addCourse(
     164            self.course3)
     165        self.app['faculties']['fac1']['dep1'].certificates[
     166            'CERT1'].addCertCourse(self.course3, level=100)
     167        self.app['faculties']['fac1'].officer_1 = 'Rosa Moonshine - Dean of Faculty'
     168        self.app['faculties']['fac1']['dep1'].officer_1 = 'Amalia Sunshine - Head of Department'
     169        studylevel = createObject('waeup.StudentStudyLevel')
     170        studylevel.level = 200
     171        studylevel.level_session = 2011
     172        self.student['studycourse']['200'] = studylevel
     173        ticket = createObject('waeup.CourseTicket')
     174        ticket.code = 'Course2'
     175        ticket.credits = 61
     176        ticket.score = 50
     177        ticket.ca = 10
     178        self.student['studycourse']['200']['Course2'] = ticket
     179        ticket = createObject('waeup.CourseTicket')
     180        ticket.code = 'Course3'
     181        ticket.credits = 30
     182        ticket.score = 70
     183        ticket.ca = 0
     184        self.student['studycourse']['200']['Course3'] = ticket
     185        self.assertEqual(ticket.grade, 'A')
     186        self.student.firstname = u'Osahenokese Tessy'
     187        self.student.lastname = u'Emwinyomwanru'
     188        report = GradRawScoreReport('fac1', 'dep1', 'CERT1', 2011, 200)
     189        result = report.create_pdf('JOB_ID')
     190        self.assertTrue(result.startswith('%PDF-'))
     191        path = os.path.join(samples_dir(), 'grad_raw_score_report.pdf')
     192        open(path, 'wb').write(result)
     193        print "Sample grad_raw_score_report.pdf written to %s" % path
     194        return
     195
Note: See TracChangeset for help on using the changeset viewer.