Changeset 723


Ignore:
Timestamp:
19 Oct 2006, 17:06:51 (18 years ago)
Author:
joachim
Message:

Import and Manager view for full-time students + results

Location:
WAeUP_SRP/trunk
Files:
4 added
15 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Students.py

    r714 r723  
    2323MAX_TRANS = 1000
    2424
     25def getInt(s):
     26    try:
     27        return int(s)
     28    except:
     29        return 0
    2530
    2631def getStudentByRegNo(self,reg_no): ###(
     
    152157                dsc = {}
    153158                dsc['study_course'] = certcode
     159                dsc['department'] = student.get('Dept')
     160                dsc['faculty'] = student.get('Faculty')
    154161                css = student.get('CurrentSession') or '2004-2005'
    155162                cs = int(css.split('-')[0]) - 2000
     
    161168                # Level
    162169                #
    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})
    180181            else:
    181182                em = 'Student with ID %(MatricNo)s %(fullname)s already exists\n' % student
     
    207208        """load Fulltime Studentdata from CSV values"""
    208209        #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"
    209215        import transaction
     216        wftool = self.portal_workflow
    210217        tr_count = 0
    211218        name = 'short_full_time_results_2004_2005'
     
    226233        for c in l:
    227234            courses[c.id] = c.getObject()
     235        level_changed = False
     236        student_changed = False
     237        sid = ''
     238        #import pdb;pdb.set_trace()
    228239        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
    240263            course = result.get('CosCode')
    241264            if course not in courses.keys():
     
    245268                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)
    246269                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 = {}
    277298            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'))
    281303            dlev['session'] = result.get('Session')
    282             dlev['carry_level'] = result.get('CarryLevel')
    283             d['grade'] = result.get('Grade')
     304            dcr['carry_level'] = result.get('CarryLevel')
     305            dcr['grade'] = result.get('Grade')
    284306            #d['weight'] = result.get('Weight')
    285307            dlev['verdict'] = result.get('Verdict')
     
    287309            #gpa = result.get('GPA').replace(',','.')
    288310            #d['gpa'] = float(gpa)
    289             ct.getContent().edit(mapping = d)
     311            cr.getContent().edit(mapping = dcr)
    290312            l.getContent().edit(mapping = dlev)
    291313            if tr_count > MAX_TRANS:
     
    293315                tr_count = 0
    294316            tr_count += 1
     317            wftool.doActionFor(cr,'close')
     318        wftool.doActionFor(l,level_wf_actions[dlev['verdict']])
    295319        return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
    296320
     
    564588        return "Level %s" % self.aq_parent.getId()
    565589
    566     security.declareProtected(View,"gpa")
    567     def gpa(self):
    568         """calculate the gpa"""
    569         sum = 0
    570         course_count = 0
    571         for semester in ('first','second'):
    572             sf=getattr(self,semester)
    573             for sc in sf.objectValues():
    574                 result = sc.getContent()
    575                 res = self.portal_catalog({'meta_type': 'Course',
    576                                               'id': sc.aq_parent.id})
    577                 if len(res) != 1:
    578                     continue
    579                 course = res[0].getObject().getContent()
    580                 sum += course.credits * ['F','E','D','C','B','A'].index(result.grade)
    581                 course_count += 1
    582         if course_count:
    583             return sum/course_count
    584         return 0.0
     590##    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
    585609
    586610InitializeClass(StudentStudyLevel)
     
    683707
    684708    def getCourseEntry(self,cid):
    685         res = self.portal_catalog({'meta_type': "StudentCourse",
     709        res = self.portal_catalog({'meta_type': "Course",
    686710                                           'id': cid})
    687711        if res:
     
    693717    def Title(self):
    694718        """compose title"""
    695         cid = self.getId()
     719        cid = self.aq_parent.getId()
    696720        ce = self.getCourseEntry(cid)
    697721        if ce:
  • WAeUP_SRP/trunk/profiles/default/layouts/student_course_results.xml

    r486 r723  
    1414  <property name="label">Ansbook</property>
    1515  <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>
    1627  <property name="readonly_layout_modes"/>
    1728  <property name="hidden_layout_modes"/>
     
    108119 <table>
    109120  <row>
     121   <cell name="semester"/>
     122  </row>
     123  <row>
    110124   <cell name="grade"/>
    111125  </row>
  • WAeUP_SRP/trunk/profiles/default/layouts/student_study_course.xml

    r486 r723  
    1919  <property name="hidden_readonly_layout_modes"/>
    2020 </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>
    2145 <table>
    2246  <row>
    2347   <cell name="study_course"/>
    2448  </row>
     49  <row>
     50   <cell name="faculty"/>
     51  </row>
     52  <row>
     53   <cell name="department"/>
     54  </row>
    2555 </table>
    2656</object>
  • WAeUP_SRP/trunk/profiles/default/schemas/student_course_results.xml

    r486 r723  
    88 <field name="score" meta_type="CPS Int Field"/>
    99 <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"/>
    1113 <field name="weight" meta_type="CPS String Field"/>
    1214</object>
  • WAeUP_SRP/trunk/profiles/default/schemas/student_study_course.xml

    r486 r723  
    11<?xml version="1.0"?>
    22<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>
    412</object>
  • WAeUP_SRP/trunk/profiles/default/types/StudentCourseResult.xml

    r684 r723  
    1717 <property name="cps_display_as_document_in_listing">True</property>
    1818 <property name="schemas">
    19   <element value="course_results"/>
     19  <element value="student_course_results"/>
    2020 </property>
    2121 <property name="layouts">
    22   <element value="course_results"/>
     22  <element value="student_course_results"/>
    2323 </property>
    2424 <property name="layout_clusters"/>
  • WAeUP_SRP/trunk/profiles/default/types/StudentStudyCourse.xml

    r486 r723  
    3030 <property name="storage_methods"/>
    3131 <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"/>
    3434 <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">
    3636  <permission value="View"/>
    3737 </action>
  • WAeUP_SRP/trunk/profiles/default/types/StudentStudyLevel.xml

    r486 r723  
    88 <property name="product">WAeUP_SRP</property>
    99 <property name="factory">addStudentStudyLevel</property>
    10  <property name="immediate_view">academics_contents</property>
     10 <property name="immediate_view">student_index</property>
    1111 <property name="global_allow">True</property>
    1212 <property name="filter_content_types">True</property>
     
    2828 <property name="storage_methods"/>
    2929 <property name="cps_is_portlet">False</property>
    30  <alias from="(Default)" to="academics_contents"/>
     30 <alias from="(Default)" to="student_index"/>
    3131 <alias from="create_do" to="waeup_document_create_do"/>
    3232 <alias from="created" to="level_created"/>
    33  <alias from="view" to="academics_contents"/>
     33 <alias from="view" to="student_index"/>
    3434 <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">
    3636  <permission value="View"/>
    3737 </action>
  • WAeUP_SRP/trunk/profiles/default/workflows.xml

    r639 r723  
    5858   <bound-workflow workflow_id="section_folder_wf"/>
    5959  </type>
    60   <type type_id="Semester">
    61    <bound-workflow workflow_id="section_folder_wf"/>
    62   </type>
    6360  <type type_id="Student">
    6461   <bound-workflow workflow_id="waeup_student_wf"/>
     
    7774  </type>
    7875  <type type_id="StudentStudyCourse">
    79    <bound-workflow workflow_id="section_folder_wf"/>
     76   <bound-workflow workflow_id="waeup_student_subobject_wf"/>
    8077  </type>
    8178  <type type_id="StudentCourseResult">
    82    <bound-workflow workflow_id="waeup_base_wf"/>
     79   <bound-workflow workflow_id="waeup_student_subobject_wf"/>
    8380  </type>
    8481  <type type_id="StudentsFolder">
     
    8986  </type>
    9087  <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"/>
    9589  </type>
    9690  <type type_id="University">
  • WAeUP_SRP/trunk/profiles/default/workflows/waeup_course_registration_wf/definition.xml

    r722 r723  
    2323 </state>
    2424 <state state_id="created" title="">
     25  <exit-transition transition_id="create_content"/>
    2526  <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"/>
    2633 </state>
    2734 <state state_id="school_fee_pin_entered" title="">
  • WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_subobject_wf/definition.xml

    r659 r723  
    1212 <state state_id="created" title="">
    1313  <exit-transition transition_id="close"/>
     14  <exit-transition transition_id="create_content"/>
    1415  <exit-transition transition_id="open"/>
    1516  <permission-map name="Modify portal content"
     
    2425 <state state_id="opened" title="">
    2526  <exit-transition transition_id="close"/>
     27  <exit-transition transition_id="create_content"/>
    2628  <permission-map name="Modify portal content"
    2729                  acquired="True">
     
    5557  <transition-behavior behavior_id="initial-create"/>
    5658 </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>
    5767 <transition transition_id="open" title=""
    5868             new_state="opened" trigger="USER"
  • WAeUP_SRP/trunk/profiles/default/workflows/waeup_student_wf/definition.xml

    r677 r723  
    3737 <state state_id="created" title="">
    3838  <exit-transition transition_id="create_content"/>
     39  <exit-transition transition_id="clear_and_validate"/>
    3940  <exit-transition transition_id="enter_application_pin"/>
    4041  <exit-transition transition_id="open"/>
  • WAeUP_SRP/trunk/skins/waeup_student/getStudentInfo.py

    r674 r723  
    2121roles = member.getRoles()
    2222info = {}
    23 info['is_manager'] = context.isManager
     23info['is_manager'] = context.isManager()
    2424info['is_student'] = context.isStudent()
    2525member_id = str(member)
     
    6666              'StudentPersonal': '',
    6767              }
    68 s_view_links = {'StudentApplication': 'application_view',
    69               'StudentAccommodation': 'accommodation_view',
    70               'StudentPersonal': 'personal_view',
     68s_view_links = {'StudentApplication': None,
     69              'StudentAccommodation': None,
     70              'StudentPersonal': None,
     71              'StudentStudyCourse': 'study_course_view',
    7172              }
    7273sos = context.portal_catalog(container_path=student_path)
     
    8081    row['type'] = so.portal_type
    8182    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)
    8685    se_link = s_edit_links.get(so.portal_type,None)
    8786    row['s_edit_link'] = None
  • WAeUP_SRP/trunk/skins/waeup_student/student_index.py

    r681 r723  
    2020    return redirect("%s/srp_anonymous_view" % context.absolute_url())
    2121if 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()
    2226    return redirect("%s/student_view" % context.absolute_url())
    2327if context.isStudent():
  • WAeUP_SRP/trunk/skins/waeup_student/student_view.pt

    r674 r723  
    2323          <tr tal:repeat="row rows"
    2424            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}">
    2626              <strong tal:content="row/title" /></a> </td>
    2727            <td>
Note: See TracChangeset for help on using the changeset viewer.