Changeset 13834


Ignore:
Timestamp:
19 Apr 2016, 06:42:26 (9 years ago)
Author:
Henrik Bettermann
Message:

Further customizations for taking the ca into consideration and displaying the ca on all forms and slips.

Location:
main/waeup.aaue/trunk/src/waeup/aaue/students
Files:
3 added
4 edited

Legend:

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

    r13795 r13834  
    3131    CourseTicketAddFormPage,
    3232    StudyLevelDisplayFormPage,
     33    StudyLevelManageFormPage,
     34    StudyLevelEditFormPage,
    3335    ExportPDFTranscriptSlip,
    3436    ExportPDFAdmissionSlip,
     
    204206        'validation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
    205207
     208class CustomStudyLevelManageFormPage(StudyLevelManageFormPage):
     209    """ Page to edit the student study level data
     210    """
     211    grok.context(ICustomStudentStudyLevel)
     212
     213class CustomStudyLevelEditFormPage(StudyLevelEditFormPage):
     214    """ Page to edit the student study level data by students
     215    """
     216    grok.context(ICustomStudentStudyLevel)
     217
    206218class CustomExportPDFCourseRegistrationSlip(
    207219    NigeriaExportPDFCourseRegistrationSlip):
     
    289301        Cred = translate('Cred.', 'waeup.kofa', target_language=portal_language)
    290302        Score = translate('Score', 'waeup.kofa', target_language=portal_language)
     303        CA = translate('CA', 'waeup.kofa', target_language=portal_language)
    291304        Grade = translate('Grade', 'waeup.kofa', target_language=portal_language)
    292305        Signature = translate(_('Lecturer\'s Signature'), 'waeup.aaue',
     
    307320                               (Cred, 'credits', 1.5),
    308321                               (Score, 'score', 1.4),
     322                               (CA, 'ca', 1.4),
    309323                               (Grade, 'grade', 1.4),
    310324                               (Signature, 'dummy', 3),
     
    337351            'Akhimien Felicia O. (MANUPA) <br /> Principal Assistant Registrar  <br /> '
    338352            'Exams, Records and Data Processing Division <br /> For: Registrar')],)
     353
     354    def render(self):
     355        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     356        Term = translate(_('Term'), 'waeup.kofa', target_language=portal_language)
     357        Code = translate(_('Code'), 'waeup.kofa', target_language=portal_language)
     358        Title = translate(_('Title'), 'waeup.kofa', target_language=portal_language)
     359        Cred = translate(_('Credits'), 'waeup.kofa', target_language=portal_language)
     360        Score = translate(_('Score'), 'waeup.kofa', target_language=portal_language)
     361        CA = translate(_('CA'), 'waeup.kofa', target_language=portal_language)
     362        Grade = translate(_('Grade'), 'waeup.kofa', target_language=portal_language)
     363        studentview = StudentBasePDFFormPage(self.context.student,
     364            self.request, self.omit_fields)
     365        students_utils = getUtility(IStudentsUtils)
     366
     367        tableheader = [(Code,'code', 2.5),
     368                         (Title,'title', 7),
     369                         (Term, 'semester', 1.5),
     370                         (Cred, 'credits', 1.5),
     371                         (Score, 'score', 1.5),
     372                         (CA, 'ca', 1.5),
     373                         (Grade, 'grade', 1.5),
     374                         ]
     375
     376        return students_utils.renderPDFTranscript(
     377            self, 'transcript.pdf',
     378            self.context.student, studentview,
     379            omit_fields=self.omit_fields,
     380            tableheader=tableheader,
     381            signatures=self._signatures(),
     382            sigs_in_footer=self._sigsInFooter(),
     383            )
    339384
    340385class CustomExportPDFAdmissionSlip(ExportPDFAdmissionSlip):
  • main/waeup.aaue/trunk/src/waeup/aaue/students/interfaces.py

    r13795 r13834  
    304304
    305305    ca = schema.Int(
    306         title = _(u'Continuous Assessment'),
     306        title = _(u'CA'),
    307307        default = None,
    308308        required = False,
     
    310310        )
    311311
    312 ICustomCourseTicket['ca'].order = ICustomCourseTicket['mandatory'].order
     312ICustomCourseTicket['ca'].order = ICustomCourseTicket['score'].order
    313313
    314314class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo):
  • main/waeup.aaue/trunk/src/waeup/aaue/students/studylevel.py

    r13071 r13834  
    3636
    3737
     38def getGradeWeightFromScore(score, ca):
     39    if None in (score, ca):
     40        return (None, None)
     41    total = score + ca
     42    if total >= 70:
     43        return ('A',5)
     44    if total >= 60:
     45        return ('B',4)
     46    if total >= 50:
     47        return ('C',3)
     48    if total >= 45:
     49        return ('D',2)
     50    if total >= 40:
     51        return ('E',1)
     52    return ('F',0)
     53
     54
    3855class CustomStudentStudyLevel(StudentStudyLevel):
    3956    """This is a container for course tickets.
     
    5774                total += ticket.credits
    5875        return total
     76
     77    @property
     78    def gpa_params(self):
     79        """Calculate gpa parameters for this level.
     80        """
     81        credits_weighted = 0.0
     82        credits_counted = 0
     83        level_gpa = 0.0
     84        for ticket in self.values():
     85            if None not in (ticket.score, ticket.ca):
     86                credits_counted += ticket.credits
     87                credits_weighted += ticket.credits * ticket.weight
     88        if credits_counted:
     89            level_gpa = round(credits_weighted/credits_counted, 3)
     90        return level_gpa, credits_counted, credits_weighted
    5991
    6092    @property
     
    111143    grok.provides(ICustomCourseTicket)
    112144
     145    @property
     146    def grade(self):
     147        """Returns the grade calculated from score.
     148        """
     149        return getGradeWeightFromScore(self.score, self.ca)[0]
     150
     151    @property
     152    def weight(self):
     153        """Returns the weight calculated from score.
     154        """
     155        return getGradeWeightFromScore(self.score, self.ca)[1]
     156
    113157CustomCourseTicket = attrs_to_fields(CustomCourseTicket)
    114158
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r13786 r13834  
    8686        # First course has been added automatically.
    8787        # Set score.
    88         studylevel['COURSE1'].score = 55
     88        studylevel['COURSE1'].score = 35
     89        studylevel['COURSE1'].ca = 20
    8990        # GPA is 3.0.
    9091        self.assertEqual(studylevel.gpa_params[0], 3.0)
     
    9394        courseticket.title = u'Any TITLE'
    9495        courseticket.credits = 13
    95         courseticket.score = 66
     96        courseticket.score = 44
     97        courseticket.ca = 22
    9698        courseticket.semester = 1
    9799        courseticket.dcode = u'ANYDCODE'
Note: See TracChangeset for help on using the changeset viewer.