Hi all,
I'm trying to set up a Python-CodeRunner that does not ask students to write down an entire function but to give a single line of code instead. That one line ought change a dictionary thus the dictionary needs to be declared somehow somewhere in advance. I thought the template parms might be the best place to do so and put some JSON there:
{ "noten" : [2.0, 3.0, 1.0] }
I consider this to be the equivalent to Python's
noten = [2.0, 3.0, 1.0]
So I expected to first test
(len(noten) == 2) & (noten[0] == 3.0) & (noten[1] == 1.0)
to come up with True or False but got
***Laufzeitfehler***
Traceback (most recent call last):
File "__tester__.python3", line 1, in <module>
noten.remove(2.0)
NameError: name 'noten' is not defined
Debug is
Run 1
noten.remove(2.0)
__student_answer__ = """noten.remove(2.0)"""
SEPARATOR = "#<ab@17943918#@>#"
(len(noten) == 2) & (noten[0] == 3.0) & (noten[1] == 1.0)
Providing the list along with the test case itself doesn't work neither. Being a bloody newbie I'm afraid of missing something very basic ....
Where can I declare the list?
Many thanks in advance
Christian
OK, initializing the variable right before {{ STUDEN_ANSWER }} is the
right place to put that line. Bad idea to test some void method such
as remove this way ;-)
I think you probably need to read through the documentation, perhaps starting with the section on the architecture of CodeRunner: see here. Or you could watch the YouTube videos.
The default Python3 question type builds a program consisting of the student-supplied code followed by the test code. You are trying to insert some of your own code before the student code and then have the test code following that. To achieve that you need to use your own customised template or (when you get more familiar with CodeRunner) your own question type.
Template parameters are a way for question authors to write more general templates. For example, if the template had contained the line
test_list = {{ noten }}
your template parameter would have defined a list test_list in the way you want. But since the standard Python3 template contains no such code, your parameter achieved nothing. I think you can forget about template parameters until you've started writing your own question types.
I suggest after reading the documentation you experiment with changing the template by clicking the Customise checkbox and seeing if you can find a place to insert an extra line of code, such as
noten = [2.0, 3.0, 1.0]
to achieve the result you want.
You might also be interested in the new "gap filler" question type: see here.
Sry, don't want to wast your time. Debugging is enabled indicating non of the tests being executed:
Silly me! Splitting the different ifs into individual tests does the trick!
Great software, many thanks!