Ignore:
Timestamp:
17 May 2019, 15:13:53 (6 years ago)
Author:
Henrik Bettermann
Message:

Enable lecturers to edit imported_ts.

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

Legend:

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

    r15409 r15414  
    10351035
    10361036        We expect uploadfile to be a regular CSV file with columns
    1037         ``student_id``, ``score`` and ``ca`` (other cols are ignored).
     1037        ``student_id``, ``score``, ``imported_ts``
     1038        and ``ca`` (other cols are ignored).
    10381039        """
    10391040        result = dict()
     
    10411042        reader = csv.DictReader(data)
    10421043        for row in reader:
    1043             if not ('student_id' in row and 'score' in row and 'ca' in row):
     1044            if not ('student_id' in row and 'score' in row and 'ca' in row and
     1045                'imported_ts' in row):
    10441046                continue
    1045             result[row['student_id']] = (row['score'], row['ca'])
     1047            result[row['student_id']] = (
     1048                row['score'], row['ca'], row['imported_ts'])
    10461049        return result
    10471050
     
    10631066                return False
    10641067        else:
    1065             formvals = dict(zip(form['sids'], zip(form['scores'], form['cas'])))
     1068            formvals = dict(zip(form['sids'], zip(
     1069                form['scores'], form['cas'], form['imported_tss'])))
    10661070        for ticket in self.editable_tickets:
    10671071            ticket_error = False
    10681072            score = ticket.score
    10691073            ca = ticket.ca
     1074            imported_ts = ticket.imported_ts
    10701075            sid = ticket.student.student_id
    10711076            if formvals[sid][0] == '':
     
    10731078            if formvals[sid][1] == '':
    10741079                ca = None
     1080            if formvals[sid][2] == '':
     1081                imported_ts = None
    10751082            try:
    10761083                if formvals[sid][0]:
     
    10781085                if formvals[sid][1]:
    10791086                    ca = int(formvals[sid][1])
     1087                if formvals[sid][2]:
     1088                    imported_ts = int(formvals[sid][2])
    10801089            except ValueError:
    10811090                error += '%s, ' % ticket.student.display_fullname
     
    11021111                    (ob_class, ticket.student.student_id,
    11031112                     ticket.level, ticket.code, ca))
     1113            if not ticket_error and ticket.imported_ts != imported_ts:
     1114                try:
     1115                    ticket.imported_ts = imported_ts
     1116                except TooBig:
     1117                    error += '%s, ' % ticket.student.display_fullname
     1118                    pass
     1119                ticket.student.__parent__.logger.info(
     1120                    '%s - %s %s/%s imported_ts updated (%s)' %
     1121                    (ob_class, ticket.student.student_id,
     1122                     ticket.level, ticket.code, imported_ts))
    11041123        if error:
    1105             self.flash(_('Error: Score(s) and CA(s) of %s have not be updated. '
     1124            self.flash(_('Error: Score(s), CA(s) and Imported TS(s) of %s have not be updated. '
    11061125              % error.strip(', ')), type="danger")
    11071126        return True
  • main/waeup.aaue/trunk/src/waeup/aaue/students/browser_templates/editscorespage.pt

    r15411 r15414  
    11<p i18n:domain="waeup.kofa" i18n:translate="edit_scores_info">
    22  This page helps you to update your students' course results.
    3   You can either update scores and CAs by importing a csv file
     3  You can either update Scores, CAs and Imported Total Scores by importing a csv file
    44  (press 'Help' for further information) or by
    5   changing score or CA values in the table below. Only scores and CAs
    6   of students in current session
     5  changing Score, CA or Imported Total Score values in the table below.
     6  Only course results of students in current session
    77  <span  i18n:name="current_academic_session"
    88         tal:replace="view/session_title"></span>
     
    8181      <th i18n:translate="">Course of Studies</th>
    8282      <th i18n:translate="">Level</th>
    83       <th i18n:translate="">Imp. TS</th>
    8483      <th i18n:translate="">Score</th>
    8584      <th i18n:translate="">CA</th>
     85      <th i18n:translate="">Imp. Total Score</th>
    8686    </tr>
    8787    </thead>
     
    9494      <td tal:content="ticket/student/certcode">CERTCODE</td>
    9595      <td tal:content="ticket/level">LEVEL</td>
    96       <td tal:content="ticket/imported_ts">IMPORTED TS</td>
    9796      <td style="width: 65px;">
    9897          <input type="text" name="scores:list" class="form-control"
     
    105104                 tal:attributes="value ticket/ca" />
    106105      </td>
     106      <td style="width: 65px;">
     107          <input type="text" name="imported_tss:list" class="form-control"
     108                 tal:attributes="value ticket/imported_ts" />
     109      </td>
    107110    </tr>
    108111    </tbody>
  • main/waeup.aaue/trunk/src/waeup/aaue/students/export.py

    r15336 r15414  
    117117              'depcode', 'faccode',
    118118              'level', 'code', 'level_session', 'ca', 'score',
    119               'total_score', 'grade')
     119              'total_score', 'grade', 'imported_ts')
    120120
    121121    def mangle_value(self, value, name, context=None):
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r15398 r15414  
    4646UPLOAD_CSV_TEMPLATE = (
    4747    'matric_number,student_id,display_fullname,level,code,level_session,'
    48     'score,ca\r\n'
    49     '234,E1000000,Anna Tester,100,COURSE1,2004,%s,%s\r\n')
     48    'score,ca,imported_ts\r\n'
     49    '234,E1000000,Anna Tester,100,COURSE1,2004,%s,%s,%s\r\n')
    5050
    5151class OfficerUITests(StudentsFullSetup):
     
    371371        self.browser.open(self.edit_scores_url)
    372372        upload_ctrl = self.browser.getControl(name='uploadfile:file')
    373         upload_file = StringIO(UPLOAD_CSV_TEMPLATE % ('65','22'))
     373        upload_file = StringIO(UPLOAD_CSV_TEMPLATE % ('65','22','77'))
    374374        upload_ctrl.add_file(upload_file, 'text/csv', 'myscores.csv')
    375375        self.browser.getControl("Update editable scores from").click()
     
    379379        self.assertEqual(
    380380            self.student['studycourse']['100']['COURSE1'].ca, 22)
     381        self.assertEqual(
     382            self.student['studycourse']['100']['COURSE1'].imported_ts, 77)
    381383
    382384    def test_scores_previous_session(self):
     
    400402            'matric_number,student_id,display_fullname,'
    401403            'depcode,faccode,level,code,level_session,ca,score,'
    402             'total_score,grade\r\n234,E1000000,"TESTER, Anna",dep1,fac1,'
    403             '100,COURSE1,2003,,55,,\r\n')
     404            'total_score,grade,imported_ts\r\n234,E1000000,"TESTER, Anna",dep1,fac1,'
     405            '100,COURSE1,2003,,55,,,\r\n')
    404406        self.browser.open(self.edit_prev_scores_url)
    405407        upload_ctrl = self.browser.getControl(name='uploadfile:file')
    406         upload_file = StringIO(UPLOAD_CSV_TEMPLATE % ('65','22'))
     408        upload_file = StringIO(UPLOAD_CSV_TEMPLATE % ('65','22','77'))
    407409        upload_ctrl.add_file(upload_file, 'text/csv', 'myscores.csv')
    408410        self.browser.getControl("Update editable scores from").click()
     
    412414        self.assertEqual(
    413415            self.student['studycourse']['100']['COURSE1'].ca, 22)
     416        self.assertEqual(
     417            self.student['studycourse']['100']['COURSE1'].imported_ts, 77)
    414418
    415419    def test_lecturers_can_download_course_tickets(self):
     
    12441248        self.browser.getControl(name="scores:list", index=0).value = 'abc'
    12451249        self.browser.getControl("Update scores").click()
    1246         self.assertTrue('Error: Score(s) and CA(s) of TESTER, Anna have not be updated.'
     1250        self.assertTrue('Error: Score(s), CA(s) and Imported TS(s) of TESTER, Anna have not be updated.'
    12471251            in self.browser.contents)
    12481252        # Scores can be removed.
Note: See TracChangeset for help on using the changeset viewer.