Index: main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 13755)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py	(revision 13770)
@@ -22,4 +22,5 @@
 import grok
 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
+from zope.securitypolicy.interfaces import IPrincipalRoleManager
 from datetime import datetime, timedelta, date
 from mechanize import LinkNotFoundError
@@ -33,4 +34,5 @@
 from waeup.kofa.students.accommodation import BedTicket
 from waeup.kofa.testing import FunctionalTestCase
+from waeup.kofa.authentication import LocalRoleSetEvent
 from waeup.kofa.browser.tests.test_pdf import samples_dir
 from waeup.aaue.testing import FunctionalLayer
@@ -634,2 +636,70 @@
             in self.browser.contents)
         return
+
+    def test_handle_courses_by_lecturer(self):
+        self.app['users'].addUser('mrslecturer', 'mrslecturersecret')
+        self.app['users']['mrslecturer'].email = 'mrslecturer@foo.ng'
+        self.app['users']['mrslecturer'].title = u'Mercedes Benz'
+        # Add course ticket
+        studylevel = createObject(u'waeup.StudentStudyLevel')
+        studylevel.level = 100
+        studylevel.level_session = 2004
+        self.student['studycourse'].addStudentStudyLevel(
+            self.certificate, studylevel)
+        # Assign local Lecturer role for a certificate.
+        course = self.app['faculties']['fac1']['dep1'].courses['COURSE1']
+        prmlocal = IPrincipalRoleManager(course)
+        prmlocal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrslecturer')
+        notify(LocalRoleSetEvent(
+            course, 'waeup.local.Lecturer', 'mrslecturer', granted=True))
+        # Login as lecturer.
+        self.browser.open(self.login_path)
+        self.browser.getControl(name="form.login").value = 'mrslecturer'
+        self.browser.getControl(name="form.password").value = 'mrslecturersecret'
+        self.browser.getControl("Login").click()
+        self.browser.getLink("My Roles").click()
+        self.browser.getLink(
+            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1").click()
+        # Course results can be batch edited via the edit_courses view.
+        self.app['faculties']['fac1']['dep1'].score_editing_disabled = False
+        self.app['configuration'].current_academic_session = 2004
+        IWorkflowState(self.student).setState('courses validated')
+        self.browser.open(
+            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores")
+        self.assertTrue(
+            'input type="text" name="scores"'
+            in self.browser.contents)
+        self.browser.getControl(name="scores", index=0).value = '55'
+        self.browser.getControl(name="cas", index=0).value = '66'
+        self.browser.getControl("Update scores").click()
+        # New score and ca has been set.
+        self.assertEqual(
+            self.student['studycourse']['100']['COURSE1'].score, 55)
+        self.assertEqual(
+            self.student['studycourse']['100']['COURSE1'].ca, 66)
+        # Score editing has been logged.
+        logfile = os.path.join(
+            self.app['datacenter'].storage, 'logs', 'students.log')
+        logcontent = open(logfile).read()
+        self.assertTrue('mrslecturer - waeup.aaue.students.browser.CustomEditScoresPage - '
+                        'E1000000 100/COURSE1 score updated (55)' in logcontent)
+        self.assertTrue('mrslecturer - waeup.aaue.students.browser.CustomEditScoresPage - '
+                        'E1000000 100/COURSE1 ca updated (66)' in logcontent)
+        # Non-integer scores won't be accepted.
+        self.browser.open(
+            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores")
+        self.assertTrue('value="55" />' in self.browser.contents)
+        self.browser.getControl(name="scores", index=0).value = 'abc'
+        self.browser.getControl("Update scores").click()
+        self.assertTrue('Error: Score(s) and CA(s) of Anna Tester have not be updated.'
+            in self.browser.contents)
+        # Scores can be removed.
+        self.browser.open(
+            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores")
+        self.browser.getControl(name="scores", index=0).value = ''
+        self.browser.getControl("Update scores").click()
+        self.assertEqual(
+            self.student['studycourse']['100']['COURSE1'].score, None)
+        logcontent = open(logfile).read()
+        self.assertTrue('mrslecturer - waeup.aaue.students.browser.CustomEditScoresPage - '
+                        'E1000000 100/COURSE1 score updated (None)' in logcontent)
Index: main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py
===================================================================
--- main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py	(revision 13755)
+++ main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py	(revision 13770)
@@ -162,8 +162,8 @@
         self.assertEqual(
             result,
-            'automatic,carry_over,code,credits,dcode,fcode,level,level_session,'
+            'automatic,ca,carry_over,code,credits,dcode,fcode,level,level_session,'
             'mandatory,passmark,score,semester,title,student_id,certcode,'
             'display_fullname,matric_number\r\n'
-            '1,1,CRS1,100,DEP1,FAC1,100,2012,0,100,,2,Course 1,A111111,CERT1,'
+            '1,,1,CRS1,100,DEP1,FAC1,100,2012,0,100,,2,Course 1,A111111,CERT1,'
             'Anna M. Tester,234\r\n'
             )
