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

Enable lecturers to edit imported_ts.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.