Changeset 1380
- Timestamp:
- 31 Jan 2007, 16:24:18 (18 years ago)
- Location:
- WAeUP_SRP/trunk/skins
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/skins/waeup_student/getStudyCourseInfo.py
r913 r1380 18 18 19 19 info = {} 20 info['is_so'] = context.isSectionOfficer() 20 21 info['action'] = "%s" % context.campus.absolute_url() 21 22 info['choosen_ids'] = request.get('ids',[]) 22 info['doc'] = context.getContent() 23 course = info['doc'] = context.getContent() 24 student_id = context.getStudentId() 25 res = context.students_catalog(id = student_id) 26 if not res: 27 return None 28 sbrain = res[0] 29 cert_id = sbrain.course 30 res = context.portal_catalog(portal_type = "Certificate", id = cert_id) 31 ci = {} 32 if res: 33 info['cert_id'] = cert_id 34 brain = res[0] 35 ci['study_course'] = brain.getId 36 ci['title'] = brain.Title 37 pl = brain.getPath().split('/') 38 ci['faculty'] = pl[-4] 39 ci['department'] = pl[-3] 40 info['course_doc'] = ci 41 else: 42 info['course'] = None 23 43 items = [] 24 levels = context.objectValues() 44 current_level = sbrain.level 45 levels = context.objectIds() 46 if current_level not in levels: 47 context.invokeFactory('StudentStudyLevel',"%s" % current_level) 48 level = getattr(context,"%s" % current_level) 49 level.getContent().edit(mapping={'session': "2006/2007"}) 50 context.portal_workflow.doActionFor(level,'open') 51 context.portal_workflow.doActionFor(level,'close_for_edit') 52 levels.append(current_level) 53 #from Products.zdb import set_trace;set_trace() 25 54 for l in levels: 26 55 row = {} 27 ld = l.getContent() 28 row['id'] = l.getId() 29 if hasattr(ld,'Title'): 30 row['title'] = ld.Title() 31 else: 32 row['title'] = getattr(ld,'title','no title') 33 row['url'] = l.absolute_url() 56 row['id'] = l 57 row['title'] = "Level %s" % l 58 row['url'] = "%s/%s" % (context.absolute_url(),l) 34 59 items.append(row) 60 35 61 info['items'] = items 36 62 return info -
WAeUP_SRP/trunk/skins/waeup_student/getStudyLevelInfo.py
r913 r1380 12 12 return Info about the Studylevel 13 13 """ 14 from Products.AdvancedQuery import Eq, Between, Le,In 15 evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery 16 request = context.REQUEST 17 session = request.SESSION 18 response = request.RESPONSE 19 14 20 def calculateGPA(): 15 21 """calculate the gpa""" … … 29 35 return 0.0 30 36 31 request = context.REQUEST 37 def cmp_semester(a,b): 38 if a['semester'] == b['semester']: 39 return 0 40 if a['semester'] > b['semester']: 41 return 1 42 return -1 43 32 44 33 45 wf = context.portal_workflow 34 46 mtool = context.portal_membership 35 path_info = request.get('PATH_INFO').split('/') 36 try: 37 i = int(path_info[-1]) 38 p = 0 39 except: 40 p = 1 47 student_id = context.getStudentId() 48 41 49 info = {} 42 pt = request.get('PATH_TRANSLATED').split('/') 43 44 student_id = pt[-(3+p)] 45 level_id = pt[-(1+p)] 46 info['action'] = "%s" % context.absolute_url() 50 info['student'] = student = context.students_catalog(id=student_id)[0] 47 51 info['choosen_ids'] = request.get('ids',[]) 48 52 info['doc'] = context.getContent() 49 study_course = context.aq_parent.getContent() 50 cert_id = study_course.study_course 51 brain = context.portal_catalog(meta_type="Student",id = student_id)[-1] 52 cp = brain.getPath() 53 info['container_path'] = cp 53 ##study_course = context.aq_parent.getContent() 54 ##cert_id = study_course.study_course 55 cert_id = student.course 54 56 info['cert_id'] = cert_id 57 normal = [] 58 carry_overs = [] 59 for id,obj in context.objectItems(): 60 if id.endswith('_co'): 61 d = context.getCourseInfo(id[:-3]) 62 d['grade'] = obj.getContent().grade 63 carry_overs.append(d) 64 else: 65 d = context.getCourseInfo(id) 66 coe = obj.getContent().core_or_elective 67 d['coe'] = 'Core' 68 if not coe: 69 d['coe'] = 'Elective' 70 normal.append(d) 55 71 56 res = context.portal_catalog(meta_type="StudentCourseResult", 57 container_path="%s/study_course/%s" % (cp,level_id)) 58 first = [] 59 second = [] 60 sum = 0 61 course_count = 0 62 for r in res: 63 row = {} 64 ro = r.getObject() 65 rd = ro.getContent() 66 row['id'] = ro.getId() 67 row['credits'] = rd.credits 68 if row['credits'] and rd.grade: 69 credits = int(rd.credits) 70 sum += credits * ['F','E','D','C','B','A'].index(rd.grade) 71 course_count += credits 72 row['sum'] = sum 73 row['count'] = course_count 74 row['title'] = rd.title 75 #row['core'] = rd.core_or_elective 76 row['semester'] = rd.semester 77 row['score'] = rd.score 78 row['grade'] = rd.grade 79 row['weight'] = rd.weight 80 row['url'] = ro.absolute_url() 81 row['review_state'] = wf.getInfoFor(ro,'review_state','None') 82 row['is_editable'] = mtool.checkPermission('Modify portal content', ro) 83 if rd.semester == 1: 84 first.append(row) 85 else: 86 second.append(row) 87 first.sort() 88 second.sort() 89 gpaf = 0.0 90 if course_count: 91 gpaf = (float(sum)/course_count) 92 gpa = "%4.2f" % gpaf 93 info['doc'].edit(mapping={'gpa': gpaf}) 94 info['first'] = first 95 info['second'] = second 72 carry_overs.sort(cmp_semester) 73 info['carry_overs'] = carry_overs 74 normal.sort(cmp_semester) 75 info['normal'] = normal 96 76 return info -
WAeUP_SRP/trunk/skins/waeup_student/student_index.py
r1368 r1380 12 12 return the current student_index_html 13 13 """ 14 from Products.AdvancedQuery import Eq, Between, Le,In 15 evalAdvancedQuery = context.portal_catalog.evalAdvancedQuery 14 16 15 17 request = context.REQUEST 16 redirect = request.RESPONSE.redirect 18 session = request.SESSION 19 response = request.RESPONSE 20 redirect = response.redirect 17 21 pm = context.portal_membership 18 22 member = pm.getAuthenticatedMember() … … 38 42 elif context.portal_type == 'Payment': 39 43 return context.payment_receipt() 44 elif context.portal_type == 'StudentStudyLevel': 45 if context.objectIds(): 46 return context.study_level_view() 47 student = context.students_catalog(id=context.getStudentId())[0] 48 cert_id = student.course 49 in_progress = session.get('in_progress','finished') 50 if in_progress == 'finished': 51 session.set('in_progress','started') 52 view = context.in_progress_view(refresh=3,page='study_level_view') 53 response.setHeader('Content-type','text/html; charset=ISO-8859-15') 54 response.setHeader('Content-length','%d' % (len(view))) 55 response.setStatus('OK') 56 response.write(view) 57 response.write('') 58 elif in_progress == 'started': 59 return 60 #from Products.zdb import set_trace;set_trace() 61 results = context.results_import(matric_no = student.matric_no) 62 carry_overs = [brain for brain in results if brain.GRADE in ('D','E','F')] 63 l = [] 64 for co in carry_overs: 65 d = context.getCourseInfo(co.CosCode) 66 d['grade'] = co.GRADE 67 d['carry_level'] = co.CarryLevel 68 cr_id = context.invokeFactory('StudentCourseResult',"%s_co" % co.CosCode) 69 getattr(context,cr_id).getContent().edit(mapping=d) 70 res = context.portal_catalog(portal_type="Certificate", id = cert_id) 71 l = [] 72 if res: 73 cert = res[0] 74 path = cert.getPath() 75 query = Eq("path",path) &\ 76 Eq('portal_type','CertificateCourse') &\ 77 Eq('SearchableText', "%s" % student.level) 78 courses = evalAdvancedQuery(query) 79 for c in courses: 80 d = context.getCourseInfo(c.getId) 81 cr_id = context.invokeFactory('StudentCourseResult',c.getId) 82 d['core_or_elective'] = getattr(c.getObject().getContent(),'core_or_elective') 83 getattr(context,cr_id).getContent().edit(mapping=d) 84 session.set('in_progress','finished') 85 return "finished" 40 86 students_url = "%s/campus/students" % (context.portal_url()) 41 87 id = str(member) -
WAeUP_SRP/trunk/skins/waeup_student/study_course_view.pt
r1096 r1380 1 <metal:html tal:define="is_so context/isSectionOfficer; 2 s_info context/getStudentInfo;" 3 > 4 <span tal:condition="not: s_info"> 5 <span tal:content="here/illegal_view" /> 6 </span> 7 <metal:block tal:condition="s_info"> 8 <span tal:define="info context/getStudyCourseInfo"> 1 <metal:html> 9 2 <metal:body use-macro="here/waeup_content_master/macros/master"> 10 <metal:block fill-slot="header"> 3 <metal:block fill-slot="header" 4 tal:define="global info context/getStudyCourseInfo; 5 global is_so info/is_so; 6 " 7 > 11 8 <a href="" 12 9 tal:attributes="href string:${here/academicsParent}"> … … 15 12 </a> 16 13 <h3> 17 <span tal:condition="python:is_so and s_info">18 <span tal:content=" s_info/student/Title" />:14 <span tal:condition="python:is_so and info"> 15 <span tal:content="info/student/Title" />: 19 16 </span> 20 17 <span tal:content="here/title_or_id" /> … … 25 22 <span tal:omit-tag="" tal:condition="nothing" 26 23 tal:content="structure python: info['doc'].render(layout_mode='view')" /> 27 <table tal:define="sc python: s_info['course_doc']">24 <table tal:define="sc python: info['course_doc']"> 28 25 <tr> 29 26 <td width="180px">Certificate:</td> … … 97 94 98 95 </metal:body> 99 </span>100 </metal:block>101 96 </metal:html> -
WAeUP_SRP/trunk/skins/waeup_student/study_level_view.pt
r913 r1380 1 <metal:html tal:define="info context/getStudyLevelInfo; 2 is_so context/isSectionOfficer; 3 s_info context/getStudentInfo;" 4 > 1 <metal:html> 5 2 <metal:body use-macro="here/waeup_content_master/macros/master"> 6 <metal:block fill-slot="header"> 3 <metal:block fill-slot="header" 4 tal:define="global info context/getStudyLevelInfo; 5 global is_so context/isSectionOfficer;" 6 > 7 7 <a href="" 8 8 tal:attributes="href string:${here/academicsParent}"> … … 11 11 </a> 12 12 <h3> 13 14 <span tal:content="s_info/student/Title" />:15 16 13 <span tal:condition="python:is_so and s_info"> 14 <span tal:content="info/student/name" />: 15 </span> 16 <span tal:content="here/title_or_id" /> 17 17 </h3> 18 18 <br /> 19 <div tal:condition="python:0" tal:content="info/container_path"/>20 <div tal:condition="python:0" tal:content="info/cert_id"/>21 <div tal:condition="python:0" tal:content="info/gpa"/>22 19 </metal:block> 23 20 <metal:main fill-slot="main" tal:condition="python:1"> 24 <span tal:omit-tag="" 25 tal:content="structure python: info['doc'].render(layout_mode='view')" /> 26 27 <form action="" method="post" class="group" 28 tal:attributes="action info/action" 29 > 21 <form action="." method="post" class="group"> 22 <h3>Carryover Courses</h3> 30 23 <table tal:condition="python: 1" class="contentListing" width="100%" summary="content layout" id="folder_content"> 31 < span tal:repeat="sem python:('first','second')">32 <tr><th colspan="3" tal:content="python: test(sem == 'first','First Semester', 'Second Semester')" />33 <t r tal:repeat="row python: info[sem]"34 tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')">35 <td align="left" valign="middle" style="width: 5px;"36 tal:condition="python:1 and is_so">37 <input type="checkbox" name="ids:list" value="" id="" class="noborder"38 tal:condition="is_so"39 tal:define="id row/id"40 tal:attributes="value id;41 id python:'cb_' + id;42 checked python:id in info['choosen_ids'];"43 />44 45 <td><a href="view" tal:attributes="href string:${row/url}">46 <strong tal:content="row/title" /></a> </td>47 <td tal:content="row/id"></td>48 <td tal:content="row/semester"></td>49 <td tal:content="row/credits"></td>50 <td tal:condition="is_so" tal:content="row/score"></td>51 <td tal:content="row/grade"></td>52 <td tal:content="row/weight"></td>53 <td tal:condition="python:0" tal:content="row/sum"></td>54 <td tal:condition="python:0" tal:content="row/count"></td>55 <td tal:condition="row/is_editable" tal:content="row/review_state"> </td>56 <td>57 <a tal:condition="row/is_editable"58 href="edit" tal:attributes="href string:${row/url}/external_edit_form"59 target="edit"60 onclick="javascript:window.open('','edit','width=600, height=700, directories=no, toolbar=no, location=no, menubar=no, scrollbars=yes, status=no, resizable=no, dependent=no')">61 [edit]62 </a>63 64 </tr>65 </span>66 24 <tr tal:repeat="row info/carry_overs" 25 tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')"> 26 <td align="left" valign="middle" style="width: 5px;"> 27 <input type="checkbox" name="ids:list" value="" id="" class="noborder" 28 tal:define="id row/code" 29 tal:attributes="value id; 30 id python:'cb_' + id; 31 checked python:id in info['choosen_ids'];" 32 /> 33 </td> 34 <td width="80%" tal:content="row/title"></td> 35 <td width="8%" tal:content="row/code"></td> 36 <td width="2%" tal:content="row/semester"></td> 37 <td width="2%" tal:content="row/credits"></td> 38 <td width="8%" tal:content="row/grade|nothing"></td> 39 </tr> 40 </table> 41 <h3>Session Courses</h3> 42 <table tal:condition="python: 1" class="contentListing" width="100%" summary="content layout" id="folder_content"> 43 <tr tal:repeat="row info/normal" 44 tal:attributes="class python:test(repeat['row'].even(), 'even ajaxtd', 'odd ajaxtd')"> 45 <td align="left" valign="middle" style="width: 5px;"> 46 <input type="checkbox" name="ids:list" value="" id="" class="noborder" 47 tal:define="id row/code" 48 tal:attributes="value id; 49 id python:'cb_' + id; 50 checked python:id in info['choosen_ids'];" 51 /> 52 </td> 53 <td width="80%" tal:content="row/title"></td> 54 <td width="8%" tal:content="row/code"></td> 55 <td width="2%" tal:content="row/semester"></td> 56 <td width="2%" tal:content="row/credits"></td> 57 <td width="8%" tal:content="row/coe|nothing"></td> 58 </tr> 59 </table> 67 60 <table width="100%" cellspacing="0" cellpadding="2" 68 61 class="folderButtons"> … … 70 63 <td align="left" valign="top" rowspan="3"></td> 71 64 <td align="left" valign="top"> 72 <span tal:condition="python:1 and is_so">65 <span tal:condition="python:1"> 73 66 <input type="button" value="button_select_all" class="context" 74 67 onclick="someJavaScriptFunctionThatWillBeReplaced" … … 77 70 % (cpsmcat('button_select_all'), cpsmcat('button_deselect_all'))" 78 71 /> 79 <input tal:condition="python: 0" type="submit" name="approve_checked:method"80 class="context" value=" Approve" />72 <input tal:condition="python:1" type="submit" name="register_checked:method" 73 class="context" value="Register" /> 81 74 <input tal:condition="python:0" type="submit" name="retract_checked:method" 82 75 class="context" value="Retract" /> -
WAeUP_SRP/trunk/skins/waeup_utilities/getFromData_entry_mode.py
r1334 r1380 19 19 if app is None: 20 20 return None 21 #from Products.zdb import set_trace;set_trace() 21 22 em = app.getContent().entry_mode 22 23 if em: -
WAeUP_SRP/trunk/skins/waeup_utilities/reindex_entry_mode.py
r1363 r1380 12 12 reindex students_catalog entry_mode index 13 13 """ 14 request = context.REQUEST 15 session = request.SESSION 16 response = request.RESPONSE 17 students = context.portal_url.getPortalObject().campus.students 18 def rwrite(s): 19 response.setHeader('Content-type','text/html; charset=ISO-8859-15') 20 #response.setHeader('Content-length','%d' % (len(s))) 21 #response.setStatus('OK') 22 response.write(s) 23 14 24 cat = context.students_catalog 15 25 ems = cat.uniqueValuesFor('entry_mode') 26 rwrite("entry_mode values: %s<br />\n" % (str(ems))) 27 for em in ems: 28 res = cat(entry_mode = em) 29 rwrite("entry_mode: %s = %d<br />\n" % (em,len(res))) 30 #from Products.zdb import set_trace;set_trace() 16 31 sbrains = cat() 32 count = 0 33 lc = 1 34 rwrite("%3d " % lc) 17 35 for sb in sbrains: 18 36 normalized = False 19 em= context.getFromData_entry_mode(sb.id) 20 if em: 37 em = context.getFromData_entry_mode(sb.id) 38 ec = 'x' 39 if em is None: 40 ec = 'n' 41 em = 'None' 42 if em in ('UME','DE'): 43 ec = 'C' 21 44 normalized = True 22 45 elif sb.entry_mode in ('DIRECT', 'DIRECT ENTRY',): 46 ec = 'D' 23 47 em = 'DE' 24 48 normalized = True 25 49 elif sb.entry_mode in ('U.M.E', 'UNE',): 50 ec = 'U' 26 51 em ="UME" 27 52 normalized = True 53 elif not sb.entry_mode: 54 ec = 'u' 55 em ="UME" 56 normalized = True 57 if ec != "C" and em != sb.entry_mode: 58 #from Products.zdb import set_trace;set_trace() 59 app = getattr(getattr(students,sb.id),'application',None) 60 ec = 'a' 61 if app is not None: 62 ec = 'A' 63 app.getContent().edit(mapping={'entry_mode': sb.entry_mode}) 28 64 if normalized: 29 65 cat.modifyRecord(id = sb.id, 30 66 entry_mode = em) 67 rwrite(ec) 68 count += 1 69 if count > 60: 70 lc += 1 71 rwrite("<br />\n%3d " % lc) 72 count = 0 31 73
Note: See TracChangeset for help on using the changeset viewer.