Changeset 15414 for main/waeup.aaue/trunk
- Timestamp:
- 17 May 2019, 15:13:53 (6 years ago)
- Location:
- main/waeup.aaue/trunk/src/waeup/aaue/students
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py
r15409 r15414 1035 1035 1036 1036 We expect uploadfile to be a regular CSV file with columns 1037 ``student_id``, ``score`` and ``ca`` (other cols are ignored). 1037 ``student_id``, ``score``, ``imported_ts`` 1038 and ``ca`` (other cols are ignored). 1038 1039 """ 1039 1040 result = dict() … … 1041 1042 reader = csv.DictReader(data) 1042 1043 for row in reader: 1043 if not ('student_id' in row and 'score' in row and 'ca' in row): 1044 if not ('student_id' in row and 'score' in row and 'ca' in row and 1045 'imported_ts' in row): 1044 1046 continue 1045 result[row['student_id']] = (row['score'], row['ca']) 1047 result[row['student_id']] = ( 1048 row['score'], row['ca'], row['imported_ts']) 1046 1049 return result 1047 1050 … … 1063 1066 return False 1064 1067 else: 1065 formvals = dict(zip(form['sids'], zip(form['scores'], form['cas']))) 1068 formvals = dict(zip(form['sids'], zip( 1069 form['scores'], form['cas'], form['imported_tss']))) 1066 1070 for ticket in self.editable_tickets: 1067 1071 ticket_error = False 1068 1072 score = ticket.score 1069 1073 ca = ticket.ca 1074 imported_ts = ticket.imported_ts 1070 1075 sid = ticket.student.student_id 1071 1076 if formvals[sid][0] == '': … … 1073 1078 if formvals[sid][1] == '': 1074 1079 ca = None 1080 if formvals[sid][2] == '': 1081 imported_ts = None 1075 1082 try: 1076 1083 if formvals[sid][0]: … … 1078 1085 if formvals[sid][1]: 1079 1086 ca = int(formvals[sid][1]) 1087 if formvals[sid][2]: 1088 imported_ts = int(formvals[sid][2]) 1080 1089 except ValueError: 1081 1090 error += '%s, ' % ticket.student.display_fullname … … 1102 1111 (ob_class, ticket.student.student_id, 1103 1112 ticket.level, ticket.code, ca)) 1113 if not ticket_error and ticket.imported_ts != imported_ts: 1114 try: 1115 ticket.imported_ts = imported_ts 1116 except TooBig: 1117 error += '%s, ' % ticket.student.display_fullname 1118 pass 1119 ticket.student.__parent__.logger.info( 1120 '%s - %s %s/%s imported_ts updated (%s)' % 1121 (ob_class, ticket.student.student_id, 1122 ticket.level, ticket.code, imported_ts)) 1104 1123 if error: 1105 self.flash(_('Error: Score(s) and CA(s) of %s have not be updated. '1124 self.flash(_('Error: Score(s), CA(s) and Imported TS(s) of %s have not be updated. ' 1106 1125 % error.strip(', ')), type="danger") 1107 1126 return True -
main/waeup.aaue/trunk/src/waeup/aaue/students/browser_templates/editscorespage.pt
r15411 r15414 1 1 <p i18n:domain="waeup.kofa" i18n:translate="edit_scores_info"> 2 2 This page helps you to update your students' course results. 3 You can either update scores and CAs by importing a csv file3 You can either update Scores, CAs and Imported Total Scores by importing a csv file 4 4 (press 'Help' for further information) or by 5 changing score or CA values in the table below. Only scores and CAs6 of students in current session5 changing Score, CA or Imported Total Score values in the table below. 6 Only course results of students in current session 7 7 <span i18n:name="current_academic_session" 8 8 tal:replace="view/session_title"></span> … … 81 81 <th i18n:translate="">Course of Studies</th> 82 82 <th i18n:translate="">Level</th> 83 <th i18n:translate="">Imp. TS</th>84 83 <th i18n:translate="">Score</th> 85 84 <th i18n:translate="">CA</th> 85 <th i18n:translate="">Imp. Total Score</th> 86 86 </tr> 87 87 </thead> … … 94 94 <td tal:content="ticket/student/certcode">CERTCODE</td> 95 95 <td tal:content="ticket/level">LEVEL</td> 96 <td tal:content="ticket/imported_ts">IMPORTED TS</td>97 96 <td style="width: 65px;"> 98 97 <input type="text" name="scores:list" class="form-control" … … 105 104 tal:attributes="value ticket/ca" /> 106 105 </td> 106 <td style="width: 65px;"> 107 <input type="text" name="imported_tss:list" class="form-control" 108 tal:attributes="value ticket/imported_ts" /> 109 </td> 107 110 </tr> 108 111 </tbody> -
main/waeup.aaue/trunk/src/waeup/aaue/students/export.py
r15336 r15414 117 117 'depcode', 'faccode', 118 118 'level', 'code', 'level_session', 'ca', 'score', 119 'total_score', 'grade' )119 'total_score', 'grade', 'imported_ts') 120 120 121 121 def mangle_value(self, value, name, context=None): -
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
r15398 r15414 46 46 UPLOAD_CSV_TEMPLATE = ( 47 47 'matric_number,student_id,display_fullname,level,code,level_session,' 48 'score,ca \r\n'49 '234,E1000000,Anna Tester,100,COURSE1,2004,%s,%s \r\n')48 'score,ca,imported_ts\r\n' 49 '234,E1000000,Anna Tester,100,COURSE1,2004,%s,%s,%s\r\n') 50 50 51 51 class OfficerUITests(StudentsFullSetup): … … 371 371 self.browser.open(self.edit_scores_url) 372 372 upload_ctrl = self.browser.getControl(name='uploadfile:file') 373 upload_file = StringIO(UPLOAD_CSV_TEMPLATE % ('65','22' ))373 upload_file = StringIO(UPLOAD_CSV_TEMPLATE % ('65','22','77')) 374 374 upload_ctrl.add_file(upload_file, 'text/csv', 'myscores.csv') 375 375 self.browser.getControl("Update editable scores from").click() … … 379 379 self.assertEqual( 380 380 self.student['studycourse']['100']['COURSE1'].ca, 22) 381 self.assertEqual( 382 self.student['studycourse']['100']['COURSE1'].imported_ts, 77) 381 383 382 384 def test_scores_previous_session(self): … … 400 402 'matric_number,student_id,display_fullname,' 401 403 'depcode,faccode,level,code,level_session,ca,score,' 402 'total_score,grade \r\n234,E1000000,"TESTER, Anna",dep1,fac1,'403 '100,COURSE1,2003,,55,, \r\n')404 'total_score,grade,imported_ts\r\n234,E1000000,"TESTER, Anna",dep1,fac1,' 405 '100,COURSE1,2003,,55,,,\r\n') 404 406 self.browser.open(self.edit_prev_scores_url) 405 407 upload_ctrl = self.browser.getControl(name='uploadfile:file') 406 upload_file = StringIO(UPLOAD_CSV_TEMPLATE % ('65','22' ))408 upload_file = StringIO(UPLOAD_CSV_TEMPLATE % ('65','22','77')) 407 409 upload_ctrl.add_file(upload_file, 'text/csv', 'myscores.csv') 408 410 self.browser.getControl("Update editable scores from").click() … … 412 414 self.assertEqual( 413 415 self.student['studycourse']['100']['COURSE1'].ca, 22) 416 self.assertEqual( 417 self.student['studycourse']['100']['COURSE1'].imported_ts, 77) 414 418 415 419 def test_lecturers_can_download_course_tickets(self): … … 1244 1248 self.browser.getControl(name="scores:list", index=0).value = 'abc' 1245 1249 self.browser.getControl("Update scores").click() 1246 self.assertTrue('Error: Score(s) and CA(s) of TESTER, Anna have not be updated.'1250 self.assertTrue('Error: Score(s), CA(s) and Imported TS(s) of TESTER, Anna have not be updated.' 1247 1251 in self.browser.contents) 1248 1252 # Scores can be removed.
Note: See TracChangeset for help on using the changeset viewer.