"""General helper functions for the student section. """ from grok import getSite from random import SystemRandom as r from waeup.sirp.interfaces import academic_sessions_vocab def generate_student_id(students,letter): if letter == '?': letter= r().choice('ABCDEFGHKLMNPQRSTUVWXY') sid = u"%c%d" % (letter,r().randint(99999,1000000)) while sid in students.keys(): sid = u"%c%d" % (letter,r().randint(99999,1000000)) return sid def set_returning_data(student): student['studycourse'].current_level += 100 student['studycourse'].current_session += 1 verdict = student['studycourse'].current_verdict student['studycourse'].current_verdict = '0' student['studycourse'].previous_verdict = verdict return # To be specified in customization packages. # This function is for demonstration and testing only. def getPaymentDetails(category, student): surcharge_1 = surcharge_2 = surcharge_3 = 0 p_item = u'' amount = 0 error = u'' p_session = student['studycourse'].current_session session = str(p_session) try: academic_session = getSite()['configuration'][session] except KeyError: error = u'Session configuration object is not available.' return (amount, p_item, p_session, surcharge_1, surcharge_2, surcharge_3, error) if category == 'schoolfee': amount = academic_session.fee_1 surcharge_1 = academic_session.surcharge_1 surcharge_2 = academic_session.surcharge_2 surcharge_3 = academic_session.surcharge_3 p_item = student['studycourse'].certificate.code elif category == 'clearance': p_item = student['studycourse'].certificate.code amount = academic_session.fee_2 return (amount, p_item, p_session, surcharge_1, surcharge_2, surcharge_3, error)