<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<!-- question: 0  -->
  <question type="category">
    <category>
        <text>$system$/Questions for export</text>

    </category>
  </question>

<!-- question: 18795  -->
  <question type="coderunner">
    <name>
      <text>Java echo stdin</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Write a Java program that echoes standard input to standard output.</p><p>This is a program to demonstrate that the java_program_via_python question type does a single Jobe run, provided the answer doesn't give a runtime error or a timeout.</p><p>It has 10 test cases for this reason.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>java_prog_via_python</coderunnertype>
    <prototypetype>0</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>1</precheck>
    <showsource>1</showsource>
    <answerboxlines>10</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace></useace>
    <resultcolumns></resultcolumns>
    <template></template>
    <iscombinatortemplate></iscombinatortemplate>
    <allowmultiplestdins></allowmultiplestdins>
    <answer>import java.io.IOException;

public class InOut {
    public static void main(String[] args) throws IOException {
        byte[] buffer = new byte[8192];
        while(true) {
            int bytesRead = System.in.read(buffer);
            if (bytesRead == -1) {
                return;
            }
            System.out.write(buffer, 0, bytesRead);
        }
    }
}</answer>
    <validateonsave>1</validateonsave>
    <testsplitterre></testsplitterre>
    <language></language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader></grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin></uiplugin>
    <testcases>
      <testcase testtype="0" useasexample="1" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>I'm a line of standard input
So am I</text>
      </stdin>
      <expected>
                <text>I'm a line of standard input
So am I</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text><![CDATA[JUST the place for a Snark!" the Bellman cried,
As he landed his crew with care;
Supporting each man on the top of the tide
By a finger entwined in his hair.

"Just the place for a Snark! I have said it twice:
That alone should encourage the crew.
Just the place for a Snark! I have said it thrice:
What I tell you three times is true."]]></text>
      </stdin>
      <expected>
                <text><![CDATA[JUST the place for a Snark!" the Bellman cried,
As he landed his crew with care;
Supporting each man on the top of the tide
By a finger entwined in his hair.

"Just the place for a Snark! I have said it twice:
That alone should encourage the crew.
Just the place for a Snark! I have said it thrice:
What I tell you three times is true."]]></text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>I'm a line of standard input
So am I</text>
      </stdin>
      <expected>
                <text>I'm a line of standard input
So am I</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>I'm a line of standard input
So am I</text>
      </stdin>
      <expected>
                <text>I'm a line of standard input
So am I</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>I'm a line of standard input
So am I</text>
      </stdin>
      <expected>
                <text>I'm a line of standard input
So am I</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>I'm a line of standard input
So am I</text>
      </stdin>
      <expected>
                <text>I'm a line of standard input
So am I</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>I'm a line of standard input
So am I</text>
      </stdin>
      <expected>
                <text>I'm a line of standard input
So am I</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>I'm a line of standard input
So am I</text>
      </stdin>
      <expected>
                <text>I'm a line of standard input
So am I</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>I'm a line of standard input
So am I</text>
      </stdin>
      <expected>
                <text>I'm a line of standard input
So am I</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
      <testcase testtype="0" useasexample="0" hiderestiffail="0" mark="1.0000000" >
      <testcode>
                <text></text>
      </testcode>
      <stdin>
                <text>I'm a line of standard input
So am I</text>
      </stdin>
      <expected>
                <text>I'm a line of standard input
So am I</text>
      </expected>
      <extra>
                <text></text>
      </extra>
      <display>
                <text>SHOW</text>
      </display>
    </testcase>
    </testcases>
  </question>

<!-- question: 18794  -->
  <question type="coderunner">
    <name>
      <text>UOC_JAVA_PROG_VIA_PYTHON_PROTOTYPE</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>A prototype for a Java question type that tests a Java "write-a-program" question. It attempts to run all tests in a single Jobe run with a single compilation. If the run fails for any reason, including compilation error, run-time error or timeout, the CodeRunner framework will re-run this template once for each test case until the failing test case is met.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>java_prog_via_python</coderunnertype>
    <prototypetype>2</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[""" The template for a question type that compiles and runs a student-submitted
    Java program using a combinator template that tries to run all
    test cases in a single compile-and-execute Jobe run.
    This assumes a "write a program" type of question, with no test code to
    be incorporated.
"""

import subprocess, sys, re

# Determine the main class name. Assumes only a single public class is present,
# which must have a public static void main method.
student_answer = """{{ STUDENT_ANSWER | e('py') }}"""
match = re.search(r'public\s+class\s+(\w+)', student_answer)
ok = True
if match:
    class_name = match.group(1)
else:
    print('No public class found in answer. Testing aborted.', file=sys.stderr)
    ok = False

# Write the student code to a source file and compile
if ok:
    source_filename = class_name + '.java'
    with open(source_filename, "w") as src:
        print(student_answer, file=src)
    
    return_code = subprocess.call(['javac', source_filename])
    if return_code != 0:
        print("** Compilation failed. Testing aborted **", file=sys.stderr)
        ok = False

{% if not IS_PRECHECK %}
if ok:
    # If compile succeeded and it's not a precheck run all the tests.
{% for TEST in TESTCASES %}
    testcode = """{{ TEST.testcode | e('py') }}\n"""
    standard_input = """{{ TEST.stdin | e('py') }}\n""".rstrip() + '\n'
    try:
        output = subprocess.check_output(
            ["java", class_name],
            input = standard_input,
            universal_newlines=True
        )
        print(output)
    except subprocess.CalledProcessError as e:
        if e.returncode > 0:
            # Ignore non-zero positive return codes
            if e.output:
                print(e.output)
        else:
            # But negative return codes are signals - abort
            if e.output:
                print(e.output, file=sys.stderr)
            if e.returncode < 0:
                print("Task failed with signal", -e.returncode, file=sys.stderr)
            print("** Further testing aborted **", file=sys.stderr)
            sys.exit(1);
{% if not loop.last %}
    print('#<ab@17943918#@>#');   # Testcase separator
{% endif %}
{% endfor %}
{% endif %}]]></template>
    <iscombinatortemplate>1</iscombinatortemplate>
    <allowmultiplestdins>1</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>python3</language>
    <acelang>java</acelang>
    <sandbox>jobesandbox</sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs>10</cputimelimitsecs>
    <memlimitmb>0</memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

</quiz>