Ignore:
Timestamp:
11 Feb 2020, 12:15:26 (5 years ago)
Author:
Henrik Bettermann
Message:

Add unlock_score field to CourseTicketProcessor and extend checkUpdateRequirements.

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

Legend:

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

    r15628 r16000  
    637637    Like all other student data importers, this processor also requires
    638638    either `student_id`, `reg_number` or `matric_number` to find the student.
    639     Then  it needs `level` and `code` to localize the course ticket.
     639    Then it needs `level` and `code` to localize the course ticket.
    640640
    641641    `checkConversion` first searches the courses catalog for the imported
     
    650650    nor by import. Other values can be overwritten by import.
    651651
    652     `ticket_session` is an additional attribute which can be used to store the
     652    `ticket_session` is an additional field which can be used to store the
    653653    session of the course when it was taken. Usually this information is
    654654    redundant because the parent study level object already contains this
    655655    information, except for the study level zero container which can be used to
    656656    store 'orphaned' course tickets.
     657
     658    `checkUpdateRequirements` ensures that the `score` attribute can't
     659    be accidentally overwritten by import in update mode. The `score`
     660    attribute can be unlocked by setting the boolean field
     661    `unlock_score` = 1.
    657662    """
    658663    grok.implements(IBatchProcessor)
     
    675680            'mandatory', 'score', 'carry_over', 'automatic',
    676681            'outstanding', 'course_category', 'level_session',
    677             'title', 'credits', 'passmark', 'semester', 'ticket_session'
     682            'title', 'credits', 'passmark', 'semester', 'ticket_session',
     683            'unlock_score'
    678684            ] + self.additional_fields
    679685        return sorted(fields)
     
    735741        if obj.student.studycourse_locked:
    736742            return 'Studycourse is locked.'
     743        if row.get('score',None) and obj.score and not row.get(
     744            'unlock_score',None):
     745            return 'Score attribute is locked.'
    737746        return None
    738747
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_courseticket_data.csv

    r15203 r16000  
    1 reg_number,matric_number,level,code,score,mandatory,level_session,ticket_session
    2 1,,100,COURSE1,1,True,,
    3 2,,100,COURSE1,2,False,,
    4 ,100002,100,COURSE1,3,False,,
    5 1,,200,COURSE1,1,True,2008,
    6 1,,nonsense,COURSE1,5,,,
    7 1,,100,NONSENSE,5,,,
    8 1,,200,COURSE1,6,,2004,
    9 1,,300,COURSE1,6,,2008,
    10 1,,300,COURSE1,6,,2008X,
     1reg_number,matric_number,level,code,score,mandatory,level_session,ticket_session,unlock_score
     21,,100,COURSE1,1,True,,,
     32,,100,COURSE1,2,False,,,
     4,100002,100,COURSE1,3,False,,,
     51,,200,COURSE1,1,True,2008,,
     61,,nonsense,COURSE1,5,,,,
     71,,100,NONSENSE,5,,,,
     81,,200,COURSE1,6,,2004,,
     91,,300,COURSE1,6,,2008,,
     101,,300,COURSE1,6,,2008X,,
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r15628 r16000  
    962962        self.assertEqual(num_warns,5)
    963963        self.assertEqual(fail_file,
    964             'reg_number,code,mandatory,level,level_session,ticket_session,score,matric_number,--ERRORS--\r\n'
    965             '1,COURSE1,<IGNORE>,nonsense,<IGNORE>,<IGNORE>,5,<IGNORE>,Not all parents do exist yet.\r\n'
    966             '1,NONSENSE,<IGNORE>,100,<IGNORE>,<IGNORE>,5,<IGNORE>,code: non-existent\r\n'
    967             '1,COURSE1,<IGNORE>,200,2004,<IGNORE>,6,<IGNORE>,level_session: does not match 2008\r\n'
    968             '1,COURSE1,<IGNORE>,300,2008,<IGNORE>,6,<IGNORE>,level object: does not exist\r\n'
    969             '1,COURSE1,<IGNORE>,300,2008X,<IGNORE>,6,<IGNORE>,level_session: Invalid value\r\n')
     964            'reg_number,code,mandatory,level,level_session,ticket_session,score,unlock_score,matric_number,--ERRORS--\r\n'
     965            '1,COURSE1,<IGNORE>,nonsense,<IGNORE>,<IGNORE>,5,<IGNORE>,<IGNORE>,Not all parents do exist yet.\r\n'
     966            '1,NONSENSE,<IGNORE>,100,<IGNORE>,<IGNORE>,5,<IGNORE>,<IGNORE>,code: non-existent\r\n'
     967            '1,COURSE1,<IGNORE>,200,2004,<IGNORE>,6,<IGNORE>,<IGNORE>,level_session: does not match 2008\r\n'
     968            '1,COURSE1,<IGNORE>,300,2008,<IGNORE>,6,<IGNORE>,<IGNORE>,level object: does not exist\r\n'
     969            '1,COURSE1,<IGNORE>,300,2008X,<IGNORE>,6,<IGNORE>,<IGNORE>,level_session: Invalid value\r\n')
    970970        assert self.processor.entryExists(
    971971            dict(reg_number='1', level='100', code='COURSE1'),
     
    10151015        self.assertEqual(num_warns,5)
    10161016        self.assertEqual(fail_file,
    1017             'reg_number,code,mandatory,level,level_session,ticket_session,score,matric_number,--ERRORS--\r\n'
    1018             '1,COURSE1,<IGNORE>,nonsense,<IGNORE>,<IGNORE>,5,<IGNORE>,Cannot update: no such entry\r\n'
    1019             '1,NONSENSE,<IGNORE>,100,<IGNORE>,<IGNORE>,5,<IGNORE>,code: non-existent\r\n'
    1020             '1,COURSE1,<IGNORE>,200,2004,<IGNORE>,6,<IGNORE>,level_session: does not match 2008\r\n'
    1021             '1,COURSE1,<IGNORE>,300,2008,<IGNORE>,6,<IGNORE>,level object: does not exist\r\n'
    1022             '1,COURSE1,<IGNORE>,300,2008X,<IGNORE>,6,<IGNORE>,level_session: Invalid value\r\n')
     1017            'reg_number,code,mandatory,level,level_session,ticket_session,score,unlock_score,matric_number,--ERRORS--\r\n'
     1018            '1,COURSE1,<IGNORE>,nonsense,<IGNORE>,<IGNORE>,5,<IGNORE>,<IGNORE>,Cannot update: no such entry\r\n'
     1019            '1,NONSENSE,<IGNORE>,100,<IGNORE>,<IGNORE>,5,<IGNORE>,<IGNORE>,code: non-existent\r\n'
     1020            '1,COURSE1,<IGNORE>,200,2004,<IGNORE>,6,<IGNORE>,<IGNORE>,level_session: does not match 2008\r\n'
     1021            '1,COURSE1,<IGNORE>,300,2008,<IGNORE>,6,<IGNORE>,<IGNORE>,level object: does not exist\r\n'
     1022            '1,COURSE1,<IGNORE>,300,2008X,<IGNORE>,6,<IGNORE>,<IGNORE>,level_session: Invalid value\r\n')
    10231023        shutil.rmtree(os.path.dirname(fin_file))
    10241024
     
    10571057        self.assertEqual(num_warns,7)
    10581058        self.assertEqual(fail_file,
    1059             'reg_number,code,mandatory,level,level_session,ticket_session,score,matric_number,--ERRORS--\r\n'
    1060             '1,COURSE1,True,100,<IGNORE>,<IGNORE>,1,<IGNORE>,Studycourse is locked.\r\n'
    1061             '1,COURSE1,True,200,2008,<IGNORE>,1,<IGNORE>,Studycourse is locked.\r\n'
    1062             '1,COURSE1,<IGNORE>,nonsense,<IGNORE>,<IGNORE>,5,<IGNORE>,Cannot update: no such entry\r\n'
    1063             '1,NONSENSE,<IGNORE>,100,<IGNORE>,<IGNORE>,5,<IGNORE>,code: non-existent\r\n'
    1064             '1,COURSE1,<IGNORE>,200,2004,<IGNORE>,6,<IGNORE>,level_session: does not match 2008\r\n'
    1065             '1,COURSE1,<IGNORE>,300,2008,<IGNORE>,6,<IGNORE>,level object: does not exist\r\n'
    1066             '1,COURSE1,<IGNORE>,300,2008X,<IGNORE>,6,<IGNORE>,level_session: Invalid value\r\n')
     1059            'reg_number,code,mandatory,level,level_session,ticket_session,score,unlock_score,matric_number,--ERRORS--\r\n'
     1060            '1,COURSE1,True,100,<IGNORE>,<IGNORE>,1,<IGNORE>,<IGNORE>,Studycourse is locked.\r\n'
     1061            '1,COURSE1,True,200,2008,<IGNORE>,1,<IGNORE>,<IGNORE>,Studycourse is locked.\r\n'
     1062            '1,COURSE1,<IGNORE>,nonsense,<IGNORE>,<IGNORE>,5,<IGNORE>,<IGNORE>,Cannot update: no such entry\r\n'
     1063            '1,NONSENSE,<IGNORE>,100,<IGNORE>,<IGNORE>,5,<IGNORE>,<IGNORE>,code: non-existent\r\n'
     1064            '1,COURSE1,<IGNORE>,200,2004,<IGNORE>,6,<IGNORE>,<IGNORE>,level_session: does not match 2008\r\n'
     1065            '1,COURSE1,<IGNORE>,300,2008,<IGNORE>,6,<IGNORE>,<IGNORE>,level object: does not exist\r\n'
     1066            '1,COURSE1,<IGNORE>,300,2008X,<IGNORE>,6,<IGNORE>,<IGNORE>,level_session: Invalid value\r\n')
    10671067        shutil.rmtree(os.path.dirname(fin_file))
    10681068
Note: See TracChangeset for help on using the changeset viewer.