Ignore:
Timestamp:
24 Jun 2017, 07:11:54 (8 years ago)
Author:
Henrik Bettermann
Message:

Implement study_mode filter for lecturer pages.

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

Legend:

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

    r14518 r14700  
    2121from zc.sourcefactory.basic import BasicSourceFactory
    2222from waeup.kofa.interfaces import (SimpleKofaVocabulary,
    23     ISessionConfiguration, academic_sessions_vocab)
     23    ISessionConfiguration, academic_sessions_vocab,
     24    ContextualDictSourceFactoryBase)
    2425
    2526_ = MessageFactory = zope.i18nmessageid.MessageFactory('waeup.aaue')
     27
     28class EnableScoreEditingGroupSource(ContextualDictSourceFactoryBase):
     29    """A source for filtering groups of students
     30    """
     31    DICT_NAME = 'ENABLE_SCORE_EDITING_GROUP_DICT'
    2632
    2733# It's recommended to replicate all fields from the base package here.
     
    254260        )
    255261
     262    score_editing_enabled = schema.List(
     263        title = _(u'Score editing enabled'),
     264        value_type = schema.Choice(
     265            source = EnableScoreEditingGroupSource(),
     266            ),
     267        required = False,
     268        defaultFactory=list,
     269        )
     270
    256271
    257272    def getSessionString():
  • main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py

    r14697 r14700  
    815815    grok.template('editscorespage')
    816816
     817    def _searchCatalog(self, session):
     818        cat = queryUtility(ICatalog, name='coursetickets_catalog')
     819        coursetickets = cat.searchResults(
     820            session=(session, session),
     821            code=(self.context.code, self.context.code)
     822            )
     823        try:
     824            score_editing_enabled = grok.getSite()[
     825                'configuration'][str(session)].score_editing_enabled
     826        except KeyError:
     827            return []
     828        coursetickets_list = [
     829            i for i in coursetickets
     830            if i.student.current_mode in score_editing_enabled]
     831        return coursetickets_list
    817832
    818833    def _extract_uploadfile(self, uploadfile):
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r14661 r14700  
    218218
    219219    def test_for_instalment_payments(self):
    220 
    221220        configuration_1 = createObject('waeup.SessionConfiguration')
    222221        configuration_1.academic_session = 2015
     
    364363        # set value to change from
    365364        self.student['studycourse']['100']['COURSE1'].score = 55
     365        self.app['configuration']['2004'].score_editing_enabled = ['ug_ft']
    366366        self.browser.open(self.edit_scores_url)
    367367        upload_ctrl = self.browser.getControl(name='uploadfile:file')
     
    381381        self.browser.open(self.edit_prev_scores_url)
    382382        self.assertTrue('No student found' in self.browser.contents)
     383        configuration = createObject('waeup.SessionConfiguration')
     384        configuration.academic_session = 2003
     385        self.app['configuration'].addSessionConfiguration(configuration)
     386        self.app['configuration']['2003'].score_editing_enabled = ['ug_ft']
    383387        self.student['studycourse']['100'].level_session = 2003
    384388        notify(grok.ObjectModifiedEvent(self.student['studycourse']['100']['COURSE1']))
     
    407411        self.student['studycourse']['100']['COURSE1'].score = 55
    408412        self.student['studycourse']['100']['COURSE1'].ca = 11
     413        self.app['configuration']['2004'].score_editing_enabled = ['ug_ft']
    409414        pdf_url = '%s/coursetickets.pdf' % self.course_url
    410415        self.browser.open(pdf_url)
     
    415420        open(path, 'wb').write(self.browser.contents)
    416421        print "Sample PDF coursetickets.pdf written to %s" % path
     422
     423    def test_lecturers_do_only_see_selected_students(self):
     424        # A course ticket slip can be downloaded
     425        self.login_as_lecturer()
     426        self.student['studycourse']['100']['COURSE1'].score = 55
     427        self.student['studycourse']['100']['COURSE1'].ca = 11
     428        self.browser.open(self.edit_scores_url)
     429        self.assertTrue('No student found' in self.browser.contents)
     430        self.app['configuration']['2004'].score_editing_enabled = ['ug_ft']
     431        self.browser.open(self.edit_scores_url)
     432        self.assertFalse('No student found' in self.browser.contents)
     433        self.assertTrue('TESTER, Anna' in self.browser.contents)
    417434
    418435    def test_transcripts(self):
     
    11191136        self.app['faculties']['fac1']['dep1'].score_editing_disabled = False
    11201137        self.app['configuration'].current_academic_session = 2004
     1138        self.app['configuration']['2004'].score_editing_enabled = ['ug_ft']
    11211139        IWorkflowState(self.student).setState('courses validated')
    11221140        self.browser.open(
  • main/waeup.aaue/trunk/src/waeup/aaue/utils/utils.py

    r14650 r14700  
    162162        'ijmbe': 'IJMBE Preparation',
    163163        }
     164
     165    ENABLE_SCORE_EDITING_GROUP_DICT = STUDY_MODES_DICT
    164166
    165167    VERDICTS_DICT = {
Note: See TracChangeset for help on using the changeset viewer.