Last active
March 13, 2025 13:38
-
-
Save timmc-edx/6c6004c9beb42da316d0dc75138325c5 to your computer and use it in GitHub Desktop.
Loncapa problem allowing straight-up Python execution, returning output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<problem> | |
<script type="loncapa/python"> | |
out = "[missing]" | |
def run_code(expect, answer_inputs): | |
global out | |
exec(answer_inputs, globals(), globals()) | |
return { | |
"input_list": [ | |
{ | |
"ok": True, | |
"msg": f"Output:\n{out}", | |
"grade_decimal": 1, | |
}, | |
], | |
} | |
</script> | |
<customresponse cfn="run_code"> | |
<p>Set output variable <code>out</code> to see results.</p> | |
<textbox>out = "..."</textbox> | |
</customresponse> | |
</problem> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment