Commit 2136db26 authored by Gabriel Dengler's avatar Gabriel Dengler
Browse files

Some fixes in grades properties reading

parent b6571ad2
......@@ -160,8 +160,8 @@ def read_module_properties(module):
status = module['Status']
ects = module['ECTS']
if not grade or not ects:
ects = 0
if not grade:
this_ects = 0
grade_ects = 0
for child_exam in module['exams']:
......@@ -169,13 +169,24 @@ def read_module_properties(module):
raw_ects = ''.join(filter(lambda x: x == '.' or x.isdigit(), child_exam['ECTS'].replace(',', '.')))
raw_grade = ''.join(filter(lambda x: x == '.' or x.isdigit(), child_exam['Note'].replace(',', '.')))
ects += float(raw_ects)
grade_ects += float(raw_ects) * float(raw_grade)
if float(raw_grade) > 0:
this_ects += float(raw_ects)
grade_ects += float(raw_ects) * float(raw_grade)
except ValueError:
pass
grade = grade_ects/ects
grade = grade_ects/this_ects
grade = '{:.1f}'.format(grade).replace('.', ',')
if not ects:
ects = 0
for child_exam in module['exams']:
try:
raw_ects = ''.join(filter(lambda x: x == '.' or x.isdigit(), child_exam['ECTS'].replace(',', '.')))
ects += float(raw_ects)
except ValueError:
pass
ects = '{:.1f}'.format(ects).replace('.', ',')
if not date:
......@@ -289,9 +300,9 @@ def tgc_on_grades(update, context):
except ValueError:
pass
send_message(chat_id, "ECTS: " + str(ects))
send_message(chat_id, "ECTS: " + str(ects).replace('.', ','))
if ects != 0:
send_message(chat_id, "Total Grade: " + str(grade_ects/ects))
send_message(chat_id, "Total Grade: " + str(grade_ects/ects).replace('.', ','))
def tgc_on_goodbye(update, context):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment