Changeset 2766


Ignore:
Timestamp:
26 Nov 2007, 19:18:09 (17 years ago)
Author:
joachim
Message:

M skins/waeup_student/create_level.py
use course_results for carry_overs

M skins/waeup_pins/pins_view.pt
M skins/waeup_pins/search_pins.py
sort batches in select-box

M Widgets.py
M WAeUPTables.py
M WAeUPTool.py
mass_(create,edit)_courseresults edits verdict in level.

M profiles/default/layouts/application_cest.xml
M profiles/default/applicants_catalog.xml
new meta_data field "serial", index must be added manually

Location:
WAeUP_SRP
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • WAeUP_SRP/base/WAeUPTables.py

    r2761 r2766  
    536536            raise ValueError("More than one record with uid %s" % uid)
    537537        if len(records) == 0:
    538             return -1
     538            return -1,None
    539539        record = records[0]
    540540        if record.student == "":
     
    546546            try:
    547547                self.catalog_object(dict2ob(record_data), uid)
    548                 return 1
     548                return 1,record
    549549            except ConflictError:
    550                 return 2
     550                return 2,record
    551551        if record.student.upper() != student_id.upper():
    552             return 0
     552            return 0,record
    553553        if record.student.upper() == student_id.upper():
    554             return 2
    555         return -3
     554            return 2,record
     555        return -3,record
    556556InitializeClass(PinTable)
    557557###)
  • WAeUP_SRP/base/WAeUPTool.py

    r2755 r2766  
    14451445        if course_id not in self._v_courses.keys():
    14461446            return '', "No course with ID: %s" % course_id
    1447         id_key = ''
    1448         for id_key in ('student_id','matric_no'):
    1449             id_field = mapping.get(id_key,None)
    1450             if id_field is not None:
    1451                 student_id = id_field
    1452                 break
    1453         query = Eq(id_key,id_field)
    1454         res = self.students_catalog.evalAdvancedQuery(query)
    1455         if not res:
     1447        # id_key = ''
     1448        # for id_key in ('student_id','matric_no'):
     1449        #     id_field = mapping.get(id_key,None)
     1450        #     if id_field is not None:
     1451        #         student_id = id_field
     1452        #         break
     1453        # query = Eq(id_key,id_field)
     1454        # res = self.students_catalog.evalAdvancedQuery(query)
     1455        student_rec = self.students_catalog.getRecordByKey(mapping['student_id'])
     1456        if student_rec is None:
    14561457            return '', "no student with %(id_key)s %(id_field)s" % vars()
    1457         if id_field != "student_id":
    1458             mapping['student_id'] = res[0].id
     1458        # if id_field != "student_id":
     1459        #     mapping['student_id'] = res[0].id
     1460        student_id = student_rec.id
     1461        level_id = mapping['level_id']
     1462        code = mapping['code']
    14591463        if mapping['student_id'] not in self._v_level_created:
    14601464            try:
    14611465                context = getattr(getattr(students_folder,
    1462                                           "%(student_id)s" % mapping),
     1466                                          "%(student_id)s" % vars()),
    14631467                                  'study_course')
    14641468            except:
    1465                 return '', "could not create level %(level_id)s for %(student_id)s" % mapping
    1466             if mapping['level_id'] not in context.objectIds():
    1467                 context.invokeFactory('StudentStudyLevel',"%(level_id)s" % mapping)
    1468                 level = getattr(context,"%(level_id)s" % mapping)
     1469                return '', "could not create level %(level_id)s for %(student_id)s" % vars()
     1470            if level_id not in context.objectIds():
     1471                context.invokeFactory('StudentStudyLevel',"%(level_id)s" % vars())
     1472                level = getattr(context,"%(level_id)s" % vars())
    14691473                self.portal_workflow.doActionFor(level,'open')
    1470 
    14711474                # the session string must not be copied into the level object
    1472                 #level.getContent().edit(mapping={'session': "%(session_id)s" % mapping})
    1473 
    1474                 #self.portal_workflow.doActionFor(level,'close_for_edit')
    1475             self._v_level_created += mapping['student_id'],
    1476         mapping['key'] = key = "%(student_id)s|%(level_id)s|%(code)s" % mapping
     1475                if student_rec.current_verdict:
     1476                    level.getContent().edit(mapping={'verdict': "%s" %
     1477                                                     student_rec.current_verdict,
     1478                                                     'session': "%s" %
     1479                                                     student_rec.current_session,
     1480                                                    })
     1481                    self.portal_workflow.doActionFor(level,'close')
     1482            self._v_level_created += student_id,
     1483        mapping['key'] = key = "%(student_id)s|%(level_id)s|%(code)s" % vars()
    14771484        for k in ('semester','credits',):
    14781485            mapping[k] = getattr(self._v_courses[course_id],k)
     
    14951502        # if course_id not in self._v_courses.keys():
    14961503        #     return '', "No course with ID: %s" % did
    1497         id_key = ''
    1498         for id_key in ('student_id','matric_no'):
    1499             id_field = mapping.get(id_key,None)
    1500             if id_field is not None:
    1501                 student_id = id_field
    1502                 break
    1503         query = Eq(id_key,id_field)
    1504         res = self.students_catalog.evalAdvancedQuery(query)
    1505         if not res:
    1506             return '', "No student with %(id_field)s: %(id_key)s" % vars()
    1507         if id_field != "student_id":
    1508             mapping['student_id'] = res[0].id
    1509         mapping['key'] = key = "%(student_id)s|%(level_id)s|%(code)s" % mapping
     1504        # id_key = ''
     1505        # for id_key in ('student_id','matric_no'):
     1506        #     id_field = mapping.get(id_key,None)
     1507        #     if id_field is not None:
     1508        #         student_id = id_field
     1509        #         break
     1510        # query = Eq(id_key,id_field)
     1511        # res = self.students_catalog.evalAdvancedQuery(query)
     1512        # if not res:
     1513        #     return '', "No student with %(id_field)s: %(id_key)s" % vars()
     1514        # if id_field != "student_id":
     1515        #     mapping['student_id'] = res[0].id
     1516        students_folder = self.portal_url.getPortalObject().campus.students
     1517        student_rec = self.students_catalog.getRecordByKey(mapping['student_id'])
     1518        if student_rec is None:
     1519            return '', "no student with %(id_key)s %(id_field)s" % vars()
     1520        student_id = student_rec.id
     1521        level_id = mapping['level_id']
     1522        code = mapping['code']
     1523        mapping['key'] = key = "%(student_id)s|%(level_id)s|%(code)s" % vars()
    15101524        # for k in ('semester',):
    15111525        #     mapping[k] = getattr(self._v_courses[course_id],k)
     
    15141528        except KeyError:
    15151529            return '', "No course result to edit: %s" % key
     1530        if student_rec.current_verdict:
     1531            #makes only sense if the course_results are imported for the current session
     1532            try:
     1533                level = getattr(getattr(getattr(students_folder,
     1534                                                "%(student_id)s" % vars()),
     1535                                        'study_course'),
     1536                                "%(level_id)s" % vars())
     1537            except:
     1538                return '', "could not find level %(level_id)s for %(student_id)s" % vars()
     1539            if self.portal_workflow.getInfoFor(level,'review_state',None) == "closed":
     1540                self.portal_workflow.doActionFor(level,'open')
     1541            level.getContent().edit(mapping={'verdict': "%s" %
     1542                                                student_rec.current_verdict,
     1543                                                'session': "%s" %
     1544                                                student_rec.current_session,
     1545                                            })
     1546            self.portal_workflow.doActionFor(level,'close')
    15161547        return key,''
    15171548    ###)
  • WAeUP_SRP/base/Widgets.py

    r2738 r2766  
    2424#from Products.ExtFile.ExtFile import ExtFile
    2525import logging,os,re
     26import random
    2627import operator
    2728p_home = Globals.package_home(globals())
     
    3132
    3233
    33 class WAeUPPasswordWidget(CPSPasswordWidget):
     34class WAeUPPasswordWidget(CPSPasswordWidget): ###(
    3435    """WAeUP Password Widget"""
    3536    meta_type = 'WAeUP Password Widget'
     
    117118
    118119widgetRegistry.register(WAeUPPasswordWidget)
    119 
     120###)
    120121
    121122class CPSSelectWidgetForRecord(CPSSelectWidget): ###(
     
    13201321
    13211322        while do:
    1322             ok = pins.searchAndSetRecord(pin,ref,prefix)
     1323            ok,record = pins.searchAndSetRecord(pin,ref,prefix)
    13231324            if ok < -2 or ok > 2:
    13241325                err = 'Unknown error, please report!'
     
    14731474    def validate(self, datastructure, **kw): ###(
    14741475        """Validate datastructure and update datamodel."""
    1475         #import pdb;pdb.set_trace()
    14761476        s_logger = logging.getLogger('Widgets.ScratchcardPinWidget.validate')
    14771477        widget_id = self.getWidgetId()
     
    15191519                s_logger.info('%s/%s entered wrong data together with PIN %s' % (member_id,ref,pin_str))
    15201520        while do:
    1521             ok = pins.searchAndSetRecord(pin,ref,prefix)
     1521            ok,pin_record = pins.searchAndSetRecord(pin,ref,prefix)
    15221522            if ok < -2 or ok > 2:
    15231523                err = 'Unknown error, please report!'
     
    15561556                        d['reg_no'] = applicant.reg_no
    15571557                        d['pin'] = pin_str
     1558                        d['serial'] = "%c%05d" % (pin_record.prefix_batch[-1],
     1559                                                  pin_record.serial)
    15581560                        #d['screening_type'] = screening_type
    15591561                        #d['status'] = 'entered'
  • WAeUP_SRP/base/skins/waeup_pins/pins_view.pt

    r2140 r2766  
    6262                >
    6363          <option value="--">Goto Batch ...</option>
    64           <option tal:repeat="batch context/objectIds"
     64          <option tal:repeat="batch info/batches"
    6565                  tal:attributes="value batch"
    6666                  tal:content="batch">
  • WAeUP_SRP/base/skins/waeup_pins/search_pins.py

    r2615 r2766  
    109109    view = context.batch_view
    110110elif context.portal_type == "ScratchCardBatchesFolder":
     111    batches = context.objectIds()
     112    batches.sort()
     113    info['batches'] = batches
    111114    view = context.pins_view
    112115if psm == '':
  • WAeUP_SRP/base/skins/waeup_student/create_level.py

    r2758 r2766  
    3939lt = context.portal_layouts
    4040wt = context.waeup_tool
    41 student = context.students_catalog(id=student_id)[0]
     41student = context.students_catalog.getRecordByKey(student_id)
    4242cert_id = student.course
    4343current_level = student.level
     
    5151
    5252if context.hasObject(current_level):
    53     level = getattr(context,"%s" % current_level)
     53    #level = getattr(context,"%s" % current_level)
     54    return response.redirect("%s/%s" % (context.absolute_url(),current_level))
    5455else:
    5556    context.invokeFactory('StudentStudyLevel',"%s" % current_level)
     
    6566    results = context.results_import(matric_no = student.matric_no)
    6667l = []
    67 
    6868
    6969# fetch carry_over courses from results_import
     
    110110        records.append(d)
    111111# fetch carry_over courses from the course_results catalog
    112 # else
     112else:
     113    res = context.aq_results(Eq('student_id',student_id),
     114                             sortSpecs=('level_id',))
     115    last_level_id = res[-1].level_id
     116    for result in res:
     117        course_id = result.code
     118        if course_id in l or result.level_id != last_level_id:
     119            continue
     120        query = Eq('code',course_id)
     121        c_res = aq_courses(query)
     122        if not c_res:
     123            #logger.info('%s", course %s not found in courses_catalog' % (student.id,result.CosCode))
     124            continue
     125        course_cat_entry = c_res[0]
     126        passmark = getattr(course_cat_entry,'passmark',None)
     127        try:
     128            score = int(result.score)
     129        except:
     130            # logger.info('%s, course %s has invalid score %s"' % (student.id,
     131            #                                                     course_id,
     132            #                                                     result.Score))
     133            continue
     134        if int(c_res[0].passmark) <= score:
     135            continue
     136        l += course_id,
     137        d = context.getCourseInfo(course_id)
     138        d['course_id'] = course_id
     139        d['carry_over'] = True
     140        d['code'] = course_id
     141        d['student_id'] = student_id
     142        d['level_id'] = level_id
     143        d['session_id'] = session_id
     144        records.append(d)
    113145
    114146# fetch session courses from the certificate
  • WAeUP_SRP/uniben/profiles/default/applicants_catalog.xml

    r2759 r2766  
    1717 <column value="phone"/>
    1818 <column value="pin"/>
     19 <column value="serial"/>
    1920 <column value="eng_score"/>
    2021 <column value="subj1"/>
     
    5960  <indexed_attr value="reg_no"/>
    6061 </index>
     62 <index name="serial" meta_type="FieldIndex">
     63  <indexed_attr value="serial"/>
     64 </index>
    6165 <index name="status" meta_type="FieldIndex">
    6266  <indexed_attr value="status"/>
  • WAeUP_SRP/uniben/profiles/default/layouts/application_cest.xml

    r2763 r2766  
    815815    </row>
    816816    <row>
     817      <cell name="serial" ncols="2"/>
     818    </row>
     819    <row>
    817820      <cell name="firstname" ncols="2"/>
    818821    </row>
Note: See TracChangeset for help on using the changeset viewer.