Request - Add globalextra and test extra to custom template

Request - Add globalextra and test extra to custom template

by Sakari Lukkarinen -
Number of replies: 0

Another usability related request. I have used CodeRunner to teach the basics of numpy and matplotlib for our first year ICT bachelor level students. In all my problems, I use customised template and global extras. In global extras I have created the standard import clauses:

import numpy as np
import matplotlib.pyplot as plt

Quite often I write the correct values in test extras and then use in the test code, like:

print(np.allclose(x, x_test))

to test if the student's numpy array is correct. My request is that the custom template code should include by default the global extra and test extra:

{{ QUESTION.globalextra }}
{{ STUDENT_ANSWER }}

__student_answer__ = """{{ STUDENT_ANSWER | e('py') }}"""

SEPARATOR = "#...#"

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