summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authorprathamesh2020-06-10 11:56:49 +0530
committerprathamesh2020-06-10 11:56:49 +0530
commitc27bc87afd68266da59af6e7f2b3b8cc8db13fad (patch)
tree9075a0019cbba086f4bdefb54346b259d8580cb6 /yaksh
parent73dc8f6820c6c86fd8e70a68456ca2e541801bde (diff)
downloadonline_test-c27bc87afd68266da59af6e7f2b3b8cc8db13fad.tar.gz
online_test-c27bc87afd68266da59af6e7f2b3b8cc8db13fad.tar.bz2
online_test-c27bc87afd68266da59af6e7f2b3b8cc8db13fad.zip
Allow moderator to hide test cases from the user
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/bash_code_evaluator.py1
-rw-r--r--yaksh/bash_stdio_evaluator.py1
-rw-r--r--yaksh/cpp_code_evaluator.py5
-rw-r--r--yaksh/cpp_stdio_evaluator.py1
-rw-r--r--yaksh/grader.py3
-rw-r--r--yaksh/hook_evaluator.py1
-rw-r--r--yaksh/java_code_evaluator.py5
-rw-r--r--yaksh/java_stdio_evaluator.py1
-rw-r--r--yaksh/models.py7
-rw-r--r--yaksh/python_assertion_evaluator.py1
-rw-r--r--yaksh/python_stdio_evaluator.py1
-rw-r--r--yaksh/r_code_evaluator.py1
-rw-r--r--yaksh/scilab_code_evaluator.py1
-rw-r--r--yaksh/templates/yaksh/error_template.html8
-rw-r--r--yaksh/templates/yaksh/view_answerpaper.html9
15 files changed, 39 insertions, 7 deletions
diff --git a/yaksh/bash_code_evaluator.py b/yaksh/bash_code_evaluator.py
index 61cb9fa..f97d386 100644
--- a/yaksh/bash_code_evaluator.py
+++ b/yaksh/bash_code_evaluator.py
@@ -27,6 +27,7 @@ class BashCodeEvaluator(BaseEvaluator):
self.test_case_args = test_case_data.get('test_case_args')
self.weight = test_case_data.get('weight')
+ self.hidden = test_case_data.get('hidden')
def teardown(self):
# Delete the created file.
diff --git a/yaksh/bash_stdio_evaluator.py b/yaksh/bash_stdio_evaluator.py
index f445e09..8d14758 100644
--- a/yaksh/bash_stdio_evaluator.py
+++ b/yaksh/bash_stdio_evaluator.py
@@ -23,6 +23,7 @@ class BashStdIOEvaluator(StdIOEvaluator):
self.expected_input = test_case_data.get('expected_input')
self.expected_output = test_case_data.get('expected_output')
self.weight = test_case_data.get('weight')
+ self.hidden = test_case_data.get('hidden')
def teardown(self):
os.remove(self.submit_code_path)
diff --git a/yaksh/cpp_code_evaluator.py b/yaksh/cpp_code_evaluator.py
index d249c66..0f19596 100644
--- a/yaksh/cpp_code_evaluator.py
+++ b/yaksh/cpp_code_evaluator.py
@@ -8,6 +8,7 @@ import subprocess
from .file_utils import copy_files, delete_files
from .base_evaluator import BaseEvaluator
from .grader import CompilationError, TestCaseError
+from .error_messages import prettify_exceptions
class CppCodeEvaluator(BaseEvaluator):
@@ -29,6 +30,7 @@ class CppCodeEvaluator(BaseEvaluator):
# Set test case data values
self.test_case = test_case_data.get('test_case')
self.weight = test_case_data.get('weight')
+ self.hidden = test_case_data.get('hidden')
def teardown(self):
# Delete the created file.
@@ -142,7 +144,8 @@ class CppCodeEvaluator(BaseEvaluator):
mark_fraction = 1.0 if self.partial_grading else 0.0
else:
err = "{0} \n {1}".format(stdout, stderr)
- raise AssertionError(err)
+ err = prettify_exceptions('AssertionError', err)
+ return success, err, mark_fraction
else:
err = "Test case Error:"
try:
diff --git a/yaksh/cpp_stdio_evaluator.py b/yaksh/cpp_stdio_evaluator.py
index 3f44cb2..a48f701 100644
--- a/yaksh/cpp_stdio_evaluator.py
+++ b/yaksh/cpp_stdio_evaluator.py
@@ -24,6 +24,7 @@ class CppStdIOEvaluator(StdIOEvaluator):
self.expected_input = test_case_data.get('expected_input')
self.expected_output = test_case_data.get('expected_output')
self.weight = test_case_data.get('weight')
+ self.hidden = test_case_data.get('hidden')
def teardown(self):
if os.path.exists(self.submit_code_path):
diff --git a/yaksh/grader.py b/yaksh/grader.py
index c1be493..c0d81fa 100644
--- a/yaksh/grader.py
+++ b/yaksh/grader.py
@@ -143,6 +143,9 @@ class Grader(object):
test_case_instance.compile_code()
eval_result = test_case_instance.check_code()
test_case_success, err, mark_fraction = eval_result
+ if not isinstance(err, dict):
+ err = prettify_exceptions('Error', err)
+ err['hidden'] = test_case_instance.hidden
if test_case_success:
weight += mark_fraction * test_case_instance.weight
else:
diff --git a/yaksh/hook_evaluator.py b/yaksh/hook_evaluator.py
index 33c1549..ff428c3 100644
--- a/yaksh/hook_evaluator.py
+++ b/yaksh/hook_evaluator.py
@@ -25,6 +25,7 @@ class HookEvaluator(BaseEvaluator):
# Set test case data values
self.hook_code = test_case_data.get('hook_code')
self.weight = test_case_data.get('weight')
+ self.hidden = test_case_data.get('hidden')
def teardown(self):
# Delete the created file.
diff --git a/yaksh/java_code_evaluator.py b/yaksh/java_code_evaluator.py
index 35573c0..9689c25 100644
--- a/yaksh/java_code_evaluator.py
+++ b/yaksh/java_code_evaluator.py
@@ -8,6 +8,7 @@ import subprocess
from .base_evaluator import BaseEvaluator
from .file_utils import copy_files, delete_files
from .grader import CompilationError, TestCaseError
+from .error_messages import prettify_exceptions
class JavaCodeEvaluator(BaseEvaluator):
@@ -27,6 +28,7 @@ class JavaCodeEvaluator(BaseEvaluator):
# Set test case data values
self.test_case = test_case_data.get('test_case')
self.weight = test_case_data.get('weight')
+ self.hidden = test_case_data.get('hidden')
def teardown(self):
# Delete the created file.
@@ -150,7 +152,8 @@ class JavaCodeEvaluator(BaseEvaluator):
mark_fraction = 1.0 if self.partial_grading else 0.0
else:
err = stdout + "\n" + stderr
- raise AssertionError(err)
+ err = prettify_exceptions('AssertionError', err)
+ return success, err, mark_fraction
else:
err = "Test case Error:"
try:
diff --git a/yaksh/java_stdio_evaluator.py b/yaksh/java_stdio_evaluator.py
index 0d7e480..375676f 100644
--- a/yaksh/java_stdio_evaluator.py
+++ b/yaksh/java_stdio_evaluator.py
@@ -24,6 +24,7 @@ class JavaStdIOEvaluator(StdIOEvaluator):
self.expected_input = test_case_data.get('expected_input')
self.expected_output = test_case_data.get('expected_output')
self.weight = test_case_data.get('weight')
+ self.hidden = test_case_data.get('hidden')
def teardown(self):
if os.path.exists(self.submit_code_path):
diff --git a/yaksh/models.py b/yaksh/models.py
index 7d4dd98..1b076a8 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -2534,11 +2534,13 @@ class StandardTestCase(TestCase):
test_case = models.TextField()
weight = models.FloatField(default=1.0)
test_case_args = models.TextField(blank=True)
+ hidden = models.BooleanField(default=False)
def get_field_value(self):
return {"test_case_type": "standardtestcase",
"test_case": self.test_case,
"weight": self.weight,
+ "hidden": self.hidden,
"test_case_args": self.test_case_args}
def __str__(self):
@@ -2549,11 +2551,13 @@ class StdIOBasedTestCase(TestCase):
expected_input = models.TextField(default=None, blank=True, null=True)
expected_output = models.TextField(default=None)
weight = models.IntegerField(default=1.0)
+ hidden = models.BooleanField(default=False)
def get_field_value(self):
return {"test_case_type": "stdiobasedtestcase",
"expected_output": self.expected_output,
"expected_input": self.expected_input,
+ "hidden": self.hidden,
"weight": self.weight}
def __str__(self):
@@ -2599,10 +2603,11 @@ class HookTestCase(TestCase):
)
weight = models.FloatField(default=1.0)
+ hidden = models.BooleanField(default=False)
def get_field_value(self):
return {"test_case_type": "hooktestcase", "hook_code": self.hook_code,
- "weight": self.weight}
+ "hidden": self.hidden, "weight": self.weight}
def __str__(self):
return u'Hook Testcase | Correct: {0}'.format(self.hook_code)
diff --git a/yaksh/python_assertion_evaluator.py b/yaksh/python_assertion_evaluator.py
index 4b016a1..368206a 100644
--- a/yaksh/python_assertion_evaluator.py
+++ b/yaksh/python_assertion_evaluator.py
@@ -24,6 +24,7 @@ class PythonAssertionEvaluator(BaseEvaluator):
# Set test case data values
self.test_case = test_case_data.get('test_case')
self.weight = test_case_data.get('weight')
+ self.hidden = test_case_data.get('hidden')
def teardown(self):
# Delete the created file.
diff --git a/yaksh/python_stdio_evaluator.py b/yaksh/python_stdio_evaluator.py
index a1e8f72..272bf34 100644
--- a/yaksh/python_stdio_evaluator.py
+++ b/yaksh/python_stdio_evaluator.py
@@ -36,6 +36,7 @@ class PythonStdIOEvaluator(BaseEvaluator):
self.expected_input = test_case_data.get('expected_input')
self.expected_output = test_case_data.get('expected_output')
self.weight = test_case_data.get('weight')
+ self.hidden = test_case_data.get('hidden')
def teardown(self):
# Delete the created file.
diff --git a/yaksh/r_code_evaluator.py b/yaksh/r_code_evaluator.py
index 8eaeb38..8aeb7ec 100644
--- a/yaksh/r_code_evaluator.py
+++ b/yaksh/r_code_evaluator.py
@@ -24,6 +24,7 @@ class RCodeEvaluator(BaseEvaluator):
# Set test case data values
self.test_case = test_case_data.get('test_case')
self.weight = test_case_data.get('weight')
+ self.hidden = test_case_data.get('hidden')
def teardown(self):
# Delete the created file.
diff --git a/yaksh/scilab_code_evaluator.py b/yaksh/scilab_code_evaluator.py
index 9f26234..a3df443 100644
--- a/yaksh/scilab_code_evaluator.py
+++ b/yaksh/scilab_code_evaluator.py
@@ -23,6 +23,7 @@ class ScilabCodeEvaluator(BaseEvaluator):
# Set test case data values
self.test_case = test_case_data.get('test_case')
self.weight = test_case_data.get('weight')
+ self.hidden = test_case_data.get('hidden')
def teardown(self):
# Delete the created file.
diff --git a/yaksh/templates/yaksh/error_template.html b/yaksh/templates/yaksh/error_template.html
index 9cfeac1..b93d2f1 100644
--- a/yaksh/templates/yaksh/error_template.html
+++ b/yaksh/templates/yaksh/error_template.html
@@ -13,6 +13,9 @@
<div class="card-header alert-danger">Error No. {{ forloop.counter }}</div>
<div class="card-body ">
<div class="">
+ {% if error.hidden %}
+ <strong> Hidden test case failed </strong>
+ {% else %}
{% if not error.type %}
<pre><code> {{error|safe}} </code></pre>
@@ -87,10 +90,11 @@
</tr>
</table>
{% endif %}
- </div>
+ {% endif %}
+ </div>
</div>
</div>
<br>
</div>
{% endfor %}
-{% endif %} \ No newline at end of file
+{% endif %}
diff --git a/yaksh/templates/yaksh/view_answerpaper.html b/yaksh/templates/yaksh/view_answerpaper.html
index d955192..905a111 100644
--- a/yaksh/templates/yaksh/view_answerpaper.html
+++ b/yaksh/templates/yaksh/view_answerpaper.html
@@ -159,12 +159,15 @@
<span class="badge badge-pill badge-primary">Test cases:
</span>
</h5>
+ <ul>
{% for testcase in question.get_test_cases %}
+ {% if not testcase.hidden %}
<strong>
- {{ forloop.counter }}. {{ testcase }}
+ <li> {{ testcase }} </li>
</strong>
- <br>
+ {% endif %}
{% endfor %}
+ </ul>
{% endif %}
<br>
<div class="card">
@@ -230,6 +233,7 @@
<div class="card-body">
{% with ans.error_list as err %}
{% for error in err %}
+ {% if not error.hidden %}
{% if error.type == 'stdio' %}
{% if error.given_input %}
<table class="table table-bordered table-responsive-sm">
@@ -293,6 +297,7 @@
{% else %}
<pre><code> {{error}} </code></pre>
{% endif %}
+ {% endif %}
{% endfor %}
{% endwith %}
{% if question.type == "code" %}