Ignore:
Timestamp:
29 Sep 2016, 08:54:32 (8 years ago)
Author:
Henrik Bettermann
Message:

Add imported_gpa and imported_cgpa fields and adjust exporters and batch processors.

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

Legend:

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

    r13865 r14206  
    2929    ICustomStudentOnlinePayment,
    3030    ICustomCourseTicketImport,
     31    ICustomStudentStudyLevel,
     32    ICustomStudentStudyCourse
    3133    )
    3234from waeup.kofa.students.batching import (
    3335    StudentProcessor, StudentOnlinePaymentProcessor,
     36    StudentStudyLevelProcessor,
     37    StudentStudyCourseProcessor,
    3438    CourseTicketProcessor)
    3539
     
    4650    iface = ICustomStudentOnlinePayment
    4751
     52class CustomStudentStudyCourseProcessor(StudentStudyCourseProcessor):
     53    """
     54    """
     55    iface = ICustomStudentStudyCourse
     56
     57class CustomStudentStudyLevelProcessor(StudentStudyLevelProcessor):
     58    """
     59    """
     60    iface = ICustomStudentStudyLevel
     61
    4862class CustomCourseTicketProcessor(CourseTicketProcessor):
    4963    """A batch processor for ICourseTicket objects.
  • main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py

    r14165 r14206  
    248248    grok.context(ICustomStudentStudyLevel)
    249249    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit(
    250         'total_credits', 'gpa', 'level')
     250        'total_credits', 'gpa', 'level', 'imported_gpa', 'imported_cgpa')
    251251    form_fields[
    252252        'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
     
    278278    form_fields = grok.AutoFields(ICustomStudentStudyLevel).omit(
    279279        'level_session', 'level_verdict',
    280         'validated_by', 'validation_date', 'gpa', 'level')
     280        'validated_by', 'validation_date', 'gpa', 'level',
     281        'imported_gpa', 'imported_cgpa')
    281282
    282283    omit_fields = ('password', 'suspended', 'suspended_comment',
  • main/waeup.aaue/trunk/src/waeup/aaue/students/interfaces.py

    r14113 r14206  
    1818
    1919from zope import schema
     20from zope.interface import Attribute
    2021from zc.sourcefactory.contextual import BasicContextualSourceFactory
    2122from zope.catalog.interfaces import ICatalog
     
    283284    """
    284285
     286    imported_cgpa = schema.Float(
     287        title = _(u'Imported Cumulative GPA'),
     288        required = False,
     289        readonly = True,
     290        )
     291
    285292class ICustomStudentStudyLevel(INigeriaStudentStudyLevel):
    286293    """A container for course tickets.
     
    305312        readonly = True,
    306313        )
     314
     315    imported_gpa = schema.Float(
     316        title = _(u'Imported Level GPA'),
     317        required = False,
     318        readonly = True,
     319        )
     320
     321    imported_cgpa = schema.Float(
     322        title = _(u'Imported Cumulative GPA'),
     323        required = False,
     324        readonly = True,
     325        )
     326
    307327
    308328class ICustomStudentOnlinePayment(ICustomOnlinePayment):
  • main/waeup.aaue/trunk/src/waeup/aaue/students/studylevel.py

    r14161 r14206  
    8787        if credits_counted:
    8888            level_gpa = round(credits_weighted/credits_counted, 3)
     89        # Override level_gpa if value has been imported
     90        imported_gpa = getattr(self, 'imported_gpa', None)
     91        if imported_gpa:
     92            level_gpa = imported_gpa
    8993        return level_gpa, credits_counted, credits_weighted
    9094
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r14165 r14206  
    4343
    4444
    45 class StudentProcessorTest(FunctionalTestCase):
    46     """Perform some batching tests.
    47     """
    48 
    49     layer = FunctionalLayer
    50 
    51     def setUp(self):
    52         super(StudentProcessorTest, self).setUp()
    53         # Setup a sample site for each test
    54         app = University()
    55         self.dc_root = tempfile.mkdtemp()
    56         app['datacenter'].setStoragePath(self.dc_root)
    57 
    58         # Prepopulate the ZODB...
    59         self.getRootFolder()['app'] = app
    60         # we add the site immediately after creation to the
    61         # ZODB. Catalogs and other local utilities are not setup
    62         # before that step.
    63         self.app = self.getRootFolder()['app']
    64         # Set site here. Some of the following setup code might need
    65         # to access grok.getSite() and should get our new app then
    66         setSite(app)
    67 
    68 
    69     def tearDown(self):
    70         super(StudentProcessorTest, self).tearDown()
    71         shutil.rmtree(self.workdir)
    72         shutil.rmtree(self.dc_root)
    73         clearSite()
    74         return
    75 
    7645UPLOAD_CSV_TEMPLATE = (
    7746    'matric_number,student_id,display_fullname,level,code,level_session,'
     
    144113        self.assertEqual(self.student['studycourse']['100'].gpa_params[2], 82.0)
    145114        # sgpa = 82 / 23
    146         self.assertEqual(self.student['studycourse']['100'].gpa_params[0], 3.565)
     115        self.assertEqual(
     116            self.student['studycourse']['100'].gpa_params[0], 3.565)
     117        # imported gpa values override calculated values
     118        studylevel.imported_gpa = 4.3
     119        studylevel.imported_cgpa = 5.4
     120        self.assertEqual(self.student['studycourse']['100'].gpa_params[0], 4.3)
     121        self.assertEqual(
     122            self.student['studycourse']['100'].cumulative_params[0], 5.4)
     123        self.assertEqual(self.student['studycourse']['100'].gpa, 4.3)
     124        self.student['studycourse'].imported_cgpa = 6.6
     125        self.assertEqual(
     126            self.student['studycourse'].getTranscriptData()[1], 6.6)
    147127        return
    148128
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py

    r14111 r14206  
    138138        self.assertEqual(
    139139            result,
    140             'gpa,level,level_session,level_verdict,total_credits,'
     140            'gpa,imported_cgpa,imported_gpa,'
     141            'level,level_session,level_verdict,total_credits,'
    141142            'total_credits_s1,total_credits_s2,'
    142143            'validated_by,validation_date,'
    143144            'student_id,number_of_tickets,certcode\r\n'
    144             '0.0,100,2012,A,100,,,,,A111111,1,CERT1\r\n'
     145            '0.0,,,100,2012,A,100,,,,,A111111,1,CERT1\r\n'
    145146            )
    146147        return
Note: See TracChangeset for help on using the changeset viewer.