Changeset 14643 for main


Ignore:
Timestamp:
22 Mar 2017, 10:25:56 (8 years ago)
Author:
Henrik Bettermann
Message:

Show course_category in table header if it exists.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/students/reports
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/raw_score_report.py

    r14625 r14643  
    5555        canvas.drawString( 0, -1, self.text)
    5656
    57 def tbl_data_to_table(data, course_codes):
     57def tbl_data_to_table(data, certcourses):
    5858    col_names = (
    5959            #'Student Id',
     
    6262            'Name',
    6363            )
    64     catalog = getUtility(ICatalog, name='courses_catalog')
    65     for code in course_codes:
    66         course = list(catalog.searchResults(code=(code, code)))[0]
    67         col_names += (TTR('%s (%s)' % (code, course.credits)),)
     64    #catalog = getUtility(ICatalog, name='courses_catalog')
     65    for certcourse in certcourses:
     66        course = certcourse.course
     67        if certcourse.course_category:
     68            col_names += (TTR('%s (%s, %s)' % (
     69                course.code, course.credits, certcourse.course_category)),)
     70        else:
     71            col_names += (TTR('%s (%s)' % (course.code, course.credits)),)
    6872    table = [col_names]
    6973    sn = 1
     
    7175        scores = tuple()
    7276        composed_line = (sn,) + line[:-1]
    73         for code in course_codes:
    74             result = line[-1].get(code)
     77        for certcourse in certcourses:
     78            result = line[-1].get(certcourse.course.code)
    7579            if not result:
    7680                scores += ('N/R',)
     
    136140        """
    137141        site = grok.getSite()
    138         course_codes = []
     142        #course_codes = []
     143        certcourses = []
    139144        department = site['faculties'][faccode][depcode]
    140145        if certcode == 'all':
     
    142147                for certcourse in cert.values():
    143148                    if certcourse.level == level:
    144                         course_codes.append(certcourse.getCourseCode())
     149                        #course_codes.append(certcourse.getCourseCode())
     150                        certcourses.append(certcourse)
    145151        else:
    146152            certificate = site['faculties'][faccode][depcode].certificates[certcode]
    147153            for certcourse in certificate.values():
    148154                if certcourse.level == level:
    149                     course_codes.append(certcourse.getCourseCode())
    150         return course_codes
    151 
    152     def _get_students(self, faccode, depcode, certcode, session, level, course_codes):
     155                    #course_codes.append(certcourse.getCourseCode())
     156                    certcourses.append(certcourse)
     157        return certcourses
     158
     159    def _get_students(self, faccode, depcode, certcode, session, level, certcourses):
    153160        """Get students in a certain department/certificate who registered courses
    154161        in a certain session at a certain level.
     
    176183            scores = dict()
    177184            for ticket in level_obj.values():
    178                 if ticket.code in course_codes:
     185                if ticket.code in [i.course.code for i in certcourses]:
    179186                    if ticket.total_score is not None:
    180187                        scores[ticket.code] = (ticket.total_score, ticket.grade)
     
    224231            getUtility(IKofaUtils).tzinfo).strftime("%Y-%m-%d %H:%M:%S %Z")
    225232        self.past_levels = range(int(level/100)*100, 0, -100)
    226         self.course_codes = dict()
     233        #self.course_codes = dict()
     234        self.certcourses = dict()
    227235        self.data = dict()
    228236        for level in self.past_levels:
    229             course_codes = self._get_courses(
     237            certcourses = self._get_courses(
    230238                faccode, depcode, certcode, session, level)
    231             self.course_codes[level] = course_codes
     239            self.certcourses[level] = certcourses
     240            #course_codes = [i.getCourseCode() for i in certcourses]
     241            #self.course_codes[level] = course_codes
    232242            self.data[level] = self._get_students(
    233243                faccode, depcode, certcode, session,
    234                 self.levelcode, course_codes)
     244                self.levelcode, certcourses)
    235245
    236246    def create_pdf(self, job_id):
     
    239249        for level in self.past_levels:
    240250            table_data[level] = tbl_data_to_table(
    241                 self.data[level], self.course_codes[level])
    242         col_widths = [1*cm, 4*cm, 5*cm] + [1*cm] * len(self.course_codes)
     251                self.data[level], self.certcourses[level])
     252        col_widths = [1*cm, 4*cm, 5*cm] + [1*cm] * len(self.certcourses)
    243253        pdf_data = [Paragraph('<b>%s - Report %s</b>'
    244254                              % (self.creation_dt_string, job_id),
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/tests/test_raw_score_report.py

    r14605 r14643  
    3838        rsr = RawScoreReport('fac1', 'dep1', 'CERT1', 2010, 100)
    3939        result = rsr._get_courses('fac1', 'dep1', 'CERT1', 2010, 100)
    40         self.assertEqual(result, [(u'Course1')])
     40        self.assertEqual(result, [self.certificate.values()[0]])
     41        self.assertEqual(
     42            result,
     43            [self.app['faculties']['fac1']['dep1'].certificates[
     44                'CERT1']['Course1_100']])
    4145        return
    4246
     
    5761
    5862    def test_create_pdf(self):
     63        self.app['faculties']['fac1']['dep1'].certificates[
     64                'CERT1']['Course1_100'].course_category = 'xyz'
    5965        self.course = createObject('waeup.Course')
    6066        self.course.code = 'Course2'
Note: See TracChangeset for help on using the changeset viewer.