<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<!-- question: 1465  -->
  <question type="coderunner">
    <name>
      <text>LOCAL_PROTOTYPE_openscad_via_python</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<h4>openscad_via_python</h4><p><br></p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1</defaultgrade>
    <penalty>0</penalty>
    <hidden>0</hidden>
    <idnumber></idnumber>
    <coderunnertype>openscad_via_python</coderunnertype>
    <prototypetype>2</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>6</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <globalextra></globalextra>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[""" 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"])

# Test 2
student_answer = """difference() {\n {{ STUDENT_ANSWER }}\n{{ QUESTION.answer }} }"""
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"])

# Test 3
student_answer = """difference() {\n {{ QUESTION.answer }}\n{{ STUDENT_ANSWER }} }"""
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"])

if test1 == 0 and test2 == 1 and test3 == 1:
    print("Your program has successfully recreated the given object.")
elif test1 == 1:
    print("There is an error in your OpenSCAD program.")
elif test2 == 0 or test3 == 0:
    print("Your program does not generate the given object.")]]></template>
    <iscombinatortemplate>0</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre></testsplitterre>
    <language>python3</language>
    <acelang>C</acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <attachments>0</attachments>
    <attachmentsrequired>0</attachmentsrequired>
    <maxfilesize>0</maxfilesize>
    <filenamesregex></filenamesregex>
    <filenamesexplain></filenamesexplain>
    <displayfeedback>0</displayfeedback>
    <testcases>
    </testcases>
  </question>

</quiz>