Changeset 13770 for main/waeup.aaue/trunk/src/waeup
- Timestamp:
- 8 Mar 2016, 17:21:35 (9 years ago)
- Location:
- main/waeup.aaue/trunk/src/waeup/aaue/students
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.aaue/trunk/src/waeup/aaue/students/browser.py
r13713 r13770 36 36 StudentFilesUploadPage, 37 37 PaymentsManageFormPage, 38 CourseTicketDisplayFormPage, 39 CourseTicketManageFormPage, 40 EditScoresPage 38 41 ) 39 42 from kofacustom.nigeria.students.browser import ( … … 55 58 ICustomStudentPersonal, 56 59 ICustomStudentPersonalEdit, 57 ICustomUGStudentClearance) 60 ICustomUGStudentClearance, 61 ICustomCourseTicket) 58 62 from waeup.aaue.interswitch.browser import gateway_net_amt 59 63 from waeup.aaue.interfaces import MessageFactory as _ … … 444 448 requires that no application slip exists. 445 449 """ 450 451 class CustomCourseTicketDisplayFormPage(CourseTicketDisplayFormPage): 452 """ Page to display course tickets 453 """ 454 form_fields = grok.AutoFields(ICustomCourseTicket) 455 456 class CustomCourseTicketManageFormPage(CourseTicketManageFormPage): 457 """ Page to manage course tickets 458 """ 459 form_fields = grok.AutoFields(ICustomCourseTicket) 460 form_fields['title'].for_display = True 461 form_fields['fcode'].for_display = True 462 form_fields['dcode'].for_display = True 463 form_fields['semester'].for_display = True 464 form_fields['passmark'].for_display = True 465 form_fields['credits'].for_display = True 466 form_fields['mandatory'].for_display = False 467 form_fields['automatic'].for_display = True 468 form_fields['carry_over'].for_display = True 469 470 class CustomEditScoresPage(EditScoresPage): 471 """Page that filters and lists students. 472 """ 473 grok.template('editscorespage') 474 475 def update(self, *args, **kw): 476 form = self.request.form 477 ob_class = self.__implemented__.__name__.replace('waeup.kofa.','') 478 self.current_academic_session = grok.getSite()[ 479 'configuration'].current_academic_session 480 if self.context.__parent__.__parent__.score_editing_disabled: 481 self.flash(_('Score editing disabled.'), type="warning") 482 self.redirect(self.url(self.context)) 483 return 484 if not self.current_academic_session: 485 self.flash(_('Current academic session not set.'), type="warning") 486 self.redirect(self.url(self.context)) 487 return 488 self.tickets = self._searchCatalog(self.current_academic_session) 489 editable_tickets = [ 490 ticket for ticket in self.tickets if ticket.editable_by_lecturer] 491 if not self.tickets: 492 self.flash(_('No student found.'), type="warning") 493 self.redirect(self.url(self.context)) 494 return 495 if 'UPDATE' in form: 496 tno = 0 497 error = '' 498 if not editable_tickets: 499 return 500 scores = form['scores'] 501 cas = form['cas'] 502 if isinstance(scores, basestring): 503 scores = [scores] 504 if isinstance(cas, basestring): 505 cas = [cas] 506 for ticket in editable_tickets: 507 ticket_error = False 508 score = ticket.score 509 ca = ticket.ca 510 if scores[tno] == '': 511 score = None 512 if cas[tno] == '': 513 ca = None 514 try: 515 if scores[tno]: 516 score = int(scores[tno]) 517 if cas[tno]: 518 ca = int(cas[tno]) 519 except ValueError: 520 error += '%s, ' % ticket.student.display_fullname 521 ticket_error = True 522 if not ticket_error and ticket.score != score: 523 ticket.score = score 524 ticket.student.__parent__.logger.info( 525 '%s - %s %s/%s score updated (%s)' % 526 (ob_class, ticket.student.student_id, 527 ticket.level, ticket.code, score)) 528 if not ticket_error and ticket.ca != ca: 529 ticket.ca = ca 530 ticket.student.__parent__.logger.info( 531 '%s - %s %s/%s ca updated (%s)' % 532 (ob_class, ticket.student.student_id, 533 ticket.level, ticket.code, ca)) 534 tno += 1 535 if error: 536 self.flash(_('Error: Score(s) and CA(s) of %s have not be updated. ' 537 'Only integers are allowed.' % error.strip(', ')), 538 type="danger") 539 return -
main/waeup.aaue/trunk/src/waeup/aaue/students/export.py
r13768 r13770 89 89 90 90 fields = ('matric_number', 'reg_number', 'student_id', 91 'level', 'code', 'level_session', 'score' )91 'level', 'code', 'level_session', 'score', 'ca') 92 92 -
main/waeup.aaue/trunk/src/waeup/aaue/students/interfaces.py
r13735 r13770 281 281 """ 282 282 283 ca = schema.Int( 284 title = _(u'Continuous Assessment'), 285 default = None, 286 required = False, 287 missing_value = None, 288 ) 289 290 ICustomCourseTicket['ca'].order = ICustomCourseTicket['mandatory'].order 291 283 292 class ICustomStudentUpdateByRegNo(INigeriaStudentUpdateByRegNo): 284 293 """Representation of a student. Skip regular reg_number validation. -
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py
r13755 r13770 22 22 import grok 23 23 from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState 24 from zope.securitypolicy.interfaces import IPrincipalRoleManager 24 25 from datetime import datetime, timedelta, date 25 26 from mechanize import LinkNotFoundError … … 33 34 from waeup.kofa.students.accommodation import BedTicket 34 35 from waeup.kofa.testing import FunctionalTestCase 36 from waeup.kofa.authentication import LocalRoleSetEvent 35 37 from waeup.kofa.browser.tests.test_pdf import samples_dir 36 38 from waeup.aaue.testing import FunctionalLayer … … 634 636 in self.browser.contents) 635 637 return 638 639 def test_handle_courses_by_lecturer(self): 640 self.app['users'].addUser('mrslecturer', 'mrslecturersecret') 641 self.app['users']['mrslecturer'].email = 'mrslecturer@foo.ng' 642 self.app['users']['mrslecturer'].title = u'Mercedes Benz' 643 # Add course ticket 644 studylevel = createObject(u'waeup.StudentStudyLevel') 645 studylevel.level = 100 646 studylevel.level_session = 2004 647 self.student['studycourse'].addStudentStudyLevel( 648 self.certificate, studylevel) 649 # Assign local Lecturer role for a certificate. 650 course = self.app['faculties']['fac1']['dep1'].courses['COURSE1'] 651 prmlocal = IPrincipalRoleManager(course) 652 prmlocal.assignRoleToPrincipal('waeup.local.Lecturer', 'mrslecturer') 653 notify(LocalRoleSetEvent( 654 course, 'waeup.local.Lecturer', 'mrslecturer', granted=True)) 655 # Login as lecturer. 656 self.browser.open(self.login_path) 657 self.browser.getControl(name="form.login").value = 'mrslecturer' 658 self.browser.getControl(name="form.password").value = 'mrslecturersecret' 659 self.browser.getControl("Login").click() 660 self.browser.getLink("My Roles").click() 661 self.browser.getLink( 662 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1").click() 663 # Course results can be batch edited via the edit_courses view. 664 self.app['faculties']['fac1']['dep1'].score_editing_disabled = False 665 self.app['configuration'].current_academic_session = 2004 666 IWorkflowState(self.student).setState('courses validated') 667 self.browser.open( 668 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores") 669 self.assertTrue( 670 'input type="text" name="scores"' 671 in self.browser.contents) 672 self.browser.getControl(name="scores", index=0).value = '55' 673 self.browser.getControl(name="cas", index=0).value = '66' 674 self.browser.getControl("Update scores").click() 675 # New score and ca has been set. 676 self.assertEqual( 677 self.student['studycourse']['100']['COURSE1'].score, 55) 678 self.assertEqual( 679 self.student['studycourse']['100']['COURSE1'].ca, 66) 680 # Score editing has been logged. 681 logfile = os.path.join( 682 self.app['datacenter'].storage, 'logs', 'students.log') 683 logcontent = open(logfile).read() 684 self.assertTrue('mrslecturer - waeup.aaue.students.browser.CustomEditScoresPage - ' 685 'E1000000 100/COURSE1 score updated (55)' in logcontent) 686 self.assertTrue('mrslecturer - waeup.aaue.students.browser.CustomEditScoresPage - ' 687 'E1000000 100/COURSE1 ca updated (66)' in logcontent) 688 # Non-integer scores won't be accepted. 689 self.browser.open( 690 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores") 691 self.assertTrue('value="55" />' in self.browser.contents) 692 self.browser.getControl(name="scores", index=0).value = 'abc' 693 self.browser.getControl("Update scores").click() 694 self.assertTrue('Error: Score(s) and CA(s) of Anna Tester have not be updated.' 695 in self.browser.contents) 696 # Scores can be removed. 697 self.browser.open( 698 "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores") 699 self.browser.getControl(name="scores", index=0).value = '' 700 self.browser.getControl("Update scores").click() 701 self.assertEqual( 702 self.student['studycourse']['100']['COURSE1'].score, None) 703 logcontent = open(logfile).read() 704 self.assertTrue('mrslecturer - waeup.aaue.students.browser.CustomEditScoresPage - ' 705 'E1000000 100/COURSE1 score updated (None)' in logcontent) -
main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_export.py
r13715 r13770 162 162 self.assertEqual( 163 163 result, 164 'automatic,ca rry_over,code,credits,dcode,fcode,level,level_session,'164 'automatic,ca,carry_over,code,credits,dcode,fcode,level,level_session,' 165 165 'mandatory,passmark,score,semester,title,student_id,certcode,' 166 166 'display_fullname,matric_number\r\n' 167 '1, 1,CRS1,100,DEP1,FAC1,100,2012,0,100,,2,Course 1,A111111,CERT1,'167 '1,,1,CRS1,100,DEP1,FAC1,100,2012,0,100,,2,Course 1,A111111,CERT1,' 168 168 'Anna M. Tester,234\r\n' 169 169 )
Note: See TracChangeset for help on using the changeset viewer.