Ignore:
Timestamp:
7 Nov 2012, 08:27:23 (12 years ago)
Author:
Henrik Bettermann
Message:

Add 'show students' button to CoursePage?.

Lecturers can now list all students in course but they can neither access the students nor the respective course tickets. A CourseTicketPrincipalRoleManager? does not yet exist. And we have to discuss what lecturers are supposed to see. In my opinion, lecturers must no see student data.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/pages.py

    r9545 r9565  
    6262
    6363from waeup.kofa.students.catalog import search as searchstudents
     64from waeup.kofa.students.catalog import StudentQueryResultItem
    6465from waeup.kofa.university.catalog import search
    6566from waeup.kofa.university.vocabularies import course_levels
     
    18901891    """
    18911892    grok.context(ICertificate)
    1892     grok.require('waeup.showStudents')
    18931893    grok.name('showcertstudents')
    1894     pnav = 1
    1895     label = _('Students')
    18961894
    18971895    @property
     
    18991897        hitlist = searchstudents(query=self.context.code,
    19001898            searchtype='certcode', view=self)
     1899        return hitlist
     1900
     1901class ShowStudentsInCoursePage(ShowStudentsInDepartmentPage):
     1902    """Page that lists all students studying a certificate.
     1903    """
     1904    grok.context(ICourse)
     1905    grok.name('showcoursestudents')
     1906
     1907    @property
     1908    def getStudents(self):
     1909        hitlist = []
     1910        cat = queryUtility(ICatalog, name='coursetickets_catalog')
     1911        results = cat.searchResults(code=(self.context.code, self.context.code))
     1912        for result in results:
     1913            hitlist.append(StudentQueryResultItem(result.student, view=self))
    19011914        return hitlist
    19021915
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py

    r9274 r9565  
    452452    text = _('Manage certificate')
    453453
     454class ShowCourseStudentsActionButton(ManageActionButton):
     455    """ 'Show students' button in course.
     456    """
     457    grok.context(ICourse)
     458    grok.view(CoursePage)
     459    grok.require('waeup.showStudents')
     460    icon = 'actionicon_student.png'
     461    text = _('Show students')
     462    target = 'showcoursestudents'
     463
    454464class ShowCertificateStudentsActionButton(ManageActionButton):
    455465    """ 'Show students' button for certificates.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/dynamicroles.py

    r9002 r9565  
    2929from waeup.kofa.students.interfaces import IStudent
    3030
    31 # All components in here have the same context: Student instances
    32 grok.context(IStudent)
    33 
    3431class StudentPrincipalRoleManager(AnnotationPrincipalRoleManager,
    3532                                    grok.Adapter):
    3633    grok.provides(IPrincipalRoleManager)
     34    grok.context(IStudent)
    3735
    3836    #: The attribute name to lookup for additional roles
     
    7068            obj = getattr(self._context, self.extra_attrib, None)
    7169            current_level = 0
    72         # Lookup local roles for connected course and all parent
     70        # Lookup local roles for connected certificate and all parent
    7371        # objects. This way we fake 'role inheritance'.
    7472        while obj is not None:
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r9563 r9565  
    14061406        self.assertTrue(self.student_id in self.browser.contents)
    14071407
     1408    def test_handle_courses_by_lecturer(self):
     1409        # Create course lecturer
     1410        self.app['users'].addUser('mrslecturer', 'mrslecturersecret')
     1411        self.app['users']['mrslecturer'].email = 'mrslecturer@foo.ng'
     1412        self.app['users']['mrslecturer'].title = u'Mercedes Benz'
     1413        # Assign local Courselecturer100 role for a certificate
     1414        course = self.app['faculties']['fac1']['dep1'].courses['COURSE1']
     1415        prmlocal = IPrincipalRoleManager(course)
     1416        prmlocal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrslecturer')
     1417        # Login as lecturer
     1418        self.browser.open(self.login_path)
     1419        self.browser.getControl(name="form.login").value = 'mrslecturer'
     1420        self.browser.getControl(name="form.password").value = 'mrslecturersecret'
     1421        self.browser.getControl("Login").click()
     1422        self.assertMatches('...You logged in...', self.browser.contents)
     1423        # CO can see her roles
     1424        self.browser.getLink("My Roles").click()
     1425        self.assertMatches(
     1426            '...<div>Academics Officer (view only)</div>...',
     1427            self.browser.contents)
     1428        # But not her local role ...
     1429        self.assertFalse('Lecturer' in self.browser.contents)
     1430        # ... because we forgot to notify the course that the local role
     1431        # has changed
     1432        notify(LocalRoleSetEvent(
     1433            course, 'waeup.local.Lecturer', 'mrslecturer', granted=True))
     1434        self.browser.open('http://localhost/app/users/mrslecturer/my_roles')
     1435        self.assertTrue('Lecturer' in self.browser.contents)
     1436        self.assertMatches(
     1437            '...<a href="http://localhost/app/faculties/fac1/dep1/courses/COURSE1">...',
     1438            self.browser.contents)
     1439        # The lecturer can go to her course
     1440        self.browser.getLink(
     1441            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1").click()
     1442        # and view the list of students
     1443        self.browser.getLink("Show students").click()
     1444        self.assertTrue('<th>Fullname</th>' in self.browser.contents)
     1445        # No student in course so far
     1446        self.assertFalse(self.student_id in self.browser.contents)
     1447        studylevel = createObject(u'waeup.StudentStudyLevel')
     1448        studylevel.level = 100
     1449        self.student['studycourse'].addStudentStudyLevel(
     1450            self.certificate, studylevel)
     1451        # Now the student has registered the course and can
     1452        # be seen by the lecturer.
     1453        self.assertFalse(self.student_id in self.browser.contents)
     1454        # XXX: So far the lecturer can neither access ths student ...
     1455        self.assertRaises(
     1456            Unauthorized, self.browser.open, self.student_path)
     1457        # ... nor the respective course ticket since a
     1458        # CourseTicketPrincipalRoleManager does not yet exist.
     1459        self.assertTrue('COURSE1' in self.student['studycourse']['100'].keys())
     1460        course_ticket_path = self.student_path + '/studycourse/100/COURSE1'
     1461        self.assertRaises(
     1462            Unauthorized, self.browser.open, course_ticket_path)
     1463
    14081464    def test_change_current_mode(self):
    14091465        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
Note: See TracChangeset for help on using the changeset viewer.