Changeset 9293 for main/waeup.kofa/trunk


Ignore:
Timestamp:
4 Oct 2012, 14:56:44 (12 years ago)
Author:
Henrik Bettermann
Message:

Update current level_verdict when importing verdicts.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_batching.py

    r8616 r9293  
    334334        self.assertEqual(num_warns,2)
    335335        fail_contents = open(fail_file, 'rb').read()
    336         shutil.rmtree(os.path.dirname(fail_file))
    337336        # CERT2 is in wrong category ...
    338337        self.assertTrue('course1: wrong application category' in fail_contents)
    339338        # ... and CERT3 does not exist.
    340339        self.assertTrue('course1: Invalid value' in fail_contents)
     340        shutil.rmtree(os.path.dirname(fail_file))
    341341        return
    342342
  • main/waeup.kofa/trunk/src/waeup/kofa/students/batching.py

    r9284 r9293  
    734734        # Check if new verdict is provided
    735735        if row['current_verdict'] in (IGNORE_MARKER, ''):
    736             return 'Verdict is missing.'
     736            return 'No verdict in import file.'
     737        # Check if studylevel exists#
     738        level_string = str(obj.current_level)
     739        if obj.get(level_string) is None:
     740            return 'Study level object is missing.'
    737741        # Check if student is in state REGISTERED or VALIDATED
    738742        if row.get('bypass_validation') in ('1', 'True', 'TRUE', 'yes'):
     
    750754        vals_to_set = dict((key, val) for key, val in row.items()
    751755                           if key not in ('current_session','current_level'))
    752         items_changed = super(StudentVerdictProcessor, self).updateEntry(
    753             obj, vals_to_set, site)
    754         parent = self.getParent(row, site)
    755         parent.__parent__.logger.info(
    756             '%s - Verdict updated: %s'
    757             % (parent.student_id, items_changed))
     756        super(StudentVerdictProcessor, self).updateEntry(obj, vals_to_set, site)
     757        parent = self.getParent(row, site)
     758        # Set current_vedict in corresponding studylevel
     759        level_string = str(obj.current_level)
     760        obj[level_string].level_verdict = row['current_verdict']
    758761        # Fire transition depending on student's state
    759762        if obj.__parent__.state == REGISTERED:
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_student_data.csv

    r9284 r9293  
    77X999999,Herbert,Mueller,6,1990-01-02,100005,aa@aa.ng,1234,m,courses registered
    88X111111,Fabian,Riester,7,1990-01-02,100006,aa@aa.ng,1234,m,courses validated
     9X222222,Thomas,Kinderman,8,1990-01-02,100007,aa@aa.ng,1234,m,courses validated
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_studycourse_data.csv

    r9284 r9293  
    886,,CERT1,2008,200
    997,,CERT1,2008,200
     108,,CERT1,2008,200
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_studylevel_data.csv

    r7536 r9293  
    11reg_number,matric_number,level_session,level_verdict,level
    2 1,,2008,A,100
     21,,2008,,100
     31,,2008,,200
    342,,2008,B,100
    45,100002,2009,C,100
    561,,2008,A,111
    671,,2008,A,nonsense
     84,,2008,A,200
     95,,2008,A,200
     106,,2008,A,200
     117,,2008,A,200
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/sample_verdict_data.csv

    r9284 r9293  
    11matric_number,current_session,current_level,current_verdict,bypass_validation
    2 100000,2008,200,A,0
     2100000,2008,200,0,0
    33100001,2008,100,B,False
    44100002,2007,200,C,
     
    77100005,2008,200,A,1
    88100006,2008,200,A,True
     9100007,2008,200,A,True
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r9284 r9293  
    360360            self.csv_file, STUDENT_HEADER_FIELDS)
    361361        self.assertEqual(num_warns,0)
    362         self.assertEqual(len(self.app['students']), 8)
     362        self.assertEqual(len(self.app['students']), 9)
    363363        self.assertEqual(self.app['students']['X666666'].reg_number,'1')
    364364        self.assertEqual(
     
    594594            studycourse_file, STUDYCOURSE_HEADER_FIELDS,'update')
    595595        shutil.rmtree(os.path.dirname(fin_file))
     596        # Import study levels
     597        self.csv_file = os.path.join(
     598            self.workdir, 'sample_studylevel_data.csv')
     599        open(self.csv_file, 'wb').write(STUDYLEVEL_SAMPLE_DATA)
     600        processor = StudentStudyLevelProcessor()
     601        num, num_warns, fin_file, fail_file = processor.doImport(
     602            self.csv_file, STUDYLEVEL_HEADER_FIELDS,'create')
     603        content = open(fail_file).read()
     604        shutil.rmtree(os.path.dirname(fin_file))
    596605
    597606        self.processor = StudentVerdictProcessor()
     
    602611
    603612    def test_import(self):
    604         num, num_warns, fin_file, fail_file = self.processor.doImport(
    605             self.csv_file, VERDICT_HEADER_FIELDS,'update')
    606         self.assertEqual(num_warns,4)
    607613        studycourse = self.processor.getEntry(dict(matric_number='100000'),
    608614                                              self.app)
     615        self.assertEqual(studycourse['200'].level_verdict, None)
    609616        student = self.processor.getParent(
    610617            dict(matric_number='100000'), self.app)
    611         self.assertEqual(studycourse.current_verdict, 'A')
     618        num, num_warns, fin_file, fail_file = self.processor.doImport(
     619            self.csv_file, VERDICT_HEADER_FIELDS,'update')
     620        content = open(fail_file).read()
     621        self.assertEqual(num_warns,5)
     622        self.assertEqual(studycourse.current_verdict, '0')
    612623        self.assertEqual(student.state, 'returning')
    613624        self.assertEqual(studycourse.current_level, 200)
     625        self.assertEqual(studycourse['200'].level_verdict, '0')
    614626        student = self.processor.getParent(
    615627            dict(matric_number='100005'), self.app)
    616         self.assertEqual(studycourse.current_verdict, 'A')
     628        self.assertEqual(studycourse.current_verdict, '0')
    617629        self.assertEqual(student.state, 'returning')
    618630        self.assertEqual(studycourse.current_level, 200)
     
    625637            '2007,C,<IGNORE>,100002,200,Current session does not correspond.\r\n'
    626638            '2008,A,<IGNORE>,100003,200,Student in wrong state.\r\n'
    627             '2008,<IGNORE>,<IGNORE>,100004,200,Verdict is missing.\r\n'
     639            '2008,<IGNORE>,<IGNORE>,100004,200,No verdict in import file.\r\n'
     640            '2008,A,True,100007,200,Study level object is missing.\r\n'
    628641            )
    629642        shutil.rmtree(os.path.dirname(fin_file))
     
    685698        self.assertEqual(studylevel.__parent__.certificate.code, u'CERT1')
    686699        self.assertEqual(studylevel.level_session, 2008)
    687         self.assertEqual(studylevel.level_verdict, 'A')
     700        self.assertEqual(studylevel.level_verdict, None)
    688701        self.assertEqual(studylevel.level, 100)
    689702        shutil.rmtree(os.path.dirname(fin_file))
  • main/waeup.kofa/trunk/src/waeup/kofa/university/tests/test_batching.py

    r9283 r9293  
    106106        self.logfile = os.path.join(
    107107            self.app['datacenter'].storage, 'logs', 'main.log')
    108         return
    109108        return
    110109
Note: See TracChangeset for help on using the changeset viewer.