Changeset 9686


Ignore:
Timestamp:
19 Nov 2012, 13:04:30 (12 years ago)
Author:
Henrik Bettermann
Message:

Customize level pages and level slip do hide score and display grade instead.

Location:
main/waeup.uniben/trunk/src/waeup/uniben/students
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.uniben/trunk/src/waeup/uniben/students/browser.py

    r9558 r9686  
    2121from zope.component import getUtility
    2222from hurry.workflow.interfaces import IWorkflowInfo
    23 from waeup.kofa.interfaces import REQUESTED, IExtFileStore
     23from waeup.kofa.interfaces import REQUESTED, IExtFileStore, IKofaUtils
    2424from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
    2525from waeup.kofa.browser.layout import KofaEditFormPage
     
    2727from waeup.kofa.students.browser import (
    2828    StudentClearPage, StudentRejectClearancePage,
    29     StudyLevelEditFormPage, StudentBasePDFFormPage,
     29    StudyLevelEditFormPage, StudyLevelDisplayFormPage,
     30    StudentBasePDFFormPage, ExportPDFCourseRegistrationSlipPage,
     31    CourseTicketDisplayFormPage,
    3032    msave, emit_lock_message)
    31 from waeup.kofa.students.interfaces import IStudentsUtils
     33from waeup.kofa.students.interfaces import IStudentsUtils, ICourseTicket
    3234from waeup.kofa.students.workflow import FORBIDDEN_POSTGRAD_TRANS
    3335from kofacustom.nigeria.students.browser import (
     
    176178
    177179    """
     180    grok.template('studyleveleditpage')
    178181
    179182    def _registerCourses(self, **data):
     
    197200        self.redirect(self.url(self.context))
    198201        return
     202
     203class CustomStudyLevelDisplayFormPage(StudyLevelDisplayFormPage):
     204    """ Page to display student study levels
     205    """
     206    grok.template('studylevelpage')
     207
     208class CustomExportPDFCourseRegistrationSlipPage(
     209    ExportPDFCourseRegistrationSlipPage):
     210    """Deliver a PDF slip of the context.
     211    """
     212
     213    def render(self):
     214        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     215        Sem = translate(_('Sem.'), 'waeup.kofa', target_language=portal_language)
     216        Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language)
     217        Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language)
     218        Dept = translate(_('Dept.'), 'waeup.kofa', target_language=portal_language)
     219        Faculty = translate(_('Faculty'), 'waeup.kofa', target_language=portal_language)
     220        Cred = translate(_('Cred.'), 'waeup.kofa', target_language=portal_language)
     221        Mand = translate(_('Requ.'), 'waeup.kofa', target_language=portal_language)
     222        Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language)
     223        studentview = StudentBasePDFFormPage(self.context.student,
     224            self.request, self.omit_fields)
     225        students_utils = getUtility(IStudentsUtils)
     226        tabledata = sorted(self.context.values(),
     227            key=lambda value: str(value.semester) + value.code)
     228        return students_utils.renderPDF(
     229            self, 'course_registration_slip.pdf',
     230            self.context.student, studentview,
     231            tableheader=[(Sem,'semester', 1.5),(Code,'code', 2.5),
     232                         (Title,'title', 5),
     233                         (Dept,'dcode', 1.5), (Faculty,'fcode', 1.5),
     234                         (Cred, 'credits', 1.5),
     235                         (Mand, 'mandatory', 1.5),
     236                         (Grade, 'grade', 1.5),
     237                         #('Auto', 'automatic', 1.5)
     238                         ],
     239            tabledata=tabledata)
     240
     241class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage):
     242    """ Page to display course tickets
     243    """
     244    form_fields = grok.AutoFields(ICourseTicket).omit('score')
  • main/waeup.uniben/trunk/src/waeup/uniben/students/tests/test_browser.py

    r9570 r9686  
    326326                           self.browser.contents)
    327327
     328    def test_student_course_registration(self):
     329        # Uniben students see grade instead of score on all level pages
     330        # and on course ticket page.
     331        IWorkflowState(self.student).setState('school fee paid')
     332        self.browser.open(self.login_path)
     333        self.browser.getControl(name="form.login").value = self.student_id
     334        self.browser.getControl(name="form.password").value = 'spwd'
     335        self.browser.getControl("Login").click()
     336        # Now students can add the current study level
     337        self.browser.getLink("Study Course").click()
     338        self.browser.getLink("Add course list").click()
     339        self.assertMatches('...Add current level 100 (Year 1)...',
     340                           self.browser.contents)
     341        self.browser.getControl("Create course list now").click()
     342        # A level with one course ticket was created
     343        self.assertEqual(self.student['studycourse']['100'].number_of_tickets, 1)
     344        self.browser.getLink("100").click()
     345        self.assertTrue('<th>Grade</th>' in self.browser.contents)
     346        self.assertFalse('<th>Score</th>' in self.browser.contents)
     347        self.browser.getLink("Edit course list").click()
     348        self.assertTrue('<th>Grade</th>' in self.browser.contents)
     349        self.assertFalse('<th>Score</th>' in self.browser.contents)
     350        self.browser.getLink("COURSE1").click()
     351        self.assertFalse('Score' in self.browser.contents)
     352        # Students can open the customized pdf course registration slip
     353        self.browser.open(self.student_path + '/studycourse/100')
     354        self.browser.getLink("Download course registration slip").click()
     355        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     356        self.assertEqual(self.browser.headers['Content-Type'], 'application/pdf')
     357
    328358    def test_get_returning_data(self):
    329359        # Student is in level 100, session 2004 with verdict A
Note: See TracChangeset for help on using the changeset viewer.