Ignore:
Timestamp:
27 Feb 2017, 06:11:10 (8 years ago)
Author:
Henrik Bettermann
Message:

Add LevelReportDataExporter?.

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

Legend:

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

    r14442 r14593  
    1818"""Exporters for student related stuff.
    1919"""
     20import grok
     21from zope.component import getUtility
    2022from waeup.kofa.utils.batching import ExporterBase
    2123from waeup.kofa.utils.helpers import iface_names
    22 from waeup.kofa.students.export import DataForLecturerExporter
     24from waeup.kofa.interfaces import IKofaUtils
     25from waeup.kofa.students.export import (get_levels,
     26    DataForLecturerExporter, StudentExporterBase,)
    2327from waeup.aaue.students.interfaces import (
    2428    ICustomStudent, ICustomStudentStudyCourse,
     
    103107              'level', 'code', 'level_session', 'ca', 'score')
    104108
     109class LevelReportDataExporter(grok.GlobalUtility, StudentExporterBase):
     110    """
     111    """
     112    grok.name('levelreportdata')
     113
     114    fields = ('matric_number', 'display_fullname',
     115        'credits_counted', 'credits_passed','level_gpa',
     116        'failed_courses','not_taken_courses','cum_credits_taken',
     117        'cum_credits_passed','cgpa','remark')
     118    title = u'Summary of Result Data'
     119
     120    def filter_func(self, x, **kw):
     121        return get_levels(x)
     122
     123    def mangle_value(self, value, name, context=None):
     124        """The mangler determines the student id, nothing else.
     125        """
     126        if context is not None:
     127            student = context.student
     128            format_float = getUtility(IKofaUtils).format_float
     129            if name in ('matric_number',
     130                        'display_fullname',) and student is not None:
     131                value = getattr(student, name, None)
     132            elif name == 'credits_counted':
     133                value = context.gpa_params[1]
     134            elif name == 'credits_passed':
     135                value = context.passed_params[2]
     136            elif name == 'level_gpa':
     137                value = format_float(context.gpa_params[0], 3)
     138            elif name == 'failed_courses':
     139                value = context.passed_params[4]
     140            elif name == 'not_taken_courses':
     141                value = context.passed_params[5]
     142            elif name == 'cum_credits_taken':
     143                value = context.cumulative_params[1]
     144            elif name == 'cum_credits_passed':
     145                value = context.cumulative_params[4]
     146            elif name == 'cgpa':
     147                value = format_float(context.cumulative_params[0], 3)
     148            elif name == 'remark':
     149                value = getattr(context, 'remark', '')
     150        return super(
     151            LevelReportDataExporter, self).mangle_value(
     152            value, name, context=context)
     153
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py

    r14576 r14593  
    1010    CustomStudentExporter, CustomStudentPaymentExporter,
    1111    CustomStudentStudyLevelExporter,
    12     CustomCourseTicketExporter)
     12    CustomCourseTicketExporter,
     13    LevelReportDataExporter)
    1314from waeup.aaue.testing import FunctionalLayer
    1415
     
    174175        return
    175176
     177class LevelReportDataExporterTest(StudentImportExportSetup):
     178
     179    layer = FunctionalLayer
     180
     181    def setUp(self):
     182        super(LevelReportDataExporterTest, self).setUp()
     183        self.setup_for_export()
     184        return
     185
     186    def test_export_all(self):
     187        # we can really export study levels
     188        # set values we can expect in export file
     189        self.setup_student(self.student)
     190        exporter = LevelReportDataExporter()
     191        exporter.export_all(self.app, self.outfile)
     192        result = open(self.outfile, 'rb').read()
     193        self.assertEqual(
     194            result,
     195            'matric_number,display_fullname,credits_counted,credits_passed,'
     196            'level_gpa,failed_courses,not_taken_courses,cum_credits_taken,'
     197            'cum_credits_passed,cgpa,remark\r\n'
     198            '234,"TESTER, Anna M.",0,0,0.000,,CRS1 ,0,0,0.000,\r\n'
     199            )
     200        return
     201
     202
  • main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py

    r14585 r14593  
    495495    # AAUE prefix
    496496    STUDENT_ID_PREFIX = u'E'
     497
     498    STUDENT_EXPORTER_NAMES = ('students', 'studentstudycourses',
     499            'studentstudylevels', 'coursetickets',
     500            'studentpayments', 'studentunpaidpayments',
     501            'bedtickets', 'paymentsoverview',
     502            'studylevelsoverview', 'combocard', 'bursary',
     503            'levelreportdata')
Note: See TracChangeset for help on using the changeset viewer.