1 | """General helper functions for the student section. |
---|
2 | """ |
---|
3 | from grok import getSite |
---|
4 | from random import SystemRandom as r |
---|
5 | from waeup.sirp.interfaces import academic_sessions_vocab |
---|
6 | |
---|
7 | def generate_student_id(students,letter): |
---|
8 | if letter == '?': |
---|
9 | letter= r().choice('ABCDEFGHKLMNPQRSTUVWXY') |
---|
10 | sid = u"%c%d" % (letter,r().randint(99999,1000000)) |
---|
11 | while sid in students.keys(): |
---|
12 | sid = u"%c%d" % (letter,r().randint(99999,1000000)) |
---|
13 | return sid |
---|
14 | |
---|
15 | def set_returning_data(student): |
---|
16 | student['studycourse'].current_level += 100 |
---|
17 | student['studycourse'].current_session += 1 |
---|
18 | verdict = student['studycourse'].current_verdict |
---|
19 | student['studycourse'].current_verdict = '0' |
---|
20 | student['studycourse'].previous_verdict = verdict |
---|
21 | return |
---|
22 | |
---|
23 | # To be specified in customization packages. |
---|
24 | # This function is for demonstration and testing only. |
---|
25 | def getPaymentDetails(category, student): |
---|
26 | surcharge_1 = surcharge_2 = surcharge_3 = 0 |
---|
27 | p_item = u'' |
---|
28 | amount = 0 |
---|
29 | error = u'' |
---|
30 | p_session = student['studycourse'].current_session |
---|
31 | session = str(p_session) |
---|
32 | try: |
---|
33 | academic_session = getSite()['configuration'][session] |
---|
34 | except KeyError: |
---|
35 | error = u'Session configuration object is not available.' |
---|
36 | return (amount, p_item, p_session, |
---|
37 | surcharge_1, surcharge_2, surcharge_3, error) |
---|
38 | if category == 'schoolfee': |
---|
39 | amount = academic_session.fee_1 |
---|
40 | surcharge_1 = academic_session.surcharge_1 |
---|
41 | surcharge_2 = academic_session.surcharge_2 |
---|
42 | surcharge_3 = academic_session.surcharge_3 |
---|
43 | p_item = student['studycourse'].certificate.code |
---|
44 | elif category == 'clearance': |
---|
45 | p_item = student['studycourse'].certificate.code |
---|
46 | amount = academic_session.fee_2 |
---|
47 | return (amount, p_item, p_session, |
---|
48 | surcharge_1, surcharge_2, surcharge_3, error) |
---|