Changeset 454 for WAeUP_SRP


Ignore:
Timestamp:
31 Aug 2006, 10:37:54 (18 years ago)
Author:
joachim
Message:

add student_study_level,
adopted result_import
results import now is broken because of missing wf_state.

Location:
WAeUP_SRP/trunk
Files:
4 added
14 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Academics.py

    r440 r454  
    456456###)
    457457
     458class StudyLevel(CPSDocument): ###(
     459    """
     460    WAeUP StudyLevel containing the courses and students
     461    """
     462    meta_type = 'StudyLevel'
     463    portal_type = meta_type
     464    security = ClassSecurityInfo()
     465
     466    security.declareProtected(View,"Title")
     467    def Title(self):
     468        """compose title"""
     469        return "Level %s" % self.aq_parent.getId()
     470   
     471
     472InitializeClass(StudyLevel)
     473
     474def addStudyLevel(container, id, REQUEST=None, **kw):
     475    """Add a StudyLevel."""
     476    ob = StudyLevel(id, **kw)
     477    return CPSBase_adder(container, ob, REQUEST=REQUEST)
     478
     479###)
     480
    458481class CertificateCourse(CPSDocument): ###(
    459482    """
     
    476499        """compose title"""
    477500        ce = self.getCourseEntry(self.id.upper())
     501        #print self.id, self.aq_parent.id
    478502        if ce:
    479503            return "%s" % ce.Title
     
    610634###)
    611635
    612 class CourseTicket(CPSDocument): ###(
    613     """
    614     WAeUP CourseTicket
    615     """
    616     meta_type = 'CourseTicket'
    617     portal_type = meta_type
    618     security = ClassSecurityInfo()
    619     def getCourseEntry(self,cid):
    620         res = self.portal_catalog({'meta_type': "Course",
    621                                            'id': cid})
    622         if res:
    623             return res[-1]
    624         else:
    625             return None
    626 
    627     security.declareProtected(View,"Title")
    628     def Title(self):
    629         """compose title"""
    630         ce = self.getCourseEntry(self.id.upper())
    631         if ce:
    632             return "%s" % ce.Title
    633         return "No such course"
    634 
    635 InitializeClass(CourseTicket)
    636 
    637 def addCourseTicket(container, id, REQUEST=None, **kw):
    638     """Add a CourseTicket."""
    639     ob = CourseTicket(id, **kw)
    640     return CPSBase_adder(container, ob, REQUEST=REQUEST)
    641 ###)
    642 
     636
  • WAeUP_SRP/trunk/Students.py

    r453 r454  
    112112                dc = {'Title': 'Clearance Data'}
    113113                dc['matric_no'] = matric_no
    114                 lga = student.get('State') + ' / ' + student.get('LGA')
     114                lga = student.get('State') + ' / ' + student.get('LGA')               
    115115                dc['lga'] = lga
    116116                dc['nationality'] = student.get('Nationality')
    117117                dc['email'] = student.get('Emailaddress')
    118                 css = student.get('CurrentSession') or '2004-2005'
    119                 cs = int(css.split('-')[0]) - 2000
    120                 cl = int(student.get('StudentLevel'))/100
    121                 dc['entry_session'] = "200%s" % (cs - cl)               
    122118                d['firstname'] = student.get('FirstName')
    123119                d['middlename'] = student.get('MiddleName')
     
    143139                #d['department'] = student.get('Dept')
    144140                d['study_course'] = certcode
     141                css = student.get('CurrentSession') or '2004-2005'
     142                cs = int(css.split('-')[0]) - 2000
     143                cl = int(student.get('StudentLevel'))/100
     144                d['entry_session'] = "200%s" % (cs - cl)
    145145                sc.getContent().edit(mapping=d)
    146146                #
     
    151151                    #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep)
    152152                    logger.info('Creating Level %(StudentLevel)s for %(fullname)s' % student)
    153                     sc.invokeFactory('StudyLevel', level)
     153                    sc.invokeFactory('StudentStudyLevel', level)
    154154                    l = getattr(sc, level)
    155155                    certificate = certs[certcode]
     
    198198            logger.error('Error reading %s.csv' % name)
    199199            return
    200 ##        l = self.portal_catalog({'meta_type': "Student"})
    201 ##        students = {}
    202 ##        for s in l:
    203 ##            students[s.id] = s.getObject()
    204200        l = self.portal_catalog({'meta_type': "Course"})
    205201        courses = {}
     
    217213                continue
    218214            sf = res[0].getObject().aq_parent
    219             print sf
     215            result['StudentId'] = sf.getId()
    220216            course = result.get('CosCode')
    221217            if course not in courses.keys():
     
    238234            if l is None:
    239235                #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep)
    240                 logger.info('Creating Level %(Level)s for %(Matnumber)s' % result)
    241                 sc.invokeFactory('StudyLevel', level)
     236                logger.info('Creating Level %(Level)s for %(StudentId)s %(Matnumber)s' % result)
     237                sc.invokeFactory('StudentStudyLevel', level)
    242238                l = getattr(sc, level)
    243                 #l.getContent().edit(mapping={'Title': "Level %s" % level})
    244239                l.invokeFactory('Semester','first')
    245240                l.invokeFactory('Semester','second')
     
    248243                second_s = getattr(l,'second')
    249244                second_s.getContent().edit(mapping={'Title': 'Second Semester'})
    250             snr = result.get('Semester')
     245            snr = result.get('Semster')
    251246            semester = getattr(l,'first')
    252247            if snr == "2":
    253248                semester = getattr(l,'second')
    254                 logger.info('Creating CourseTicket %(CosCode)s in Level %(Level)s for %(Matnumber)s' % result)
     249            logger.info('Creating CourseTicket %(CosCode)s in Level %(Level)s for %(StudentId)s %(Matnumber)s' % result)
    255250            semester.invokeFactory('CourseTicket',course)
    256251            ct = getattr(semester,course)
    257252            d = {}
     253            dlev = {}
    258254            d['ansbook'] = result.get('Ansbook')
    259255            d['status'] = result.get('CosStuatus')
    260256            d['score'] = result.get('Score')
    261             d['carry_level'] = result.get('CarryLevel')
     257            dlev['session'] = result.get('Session')
     258            dlev['carry_level'] = result.get('CarryLevel')
    262259            d['grade'] = result.get('Grade')
    263             d['weight'] = result.get('Weight')
    264             d['verdict'] = result.get('Verdict')
    265             d['import_id'] = result.get('id')
    266             gpa = result.get('GPA').replace(',','.')
    267             d['gpa'] = float(gpa)
     260            #d['weight'] = result.get('Weight')
     261            dlev['verdict'] = result.get('Verdict')
     262            #d['import_id'] = result.get('id')
     263            #gpa = result.get('GPA').replace(',','.')
     264            #d['gpa'] = float(gpa)
    268265            ct.getContent().edit(mapping = d)
     266            l.getContent().edit(mapping = dlev)
    269267            if tr_count > MAX_TRANS:
    270268                transaction.commit()
     
    307305        return self.title
    308306
    309 
    310307InitializeClass(Student)
    311308
     
    367364###)
    368365
     366class StudentStudyLevel(CPSDocument): ###(
     367    """
     368    WAeUP Student container for the various student data
     369    """
     370    meta_type = 'StudentStudyLevel'
     371    portal_type = meta_type
     372    security = ClassSecurityInfo()
     373
     374    security.declareProtected(View,"Title")
     375    def Title(self):
     376        """compose title"""
     377        return "Level %s" % self.aq_parent.getId()
     378
     379    security.declareProtected(View,"gpa")
     380    def gpa(self):
     381        """calculate the gpa"""
     382        sum = 0
     383        course_count = 0
     384        for semester in ('first','second'):
     385            sf=getattr(self,semester)
     386            for sc in sf.objectValues():
     387                result = sc.getContent()
     388                res = self.portal_catalog({'meta_type': 'Course',
     389                                              'id': sc.aq_parent.id})
     390                if len(res) != 1:
     391                    continue
     392                course = res[0].getObject().getContent()
     393                sum += course.credits * ['F','E','D','C','B','A'].index(result.grade)
     394                course_count += 1
     395        if course_count:
     396            return sum/course_count
     397        return 0.0
     398   
     399InitializeClass(StudentStudyLevel)
     400
     401def addStudentStudyLevel(container, id, REQUEST=None, **kw):
     402    """Add a Students personal data."""
     403    ob = StudentStudyLevel(id, **kw)
     404    return CPSBase_adder(container, ob, REQUEST=REQUEST)
     405
     406###)
     407
    369408class StudentStudyCourse(CPSDocument): ###(
    370409    """
     
    414453###)
    415454
    416 class StudyLevel(CPSDocument): ###(
    417     """
    418     WAeUP StudyLevel containing the courses and students
    419     """
    420     meta_type = 'StudyLevel'
    421     portal_type = meta_type
    422     security = ClassSecurityInfo()
    423 
    424     security.declareProtected(View,"Title")
    425     def Title(self):
    426         """compose title"""
    427         return "Level %s" % self.aq_parent.getId()
    428 
    429 
    430 InitializeClass(StudyLevel)
    431 
    432 def addStudyLevel(container, id, REQUEST=None, **kw):
    433     """Add a StudyLevel."""
    434     ob = StudyLevel(id, **kw)
    435     return CPSBase_adder(container, ob, REQUEST=REQUEST)
    436 
    437 ###)
    438 
    439455class Semester(CPSDocument): ###(
    440456    """
     
    454470###)
    455471
     472class CourseTicket(CPSDocument): ###(
     473    """
     474    WAeUP CourseTicket
     475    """
     476    meta_type = 'CourseTicket'
     477    portal_type = meta_type
     478    security = ClassSecurityInfo()
     479    def getCourseEntry(self,cid):
     480        res = self.portal_catalog({'meta_type': "Course",
     481                                           'id': cid})
     482        if res:
     483            return res[-1]
     484        else:
     485            return None
     486
     487    security.declareProtected(View,"Title")
     488    def Title(self):
     489        """compose title"""
     490        cid = self.getId()
     491        ce = self.getCourseEntry(cid)
     492        if ce:
     493            return "%s" % ce.Title
     494        return "No course with id %s" % cid
     495
     496InitializeClass(CourseTicket)
     497
     498def addCourseTicket(container, id, REQUEST=None, **kw):
     499    """Add a CourseTicket."""
     500    ob = CourseTicket(id, **kw)
     501    return CPSBase_adder(container, ob, REQUEST=REQUEST)
     502###)
     503
    456504class ScratchCardBatchesFolder(CPSDocument): ###(
    457505    """
  • WAeUP_SRP/trunk/__init__.py

    r452 r454  
    2020
    2121waeup_types = (
    22     "University.University",
    23     "Academics.AcademicsFolder",
    24     "Academics.Certificate",
    25     "Academics.CertificateCourse",
    26     "Academics.Faculty",
    27     "Academics.Department",
    28     "Academics.Course",
    29     "Academics.CourseTicket",
    30     "Academics.CertificateCourse",
    31     "Accommodation.AccoFolder",
    32     "Accommodation.Accommodation",
    33     "Students.StudentsFolder",
    34     "Students.Student",
    35     "Students.StudentStudyCourse",
    36     "Students.StudentAdmission",
    37     "Students.StudentClearance",
    38     "Students.StudentPersonal",
    39     "Students.ScratchCardBatch",
    40     "Students.ScratchCardBatchesFolder",
    41     "Students.StudyLevel",
    42     "Students.Semester",
     22    ("University",('University',)),
     23    ("Academics",
     24       ("AcademicsFolder",
     25        "Certificate",
     26        "CertificateCourse",
     27        "Faculty",
     28        "Department",
     29        "Course",
     30        "StudyLevel",
     31        "CertificateCourse",
     32        )
     33     ),
     34     ("Accommodation",
     35        ("AccoFolder",
     36         "Accommodation",
     37         )
     38     ),
     39     ("Students",
     40        ("StudentsFolder",
     41         "Student",
     42         "StudentStudyCourse",
     43         "CourseTicket",
     44         "StudentAdmission",
     45         "StudentClearance",
     46         "StudentPersonal",
     47         "ScratchCardBatch",
     48         "ScratchCardBatchesFolder",
     49         "StudentStudyLevel",
     50         "Semester",
     51         )
     52      ),
    4353    )
    4454
    4555contentClasses = []
    4656cc = []
    47 for t in waeup_types:
    48     module,name = t.split('.')
    49     mod = __import__('Products.WAeUP_SRP.%(module)s' % vars(),
     57for modu,names in waeup_types:
     58    mod = __import__('Products.WAeUP_SRP.%(modu)s' % vars(),
    5059                globals(),
    5160                locals(),
    52                 ["%(name)s" % vars(),"add%(name)s" % vars()]
     61                ['*',]
    5362                )
    54     contentClasses.append(getattr(mod,name))
    55     cc.append(getattr(mod,"add%(name)s" % vars()))
    56     contentConstructors = tuple(cc)
     63    for name in names:
     64        #print name
     65        contentClasses.append(getattr(mod,name))
     66        cc.append(getattr(mod,"add%(name)s" % vars()))
     67contentConstructors = tuple(cc)
    5768
    5869fti = [{} for t in range(len(contentConstructors))]
  • WAeUP_SRP/trunk/profiles/default/layouts.xml

    r444 r454  
    2424 <object name="student_schoolresults" meta_type="CPS Layout"/>
    2525 <object name="student_semester" meta_type="CPS Layout"/>
     26 <object name="student_study_level" meta_type="CPS Layout"/>
    2627 <object name="study_level" meta_type="CPS Layout"/>
    2728 <object name="university" meta_type="CPS Layout"/>
  • WAeUP_SRP/trunk/profiles/default/layouts/course_results.xml

    r398 r454  
    2525  <property name="label">Carry Level</property>
    2626  <property name="label_edit">Carry Level</property>
    27   <property name="readonly_layout_modes"/>
    28   <property name="hidden_layout_modes"/>
    29   <property name="hidden_readonly_layout_modes"/>
    30  </widget>
    31  <widget name="gpa" meta_type="Float Widget">
    32   <property name="title">GPA</property>
    33   <property name="fields">
    34    <element value="gpa"/>
    35   </property>
    36   <property name="label">GPA</property>
    37   <property name="label_edit">GPA</property>
    3827  <property name="readonly_layout_modes"/>
    3928  <property name="hidden_layout_modes"/>
     
    7362  <property name="hidden_readonly_layout_modes"/>
    7463 </widget>
    75  <widget name="status" meta_type="String Widget">
    76   <property name="title">Status</property>
    77   <property name="fields">
    78    <element value="status"/>
    79   </property>
    80   <property name="label">Status</property>
    81   <property name="label_edit">Status</property>
    82   <property name="readonly_layout_modes"/>
    83   <property name="hidden_layout_modes"/>
    84   <property name="hidden_readonly_layout_modes"/>
    85  </widget>
    86  <widget name="verdict" meta_type="String Widget">
    87   <property name="title">Verdict</property>
    88   <property name="fields">
    89    <element value="verdict"/>
    90   </property>
    91   <property name="label">Verdict</property>
    92   <property name="label_edit">Verdict</property>
    93   <property name="readonly_layout_modes"/>
    94   <property name="hidden_layout_modes"/>
    95   <property name="hidden_readonly_layout_modes"/>
    96  </widget>
    97  <widget name="weight" meta_type="String Widget">
    98   <property name="title">Weight</property>
    99   <property name="fields">
    100    <element value="weight"/>
    101   </property>
    102   <property name="label">Weight</property>
    103   <property name="label_edit">Weight</property>
    104   <property name="readonly_layout_modes"/>
    105   <property name="hidden_layout_modes"/>
    106   <property name="hidden_readonly_layout_modes"/>
    107  </widget>
    10864 <table>
    10965  <row>
     
    11470  </row>
    11571  <row>
    116    <cell name="status"/>
    117   </row>
    118   <row>
    11972   <cell name="score"/>
    120   </row>
    121   <row>
    122    <cell name="verdict"/>
    123   </row>
    124   <row>
    125    <cell name="weight"/>
    126   </row>
    127   <row>
    128    <cell name="gpa"/>
    12973  </row>
    13074  <row>
  • WAeUP_SRP/trunk/profiles/default/schemas.xml

    r444 r454  
    2020 <object name="student_personal" meta_type="CPS Schema"/>
    2121 <object name="students" meta_type="CPS Schema"/>
     22 <object name="student_study_level" meta_type="CPS Schema"/>
    2223 <object name="study_level" meta_type="CPS Schema"/>
    2324 <object name="university" meta_type="CPS Schema"/>
  • WAeUP_SRP/trunk/profiles/default/schemas/course_results.xml

    r398 r454  
    33 <field name="ansbook" meta_type="CPS String Field"/>
    44 <field name="carry_level" meta_type="CPS String Field"/>
    5  <field name="gpa" meta_type="CPS Float Field"/>
    65 <field name="grade" meta_type="CPS String Field"/>
    76 <field name="import_id" meta_type="CPS String Field"/>
    87 <field name="score" meta_type="CPS Int Field"/>
    9  <field name="status" meta_type="CPS String Field"/>
    10  <field name="verdict" meta_type="CPS String Field"/>
    11  <field name="weight" meta_type="CPS String Field"/>
    128</object>
  • WAeUP_SRP/trunk/profiles/default/types.xml

    r444 r454  
    1717 <object name="Semester" meta_type="CPS Flexible Type Information"/>
    1818 <object name="Student" meta_type="CPS Flexible Type Information"/>
     19 <object name="StudentStudyLevel" meta_type="CPS Flexible Type Information"/>
    1920 <object name="StudentStudyCourse" meta_type="CPS Flexible Type Information"/>
    2021 <object name="StudentClearance" meta_type="CPS Flexible Type Information"/>
  • WAeUP_SRP/trunk/profiles/default/types/StudentStudyCourse.xml

    r435 r454  
    1212 <property name="filter_content_types">True</property>
    1313 <property name="allowed_content_types">
    14   <element value="StudyLevel"/>
     14  <element value="StudentStudyLevel"/>
    1515 </property>
    1616 <property name="allow_discussion">False</property>
  • WAeUP_SRP/trunk/profiles/default/workflows.xml

    r453 r454  
    1515 <object name="waeup_student_wf" meta_type="CPS Workflow"/>
    1616 <object name="waeup_workspace_wf" meta_type="CPS Workflow"/>
    17  <object name="workspace_calendar_wf" meta_type="CPS Workflow"/>
    18  <object name="workspace_content_wf" meta_type="CPS Workflow"/>
    19  <object name="workspace_folder_wf" meta_type="CPS Workflow"/>
    20  <object name="workspace_folderish_content_wf" meta_type="CPS Workflow"/>
    2117 <bindings>
    2218  <default/>
     
    105101   <bound-workflow workflow_id="section_folder_wf"/>
    106102  </type>
     103  <type type_id="StudentStudyLevel">
     104   <bound-workflow workflow_id="section_folder_wf"/>
     105  </type>
    107106  <type type_id="University">
    108107   <bound-workflow workflow_id="section_folder_wf"/>
  • WAeUP_SRP/trunk/skins/waeup_academics/academics_content_lib_info_detail_tab.pt

    r452 r454  
    119119    <span tal:content="info/type">ID</span>
    120120  </td>
    121     <span tal:condition="python: context.portal_type == 'CoursesFolder'">
     121    <span tal:condition="python: info['doc'].portal_type == 'Course'">
    122122      <td>
    123123        <span tal:content="info/semester">ID</span>
     
    128128      <td>
    129129        <span tal:content="info/passmark">ID</span>
     130      </td>
     131    </span>
     132    <span tal:define="docu python: info['doc']"
     133          tal:condition="python: docu.portal_type == 'CourseTicket'">
     134      <td>
     135        <span tal:content="docu/grade">ID</span>
     136      </td>
     137      <td>
     138        <span tal:content="docu/score">ID</span>
     139      </td>
     140    </span>
     141    <span tal:define="docu python: info['doc']"
     142          tal:condition="python: docu.portal_type == 'Student'">
     143      <td>
     144        <span tal:content="info/clearance/matric_no">ID</span>
    130145      </td>
    131146    </span>
  • WAeUP_SRP/trunk/skins/waeup_academics/academics_contents.pt

    r435 r454  
    4242    <span tal:define="redirect python: response.redirect(url)"></span>
    4343  </div>
    44     <span tal:omit-tag="" tal:condition="python:display_buttons or (context.portal_type in ('Certificate','Department'))"
     44    <span tal:omit-tag="" tal:condition="python:display_buttons or context.display_content()"
    4545          tal:content="structure doc/render" />
    4646
  • WAeUP_SRP/trunk/skins/waeup_academics/academics_contents_display_buttons.py

    r371 r454  
    1414
    1515#if context.portal_type in ('Department','Certificate','StudyLevel'):
    16 if context.portal_type in ('Department','StudyLevel',):
     16if context.portal_type in ('Department',
     17                           'StudyLevel',
     18                           'Student',
     19                           'StudentAdmission',
     20                           'StudentClearance',
     21                           'StudentPersonal',
     22                           'StudentStudyCourse',
     23                           'StudentStudyLevel',
     24                           ):
    1725    return None
    1826return 1
  • WAeUP_SRP/trunk/skins/waeup_custom/getContentInfo.py

    r440 r454  
    232232            core = 'elective'
    233233        info['core_or_elective'] = core
     234    elif doc.portal_type == 'Student':
     235        info['clearance'] = proxy.clearance.getContent()
    234236    info['time'] = doc.modified()
    235237    info['doc'] = doc
Note: See TracChangeset for help on using the changeset viewer.