Changeset 398 for WAeUP_SRP/trunk/Students.py
- Timestamp:
- 21 Aug 2006, 14:29:27 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Students.py
r396 r398 19 19 p_home = Globals.package_home(globals()) 20 20 i_home = Globals.INSTANCE_HOME 21 MAX_TRANS = 1000 21 22 22 23 class StudentsFolder(CPSDocument): ###( … … 32 33 """load Fulltime Studentdata from CSV values""" 33 34 #return 35 import transaction 36 tr_count = 0 34 37 name = 'short_full_time' 35 38 no_import = False … … 64 67 continue 65 68 certcode = makeCertificateCode(student.get('CourseMajor')) 66 if sid in students_added:67 em = 'Student with ID %(MatricNo)s %(fullname)s already exists in this import\n' % student68 logger.info(em)69 no_import.write(em)70 no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)71 continue69 ## if sid in students_added: 70 ## em = 'Student with ID %(MatricNo)s %(fullname)s already exists in this import\n' % student 71 ## logger.info(em) 72 ## no_import.write(em) 73 ## no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student) 74 ## continue 72 75 s = studs.get(sid,None) 73 76 if certcode not in certs.keys(): … … 92 95 s = getattr(self,sid) 93 96 students_added.append(sid) 97 studs[sid] = s 94 98 s.invokeFactory('StudentPersonal','personal') 95 99 sp = s.personal … … 153 157 no_import.write(em) 154 158 no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student) 159 if tr_count > MAX_TRANS: 160 #transaction.commit() 161 #em = '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Transaction commited\n' % student 162 logger.info(em) 163 tr_count = 0 164 tr_count += 1 155 165 return self.students.academics_contents() 156 166 ###) 157 167 158 security.declareProtected(ModifyPortalContent,"loadFullTimeStudentsResultsFromCSV") 168 security.declareProtected(ModifyPortalContent,"loadFullTimeStudentsResultsFromCSV") ###( 159 169 def loadFullTimeStudentsResultsFromCSV(self): 160 170 """load Fulltime Studentdata from CSV values""" 161 171 #return 162 name = 'short_full_time_results_2004_2005.csv' 172 import transaction 173 tr_count = 0 174 name = 'short_full_time_results_2004_2005' 163 175 no_import = False 164 176 if not no_import: … … 177 189 for s in l: 178 190 students[s.id] = s.getObject() 179 courses = self.portal_catalog({'meta_type': "Course"}) 191 l = self.portal_catalog({'meta_type': "Course"}) 192 courses = {} 193 for c in l: 194 courses[c.id] = c.getObject() 180 195 for result in results: 181 196 sid = result.get('Matnumber') 182 197 if sid not in students.keys(): 183 em = 'Student with ID %(Matnumber)s not found\n' % student184 logger.info(em) 185 no_import.write(em) 186 no_import.write('"%(Matnumber)s","%(CosCode)s","%(Ansbook)s","%(CosStuatus)s","%(Session)s","%(Mat_Cos)s","%(Score)s","%(CarryLevel)s","%(Grade)s","%(Weight)s","%(Semster)s","%(Verdict)s","%(Level)s","%(id)s","%(GPA)s"\n' % student)198 em = 'Student with ID %(Matnumber)s not found\n' % result 199 logger.info(em) 200 no_import.write(em) 201 no_import.write('"%(Matnumber)s","%(CosCode)s","%(Ansbook)s","%(CosStuatus)s","%(Session)s","%(Mat_Cos)s","%(Score)s","%(CarryLevel)s","%(Grade)s","%(Weight)s","%(Semster)s","%(Verdict)s","%(Level)s","%(id)s","%(GPA)s"\n' % result) 187 202 continue 188 if student.get('CosCode') not in courses: 189 em = 'Course with ID %(CosCode)s not found\n' % student 190 logger.info(em) 191 no_import.write(em) 192 no_import.write('"%(Matnumber)s","%(CosCode)s","%(Ansbook)s","%(CosStuatus)s","%(Session)s","%(Mat_Cos)s","%(Score)s","%(CarryLevel)s","%(Grade)s","%(Weight)s","%(Semster)s","%(Verdict)s","%(Level)s","%(id)s","%(GPA)s"\n' % student) 203 course = result.get('CosCode') 204 if course not in courses.keys(): 205 em = 'Course with ID %(CosCode)s not found\n' % result 206 logger.info(em) 207 no_import.write(em) 208 no_import.write('"%(Matnumber)s","%(CosCode)s","%(Ansbook)s","%(CosStuatus)s","%(Session)s","%(Mat_Cos)s","%(Score)s","%(CarryLevel)s","%(Grade)s","%(Weight)s","%(Semster)s","%(Verdict)s","%(Level)s","%(id)s","%(GPA)s"\n' % result) 193 209 continue 194 level = student.get('Level')210 level = result.get('Level') 195 211 try: 196 212 int(level) 197 213 except: 198 em = 'Result for Student with ID %(Matnumber)s Course %(CosCode)s Level is empty\n' % student199 logger.info(em) 200 no_import.write(em) 201 no_import.write('"%(Matnumber)s","%(CosCode)s","%(Ansbook)s","%(CosStuatus)s","%(Session)s","%(Mat_Cos)s","%(Score)s","%(CarryLevel)s","%(Grade)s","%(Weight)s","%(Semster)s","%(Verdict)s","%(Level)s","%(id)s","%(GPA)s"\n' % student)214 em = 'Result for result with ID %(Matnumber)s Course %(CosCode)s Level is empty\n' % result 215 logger.info(em) 216 no_import.write(em) 217 no_import.write('"%(Matnumber)s","%(CosCode)s","%(Ansbook)s","%(CosStuatus)s","%(Session)s","%(Mat_Cos)s","%(Score)s","%(CarryLevel)s","%(Grade)s","%(Weight)s","%(Semster)s","%(Verdict)s","%(Level)s","%(id)s","%(GPA)s"\n' % result) 202 218 continue 203 219 sf = students.get(sid) … … 206 222 if l is None: 207 223 #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep) 208 logger.info('Creating Level %( StudentLevel)s for %(fullname)s' % student)224 logger.info('Creating Level %(Level)s for %(Matnumber)s' % result) 209 225 sc.invokeFactory('StudyLevel', level) 210 226 l = getattr(sc, level) … … 216 232 second_s = getattr(l,'second') 217 233 second_s.getContent().edit(mapping={'Title': 'Second Semester'}) 218 snr = student.get('Semester')234 snr = result.get('Semester') 219 235 semester = getattr(l,'first') 220 if snr == " 1":236 if snr == "2": 221 237 semester = getattr(l,'second') 238 logger.info('Creating CourseTicket %(CourseTicket)s in Level %(Level)s for %(Matnumber)s' % result) 239 semester.invokeFactory('CourseTicket',course) 240 ct = getattr(semester,course) 241 d = {} 242 d['ansbook'] = result.get('Ansbook') 243 d['status'] = result.get('CosStuatus') 244 d['score'] = result.get('Score') 245 d['carry_level'] = result.get('CarryLevel') 246 d['grade'] = result.get('Grade') 247 d['weight'] = result.get('Weight') 248 d['verdict'] = result.get('Verdict') 249 d['import_id'] = result.get('id') 250 gpa = result.get('GPA').replace(',','.') 251 d['gpa'] = float(gpa) 252 ct.getContent().edit(mapping = d) 253 if tr_count > MAX_TRANS: 254 transaction.commit() 255 tr_count = 0 256 tr_count += 1 257 return self.students.academics_contents() 222 258 223 224 225 259 ###) 260 261 226 262 security.declareProtected(View,"Title") 227 263 def Title(self):
Note: See TracChangeset for help on using the changeset viewer.