Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix get eval criteria #306

Merged
merged 2 commits into from
Jul 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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