import subprocess script = """{{ TEST.testcode | e('py') }}""" + '\n' + """{{ STUDENT_ANSWER | e('py') }}""" input = """{{ TEST.stdin | e('py') }}""" with open('__prog__.sh', 'w') as outfile: outfile.write(script) subprocess.run(['/bin/bash', '__prog__.sh'], text=True, input=input)
Here's a trivial example - the exported question is attached. Note in the exported question that I've set the Ace language - the language used to syntax-colour the student answer - to 'sh', while the sandbox language remains as Python.
If you want many of these questions you should convert the question to a question prototype, so that you have your own question type, e.g. just 'bash'. However, if you're new to CodeRunner you might want to hold off until you're a bit more familiar with it. And please read the documentation, as there are pitfalls.
Note: the attached question has had minimal testing so you will almost certainly want to modify it. I've never set bash questions for my students, so it may not even be the sort of thing you had in mind. If that's the case, please give an example of the sort of question you want to set.