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

Implement ‚Show course results‘ like for AAUE.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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):
Note: See TracChangeset for help on using the changeset viewer.