source: main/waeup.aaue/trunk/src/waeup/aaue/students/reports/session_results_presentation.py

Last change on this file was 16694, checked in by Henrik Bettermann, 3 years ago

Harmonise reports.

  • Property svn:keywords set to Id
File size: 5.9 KB
Line 
1## $Id: session_results_presentation.py 16694 2021-11-03 09:45:56Z henrik $
2##
3## Copyright (C) 2013 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
8##
9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
13##
14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18
19import grok
20from zope.component import getUtility
21from zope.interface import implementer, Interface, Attribute
22from waeup.kofa.interfaces import IKofaUtils
23from waeup.kofa.students.reports.session_results_presentation import (
24    SessionResultsPresentation, SessionResultsPresentationGenerator,
25    ISessionResultsPresentation, SessionResultsPresentationGeneratorPage,
26    SessionResultsPresentationPDFView)
27
28class CustomSessionResultsPresentation(SessionResultsPresentation):
29
30    note = ""
31
32    pdfcreator = ''
33
34    @property
35    def introduction (self):
36        havenot = ''
37        plurals = ''
38        num_students = sum([len(i) for i in self.data])
39        site = grok.getSite()
40        certificate = site[
41            'faculties'][self.faccode][self.depcode].certificates[self.certcode]
42        study_mode = getattr(certificate, 'study_mode', None)
43        if num_students == 0:
44            return ''
45        if num_students > 1:
46            plurals = 's'
47            if len(self.data[0]) == num_students:
48                havenot = 'have not'
49            elif len(self.data[0]):
50                havenot = 'have/have not'
51            else:
52                havenot = 'have'
53        else:
54            if self.data[0]:
55                havenot = 'has not'
56            else:
57                havenot = 'has'
58        if self.faccode == 'FBM':
59            board = 'College Academic Board'
60        elif study_mode and study_mode.startswith('dp'):
61            board = 'Institute Board'
62        else:
63            board = 'Faculty Board'
64
65        text = """I present to Senate, on behalf of the %s,
66the results of courses taught and examinations held this academic session.
67The following candidate%s %s satisfied the degree requirements
68of the Faculty and %s qualified for the award of a degree as follows:
69""" % (board, plurals, havenot, havenot)
70        return text
71
72#    note = """
73#<br /><br /><br /><br />
74#<font size='10'>
75#<strong>Note:</strong> This copy is subject to correction for typographical errors and ratification by the departmental board.
76#</font>
77#"""
78
79    @property
80    def signatures(self):
81        site = grok.getSite()
82        dean = site['faculties'][self.faccode].officer_1
83        hod = site['faculties'][self.faccode][self.depcode].officer_1
84        examiner = site['faculties'][self.faccode][self.depcode].officer_2
85        if not dean:
86            dean = 'Dean of Faculty'
87        if not hod:
88            hod = 'Head of Department'
89        if not examiner:
90            examiner = 'External Examiner'
91        dean = dean.replace(' - ', '<br />')
92        hod = hod.replace(' - ', '<br />')
93        examiner = examiner.replace(' - ', '<br />')
94        return [hod, examiner, dean]
95
96class CustomSessionResultsPresentationGenerator(
97    SessionResultsPresentationGenerator):
98
99    def generate(self, site, faccode=None, depcode=None, certcode=None,
100                 session=None, level=None, author=None):
101        result = CustomSessionResultsPresentation(faccode=faccode,
102            depcode=depcode, certcode=certcode, session=session,
103            level=level, author=author)
104        return result
105
106
107# Session Results Presentation for graduating students only
108
109class IGradSessionResultsPresentation(ISessionResultsPresentation):
110    """Marker interface to distuingish graduating students level reports
111    from ordinary level reports.
112    """
113
114@implementer(IGradSessionResultsPresentation)
115class GradSessionResultsPresentation(CustomSessionResultsPresentation):
116    """
117    """
118
119    title = 'Presentation of Results to Senate (Graduating Students)'
120
121    def _excluded(self, level_obj):
122        # Do not list student if selecetd level is not final or an extension
123        if level_obj.level < level_obj.student['studycourse'].certificate.end_level:
124            return True
125        # Filter out students with extension levels higher than selected level
126        final_level = int(max(level_obj.student['studycourse'].keys()))
127        if final_level > level_obj.level:
128            return True
129        if level_obj.remark not in (
130            'Pass', '3s_rd_s', '2s_2_s', '2s_1_s', '1s_st_s',
131            'Merit', 'Credit', 'Distinction'):
132            return True
133        return False
134
135class GradSessionResultsPresentationGenerator(SessionResultsPresentationGenerator):
136
137    title = 'Presentation of Results to Senate (Graduating Students)'
138    grok.name('grad_session_results_presentation')
139
140    def generate(self, site, faccode=None, depcode=None, certcode=None,
141                 session=None, level=None, author=None):
142        result = GradSessionResultsPresentation(faccode=faccode, depcode=depcode,
143            certcode=certcode, session=session, level=level, author=author)
144        return result
145
146class GradSessionResultsPresentationGeneratorPage(SessionResultsPresentationGeneratorPage):
147
148    grok.context(GradSessionResultsPresentationGenerator)
149
150class GradSessionResultsPresentationPDFView(SessionResultsPresentationPDFView):
151
152    grok.context(IGradSessionResultsPresentation)
153    grok.name('pdf')
154    grok.require('waeup.handleReports')
155
156    def _filename(self):
157        return 'GradSessionResultsPresentation_rno%s_%s.pdf' % (
158            self.context.__name__,
159            self.context.creation_dt_string)
Note: See TracBrowser for help on using the repository browser.