Ignore:
Timestamp:
20 Sep 2013, 12:17:39 (11 years ago)
Author:
Henrik Bettermann
Message:

Implement view for batch-editing of scores for lecturers. This is work in progress!

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/interfaces.py

    r10451 r10627  
    642642        )
    643643
     644    current_academic_session = schema.Choice(
     645        title = _(u'Current Academic Session'),
     646        source = academic_sessions_vocab,
     647        default = None,
     648        required = False,
     649        readonly = False,
     650        )
     651
    644652class ISessionConfiguration(IKofaObject):
    645653    """A session configuration object.
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r10531 r10627  
    146146    return None
    147147
     148def score_editing_disabled_message(student):
     149    config = grok.getSite()['configuration']
     150    if student.current_session != config.current_academic_session:
     151        return _('Score editing is disabled for this session.')
     152    return None
    148153
    149154def addCourseTicket(view, course=None):
     
    30443049        return list(set(hitlist))
    30453050
     3051class EditScoresPage(KofaPage):
     3052    """Page that filters and lists students.
     3053    """
     3054    grok.context(ICourse)
     3055    grok.require('waeup.manageStudent')
     3056    grok.name('edit_scores')
     3057    grok.template('editscorespage')
     3058    pnav = 1
     3059
     3060    def label(self):
     3061        session = academic_sessions_vocab.getTerm(
     3062            self.current_academic_session).title
     3063        return 'Students registered for %s in academic session %s' % (
     3064            self.context.longtitle(), session)
     3065
     3066    def _searchCatalog(self, session):
     3067        cat = queryUtility(ICatalog, name='coursetickets_catalog')
     3068        coursetickets = cat.searchResults(
     3069            session=(session, session),
     3070            code=(self.context.code, self.context.code)
     3071            )
     3072        return list(coursetickets)
     3073
     3074    def update(self,  *args, **kw):
     3075        form = self.request.form
     3076        ob_class = self.__implemented__.__name__.replace('waeup.kofa.','')
     3077        self.current_academic_session = grok.getSite()[
     3078            'configuration'].current_academic_session
     3079        datatable.need()
     3080        self.tickets = self._searchCatalog(self.current_academic_session)
     3081        if not self.tickets:
     3082            self.flash(_('No student found.'))
     3083            return
     3084        if 'UPDATE' in form:
     3085            tno = 0
     3086            error = ''
     3087            for ticket in self.tickets:
     3088                score = ticket.score
     3089                try:
     3090                    score = int(form['scores'][tno])
     3091                except ValueError:
     3092                    error += '%s, ' % ticket.student.display_fullname
     3093                if ticket.score != score:
     3094                    ticket.score = score
     3095                    ticket.student.__parent__.logger.info(
     3096                        '%s - %s %s/%s score updated (%s)' %
     3097                        (ob_class, ticket.student.student_id,
     3098                         ticket.level, ticket.code, score))
     3099                    #notify(grok.ObjectModifiedEvent(ticket))
     3100                tno += 1
     3101            if error:
     3102                self.flash(_('Error: Score(s) of %s have not be updated. '
     3103                  'Only integers are allowed.' % error.strip(', ')))
     3104        return
     3105
    30463106class ExportJobContainerOverview(KofaPage):
    30473107    """Page that lists active student data export jobs and provides links
Note: See TracChangeset for help on using the changeset viewer.