I can reduce the resolution by rendering circles with 12 sides, but I'm concerned that some of the future more complicated questions I wish to pose will cause a timeout.
I see now that using the term "test" was confusing. Within my template I conduct three different tests to see if the student's answer was a match. Let's call these developer tests, to distinguish them from the tests that a question author poses. Here's
my code:
""" The template for a question type that compiles and runs a student-submitted
OpenSCAD program.
"""
import subprocess, sys
# Test #1
student_answer = """{{ STUDENT_ANSWER }}"""
with open("prog.scad", "w") as src:
print(student_answer, file=src)
test1 = subprocess.call(["/home/pi/.local/bin/openscad","-o","prog.stl","prog.scad"],stderr=subprocess.DEVNULL)
# Test 2
student_answer = """difference(){\nunion(){\n{{ STUDENT_ANSWER }}\n}\nunion(){\n{{ QUESTION.answer }}\n}\n}"""
with open("prog.scad", "w") as src:
print(student_answer, file=src)
test2 = subprocess.call(["/home/pi/.local/bin/openscad","-o","prog.stl","prog.scad"],stderr=subprocess.DEVNULL)
# Test 3
student_answer = """difference(){\nunion(){\n{{ QUESTION.answer }}\n}\nunion(){\n{{ STUDENT_ANSWER }}\n}\n}"""
with open("prog.scad", "w") as src:
print(student_answer, file=src)
test3 = subprocess.call(["/home/pi/.local/bin/openscad","-o","prog.stl","prog.scad"],stderr=subprocess.DEVNULL)
if test1 == 0 and test2 == 1 and test3 == 1:
print("Match")
elif test1 == 1:
print("Error")
elif test2 == 0 or test3 == 0:
print("Mismatch")
I'm guessing there's a way to use a subprocess.call to run all three developer tests at once. When I do this from the command line using the "&" character to join commands for these tests, it makes a significant difference with respect to the amount
of time taken. Just want to figure out how to get the template to do something similar. Any ideas?