Changeset 2448
- Timestamp:
- 27 Oct 2007, 12:03:25 (17 years ago)
- Location:
- WAeUP_SRP
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/base/WAeUPTables.py
r2442 r2448 1366 1366 d['coe'] = 'Core' 1367 1367 id = code = d['id'] = brain.code 1368 is_carry_over = False1369 if brain.carry_over:1370 is_carry_over = True1371 #code = code[:-3]1372 1368 d['code'] = code 1373 1369 d['title'] = self.courses_catalog.evalAdvancedQuery(Eq('code',code))[0].title 1374 if is_carry_over:1375 d['coe'] = 'C ore'1370 if brain.carry_over: 1371 d['coe'] = 'Carry-Over' 1376 1372 carry_overs.append(d) 1377 1373 else: -
WAeUP_SRP/base/skins/waeup_student/add_course_result.py
r2033 r2448 64 64 65 65 66 cr_id = context.invokeFactory('StudentCourseResult',course_id) 67 cr = getattr(context,cr_id) 68 context.portal_workflow.doActionFor(cr,'open') 69 cr.getContent().edit(mapping=d) 66 # cr_id = context.invokeFactory('StudentCourseResult',course_id) 67 # cr = getattr(context,cr_id) 68 # context.portal_workflow.doActionFor(cr,'open') 69 # cr.getContent().edit(mapping=d) 70 d['course_id'] = course_id 71 d['student_id'] = student_id = context.getStudentId() 72 d['level_id'] = level_id = context.getId() 73 d['session_id'] = context.session 74 d['key'] = "%s|%s|%s" % (student_id,level_id,course_id) 75 76 context.course_results.addRecord(**d) 70 77 #context.portal_workflow.doActionFor(cr,'close') 71 78 #args['course_id'] = course_id … … 73 80 logger.info('%s added StudentCourseResult object %s at level %s for %s' % (member, 74 81 course_id, 75 context.getId(),76 context.getStudentId()))82 level_id, 83 student_id)) 77 84 78 85 psm = "You successfully added course %s!" % course_id … … 83 90 url = context.absolute_url() + '?' + urlencode(args) 84 91 return REQUEST.RESPONSE.redirect(url) 85 -
WAeUP_SRP/base/skins/waeup_student/course_edit.py
r2053 r2448 10 10 """ 11 11 """ 12 wf = context.portal_workflow 12 try: 13 from Products.zdb import set_trace 14 except: 15 def set_trace(): 16 pass 13 17 from urllib import urlencode 14 18 from Products.CPSDocument.utils import getFormUidUrlArg 19 from Products.AdvancedQuery import Eq, Between, Le,In 15 20 import DateTime 16 21 current = DateTime.DateTime() 17 22 import logging 18 23 logger = logging.getLogger('Skins.course_edit') 24 wf = context.portal_workflow 25 request = REQUEST 26 edit = "edit" in request.form.keys() 27 mtool = context.portal_membership 28 member = mtool.getAuthenticatedMember() 29 member_id = str(member) 30 requested_id = context.getStudentId() 31 if requested_id and not context.isStaff() and member_id != requested_id: 32 logger.info('%s tried to access personal object of %s' % (member_id,requested_id)) 33 student_id = requested_id 34 return REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) 35 elif context.isStaff(): 36 student_id = requested_id 37 else: 38 student_id = member_id 39 40 level_id = context.getId() 41 course_id = traverse_subpath[0] 42 query = Eq('student_id',student_id) &\ 43 Eq('level_id', level_id) &\ 44 Eq('code', course_id) 19 45 20 info = context.getCourseResultInfo() 46 course_results = context.course_results.evalAdvancedQuery(query) 47 mode = 'edit' 48 object = {} 49 course = course_results[0] 50 for field in context.course_results.schema(): 51 object[field] = getattr(course,field) 52 lt = context.portal_layouts 53 res,psm, ds = lt.renderLayout(schema_id = 'student_course_result', 54 layout_id = 'student_course_result_fe', 55 layout_mode = mode, 56 context=context, 57 mapping=edit and REQUEST, 58 ob=object, 59 commit = False) 21 60 22 if info is None: 23 logger.info('Anonymous user tried to access %s' % REQUEST.get('URL0')) 24 return REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) 61 while True: 62 if psm == 'invalid': 63 psm = "Please correct your input" 64 break 65 elif psm == '': 66 break 67 if edit: 68 data = {} 69 dm = ds.getDataModel() 70 for field in context.course_results.schema(): 71 if dm.has_key("%s" % field): 72 data[field] = dm.get(field) 73 data['key'] = object['key'] 74 context.course_results.modifyRecord(**data) 75 logger.info('%s edited course result data %s' % (student_id, course_id)) 76 psm = 'psm_content_changed' 77 break 25 78 26 student = info['student'] 27 #per = info['per'] 28 course_doc = info['course_doc'] 29 state = info['review_state'] 30 result_state = wf.getInfoFor(context,'review_state',None) 31 if result_state == "closed": 32 try: 33 context.portal_workflow.doActionFor(context,'open') 34 except: 35 pass 79 return context.course_edit_form(rendered = res, 80 psm = psm, 81 mode = mode, 82 ds = ds, 83 ) 36 84 37 is_valid, ds = course_doc.validate(request=REQUEST,38 schema_id = 'student_course_result',39 layout_id = 'student_course_result_fe',40 proxy=context,41 use_session=True)42 43 psm = ""44 args = {}45 action = "/course_edit_form"46 base_url = context.absolute_url()47 48 if is_valid:49 if cpsdocument_edit_button:50 #name = "%(firstname)s %(middlename)s %(lastname)s" % ds51 #name = name.strip()52 #name = name.replace(' ',' ')53 #email = ds.get('email')54 #phone = ds.get('phone')55 #student_id = context.getStudentId()56 #context.students_catalog.modifyRecord(id = student_id,57 # name = name,58 # email = email,59 # phone = phone,60 # sex = ds.get('sex'),61 # )62 logger.info('%s (%s) edited course result data %s' % (info['id'],info['review_state'],context.id))63 #action = ""64 #base_url = student.absolute_url()65 #url = base_url + action66 psm = 'psm_content_changed'67 else:68 psm = 'psm_content_error'69 args = getFormUidUrlArg(REQUEST)70 71 args['portal_status_message'] = psm72 url = base_url + action + '?' + urlencode(args)73 REQUEST.RESPONSE.redirect(url) -
WAeUP_SRP/base/skins/waeup_student/course_edit_form.pt
r1861 r2448 1 <metal:body use-macro="here/slip_template/macros/master"> 1 <tal:block define="rendered_main options/rendered; 2 portal_status_message options/psm; 3 ds options/ds; 4 mode options/mode; 5 course_id python:traverse_subpath[0]; 6 " 7 > 8 <metal:block define-macro="edit_form"> 9 <metal:block use-macro="here/slip_template/macros/master"> 10 <metal:block fill-slot="main"> 11 <h3>Update Your Course <span tal:content="course_id" /> </h3> 12 <br /> 13 14 <form action="ACTION" method="post" id="editForm" 15 enctype="multipart/form-data" class="workflow" 16 tal:attributes="action string:${context/absolute_url}/course_edit/${course_id}"> 17 <span tal:omit-tag="" tal:replace="structure rendered_main"/> 18 <br/> 19 <input type="submit" class="standalone" 20 name="edit" 21 value="Save" 22 id="edit"/> 23 </form> 24 </metal:block> 25 </metal:block> 26 </metal:block> 27 </tal:block> 2 28 3 <metal:main fill-slot="main"4 tal:define="info context/getCourseResultInfo;">5 <metal:block tal:condition="not: info">6 <span tal:content="here/illegal_view" />7 </metal:block>8 <metal:block tal:condition="info">9 <metal:block tal:define="rendered_main python:info['course_doc'].render(10 layout_mode='edit',11 schema_id = 'student_course_result',12 layout_id = 'student_course_result_fe',13 request=request,14 use_session=True,);15 form_action string:course_edit;16 edition python:True;17 metadata nothing;18 ">19 <h3>Update Your Course <span tal:content='here/id' /> </h3>20 <br />21 22 <form action="ACTION" method="post" id="editForm"23 enctype="multipart/form-data" class="workflow"24 tal:attributes="action form_action">25 <span tal:condition="not: info">26 <metal:block use-macro="here/error_not_found/macros/not_found" />27 </span>28 <span tal:condition="info">29 <span tal:omit-tag="" tal:replace="structure rendered_main"/>30 </span>31 <br/>32 <input type="submit" class="standalone"33 name="cpsdocument_edit_button"34 value="Save"35 id="cpsdocument_edit_button"/>36 </form>37 </metal:block>38 </metal:block>39 </metal:main>40 </metal:body>41 -
WAeUP_SRP/base/skins/waeup_student/create_level.py
r2033 r2448 64 64 level.getContent().edit(mapping={'session': current_session}) 65 65 context.portal_workflow.doActionFor(level,'close_for_edit') 66 context.waeup_tool.doCommit() 67 results = [] 66 #context.waeup_tool.doCommit() 67 level_id = level.getId() 68 student_id = context.getStudentId() 69 session_id = context.getLevelSession(level.getContent(),student_id,level_id) 70 68 71 if student.matric_no: 69 72 results = context.results_import(matric_no = student.matric_no) 73 records = [] 70 74 if results: 71 #carry_overs = [brain for brain in results if brain.GRADE in ('D','E','F')]72 75 l = [] 73 76 carry_overs = results 74 75 # carry_overs for probation students: yes or not, that is the question76 #if student.verdict == "C": # on probation77 # carry_overs = []78 79 77 for co in carry_overs: 80 c r_id = "%s_co" %co.CosCode81 if level.hasObject(c r_id): #already created78 course_id = co.CosCode 79 if level.hasObject(course_id): #already created 82 80 continue 83 81 carry_over = False … … 96 94 except: 97 95 # logger.info('%s, course %s has invalid score %s"' % (student.id, 98 # co .CosCode,96 # course_id, 99 97 # co.Score)) 100 98 continue … … 104 102 if not carry_over: 105 103 continue 104 if course_id in l: 105 # don't add twice 106 continue 107 l += course_id, 106 108 d = context.getCourseInfo(co.CosCode) 109 d['course_id'] = course_id 107 110 d['grade'] = co.GRADE 108 d['carry_level'] = co.CarryLevel 109 cr_id = level.invokeFactory('StudentCourseResult',"%s_co" % co.CosCode) 110 course_result = getattr(level,cr_id) 111 context.portal_workflow.doActionFor(course_result,'open') 112 course_result.getContent().edit(mapping=d) 113 context.waeup_tool.doCommit() 111 d['carry_over'] = carry_over 112 # course_id = level.invokeFactory('StudentCourseResult',"%s_co" % course_id) 113 # course_result = getattr(level,course_id) 114 # context.portal_workflow.doActionFor(course_result,'open') 115 # course_result.getContent().edit(mapping=d) 116 # context.waeup_tool.doCommit() 117 d['code'] = course_id 118 d['student_id'] = student_id 119 d['level_id'] = level_id 120 d['session_id'] = session_id 121 records.append(d) 122 114 123 #level['create_course_results'](cert_id,current_level) 115 124 res = context.portal_catalog(portal_type="Certificate", id = cert_id) 116 l = []117 125 if res: 118 126 cert = res[0] 119 127 path = cert.getPath() 120 #set_trace()121 128 query = Eq("path","%s/%s" % (path,current_level)) &\ 122 129 Eq('portal_type','CertificateCourse') 123 130 courses = aq_portal(query) 124 131 for c in courses: 125 cr_id = "%s" % c.getId 126 if level.hasObject(cr_id): #already created 132 course_id = "%s" % c.getId 133 if course_id in l: 134 # don't add twice 127 135 continue 136 l += course_id, 128 137 d = context.getCourseInfo(c.getId) 129 cr_id = level.invokeFactory('StudentCourseResult',c.getId) 130 course_result = getattr(level,cr_id) 131 context.portal_workflow.doActionFor(course_result,'open') 132 #d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective') 133 d['core_or_elective'] = True 134 course_result.getContent().edit(mapping=d) 135 context.waeup_tool.doCommit() 138 # course_id = level.invokeFactory('StudentCourseResult',c.getId) 139 # course_result = getattr(level,course_id) 140 # context.portal_workflow.doActionFor(course_result,'open') 141 # d['core_or_elective'] = True 142 # course_result.getContent().edit(mapping=d) 143 # context.waeup_tool.doCommit() 144 d['carry_over'] = False 145 d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective') 146 d['course_id'] = course_id 147 d['student_id'] = student_id = context.getStudentId() 148 d['level_id'] = level_id 149 d['session_id'] = session_id 150 #context.course_results.addRecord(**d) 151 records.append(d) 152 if records: 153 context.course_results.addMultipleRecords(records) 136 154 logger.info('%s finished to create level %s' % (student.id,current_level)) 137 155 … … 147 165 148 166 return response.redirect("%s/%s" % (context.absolute_url(),current_level)) 149 -
WAeUP_SRP/base/skins/waeup_student/delete_course_result.py
r1865 r2448 27 27 28 28 message = '' 29 student_id = context.getStudentId() 29 30 if ids: 30 real_ids = [] 31 for id in ids: 32 if context.hasObject(id): 33 real_ids.append(id) 34 for cr_id in real_ids: 35 cr = getattr(context,cr_id) 36 if wf.getInfoFor(cr,'review_state',None) == "closed": 37 context.portal_workflow.doActionFor(cr,'open') 38 if real_ids: 39 try: 40 context.manage_delObjects(real_ids) 41 logger.info('%s deleted StudentCourseResult object %s for %s' % (member,id,context.getStudentId())) 42 message = 'psm_item(s)_deleted' 43 except Unauthorized: 44 logger.info('%s has no permission to delete StudentCourseResult objects for %s' % (member,context.getStudentId())) 45 message = 'no item(s) deleted' 31 sid_level = "%s|%s" % (student_id,context.getId()) 32 for key in ['%s|%s' % (sid_level,id) for id in ids]: 33 context.course_results.deleteRecord(key) 34 logger.info('%s deleted CourseResults %s for %s' % (member,ids,student_id)) 35 message = 'psm_item(s)_deleted' 46 36 else: 47 37 message = 'psm_select_at_least_one_document' -
WAeUP_SRP/base/skins/waeup_student/getStudyLevelInfo.py
r2286 r2448 25 25 26 26 27 from Products.AdvancedQuery import Eq, Between, Le,In 28 try: 29 aq_portal = context.portal_catalog.evalAdvancedQuery 30 except: 31 aq_portal = context.portal_catalog_real.evalAdvancedQuery 27 # from Products.AdvancedQuery import Eq, Between, Le,In 28 # try: 29 # aq_portal = context.portal_catalog.evalAdvancedQuery 30 # except: 31 # aq_portal = context.portal_catalog_real.evalAdvancedQuery 32 course_results = context.course_results 32 33 request = context.REQUEST 33 34 #session = request.SESSION 34 35 response = request.RESPONSE 36 import logging 37 logger = logging.getLogger('Skins.getStudyLevelInfo') 35 38 36 39 def calculateGPA(): … … 61 64 62 65 student_id = context.getStudentId() 66 level_id = context.getId() 63 67 64 68 info = {} … … 85 89 info['status_info'] = "Courses validated" 86 90 info['doc'] = context.getContent() 87 ##study_course = context.aq_parent.getContent()88 ##cert_id = study_course.study_course89 91 cert_id = student.course 90 92 info['cert_id'] = cert_id 91 normal = [] 92 carry_overs = [] 93 credits_total = 0 94 for id,obj in context.objectItems(): 95 #try: 96 # credit = int(obj.getContent().credits) 97 #except ValueError: 98 # credit = 3 99 #credits_total += credit 100 if not id: 101 continue 102 if id.endswith('_co'): 103 d = context.getCourseInfo(id[:-3]) 104 try: 105 credits_total += int(d['credits']) 106 except ValueError: 107 credits_total += 0 108 d['id'] = id 109 d['grade'] = obj.getContent().grade 110 carry_overs.append(d) 111 else: 112 d = context.getCourseInfo(id) 113 d['id'] = id 114 coe = getattr(obj.getContent(),'core_or_elective',True) 115 d['coe'] = 'Core' 116 try: 117 credits_total += int(d['credits']) 118 except ValueError: 119 credits_total += 0 120 if not coe: 121 d['coe'] = 'Elective' 122 normal.append(d) 93 if context.objectIds(): 94 course_results.moveResultsHere(context,student_id) 95 logger.info("%s moved courseresults and deleted objects in level %s" % (student_id,level_id)) 96 credits_total,carry_overs,normal = course_results.getCourses(student_id,level_id) 123 97 info['credits_total'] = credits_total 124 max_credits = 50 125 if context.getId() == student.end_level: 126 max_credits = 51 127 info['max_credits'] = max_credits 128 info['credits_exceeded'] = credits_total > max_credits 98 info['credits_exceeded'] = credits_total > 51 129 99 current_session = student.session 130 100 info['submission_allowed']= not info['credits_exceeded'] and current_session == context.getSessionId()[-2:] 131 carry_overs.sort(cmp_semester_id)101 # carry_overs.sort(cmp_semester_id) 132 102 info['carry_overs'] = carry_overs 133 normal.sort(cmp_semester_id)103 # normal.sort(cmp_semester_id) 134 104 info['normal'] = normal 135 105 -
WAeUP_SRP/base/skins/waeup_student/level_delete.py
r2306 r2448 47 47 # evtool = getPublicEventService(here) 48 48 # evtool.notifyEvent('workflow_delete', ob, {}) 49 for level_id in ids: 50 context.course_results.deleteResultsHere(level_id,student_id) 49 51 here.manage_delObjects(ids) 52 50 53 message = 'portal_status_message=psm_item(s)_deleted' 51 54 else: -
WAeUP_SRP/base/skins/waeup_student/refresh_level.py
r2040 r2448 91 91 courses = aq_portal(query) 92 92 course_ids = [c.getId for c in courses if c.getId not in level.objectIds()] 93 for c _id in course_ids:93 for course_id in course_ids: 94 94 #set_trace() 95 d = context.getCourseInfo(c_id) 96 cr_id = level.invokeFactory('StudentCourseResult',c_id) 97 course_result = getattr(level,cr_id) 98 context.portal_workflow.doActionFor(course_result,'open') 95 d = context.getCourseInfo(course_id) 96 # cr_id = level.invokeFactory('StudentCourseResult',c_id) 97 # course_result = getattr(level,cr_id) 98 # context.portal_workflow.doActionFor(course_result,'open') 99 # course_result.getContent().edit(mapping=d) 100 # context.waeup_tool.doCommit() 99 101 d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective') 100 course_result.getContent().edit(mapping=d) 101 context.waeup_tool.doCommit() 102 #d['core_or_elective'] = True 103 d['course_id'] = course_id 104 d['student_id'] = student_id = context.getStudentId() 105 d['level_id'] = level_id = context.getId() 106 d['key'] = "%s|%s|%s" % (student_id,level_id,course_id) 107 context.course_results.addRecord(**d) 102 108 #session.set('in_progress','finished') 103 109 logger.info('%s updated course list' % member) -
WAeUP_SRP/base/skins/waeup_student/study_level_view.pt
r2279 r2448 55 55 /> 56 56 </td> 57 <td width=" 78%" tal:content="row/title"></td>57 <td width="66%" tal:content="row/title"></td> 58 58 <td align="center" width="10%" tal:content="row/code"></td> 59 59 <td align="center" width="2%">S<span tal:content="row/semester" /></td> 60 60 <td align="center" width="2%" tal:content="row/credits"></td> 61 <td align="center" width="8%" tal:content="row/grade|string:"></td> 61 <td align="center" width="10%"> <span tal:content="row/coe|nothing" /></td> 62 <td tal:condition="python:review_state == 'school_fee_paid'" align="center" width="5%"> </td> 63 62 64 </tr> 63 65 </table> … … 83 85 /> 84 86 </td> 85 <td width=" 78%" tal:content="row/title"></td>87 <td width="66%" tal:content="row/title"></td> 86 88 <td align="center" width="10%" tal:content="row/code"></td> 87 89 <td align="center" width="2%">S<span tal:content="row/semester" /></td> 88 90 <td align="center" width="2%" tal:content="row/credits"></td> 89 <td align="center" width=" 8%" tal:content="row/coe|nothing"></td>90 91 92 93 94 <td >95 <a tal:condition="python:review_state == 'school_fee_paid'" href="edit" tal:attributes="href string:${row/code}/course_edit_form"91 <td align="center" width="10%" tal:content="row/coe|nothing"></td> 92 93 94 95 96 <td tal:condition="python:review_state == 'school_fee_paid'" width="5%" align="center"> 97 <a href="edit" tal:attributes="href string:course_edit/${row/code}" 96 98 target="edit" 97 99 onclick="javascript:window.open('','edit','width=600, height=350, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')"> -
WAeUP_SRP/fceokene/profiles/default/layouts/student_course_result.xml
r1861 r2448 134 134 <cell name="core_or_elective "/> 135 135 </row> 136 <row>137 <cell name="carry_level"/>138 </row>139 136 </table> 140 137 </object>
Note: See TracChangeset for help on using the changeset viewer.