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

Update base64 function names #26

Merged
merged 4 commits into from
Jun 17, 2024
Merged
Changes from 2 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
14 changes: 7 additions & 7 deletions src/problem_bank_helpers/problem_bank_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,17 +369,17 @@ def backticks_to_code_tags(data):
value = value.replace("\\`", "`") # Replace escaped backticks
data["params"][param][answer]["value"] = value

def base64_encode_string(string):
"""Encode a string into a base64 representation to act as a file for prarielearn
def base64_encode(s):
Bluesy1 marked this conversation as resolved.
Show resolved Hide resolved
"""Encode a regular string into a base64 representation to act as a file for prarielearn to store
"""
# Based off of https://github.com/PrairieLearn/PrairieLearn/blob/2ff7c5cc2435bae80c0ba512631749f9c3eadb43/exampleCourse/questions/demo/autograder/python/leadingTrailing/server.py#L9-L11
return base64.b64encode(string.encode("utf-8")).decode("utf-8")
return base64.b64encode(s.encode("utf-8")).decode("utf-8")

def base64_decode_file(file):
"""Decode a base64 string which is a file from prairielearn into a useable string
def base64_decode(f):
"""Decode a base64 string (which is a file) from prairielearn into a useable string
"""
# symetrical to base64_encode_string
return base64.b64decode(to_decode.encode("utf-8")).decode("utf-8")
return base64.b64decode(f.encode("utf-8")).decode("utf-8")

def string_to_pl_user_file(string, data):
"""Encode a string to base64 and add it as the user submitted code file
Expand Down Expand Up @@ -427,4 +427,4 @@ def choose_el(x, i, j):
html += "\n".join(elements)
html += "\n</tr>"
html += "\n</table>"
return html
return html