Use CodeRunner only to check for syntaxerrors without testcase validation

Use CodeRunner only to check for syntaxerrors without testcase validation

by Adrian Perez Rodriguez -
Number of replies: 1

Hi

Did somebody have the same idea to use CodeRunner as IDE to submit code to Moodle without testing it against testcases?

I tried to delete following lines in the builtin python3 template:

{% for TEST in TESTCASES %}
{{ TEST.testcode }}
{% if not loop.last %}
print(SEPARATOR)
{% endif %}
{% endfor %}

Thanks for some advice,
Adrian

In reply to Adrian Perez Rodriguez

Re: Use CodeRunner only to check for syntaxerrors without testcase validation

by Richard Lobb -

You probably want a template with just a couple of lines like

answer = """{{ STUDENT_ANSWER | e('py') }}"""
compile(answer, '<string>', 'exec')

But you'll still need to set up a test case with empty expected output and a dummy 'testcode' (perhaps just a comment to say the code is being checked).

A nicer approach would be to use a combinator template grader, which doesn't require any test cases and doesn't need to generate a result table. But that's way harder.

You might also want to consider more-advanced checking than just "does it compile?". See the python3_pylint question type, introduced in the documentation here.