Changeset 398


Ignore:
Timestamp:
21 Aug 2006, 14:29:27 (18 years ago)
Author:
joachim
Message:

import of full_time_students_results

Location:
WAeUP_SRP/trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/trunk/Academics.py

    r389 r398  
    616616    portal_type = meta_type
    617617    security = ClassSecurityInfo()
     618    def getCourseEntry(self,cid):
     619        res = self.portal_catalog({'meta_type': "Course",
     620                                           'id': cid})
     621        if res:
     622            return res[-1]
     623        else:
     624            return None
     625
     626    security.declareProtected(View,"Title")
     627    def Title(self):
     628        """compose title"""
     629        ce = self.getCourseEntry(self.id.upper())
     630        if ce:
     631            return "%s" % ce.Title
     632        return "No such course"
    618633
    619634InitializeClass(CourseTicket)
  • WAeUP_SRP/trunk/Students.py

    r396 r398  
    1919p_home = Globals.package_home(globals())
    2020i_home = Globals.INSTANCE_HOME
     21MAX_TRANS = 1000
    2122
    2223class StudentsFolder(CPSDocument): ###(
     
    3233        """load Fulltime Studentdata from CSV values"""
    3334        #return
     35        import transaction
     36        tr_count = 0
    3437        name = 'short_full_time'
    3538        no_import = False
     
    6467                continue
    6568            certcode = makeCertificateCode(student.get('CourseMajor'))
    66             if sid in students_added:
    67                 em = 'Student with ID %(MatricNo)s %(fullname)s already exists in this import\n' % student
    68                 logger.info(em)
    69                 no_import.write(em)
    70                 no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
    71                 continue
     69##            if sid in students_added:
     70##                em = 'Student with ID %(MatricNo)s %(fullname)s already exists in this import\n' % student
     71##                logger.info(em)
     72##                no_import.write(em)
     73##                no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
     74##                continue
    7275            s = studs.get(sid,None)
    7376            if certcode not in certs.keys():
     
    9295                s = getattr(self,sid)
    9396                students_added.append(sid)
     97                studs[sid] = s
    9498                s.invokeFactory('StudentPersonal','personal')
    9599                sp = s.personal
     
    153157                no_import.write(em)
    154158                no_import.write('"%(MatricNo)s","%(EntryRegNo)s","%(CurrentSession)s","%(StudentLevel)s","%(fullname)s","%(FirstName)s","%(MiddleName)s","%(Lastname)s","%(FormerSurname)s","%(Sex)s","%(Nationality)s","%(State)s","%(LGA)s","%(PermanentAddress)s","%(PermanentAddressCity)s","%(CampusAddress)s","%(PhoneNumber)s","%(Emailaddress)s","%(Mode)s","%(CourseMajor)s","%(Faculty)s","%(Dept)s"\n' % student)
     159            if tr_count > MAX_TRANS:
     160                #transaction.commit()
     161                #em = '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Transaction commited\n' % student
     162                logger.info(em)
     163                tr_count = 0
     164            tr_count += 1
    155165        return self.students.academics_contents()
    156166    ###)
    157167
    158     security.declareProtected(ModifyPortalContent,"loadFullTimeStudentsResultsFromCSV")
     168    security.declareProtected(ModifyPortalContent,"loadFullTimeStudentsResultsFromCSV") ###(
    159169    def loadFullTimeStudentsResultsFromCSV(self):
    160170        """load Fulltime Studentdata from CSV values"""
    161171        #return
    162         name = 'short_full_time_results_2004_2005.csv'
     172        import transaction
     173        tr_count = 0
     174        name = 'short_full_time_results_2004_2005'
    163175        no_import = False
    164176        if not no_import:
     
    177189        for s in l:
    178190            students[s.id] = s.getObject()
    179         courses = self.portal_catalog({'meta_type': "Course"})
     191        l = self.portal_catalog({'meta_type': "Course"})
     192        courses = {}
     193        for c in l:
     194            courses[c.id] = c.getObject()
    180195        for result in results:
    181196            sid = result.get('Matnumber')
    182197            if sid not in students.keys():               
    183                 em = 'Student with ID %(Matnumber)s not found\n' % student
    184                 logger.info(em)
    185                 no_import.write(em)
    186                 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' % student)
     198                em = 'Student with ID %(Matnumber)s not found\n' % result
     199                logger.info(em)
     200                no_import.write(em)
     201                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)
    187202                continue
    188             if student.get('CosCode') not in courses:
    189                 em = 'Course with ID %(CosCode)s not found\n' % student
    190                 logger.info(em)
    191                 no_import.write(em)
    192                 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' % student)
     203            course = result.get('CosCode')
     204            if course not in courses.keys():
     205                em = 'Course with ID %(CosCode)s not found\n' % result
     206                logger.info(em)
     207                no_import.write(em)
     208                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)
    193209                continue
    194             level = student.get('Level')
     210            level = result.get('Level')
    195211            try:
    196212                int(level)
    197213            except:
    198                 em = 'Result for Student with ID %(Matnumber)s Course %(CosCode)s Level is empty\n' % student
    199                 logger.info(em)
    200                 no_import.write(em)
    201                 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' % student)
     214                em = 'Result for result with ID %(Matnumber)s Course %(CosCode)s Level is empty\n' % result
     215                logger.info(em)
     216                no_import.write(em)
     217                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)
    202218                continue
    203219            sf = students.get(sid)
     
    206222            if l is None:
    207223                #self.log('Creating Department %(DeptCode)s = %(Description)s' % dep)
    208                 logger.info('Creating Level %(StudentLevel)s for %(fullname)s' % student)
     224                logger.info('Creating Level %(Level)s for %(Matnumber)s' % result)
    209225                sc.invokeFactory('StudyLevel', level)
    210226                l = getattr(sc, level)
     
    216232                second_s = getattr(l,'second')
    217233                second_s.getContent().edit(mapping={'Title': 'Second Semester'})
    218             snr = student.get('Semester')
     234            snr = result.get('Semester')
    219235            semester = getattr(l,'first')
    220             if snr == "1":
     236            if snr == "2":
    221237                semester = getattr(l,'second')
     238            logger.info('Creating CourseTicket %(CourseTicket)s in Level %(Level)s for %(Matnumber)s' % result)
     239            semester.invokeFactory('CourseTicket',course)
     240            ct = getattr(semester,course)
     241            d = {}
     242            d['ansbook'] = result.get('Ansbook')
     243            d['status'] = result.get('CosStuatus')
     244            d['score'] = result.get('Score')
     245            d['carry_level'] = result.get('CarryLevel')
     246            d['grade'] = result.get('Grade')
     247            d['weight'] = result.get('Weight')
     248            d['verdict'] = result.get('Verdict')
     249            d['import_id'] = result.get('id')
     250            gpa = result.get('GPA').replace(',','.')
     251            d['gpa'] = float(gpa)
     252            ct.getContent().edit(mapping = d)
     253            if tr_count > MAX_TRANS:
     254                transaction.commit()
     255                tr_count = 0
     256            tr_count += 1
     257        return self.students.academics_contents()
    222258           
    223                
    224                
    225 
     259###)
     260
     261           
    226262    security.declareProtected(View,"Title")
    227263    def Title(self):
  • WAeUP_SRP/trunk/profiles/default/layouts.xml

    r362 r398  
    1313 <object name="clearence" meta_type="CPS Layout"/>
    1414 <object name="course" meta_type="CPS Layout"/>
     15 <object name="course_results" meta_type="CPS Layout"/>
    1516 <object name="department" meta_type="CPS Layout"/>
    1617 <object name="faculty" meta_type="CPS Layout"/>
  • WAeUP_SRP/trunk/profiles/default/schemas/course_results.xml

    r199 r398  
    11<?xml version="1.0"?>
    22<object name="course_results" meta_type="CPS Schema">
     3 <field name="ansbook" meta_type="CPS String Field"/>
     4 <field name="carry_level" meta_type="CPS String Field"/>
     5 <field name="gpa" meta_type="CPS Float Field"/>
    36 <field name="grade" meta_type="CPS String Field"/>
    4  <field name="points" meta_type="CPS Int Field"/>
     7 <field name="import_id" meta_type="CPS String Field"/>
     8 <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"/>
    512</object>
  • WAeUP_SRP/trunk/profiles/default/types/StudentsFolder.xml

    r364 r398  
    88 <property name="product">WAeUP_SRP</property>
    99 <property name="factory">addStudentsFolder</property>
    10  <property name="immediate_view">folder_view</property>
     10 <property name="immediate_view">academics_contents</property>
    1111 <property name="global_allow">True</property>
    1212 <property name="filter_content_types">True</property>
     
    7070    url_expr="string:${object_url}/loadFullTimeStudentsFromCSV"
    7171    visible="True"/>
     72 <action title="Import FtS Results" action_id="import_fulltime_students"
     73    category="import" condition_expr=""
     74    url_expr="string:${object_url}/loadFullTimeStudentsResultsFromCSV"
     75    visible="True"/>
    7276</object>
Note: See TracChangeset for help on using the changeset viewer.