Changeset 723
- Timestamp:
- 19 Oct 2006, 17:06:51 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 4 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/Students.py
r714 r723 23 23 MAX_TRANS = 1000 24 24 25 def getInt(s): 26 try: 27 return int(s) 28 except: 29 return 0 25 30 26 31 def getStudentByRegNo(self,reg_no): ###( … … 152 157 dsc = {} 153 158 dsc['study_course'] = certcode 159 dsc['department'] = student.get('Dept') 160 dsc['faculty'] = student.get('Faculty') 154 161 css = student.get('CurrentSession') or '2004-2005' 155 162 cs = int(css.split('-')[0]) - 2000 … … 161 168 # Level 162 169 # 163 l = getattr(studycourse,level,None) 164 if l is None: 165 #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep) 166 logger.info('Creating Level %(StudentLevel)s for %(fullname)s' % student) 167 studycourse.invokeFactory('StudentStudyLevel', level) 168 l = getattr(studycourse, level) 169 certificate = certs[certcode] 170 cert_level = getattr(certificate,level,None) 171 if cert_level is None: 172 logger.info('Level %(level)s not in %(certcode)s' % vars()) 173 l.getContent().edit(mapping={'Title': "Level %s" % level}) 174 ## l.invokeFactory('StudentSemester','first') 175 ## l.invokeFactory('StudentSemester','second') 176 ## first_s = getattr(l,'first') 177 ## first_s.getContent().edit(mapping={'Title': 'First Semester'}) 178 ## second_s = getattr(l,'second') 179 ## second_s.getContent().edit(mapping={'Title': 'Second Semester'}) 170 ## l = getattr(studycourse,level,None) 171 ## if 0 and l is None: 172 ## #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep) 173 ## logger.info('Creating Level %(StudentLevel)s for %(fullname)s' % student) 174 ## studycourse.invokeFactory('StudentStudyLevel', level) 175 ## l = getattr(studycourse, level) 176 ## certificate = certs[certcode] 177 ## cert_level = getattr(certificate,level,None) 178 ## if cert_level is None: 179 ## logger.info('Level %(level)s not in %(certcode)s' % vars()) 180 ## l.getContent().edit(mapping={'Title': "Level %s" % level}) 180 181 else: 181 182 em = 'Student with ID %(MatricNo)s %(fullname)s already exists\n' % student … … 207 208 """load Fulltime Studentdata from CSV values""" 208 209 #return 210 level_wf_actions = {} 211 level_wf_actions["SUCCESSFUL STUDENT"] = "pass_A" 212 level_wf_actions["STUDENT WITH CARRYOVER COURSES"] = "pass_B" 213 level_wf_actions["STUDENT FOR PROBATION"] = "pass_C" 214 level_wf_actions["STUDENT ON PROBATION/TRANSFER"] = "pass_D" 209 215 import transaction 216 wftool = self.portal_workflow 210 217 tr_count = 0 211 218 name = 'short_full_time_results_2004_2005' … … 226 233 for c in l: 227 234 courses[c.id] = c.getObject() 235 level_changed = False 236 student_changed = False 237 sid = '' 238 #import pdb;pdb.set_trace() 228 239 for result in results: 229 sid = result.get('Matnumber') 230 res = self.portal_catalog({'meta_type': "StudentClearance", 231 'matric_no': sid }) 232 if not res: 233 em = 'Student with ID %(Matnumber)s not found\n' % result 234 logger.info(em) 235 no_import.write(em) 236 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) 237 continue 238 sf = res[0].getObject().aq_parent 239 result['StudentId'] = sf.getId() 240 temp_sid = result.get('Matnumber') 241 if temp_sid != sid: 242 student_changed = True 243 res = self.portal_catalog({'meta_type': "StudentClearance", 244 'SearchableText': temp_sid }) 245 if not res: 246 em = 'Student with ID %(Matnumber)s not found\n' % result 247 logger.info(em) 248 no_import.write(em) 249 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) 250 continue 251 elif len(res) > 1: 252 em = 'More than one Student with ID %(Matnumber)s found\n' % result 253 logger.info(em) 254 no_import.write(em) 255 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) 256 continue 257 sid = temp_sid 258 sf = res[0].getObject().aq_parent 259 sc = getattr(sf,'study_course') 260 level = '' 261 else: 262 student_changed = False 240 263 course = result.get('CosCode') 241 264 if course not in courses.keys(): … … 245 268 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) 246 269 continue 247 level = result.get('Level') 248 try: 249 int(level) 250 except: 251 em = 'Result for result with ID %(Matnumber)s Course %(CosCode)s Level is empty\n' % result 252 logger.info(em) 253 no_import.write(em) 254 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) 255 continue 256 sc = getattr(sf,'study_course') 257 l = getattr(sc,level,None) 258 if l is None: 259 #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep) 260 logger.info('Creating Level %(Level)s for %(StudentId)s %(Matnumber)s' % result) 261 sc.invokeFactory('StudentStudyLevel', level) 262 l = getattr(sc, level) 263 l.invokeFactory('StudentSemester','first') 264 l.invokeFactory('StudentSemester','second') 265 first_s = getattr(l,'first') 266 first_s.getContent().edit(mapping={'Title': 'First Semester'}) 267 second_s = getattr(l,'second') 268 second_s.getContent().edit(mapping={'Title': 'Second Semester'}) 269 snr = result.get('Semster') 270 semester = getattr(l,'first') 271 if snr == "2": 272 semester = getattr(l,'second') 273 logger.info('Creating StudentCourseResult %(CosCode)s in Level %(Level)s for %(StudentId)s %(Matnumber)s' % result) 274 semester.invokeFactory('StudentCourseResult',course) 275 ct = getattr(semester,course) 276 d = {} 270 temp_level = result.get('Level') 271 result['StudentId'] = sf.getId() 272 if temp_level != level: 273 try: 274 int(temp_level) 275 except: 276 em = 'Result with ID %(Matnumber)s Course %(CosCode)s Level is empty\n' % result 277 logger.info(em) 278 no_import.write(em) 279 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) 280 continue 281 if level_changed: 282 wftool.doActionFor(l,level_wf_actions[dlev['verdict']]) 283 level_changed = True 284 level = temp_level 285 l = getattr(sc,level,None) 286 if l is None: 287 logger.info('Creating Level %(Level)s for %(StudentId)s %(Matnumber)s' % result) 288 sc.invokeFactory('StudentStudyLevel', level) 289 l = getattr(sc, level) 290 else: 291 level_changed = False 292 cr = getattr(l,course,None) 293 if cr is None: 294 logger.info('Creating Course %(CosCode)s for %(StudentId)s %(Matnumber)s in Level %(Level)s' % result) 295 l.invokeFactory('StudentCourseResult',course) 296 cr = getattr(l,course) 297 dcr = {} 277 298 dlev = {} 278 d['ansbook'] = result.get('Ansbook') 279 d['status'] = result.get('CosStuatus') 280 d['score'] = result.get('Score') 299 dcr['ansbook'] = result.get('Ansbook') 300 dcr['semester'] = getInt(result.get('Semster')) 301 dcr['status'] = result.get('CosStuatus') 302 dcr['score'] = getInt(result.get('Score')) 281 303 dlev['session'] = result.get('Session') 282 d lev['carry_level'] = result.get('CarryLevel')283 d ['grade'] = result.get('Grade')304 dcr['carry_level'] = result.get('CarryLevel') 305 dcr['grade'] = result.get('Grade') 284 306 #d['weight'] = result.get('Weight') 285 307 dlev['verdict'] = result.get('Verdict') … … 287 309 #gpa = result.get('GPA').replace(',','.') 288 310 #d['gpa'] = float(gpa) 289 c t.getContent().edit(mapping = d)311 cr.getContent().edit(mapping = dcr) 290 312 l.getContent().edit(mapping = dlev) 291 313 if tr_count > MAX_TRANS: … … 293 315 tr_count = 0 294 316 tr_count += 1 317 wftool.doActionFor(cr,'close') 318 wftool.doActionFor(l,level_wf_actions[dlev['verdict']]) 295 319 return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1')) 296 320 … … 564 588 return "Level %s" % self.aq_parent.getId() 565 589 566 security.declareProtected(View,"gpa")567 def gpa(self):568 """calculate the gpa"""569 sum = 0570 course_count = 0571 for semester in ('first','second'):572 sf=getattr(self,semester)573 for sc in sf.objectValues():574 result = sc.getContent() 575 576 577 578 579 580 581 582 if course_count:583 return sum/course_count584 return 0.0590 ## security.declarePublic("gpa") 591 ## def gpa(self): 592 ## """calculate the gpa""" 593 ## sum = 0 594 ## course_count = 0 595 ## for sc in self.objectValues(): 596 ## result = sc.getContent() 597 ## if not result.grade: 598 ## continue 599 ## res = self.portal_catalog({'meta_type': 'Course', 600 ## 'id': sc.aq_parent.id}) 601 ## if len(res) != 1: 602 ## continue 603 ## course = res[0].getObject().getContent() 604 ## sum += course.credits * ['F','E','D','C','B','A'].index(result.grade) 605 ## course_count += 1 606 ## if course_count: 607 ## return sum/course_count 608 ## return 0.0 585 609 586 610 InitializeClass(StudentStudyLevel) … … 683 707 684 708 def getCourseEntry(self,cid): 685 res = self.portal_catalog({'meta_type': " StudentCourse",709 res = self.portal_catalog({'meta_type': "Course", 686 710 'id': cid}) 687 711 if res: … … 693 717 def Title(self): 694 718 """compose title""" 695 cid = self. getId()719 cid = self.aq_parent.getId() 696 720 ce = self.getCourseEntry(cid) 697 721 if ce: -
WAeUP_SRP/trunk/profiles/default/layouts/student_course_results.xml
r486 r723 14 14 <property name="label">Ansbook</property> 15 15 <property name="label_edit">Ansbook</property> 16 <property name="readonly_layout_modes"/> 17 <property name="hidden_layout_modes"/> 18 <property name="hidden_readonly_layout_modes"/> 19 </widget> 20 <widget name="semester" meta_type="Int Widget"> 21 <property name="title">Semester</property> 22 <property name="fields"> 23 <element value="semester"/> 24 </property> 25 <property name="label">Semester</property> 26 <property name="label_edit">Semester</property> 16 27 <property name="readonly_layout_modes"/> 17 28 <property name="hidden_layout_modes"/> … … 108 119 <table> 109 120 <row> 121 <cell name="semester"/> 122 </row> 123 <row> 110 124 <cell name="grade"/> 111 125 </row> -
WAeUP_SRP/trunk/profiles/default/layouts/student_study_course.xml
r486 r723 19 19 <property name="hidden_readonly_layout_modes"/> 20 20 </widget> 21 <widget name="department" meta_type="String Widget"> 22 <property name="title">Department Code</property> 23 <property name="fields"> 24 <element value="department"/> 25 </property> 26 <property name="is_required">True</property> 27 <property name="label">Department Code</property> 28 <property name="label_edit">Department Code</property> 29 <property name="readonly_layout_modes"/> 30 <property name="hidden_layout_modes"/> 31 <property name="hidden_readonly_layout_modes"/> 32 </widget> 33 <widget name="faculty" meta_type="String Widget"> 34 <property name="title">Faculty Code</property> 35 <property name="fields"> 36 <element value="faculty"/> 37 </property> 38 <property name="is_required">True</property> 39 <property name="label">Faculty Code</property> 40 <property name="label_edit">Faculty Code</property> 41 <property name="readonly_layout_modes"/> 42 <property name="hidden_layout_modes"/> 43 <property name="hidden_readonly_layout_modes"/> 44 </widget> 21 45 <table> 22 46 <row> 23 47 <cell name="study_course"/> 24 48 </row> 49 <row> 50 <cell name="faculty"/> 51 </row> 52 <row> 53 <cell name="department"/> 54 </row> 25 55 </table> 26 56 </object> -
WAeUP_SRP/trunk/profiles/default/schemas/student_course_results.xml
r486 r723 8 8 <field name="score" meta_type="CPS Int Field"/> 9 9 <field name="status" meta_type="CPS String Field"/> 10 <field name="verdict" meta_type="CPS String Field"/> 10 <field name="semester" meta_type="CPS Int Field"> 11 <property name="default_expr">python:1</property> 12 </field> <field name="verdict" meta_type="CPS String Field"/> 11 13 <field name="weight" meta_type="CPS String Field"/> 12 14 </object> -
WAeUP_SRP/trunk/profiles/default/schemas/student_study_course.xml
r486 r723 1 1 <?xml version="1.0"?> 2 2 <object name="student_study_course" meta_type="CPS Schema"> 3 <field name="study_course" meta_type="CPS String Field"/> 3 <field name="study_course" meta_type="CPS String Field"> 4 <property name="is_searchabletext">True</property> 5 </field> 6 <field name="faculty" meta_type="CPS String Field"> 7 <property name="is_searchabletext">True</property> 8 </field> 9 <field name="department" meta_type="CPS String Field"> 10 <property name="is_searchabletext">True</property> 11 </field> 4 12 </object> -
WAeUP_SRP/trunk/profiles/default/types/StudentCourseResult.xml
r684 r723 17 17 <property name="cps_display_as_document_in_listing">True</property> 18 18 <property name="schemas"> 19 <element value=" course_results"/>19 <element value="student_course_results"/> 20 20 </property> 21 21 <property name="layouts"> 22 <element value=" course_results"/>22 <element value="student_course_results"/> 23 23 </property> 24 24 <property name="layout_clusters"/> -
WAeUP_SRP/trunk/profiles/default/types/StudentStudyCourse.xml
r486 r723 30 30 <property name="storage_methods"/> 31 31 <property name="cps_is_portlet">False</property> 32 <alias from="(Default)" to=" academics_contents"/>33 <alias from="view" to=" academics_contents"/>32 <alias from="(Default)" to="student_index"/> 33 <alias from="view" to="student_index"/> 34 34 <action title="View" action_id="view" category="object" condition_expr="" 35 url_expr="string:${object_url}/ academics_contents" visible="True">35 url_expr="string:${object_url}/student_index" visible="True"> 36 36 <permission value="View"/> 37 37 </action> -
WAeUP_SRP/trunk/profiles/default/types/StudentStudyLevel.xml
r486 r723 8 8 <property name="product">WAeUP_SRP</property> 9 9 <property name="factory">addStudentStudyLevel</property> 10 <property name="immediate_view"> academics_contents</property>10 <property name="immediate_view">student_index</property> 11 11 <property name="global_allow">True</property> 12 12 <property name="filter_content_types">True</property> … … 28 28 <property name="storage_methods"/> 29 29 <property name="cps_is_portlet">False</property> 30 <alias from="(Default)" to=" academics_contents"/>30 <alias from="(Default)" to="student_index"/> 31 31 <alias from="create_do" to="waeup_document_create_do"/> 32 32 <alias from="created" to="level_created"/> 33 <alias from="view" to=" academics_contents"/>33 <alias from="view" to="student_index"/> 34 34 <action title="View" action_id="view" category="object" condition_expr="" 35 url_expr="string:${object_url}/ academics_contents" visible="True">35 url_expr="string:${object_url}/student_index" visible="True"> 36 36 <permission value="View"/> 37 37 </action> -
WAeUP_SRP/trunk/profiles/default/workflows.xml
r639 r723 58 58 <bound-workflow workflow_id="section_folder_wf"/> 59 59 </type> 60 <type type_id="Semester">61 <bound-workflow workflow_id="section_folder_wf"/>62 </type>63 60 <type type_id="Student"> 64 61 <bound-workflow workflow_id="waeup_student_wf"/> … … 77 74 </type> 78 75 <type type_id="StudentStudyCourse"> 79 <bound-workflow workflow_id=" section_folder_wf"/>76 <bound-workflow workflow_id="waeup_student_subobject_wf"/> 80 77 </type> 81 78 <type type_id="StudentCourseResult"> 82 <bound-workflow workflow_id="waeup_ base_wf"/>79 <bound-workflow workflow_id="waeup_student_subobject_wf"/> 83 80 </type> 84 81 <type type_id="StudentsFolder"> … … 89 86 </type> 90 87 <type type_id="StudentStudyLevel"> 91 <bound-workflow workflow_id="section_folder_wf"/> 92 </type> 93 <type type_id="StudentSemester"> 94 <bound-workflow workflow_id="section_folder_wf"/> 88 <bound-workflow workflow_id="waeup_course_registration_wf"/> 95 89 </type> 96 90 <type type_id="University"> -
WAeUP_SRP/trunk/profiles/default/workflows/waeup_course_registration_wf/definition.xml
r722 r723 23 23 </state> 24 24 <state state_id="created" title=""> 25 <exit-transition transition_id="create_content"/> 25 26 <exit-transition transition_id="enter_school_fee_pin"/> 27 <exit-transition transition_id="pass_A"/> 28 <exit-transition transition_id="pass_B"/> 29 <exit-transition transition_id="probate_C"/> 30 <exit-transition transition_id="reject_D"/> 31 <exit-transition transition_id="reject_E"/> 32 <exit-transition transition_id="reject_F"/> 26 33 </state> 27 34 <state state_id="school_fee_pin_entered" title=""> -
WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_subobject_wf/definition.xml
r659 r723 12 12 <state state_id="created" title=""> 13 13 <exit-transition transition_id="close"/> 14 <exit-transition transition_id="create_content"/> 14 15 <exit-transition transition_id="open"/> 15 16 <permission-map name="Modify portal content" … … 24 25 <state state_id="opened" title=""> 25 26 <exit-transition transition_id="close"/> 27 <exit-transition transition_id="create_content"/> 26 28 <permission-map name="Modify portal content" 27 29 acquired="True"> … … 55 57 <transition-behavior behavior_id="initial-create"/> 56 58 </transition> 59 <transition transition_id="create_content" title="" 60 new_state="" trigger="USER" before_script="" 61 after_script=""> 62 63 <guard> 64 </guard> 65 <transition-behavior behavior_id="allow-sub-create"/> 66 </transition> 57 67 <transition transition_id="open" title="" 58 68 new_state="opened" trigger="USER" -
WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml
r677 r723 37 37 <state state_id="created" title=""> 38 38 <exit-transition transition_id="create_content"/> 39 <exit-transition transition_id="clear_and_validate"/> 39 40 <exit-transition transition_id="enter_application_pin"/> 40 41 <exit-transition transition_id="open"/> -
WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py
r674 r723 21 21 roles = member.getRoles() 22 22 info = {} 23 info['is_manager'] = context.isManager 23 info['is_manager'] = context.isManager() 24 24 info['is_student'] = context.isStudent() 25 25 member_id = str(member) … … 66 66 'StudentPersonal': '', 67 67 } 68 s_view_links = {'StudentApplication': 'application_view', 69 'StudentAccommodation': 'accommodation_view', 70 'StudentPersonal': 'personal_view', 68 s_view_links = {'StudentApplication': None, 69 'StudentAccommodation': None, 70 'StudentPersonal': None, 71 'StudentStudyCourse': 'study_course_view', 71 72 } 72 73 sos = context.portal_catalog(container_path=student_path) … … 80 81 row['type'] = so.portal_type 81 82 row['is_editable'] = mtool.checkPermission('Modify portal content', soo) 82 sv_link = s_view_links.get(so.portal_type,None) 83 row['s_view_link'] = None 84 if sv_link: 85 row['s_view_link'] = "%s/%s" % (student.absolute_url(),sv_link) 83 sv_link = s_view_links.get(so.portal_type,None) or "academics_document_view" 84 row['s_view_link'] = "%s/%s" % (soo.absolute_url(),sv_link) 86 85 se_link = s_edit_links.get(so.portal_type,None) 87 86 row['s_edit_link'] = None -
WAeUP_SRP/trunk/skins/waeup_student/student_index.py
r681 r723 20 20 return redirect("%s/srp_anonymous_view" % context.absolute_url()) 21 21 if context.isManager(): 22 if context.portal_type == 'StudentStudyCourse': 23 return context.study_course_view() 24 elif context.portal_type == 'StudentStudyLevel': 25 return context.study_level_view() 22 26 return redirect("%s/student_view" % context.absolute_url()) 23 27 if context.isStudent(): -
WAeUP_SRP/trunk/skins/waeup_student/student_view.pt
r674 r723 23 23 <tr tal:repeat="row rows" 24 24 tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')"> 25 <td><a href="view" tal:attributes="href string:${row/ url}/academics_document_view">25 <td><a href="view" tal:attributes="href string:${row/s_view_link}"> 26 26 <strong tal:content="row/title" /></a> </td> 27 27 <td>
Note: See TracChangeset for help on using the changeset viewer.