Ignore:
Timestamp:
30 May 2016, 14:32:21 (9 years ago)
Author:
Henrik Bettermann
Message:

Categorization by "Study Modes" too.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/browser_templates/studentlevelstatisticsreportgeneratorpage.pt

    r13857 r13870  
    1010    <select name="breakdown" class="form-control half">
    1111      <span tal:repeat="items view/breakdowns" tal:omit-tag="">
     12        <option
     13            tal:define="name python: items[1]; title python: items[0]"
     14            tal:attributes="value name">
     15          <span tal:replace="title">TITLE</span>
     16        </option>
     17      </span>
     18    </select>
     19  <br />
     20  <label for="session" i18n:translate="">Study Modes Group</label>
     21    <select name="mode" class="form-control half">
     22      <span tal:repeat="items view/modes" tal:omit-tag="">
    1223        <option
    1324            tal:define="name python: items[1]; title python: items[0]"
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/student_level_statistics.py

    r13860 r13870  
    3434    session = Attribute('Session to report')
    3535    creation_dt_string = Attribute('Human readable report creation datetime')
    36 
    37 def get_student_stats(session, breakdown):
    38     """Get students in a certain session.
     36    mode = Attribute('Study modes group to report')
     37
     38def get_student_stats(session, mode, breakdown):
     39    """Get students in a certain session and study mode.
    3940
    4041    Returns a table ordered by code (faculty or department, one per row) and
     
    7475    result = cat.searchResults(current_session=(session, session))
    7576    table = [[0 for x in xrange(2 * len(levels) + 2)] for y in xrange(len(paths)+1)]
     77    mode_groups = getUtility(IKofaUtils).MODE_GROUPS
    7678    for stud in result:
     79        if mode != 'All' and stud.current_mode not in mode_groups[mode]:
     80            continue
    7781        if getattr(stud, breakdown) is None:
    7882            continue
     
    155159    data = None
    156160    session = None
    157 
    158     def __init__(self, session, breakdown, author='System'):
     161    mode = None
     162
     163    def __init__(self, session, mode, breakdown, author='System'):
    159164        super(StudentLevelStatisticsReport, self).__init__(
    160             args=[session, breakdown], kwargs={'author':author})
     165            args=[session, mode, breakdown], kwargs={'author':author})
    161166        self.studylevelsource = StudyLevelSource().factory
    162167        self.portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     
    164169        self.breakdown = breakdown
    165170        self.author = author
     171        self.mode = mode
    166172        self.creation_dt_string = self.creation_dt.astimezone(
    167173            getUtility(IKofaUtils).tzinfo).strftime("%Y-%m-%d %H:%M:%S %Z")
    168         self.data = get_student_stats(session, breakdown)
     174        self.data = get_student_stats(session, mode, breakdown)
    169175
    170176    def create_pdf(self):
     
    178184            Table(table_data, style=TABLE_STYLE, colWidths=col_widths)]
    179185        doc_title = translate(
    180             _('Students - ${c}',
    181             mapping = {'c':self.session}))
     186            _('${a} Students - ${c}',
     187            mapping = {'a':self.mode, 'c':self.session}))
    182188        pdf = creator.create_pdf(
    183189            pdf_data, None, doc_title, self.author, doc_title + '-'
     
    192198
    193199    def generate(
    194         self, site, session=None,
     200        self, site, session=None, mode=None,
    195201        breakdown=None, author=None):
    196202        result = StudentLevelStatisticsReport(
    197             session=session,
     203            session=session, mode=mode,
    198204            breakdown=breakdown, author=author)
    199205        return result
     
    224230
    225231    def update(
    226         self, CREATE=None, session=None, breakdown=None):
     232        self, CREATE=None, session=None, mode=None, breakdown=None):
    227233        self.parent_url = self.url(self.context.__parent__)
    228234        self._set_session_values()
     235        self._set_mode_values()
    229236        self._set_breakdown_values()
    230237        if CREATE and session:
     
    234241            kw = dict(
    235242                session=int(session),
     243                mode=mode,
    236244                breakdown=breakdown)
    237245            self.flash(_('New report is being created in background'))
     
    240248            ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')
    241249            grok.getSite().logger.info(
    242                 '%s - report %s created: %s (session=%s, breakdown=%s)' % (
     250                '%s - report %s created: %s (session=%s, mode=%s, breakdown=%s)' % (
    243251                ob_class, job_id, self.context.title,
    244                 session, breakdown))
     252                session, mode, breakdown))
    245253            self.redirect(self.parent_url)
    246254            return
     
    250258        vocab_terms = academic_sessions_vocab.by_value.values()
    251259        self.sessions = [(x.title, x.token) for x in vocab_terms]
     260        return
     261
     262    def _set_mode_values(self):
     263        mode_groups = getUtility(IKofaUtils).MODE_GROUPS
     264        self.modes = sorted([(key, key) for key in mode_groups.keys()])
    252265        return
    253266
     
    264277
    265278    def _filename(self):
    266         return 'StudentLevelStatisticsReport_%s_%s.pdf' % (
    267             self.context.session,
     279        return 'StudentLevelStatisticsReport_%s_%s_%s.pdf' % (
     280            self.context.session, self.context.mode,
    268281            self.context.creation_dt_string)
    269282
  • main/waeup.aaue/trunk/src/waeup/aaue/students/reports/tests/test_student_level_statistics.py

    r13860 r13870  
    2323    def test_iface(self):
    2424        # ensure we fullfill interface contracts
    25         obj = StudentLevelStatisticsReport(2010, 'faccode')
     25        obj = StudentLevelStatisticsReport(2010, 'Undergraduate Full-Time', 'faccode')
    2626        verifyClass(IStudentLevelStatisticsReport, StudentLevelStatisticsReport)
    2727        verifyObject(IStudentLevelStatisticsReport, obj)
     
    3232        self.student.sex = 'm'
    3333        # we can get a table with one student
    34         result1 = get_student_stats(2010, 'faccode')
    35         result2 = get_student_stats(2009, 'faccode')
     34        result1 = get_student_stats(2010, 'Undergraduate Full-Time', 'faccode')
     35        result2 = get_student_stats(2009, 'Undergraduate Full-Time', 'faccode')
    3636        self.assertEqual(
    3737            result1,
     
    5454        self.create_cert(u'fac2', u'dep2', u'CERT2')
    5555        self.student.sex = 'm'
    56         result1 = get_student_stats(2010, 'faccode')
    57         result2 = get_student_stats(2009, 'faccode')
     56        result1 = get_student_stats(2010, 'Undergraduate Full-Time', 'faccode')
     57        result2 = get_student_stats(2009, 'Undergraduate Full-Time', 'faccode')
    5858        self.assertEqual(
    5959            result1,
     
    7878        self.create_cert(u'fac2', u'dep2', u'CERT2')
    7979        self.student.sex = 'm'
    80         result1 = get_student_stats(2010, 'depcode')
    81         result2 = get_student_stats(2009, 'depcode')
     80        result1 = get_student_stats(2010, 'Undergraduate Full-Time', 'depcode')
     81        result2 = get_student_stats(2009, 'Undergraduate Full-Time', 'depcode')
    8282        self.assertEqual(
    8383            result1,
     
    102102        self.create_cert(u'FAC2', u'dept2', u'CERT2')
    103103        self.student['studycourse'].current_level = 220
    104         report = StudentLevelStatisticsReport(2010, 'depcode')
     104        report = StudentLevelStatisticsReport(2010, 'Undergraduate Full-Time', 'depcode')
    105105        result = report.create_pdf()
    106106        self.assertTrue(result.startswith('%PDF-'))
  • main/waeup.aaue/trunk/src/waeup/aaue/utils/utils.py

    r13794 r13870  
    152152        'cl_regular': 'Acceptance Fee - Regular Students',
    153153        }
     154
     155    MODE_GROUPS = {
     156        'All': ('all',),
     157        'Undergraduate Full-Time': ('ug_ft', 'mde_ft', 'mug_ft', 'de_ft'),
     158        'Undergraduate Part-Time': ('ug_pt', 'de_pt'),
     159        'Postgraduate': ('pg_ft','special_pg_ft', 'special_pg_pt'),
     160        'Foundation Programme': ('found',),
     161        'Institute of Education': ('dp_ft'),
     162        }
Note: See TracChangeset for help on using the changeset viewer.