Changeset 18325


Ignore:
Timestamp:
7 Sep 2026, 16:52:19 (3 months ago)
Author:
Henrik Bettermann
Message:

Implement ‚Show course results‘ like for AAUE.

Location:
main/kofacustom.unidel/trunk/src/kofacustom/unidel
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/interfaces.py

    r18313 r18325  
    207207        )
    208208
     209    show_results = schema.List(
     210        title = _(u'Show course results'),
     211        value_type = schema.Choice(
     212            source = EnableScoreEditingGroupSource(),
     213            ),
     214        required = False,
     215        defaultFactory=list,
     216        )
     217
    209218    def getSessionString():
    210219        """Returns the session string from the vocabulary.
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/browser.py

    r18323 r18325  
    314314        'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    315315
     316    @property
     317    def show_results(self):
     318        isStudent = getattr(
     319            self.request.principal, 'user_type', None) == 'student'
     320        try:
     321            show_results = grok.getSite()[
     322                'configuration'][str(self.context.level_session)].show_results
     323        except KeyError:
     324            return False
     325        if isStudent and self.context.student.current_mode not in show_results:
     326            return False
     327        #if isStudent and self.context.student.state != RETURNING \
     328        #    and self.context.student.current_level == self.context.level:
     329        #    return False
     330        return True
     331
    316332class CustomStudyLevelManageFormPage(StudyLevelManageFormPage):
    317333    """ Page to edit the student study level data
    … …  
    338354        'adm_code', 'sex', 'suspended_comment', 'current_level',
    339355        'flash_notice', 'imported_gpa', 'imported_cgpa',)
     356
     357    @property
     358    def show_results(self):
     359        isStudent = getattr(
     360            self.request.principal, 'user_type', None) == 'student'
     361        try:
     362            show_results = grok.getSite()[
     363                'configuration'][str(self.context.level_session)].show_results
     364        except KeyError:
     365            return False
     366        if isStudent and self.context.student.current_mode not in show_results:
     367            return False
     368        if isStudent and self.context.student.state != RETURNING \
     369            and self.context.student.current_level == self.context.level:
     370            return False
     371        return True
    340372
    341373    def _signatures(self):
    … …  
    375407                 if value.semester == i and not value.outstanding],
    376408                 key=lambda value: str(value.semester) + value.code))
    377             tableheader.append([(Code,'code', 2.0),
    378                                (Title,'title', 7),
    379                                (Cred, 'credits', 1.4),
    380                                #(CC, 'course_category', 1.2),
    381                                (TotalScore, 'total_score', 1.4),
    382                                #(CA, 'ca', 1.4),
    383                                (Grade, 'grade', 1.4),
    384                                (Signature, 'dummy', 3),
    385                                ])
     409            if self.show_results:
     410                tableheader.append([(Code,'code', 2.0),
     411                                   (Title,'title', 7),
     412                                   (Cred, 'credits', 1.4),
     413                                   (CC, 'course_category', 1.2),
     414                                   (TotalScore, 'total_score', 1.4),
     415                                   #(CA, 'ca', 1.4),
     416                                   (Grade, 'grade', 1.4),
     417                                   (Signature, 'dummy', 3),
     418                                   ])
     419            else:
     420                tableheader.append([(Code,'code', 2.0),
     421                                   (Title,'title', 7),
     422                                   (Cred, 'credits', 1.5),
     423                                   (CC, 'course_category', 1.2),
     424                                   (Signature, 'dummy', 3),
     425                                   ])
    386426        return students_utils.renderPDF(
    387427            self, 'course_registration_slip.pdf',
    … …  
    399439
    400440    @property
     441    def show_results(self):
     442        isStudent = getattr(
     443            self.request.principal, 'user_type', None) == 'student'
     444        if isStudent:
     445            return False
     446        return True
     447
     448    @property
    401449    def form_fields(self):
    402         return grok.AutoFields(ICustomCourseTicket).omit('course_category',
     450        if self.show_results:
     451            return grok.AutoFields(ICustomCourseTicket).omit('course_category',
    403452            'ticket_session')
     453        else:
     454            return grok.AutoFields(ICustomCourseTicket).omit('score', 'ca',
     455                'course_category', 'ticket_session')
    404456
    405457class CustomCourseTicketManageFormPage(CourseTicketManageFormPage):
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/browser_templates/studylevelpage.pt

    r17026 r18325  
    2828      <th i18n:translate="">Cred.</th>
    2929      <th i18n:translate="">Requ.</th>
    30       <th i18n:translate="">Score</th>
    31       <th i18n:translate="">Grade</th>
     30      <th i18n:translate="" tal:condition="view/show_results" >Total Score</th>
     31      <th i18n:translate="" tal:condition="view/show_results" >Grade</th>
    3232      <th i18n:translate="">CO</th>
    3333      <th i18n:translate="">OS</th>
    … …  
    4646      <td tal:content="value/credits">CREDITS</td>
    4747      <td tal:content="value/mandatory">MANDATORY</td>
    48       <td tal:content="value/total_score|nothing">SCORE</td>
    49       <td tal:content="value/grade|nothing">GRADE</td>
     48      <td tal:condition="view/show_results" tal:content="structure value/formatted_total_score|nothing">TOTALSCORE</td>
     49      <td tal:condition="view/show_results" tal:content="value/grade|nothing">GRADE</td>
    5050      <td tal:content="value/carry_over">CO</td>
    5151      <td tal:content="value/outstanding">OS</td>
  • main/kofacustom.unidel/trunk/src/kofacustom/unidel/students/tests/test_browser.py

    r18317 r18325  
    306306        open(path, 'wb').write(self.browser.contents)
    307307        print "Sample PDF attendance.pdf written to %s" % path
     308
     309
     310class StudentUITests(StudentsFullSetup):
     311    """Tests for customized student class views and pages
     312    """
     313
     314    layer = FunctionalLayer
     315
     316    def setUp(self):
     317        super(StudentUITests, self).setUp()
     318        self.app['faculties']['fac1']['dep1'].certificates[
     319            'CERT1']['COURSE1_100'].course_category = 'C'
     320        bedticket = BedTicket()
     321        bedticket.booking_session = 2004
     322        bedticket.bed_type = u'any bed type'
     323        bedticket.bed = self.app['hostels']['hall-1']['hall-1_A_101_A']
     324        bedticket.bed_coordinates = u'My bed coordinates'
     325        self.student['accommodation'].addBedTicket(bedticket)
     326
     327    def test_student_access_course_results(self):
     328        IWorkflowState(self.student).setState('school fee paid')
     329        self.student['studycourse'].entry_session = 2004
     330        self.student['studycourse'].current_session = 2004
     331        self.browser.open(self.login_path)
     332        self.browser.getControl(name="form.login").value = self.student_id
     333        self.browser.getControl(name="form.password").value = 'spwd'
     334        self.browser.getControl("Login").click()
     335        self.browser.getLink("Study Course").click()
     336        self.browser.getLink("Add course list").click()
     337        self.browser.getControl("Create course list now").click()
     338        self.assertFalse('Score' in self.browser.contents)
     339        IWorkflowState(self.student).setState('returning')
     340        self.browser.open(self.studycourse_path + '/100')
     341        self.assertFalse('Score' in self.browser.contents)
     342        self.app['configuration']['2004'].show_results = ['ug_ft']
     343        self.browser.open(self.studycourse_path + '/100')
     344        self.assertTrue('Score' in self.browser.contents)
     345        return
Note: See TracChangeset for help on using the changeset viewer.