Skip to content

Commit

Permalink
fix: fix get eval criteria (#306)
Browse files Browse the repository at this point in the history
* fix-get-eval-criteria

* fix: fix get-eval-criteria
  • Loading branch information
LIEN-YUHSIANG authored Jul 22, 2023
1 parent 5c02b69 commit 98bfe6e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/lambda/get-course/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def to_half_width(s):
return ""
return unicodedata.normalize('NFKC', s)


# Fix the problem over here to get the correct evaluation criteria in the waseda time
def get_eval_criteria(parsed):
"""
Get the evaluation criteria from course detail page
Expand All @@ -171,13 +171,18 @@ def get_eval_criteria(parsed):
# Case 2: 2 or more rows
for r in rows[1:]:
elem = r.getchildren()
kind = elem[0].text
# kind = elem[0].text
# New code to deal with the new line character
kind = elem[0].text.rstrip()
percent = elem[1].text.strip()[:-1] or -1
try:
percent = int(percent)
except ValueError:
logging.warning(f"Unable to parse percent: {percent}")
criteria = to_half_width(elem[2].text)
# criteria = to_half_width(elem[2].text)
# New code to deal with the breakline
criteria_elements = elem[2].xpath('.//text()')
criteria = to_half_width(''.join(criteria_elements))
evals.append({
"type": to_enum(eval_type_map)(kind),
"percent": percent,
Expand Down

0 comments on commit 98bfe6e

Please sign in to comment.