summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtestapp/code_server.py14
-rw-r--r--testapp/templates/exam/question.html2
-rw-r--r--testapp/test_server.py12
3 files changed, 11 insertions, 17 deletions
diff --git a/testapp/code_server.py b/testapp/code_server.py
index 19c70b1..a3513b7 100755
--- a/testapp/code_server.py
+++ b/testapp/code_server.py
@@ -204,8 +204,8 @@ class CodeServer(object):
except TimeoutException:
# Runaway code, so kill it.
proc.kill()
- stderr = self.timeout_msg
- stdout = ''
+ # Re-raise exception.
+ raise
return proc, stdout, stderr
def check_bash_script(self, ref_script_path, submit_script_path,
@@ -398,9 +398,7 @@ class CodeServer(object):
success = False
output_path = os.getcwd() + '/output'
compile_command = "g++ %s -c -o %s" % (submit_code_path, output_path)
- ret = self._compile_command(compile_command, stdin=None,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ ret = self._compile_command(compile_command)
proc, inst_stderr = ret
# Only if compilation is successful, the program is executed
@@ -409,9 +407,7 @@ class CodeServer(object):
executable = os.getcwd() + '/executable'
compile_main = "g++ %s %s -o %s" % (ref_code_path, output_path,
executable)
- ret = self._compile_command(compile_main, stdin=None,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE)
+ ret = self._compile_command(compile_main)
proc, main_err = ret
if main_err == '':
args = [executable]
@@ -423,7 +419,6 @@ class CodeServer(object):
success, err = True, "Correct answer"
else:
err = stdout + "\n" + stderr
- success = False
os.remove(executable)
else:
err = "Error:"
@@ -433,7 +428,6 @@ class CodeServer(object):
err = err + "\n" + e.split(":", 1)[1]
except:
err = err + "\n" + main_err
- success = False
os.remove(output_path)
else:
err = "Compilation Error:"
diff --git a/testapp/templates/exam/question.html b/testapp/templates/exam/question.html
index 11ea1aa..1203c0e 100644
--- a/testapp/templates/exam/question.html
+++ b/testapp/templates/exam/question.html
@@ -92,7 +92,7 @@ function update_time()
{% endfor %}
{% else %}
- <textarea tabindex=1 rows="3" style="width:750px;margin-bottom:15px;height:auto;" readonly=yes name="snippet" id="snippet" wrap="off">{% if last_attempt %}{% else %}{% if question.type == "bash" %} #!/bin/bash{% else %} #To avoid errors use tabs for indentation for Python questions &#13;&#10; {{ question.snippet }}{% endif %}{% endif %}</textarea>
+ <textarea tabindex=1 rows="3" style="width:750px;margin-bottom:15px;height:auto;" readonly=yes name="snippet" id="snippet" wrap="off">{% if last_attempt %}{{ question.snippet }}{% else %}{% if question.type == "bash" %} #!/bin/bash{% else %}{% if question.type == "python "%} #To avoid errors use tabs for indentation for Python questions &#13;&#10; {{ question.snippet }} {% else %} {{ question.snippet }} {% endif %}{% endif %}{% endif %}</textarea>
<textarea tabindex=1 rows="10" style="width:750px;margin-bottom:10px;" name="answer" id="answer" wrap="off" onkeydown="return catchTab(this,event)">{% if last_attempt %}{{last_attempt.strip}}{% else %}{% if question.type == "bash" %}{% else %}{% endif %}{% endif %}</textarea>
<br>
diff --git a/testapp/test_server.py b/testapp/test_server.py
index f2ea84c..924a6c5 100644
--- a/testapp/test_server.py
+++ b/testapp/test_server.py
@@ -8,13 +8,13 @@ from exam.xmlrpc_clients import code_server
def check_result(result, check='correct answer'):
- if check != 'correct answer':
- assert result[0] == False
- else:
- assert result[0] == True
- if "unable to connect" in result[1].lower():
+ if check != 'correct answer':
+ assert result[0] == False
+ else:
+ assert result[0] == True
+ if "unable to connect" in result[1].lower():
assert result[0], result[1]
- assert check in result[1].lower(), result[1]
+ assert check in result[1].lower(), result[1]
def test_python():
"""Test if server runs Python code as expected."""