Thanks for your answer and "Frohes Fest" (Happy Christmas)! I have build a new Question for my students
and modified the template. Its still the same, but added some print
commands for a better debugging.
May I found probably my error. I use the python script found in the forum:
import sys, os, shutil, subprocess
__student_answer__ = """{{ STUDENT_ANSWER | e('py') }}"""
# Make package directory, put support files into it
os.mkdir("{{ QUESTION.parameters.package }}")
[shutil.move(f, "{{ QUESTION.parameters.package }}") for f in os.listdir() if f.endswith(".java")]
# Put student answer class into package directory
with open("{{ QUESTION.parameters.package }}/{{ QUESTION.parameters.class}}.java", "w") as f:
print(__student_answer__, file=f)
# Build test class in package directory too
print('Testcode : {{ TEST.testcode }}')
tester = """package {{ QUESTION.parameters.package }};
public class __Tester__ {
public static void main(String[] args) {
//Hello
//Test: {{ TEST.testcode }}
}
}
"""
with open("{{ QUESTION.parameters.package }}/__Tester__.java", "w") as f:
print(tester, file=f)
# Compile and run
if (subprocess.call(["javac", "{{ QUESTION.parameters.package }}/__Tester__.java"]) != 0 or
subprocess.call(["java", "{{ QUESTION.parameters.package }}/__Tester__"]) != 0):
print("** Further testing aborted **", file=sys.stderr)
and in my python environment everything works fine. The problem seams to be the {{ TEST.testcode }}
for the generated __Tester__
class. {{ TEST.testcode }}
is empty and I have no idea to fix this circumstance. The debug message from my student account is:
import sys, os, shutil, subprocess
__student_answer__ = """"""
# Make package directory, put support files into it
os.mkdir("Bsp211")
[shutil.move(f, "Bsp211") for f in os.listdir() if f.endswith(".java")]
# Put student answer class into package directory
with open("Bsp211/Bsp211.java", "w") as f:
print(__student_answer__, file=f)
# Build test class in package directory too
print('Testcode : ')
tester = """package Bsp211;
public class __Tester__ {
public static void main(String[] args) {
//Hello
//Test:
}
}
"""
with open("Bsp211/__Tester__.java", "w") as f:
print(tester, file=f)
# Compile and run
if (subprocess.call(["javac", "Bsp211/__Tester__.java"]) != 0 or
subprocess.call(["java", "Bsp211/__Tester__"]) != 0):
print("** Further testing aborted **", file=sys.stderr)
and the added test should be:
NotenUi ui = new NotenUi();
ui.start();
Do you have another hint for me? Attached my export.
Meanwhile: Here in Austria we have a lot of snow and a hard lockdown :-) - Hope you are fine and on this way: Happy New Year ...
Thanks - schtl