Last active
May 8, 2025 17:55
-
-
Save timmc-edx/6c6004c9beb42da316d0dc75138325c5 to your computer and use it in GitHub Desktop.
Codejail problem allowing straight-up Python execution, returning output
This file contains hidden or 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