Index: /WAeUP_SRP/base/WAeUPTool.py
===================================================================
--- /WAeUP_SRP/base/WAeUPTool.py	(revision 3142)
+++ /WAeUP_SRP/base/WAeUPTool.py	(revision 3143)
@@ -711,5 +711,6 @@
         "do it"
         files = [file for file in os.listdir("%s/import/" % (i_home))
-                 if file.endswith('.csv') and file.find('imported') == -1]
+                 if file.endswith('.csv') and (file.find('imported') == -1 and
+                                               file.find('pending') == -1)]
         return files
     ###)
@@ -1596,4 +1597,5 @@
     security.declareProtected(ModifyPortalContent,'mass_edit_course_result') ###(
     def mass_edit_course_result(self,mapping):
+        #import pdb;pdb.set_trace()
         while True:
             result_id = mapping.get('id',None)
@@ -1610,6 +1612,8 @@
             if not res:
                 return '', "No student with %(id_key)s %(id_field)s" % vars()
-            if id_field != "student_id":
+            if id_field == "matric_no":
                 mapping['student_id'] = res[0].id
+            elif id_field == "student_id":
+                mapping['matric_no'] = res[0].matric_no
             if not res:
                 return '', "No student with %(id_key)s %(id_field)s" % vars()
@@ -1623,5 +1627,5 @@
             self.course_results.modifyRecord(**mapping)
         except KeyError:
-            return key, "No course result to edit: %s" % key
+            return key, "No course result to edit: %s" % key,mapping
         return key,''
     ###)
@@ -1965,4 +1969,5 @@
                                                                           student_record.matric_no,
                                                                           matric_no)
+            mapping['matric_no'] = student_record.matric_no
         elif matric_no:
             res = self.students_catalog(matric_no = matric_no)
@@ -1980,19 +1985,22 @@
         current_session = d['session'] = mapping.get('current_session','')
         if current_session and student_record.session != current_session:
-            return student_id,'student %s: imported session %s does not match current_session %s' % (student_id,
+            msg = 'student %s: imported session %s does not match current_session %s' % (student_id,
                                                                                         current_session,
                                                                                         student_record.session)
+            return student_id,msg,mapping
         current_level = mapping.get('current_level','')
         if not current_level.isdigit():
             return '','student %s: imported level is empty' % (student_id,)
         if current_level and student_record.level != current_level:
-            return student_id,'student %s: imported level %s does not match current_level %s' % (student_id,
+            msg = 'student %s: imported level %s does not match current_level %s' % (student_id,
                                                                                     current_level,
                                                                                     student_record.level)
+            return student_id,msg,mapping
         student_review_state =  student_record.review_state
         if student_review_state == 'deactivated':
             return '',"student %s in review_state %s" % (student_id, student_review_state)
         if student_review_state not in ('courses_validated','returning'):
-            return student_id,"student %s in wrong review_state %s" % (student_id, student_review_state)
+            msg = "student %s in wrong review_state %s" % (student_id, student_review_state)
+            return student_id,msg,mapping
         student_obj = getattr(students_folder,student_id)
         f2t = self.field2types_student
@@ -2035,4 +2043,5 @@
         logger = logging.getLogger('WAeUPTool.importData')
         current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
+        import_date = DateTime.DateTime().strftime("%d/%m/%y %H:%M:%S")
         students_folder = self.portal_url.getPortalObject().campus.students
         start = True
@@ -2079,4 +2088,5 @@
             return em
         pending_fn = "%s/import/%ss_pending.csv" % (i_home,name)
+        pending_imported_fn = "%s/import/%ss_pending_imported%s.csv" % (i_home,name,current)
         if pending_only:
             import_source_fn = pending_fn
@@ -2097,8 +2107,7 @@
         diff2layout = set(import_keys).difference(set(layout.keys()))
         if diff2schema and diff2schema != set(['id',]):
-            #import pdb;pdb.set_trace()
             msg = 'not ignorable key(s): "%s" found in heading' % ", ".join(diff2schema)
             return msg
-        if mode == "create":
+        if mode in ("create","edit"):
             required_keys = [layout.getIdUnprefixed(id)
                                 for id,widget in layout.objectItems()
@@ -2137,4 +2146,5 @@
         pending_records = {}
         imports_pending = 0
+        total_pending_imported = 0
         total_pending = 0
         format = ','.join(['"%%(%s)s"' % fn for fn in import_keys])
@@ -2143,7 +2153,15 @@
         imported = []
         if name in ('verdict','course_result',):
-            #global pending_records
-            pending_keys = imported_keys[:]
+            #pending_keys = imported_keys[:]
+            sname = "%s_pending" % iname
+            pending_schema = stool._getOb(sname)
+            if schema is None:
+                em = 'No such pending_schema %s' % sname
+                logger.error('No such schema %s' % sname)
+                return em
+            pending_keys = pending_schema.keys()
             pending_keys += "Error",
+            if 'id' not in pending_keys:
+                pending_keys.insert(0,'id')
             pending_records = {}
             if os.path.exists(pending_fn):
@@ -2157,20 +2175,22 @@
             new_imports_pending = 0
             pending_imported = []
-            for item in pending_records.values():
-                id,error = importer(item)
-                if error:
-                    continue
-                else:
-                    if item.has_key('Error'):
-                        del item['Error']
-                    imported.append(item)
+            if pending_only:
+                pending_imported_ids = []
+                pending_imported = []
+                for item in pending_records.values():
+                    results = importer(item)
+                    id = results[0]
+                    error = results[1]
+                    is_pending = len(results) == 3
+                    if is_pending:
+                        continue
                     msg = format % item
                     logger.info("imported from %(pending_fn)s %(msg)s" % vars())
-                    pending_imported += id,
-                    continue
-            total_imported = len(pending_imported)
-            logger.info("imported %d pending imports" % len(pending_imported))
-            for id in pending_imported:
-                del pending_records[id]
+                    pending_imported.append(item)
+                    pending_imported_ids += id,
+                    total_pending_imported = len(pending_imported_ids)
+                    logger.info("imported %d pending imports" % len(pending_imported_ids))
+                for id in pending_imported_ids:
+                    del pending_records[id]
             pending_imports_file = open(pending_fn,'w')
             pending_csv_writer = csv.DictWriter(pending_imports_file,
@@ -2179,4 +2199,11 @@
             mapping = dict((k,k) for k in pending_keys)
             pending_csv_writer.writerow(mapping)
+            if len(pending_imported) > 0:
+                pending_imported_file = open(pending_imported_fn,'w')
+                pending_imported_csv_writer = csv.DictWriter(pending_imported_file,
+                                                             pending_keys,
+                                                             extrasaction='ignore')
+                pending_imported_csv_writer.writerow(dict((k,k) for k in imported_keys))
+                pending_imported_csv_writer.writerows(pending_imported)
         #
         if pending_only:
@@ -2215,21 +2242,26 @@
             temp_item = item.copy()
             temp_item.update(dm)
-            id,error = importer(temp_item)
-            if error:
+            #id,error = importer(temp_item)
+            results = importer(temp_item)
+            id = results[0]
+            error = results[1]
+            is_pending = len(results) == 3
+            if is_pending:
+                temp_item = results[2]
+                temp_item['Error'] = error
+                msg = format_error % temp_item
+                if id not in pending_records.keys():
+                    temp_item['id'] = id
+                    pending_records[id] = temp_item
+                    logger.info("%(id)s added to pending %(msg)s" % vars())
+                    new_imports_pending += 1
+                else:
+                    logger.info("%(id)s already in pending %(msg)s" % vars())
+                continue
+            elif error:
                 item['Error'] = error
-                if id:
-                    if id not in pending_records.keys():
-                        item['id'] = id
-                        pending_records[id] = item
-                        msg = format_error % item
-                        logger.info("%(id)s added to pending %(msg)s" % vars())
-                        new_imports_pending += 1
-                    else:
-                        logger.info("%(id)s already in pending %(msg)s" % vars())
-                    continue
-                else:
-                    not_imported.append(item)
-                    total_not_imported += 1
-                    continue
+                not_imported.append(item)
+                total_not_imported += 1
+                continue
             item = temp_item
             item['id'] = id
@@ -2267,5 +2299,6 @@
         msg += "%(total_imported)d imported, %(total_not_imported)d not imported " % vars()
         if total_pending:
-            msg += "%(new_imports_pending)d pending added, %(total_pending)d total pending in %(pending_fn)s " % vars()
+            msg += "%(new_imports_pending)d pending added, %(total_pending_imported)d pending imported " % vars()
+            msg += "%(total_pending)d total pending in %(pending_fn)s " % vars()
         msg += "(of total %(total)d)" % vars()
         logger.info(msg)
Index: /WAeUP_SRP/uniben/profiles/default/layouts/import_course_result.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/layouts/import_course_result.xml	(revision 3142)
+++ /WAeUP_SRP/uniben/profiles/default/layouts/import_course_result.xml	(revision 3143)
@@ -75,5 +75,5 @@
       <element value="session_id"/>
     </property>
-    <property name="is_required">True</property>
+    <property name="is_required">False</property>
     <property name="label">session</property>
     <property name="label_edit">session</property>
@@ -129,4 +129,5 @@
       <element value="score"/>
     </property>
+    <property name="is_required">True</property>
     <property name="label">Score</property>
     <property name="label_edit">Score</property>
@@ -135,4 +136,6 @@
     <property name="hidden_layout_modes"/>
     <property name="hidden_readonly_layout_modes"/>
+    <property name="min_value">1</property>
+    <property name="max_value">100</property>
   </widget>
 
Index: /WAeUP_SRP/uniben/profiles/default/layouts/import_verdict.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/layouts/import_verdict.xml	(revision 3142)
+++ /WAeUP_SRP/uniben/profiles/default/layouts/import_verdict.xml	(revision 3143)
@@ -11,5 +11,5 @@
     <property name="title">Id</property>
     <property name="fields">
-      <element value="student_id"/>
+      <element value="id"/>
     </property>
     <property name="is_required">False</property>
Index: /WAeUP_SRP/uniben/profiles/default/schemas.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/schemas.xml	(revision 3142)
+++ /WAeUP_SRP/uniben/profiles/default/schemas.xml	(revision 3143)
@@ -15,4 +15,5 @@
  <object name="import_course" meta_type="CPS Schema"/>
  <object name="import_course_result" meta_type="CPS Schema"/>
+ <object name="import_course_result_pending" meta_type="CPS Schema"/>
  <object name="import_department" meta_type="CPS Schema"/>
  <object name="import_faculty" meta_type="CPS Schema"/>
@@ -20,4 +21,5 @@
  <object name="import_student" meta_type="CPS Schema"/>
  <object name="import_verdict" meta_type="CPS Schema"/>
+ <object name="import_verdict_pending" meta_type="CPS Schema"/>
 
  <object name="course" meta_type="CPS Schema"/>
Index: /WAeUP_SRP/uniben/profiles/default/schemas/import_course_result_pending.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/schemas/import_course_result_pending.xml	(revision 3143)
+++ /WAeUP_SRP/uniben/profiles/default/schemas/import_course_result_pending.xml	(revision 3143)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="schema.xsl"?>
+<object name="course_result_pending" meta_type="CPS Schema">
+ <field name="student_id" meta_type="CPS String Field"/>
+ <field name="matric_no" meta_type="CPS String Field"/>
+ <field name="code" meta_type="CPS String Field"/>
+ <field name="session_id" meta_type="CPS String Field"/>
+ <field name="level_id" meta_type="CPS String Field"/>
+ <field name="credits" meta_type="CPS Int Field"/>
+ <field name="score" meta_type="CPS String Field"/>
+ <field name="grade" meta_type="CPS String Field"/>
+ <field name="carry_over" meta_type="CPS Boolean Field"/>
+ <field name="core_or_elective" meta_type="CPS Boolean Field"/>
+ <field name="semester" meta_type="CPS Int Field"/>
+</object>
Index: /WAeUP_SRP/uniben/profiles/default/schemas/import_verdict_pending.xml
===================================================================
--- /WAeUP_SRP/uniben/profiles/default/schemas/import_verdict_pending.xml	(revision 3143)
+++ /WAeUP_SRP/uniben/profiles/default/schemas/import_verdict_pending.xml	(revision 3143)
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="schema.xsl"?>
+<object name="import_verdict_pending" meta_type="CPS Schema">
+ <field name="id" meta_type="CPS String Field"/>
+ <field name="matric_no" meta_type="CPS String Field"/>
+ <field name="current_level" meta_type="CPS String Field"/>
+ <field name="current_session" meta_type="CPS String Field"/>
+ <field name="current_verdict" meta_type="CPS String Field"/>
+</object>
