- Timestamp:
- 8 Jun 2016, 15:48:51 (9 years ago)
- Location:
- main/waeup.kofa/trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/CHANGES.txt
r13886 r13894 4 4 1.4.2.dev0 (unreleased) 5 5 ======================= 6 7 * Add `DownloadScoresView` which is for lecturers only. Remove 8 `waeup.showStudents` from `Lecturer` role. Adjust 9 `DataForLecturerExporter`. Only editable course tickets are being 10 exported. 6 11 7 12 * Remove application fee fallback option. Application fees can only -
main/waeup.kofa/trunk/src/waeup/kofa/browser/viewlets.py
r13813 r13894 27 27 DepartmentPage, CoursePage, CertificatePage, CertificateCoursePage, 28 28 UsersContainerPage, UserManageFormPage, DatacenterImportStep1) 29 from waeup.kofa.students.browser import EditScoresPage 29 30 from waeup.kofa.browser.interfaces import ( 30 31 IFacultiesContainer, IFaculty, IDepartment, ICourse, ICertificate, … … 537 538 target = 'edit_scores' 538 539 grok.order(4) 540 541 class DownloadCSVFileActionButton(ManageActionButton): 542 """ 'Download csv file' button for courses. 543 """ 544 grok.context(ICourse) 545 grok.view(EditScoresPage) 546 grok.name('downloadcsv') 547 grok.require('waeup.editScores') 548 icon = 'actionicon_down.png' 549 text = _('Download editable tickets') 550 target = 'download_scores' 551 grok.order(1) 539 552 540 553 class ManageCertificateActionButton(ManageActionButton): -
main/waeup.kofa/trunk/src/waeup/kofa/permissions.py
r13763 r13894 362 362 class Lecturer(grok.Role): 363 363 """The local Lecturer role can be assigned at course level. 364 The role allows to export s tudent364 The role allows to export some student 365 365 data within the course the local role is assigned. Lecturers can't access 366 366 student data directly but they can edit the scores in course tickets. … … 368 368 grok.name('waeup.local.Lecturer') 369 369 grok.title(u'Lecturer') 370 grok.permissions('waeup.showStudents', 371 'waeup.editScores', 370 grok.permissions('waeup.editScores', 372 371 'waeup.viewAcademics', 373 372 'waeup.exportData') -
main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
r13874 r13894 3081 3081 3082 3082 class EditScoresPage(KofaPage): 3083 """Page that filters and lists students.3083 """Page that allows to edit batches of scores. 3084 3084 """ 3085 3085 grok.context(ICourse) … … 3156 3156 type="danger") 3157 3157 return 3158 3159 class DownloadScoresView(UtilityView, grok.View): 3160 """View that exports scores. 3161 """ 3162 grok.context(ICourse) 3163 grok.require('waeup.editScores') 3164 grok.name('download_scores') 3165 redirect_target = '@@export' 3166 3167 def update(self): 3168 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 3169 self.current_academic_session = grok.getSite()[ 3170 'configuration'].current_academic_session 3171 if self.context.__parent__.__parent__.score_editing_disabled: 3172 self.flash(_('Score editing disabled.'), type="warning") 3173 self.redirect(self.url(self.context)) 3174 return 3175 if not self.current_academic_session: 3176 self.flash(_('Current academic session not set.'), type="warning") 3177 self.redirect(self.url(self.context)) 3178 return 3179 site = grok.getSite() 3180 exporter = getUtility(ICSVExporter, name='lecturer') 3181 self.csv = exporter.export_filtered(site, filepath=None, 3182 catalog='coursetickets', 3183 session=self.current_academic_session, 3184 level=None, 3185 code=self.context.code) 3186 return 3187 3188 def render(self): 3189 filename = 'results_%s_%s.csv' % ( 3190 self.context.code, self.current_academic_session) 3191 self.response.setHeader( 3192 'Content-Type', 'text/csv; charset=UTF-8') 3193 self.response.setHeader( 3194 'Content-Disposition:', 'attachment; filename="%s' % filename) 3195 return self.csv 3158 3196 3159 3197 class ExportJobContainerOverview(KofaPage): … … 3430 3468 3431 3469 def _set_exporter_values(self): 3432 # We provide only the 'lecturer' exporter but can add more. 3470 # We provide only the 'coursetickets' and 'lecturer' exporter 3471 # but can add more. 3433 3472 exporters = [] 3434 for name in (' lecturer',):3473 for name in ('coursetickets', 'lecturer'): 3435 3474 util = getUtility(ICSVExporter, name=name) 3436 3475 exporters.append((util.title, name),) -
main/waeup.kofa/trunk/src/waeup/kofa/students/export.py
r13885 r13894 84 84 continue 85 85 tickets.append(ticket) 86 return tickets 87 88 def get_tickets_for_lecturer(students, **kw): 89 """Get course tickets of `students`. 90 Filter course tickets which belong to this course code and 91 which are editable by lecturers. 92 """ 93 tickets = [] 94 code = kw.get('code', None) 95 level_session = kw.get('session', None) 96 level = kw.get('level', None) 97 for level_obj in get_levels(students): 98 for ticket in level_obj.values(): 99 if ticket.code != code: 100 continue 101 if not ticket.editable_by_lecturer: 102 continue 103 if level is not None: 104 level = int(level) 105 if level_obj.level in (10, 999, None) \ 106 and int(level) != level_obj.level: 107 continue 108 if level_obj.level not in range(level, level+100, 10): 109 continue 110 if level_session is not None and \ 111 int(level_session) != level_obj.level_session: 112 continue 113 tickets.append(ticket) 86 114 return tickets 87 115 … … 349 377 value, name, context=context) 350 378 351 class DataForLecturerExporter( CourseTicketExporter):379 class DataForLecturerExporter(grok.GlobalUtility, StudentExporterBase): 352 380 """ 353 381 """ 354 382 grok.name('lecturer') 355 383 356 fields = ('matric_number', ' reg_number', 'student_id', 'display_fullname',384 fields = ('matric_number', 'student_id', 'display_fullname', 357 385 'level', 'code', 'level_session', 'score') 358 386 359 387 title = _(u'Data for Lecturer') 388 389 def filter_func(self, x, **kw): 390 return get_tickets_for_lecturer(x, **kw) 360 391 361 392 def mangle_value(self, value, name, context=None): … … 370 401 value = getattr(student, name, None) 371 402 return super( 372 CourseTicketExporter, self).mangle_value(403 DataForLecturerExporter, self).mangle_value( 373 404 value, name, context=context) 374 405 -
main/waeup.kofa/trunk/src/waeup/kofa/students/reports/level_report.py
r13879 r13894 190 190 pdf_data.append(Spacer(1, 40)) 191 191 signatures = [ 192 translate(_(' Ag.Head of Department')),192 translate(_('Head of Department')), 193 193 translate(_('Dean of Faculty'))] 194 194 signaturetables = get_signature_tables(signatures, landscape=True) -
main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
r13885 r13894 3806 3806 studylevel.level = 100 3807 3807 studylevel.level_session = 2004 3808 IWorkflowState(self.student).setState('courses validated') 3808 3809 self.student['studycourse'].addStudentStudyLevel( 3809 3810 self.certificate,studylevel) … … 3834 3835 # ... and contains the course ticket COURSE1 3835 3836 self.assertEqual(self.browser.contents, 3836 'matric_number, reg_number,student_id,display_fullname,level,code,'3837 'level_session,score\r\n234, 123,K1000000,Anna Tester,'3837 'matric_number,student_id,display_fullname,level,code,' 3838 'level_session,score\r\n234,K1000000,Anna Tester,' 3838 3839 '100,COURSE1,2004,\r\n') 3839 3840 self.assertEqual(len(self.app['datacenter'].running_exports), 1) … … 3861 3862 '- discarded: job_id=%s' % job_id in logcontent 3862 3863 ) 3864 3865 def test_course_download_lecturer(self): 3866 # We add study level 100 to the student's studycourse 3867 studylevel = StudentStudyLevel() 3868 studylevel.level = 100 3869 studylevel.level_session = 2004 3870 IWorkflowState(self.student).setState('courses validated') 3871 self.student['studycourse'].addStudentStudyLevel( 3872 self.certificate,studylevel) 3873 course1_path = 'http://localhost/app/faculties/fac1/dep1/courses/COURSE1' 3874 # Create lecturer 3875 self.app['users'].addUser('mrlecturer', 'mrlecturersecret') 3876 self.app['users']['mrlecturer'].email = 'mrlecturer@foo.ng' 3877 self.app['users']['mrlecturer'].title = 'Carlo Intelligent' 3878 prmglobal = IPrincipalRoleManager(self.course) 3879 prmglobal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrlecturer') 3880 # Login as lecturer 3881 self.browser.open(self.login_path) 3882 self.browser.getControl(name="form.login").value = 'mrlecturer' 3883 self.browser.getControl(name="form.password").value = 'mrlecturersecret' 3884 self.browser.getControl("Login").click() 3885 self.assertMatches('...You logged in...', self.browser.contents) 3886 self.browser.open(course1_path) 3887 self.assertFalse('Export' in self.browser.contents) 3888 self.browser.getLink("Update scores").click() 3889 self.assertTrue('Current academic session not set' in self.browser.contents) 3890 self.app['configuration'].current_academic_session = 2004 3891 self.browser.getLink("Update scores").click() 3892 self.browser.getLink("Download editable tickets").click() 3893 self.assertEqual(self.browser.headers['Status'], '200 Ok') 3894 self.assertEqual(self.browser.headers['Content-Type'], 3895 'text/csv; charset=UTF-8') 3896 self.assertEqual(self.browser.contents, 'matric_number,student_id,' 3897 'display_fullname,level,code,level_session,score\r\n234,' 3898 'K1000000,Anna Tester,100,COURSE1,2004,\r\n') 3863 3899 3864 3900 def test_export_departmet_officers(self):
Note: See TracChangeset for help on using the changeset viewer.