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

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

Filter out students with extension levels higher than selected level

  • Property svn:keywords set to Id
File size: 3.9 KB
Line 
1## $Id: level_report.py 16692 2021-11-02 13:03:05Z 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.interface import implementer, Interface, Attribute
21from waeup.kofa.students.reports.level_report import (
22    LevelReport, LevelReportGenerator,
23    ILevelReport, LevelReportGeneratorPage,
24    LevelReportPDFView)
25
26class CustomLevelReport(LevelReport):
27
28    note = ""
29
30#    note = """
31#<br /><br /><br /><br />
32#<font size='10'>
33#<strong>Note:</strong> This copy is subject to correction for typographical errors and ratification by the departmental board.
34#</font>
35#"""
36
37    @property
38    def signatures(self):
39        site = grok.getSite()
40        dean = site['faculties'][self.faccode].officer_1
41        hod = site['faculties'][self.faccode][self.depcode].officer_1
42        if not dean:
43            dean = 'Dean of Faculty'
44        if not hod:
45            hod = 'Head of Department'
46        dean = dean.replace(' - ', '<br />')
47        hod = hod.replace(' - ', '<br />')
48        return [hod, dean]
49
50class CustomLevelReportGenerator(LevelReportGenerator):
51
52    def generate(self, site, faccode=None, depcode=None, certcode=None,
53                 session=None, level=None, author=None):
54        result = CustomLevelReport(faccode=faccode, depcode=depcode,
55            certcode=certcode, session=session, level=level, author=author)
56        return result
57
58# Level Report for graduating students only
59
60class IGradLevelReport(ILevelReport):
61    """Marker interface to distuingish graduating students level reports
62    from ordinary level reports.
63    """
64
65@implementer(IGradLevelReport)
66class GradLevelReport(CustomLevelReport):
67    """
68    """
69
70    title = 'Summary of Results'
71
72    @property
73    def right_footer(self):
74        return self.title + ' (Graduating Students) - %s -' % self.session
75
76    def _excluded(self, level_obj):
77        # Do not list student if selecetd level is not final or an extension
78        if level_obj.level < level_obj.student['studycourse'].certificate.end_level:
79            return True
80        # Filter out students with extension levels higher than selected level
81        final_level = int(max(level_obj.student['studycourse'].keys()))
82        if final_level > level_obj.level:
83            return True
84        if level_obj.remark not in (
85            'Pass', '3s_rd_s', '2s_2_s', '2s_1_s', '1s_st_s',
86            'Merit', 'Credit', 'Distinction'):
87            return True
88        return False
89
90class GradLevelReportGenerator(LevelReportGenerator):
91
92    title = 'Summary of Results (Graduating Students)'
93    grok.name('grad_level_report')
94
95    def generate(self, site, faccode=None, depcode=None, certcode=None,
96                 session=None, level=None, author=None):
97        result = GradLevelReport(faccode=faccode, depcode=depcode,
98            certcode=certcode, session=session, level=level, author=author)
99        return result
100
101class GradLevelReportGeneratorPage(LevelReportGeneratorPage):
102
103    grok.context(GradLevelReportGenerator)
104
105class GradLevelReportPDFView(LevelReportPDFView):
106
107    grok.context(IGradLevelReport)
108    grok.name('pdf')
109    grok.require('waeup.handleReports')
110
111    def _filename(self):
112        return 'GradLevelReport_rno%s_%s.pdf' % (
113            self.context.__name__,
114            self.context.creation_dt_string)
Note: See TracBrowser for help on using the repository browser.