summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yaksh/grader.py14
-rw-r--r--yaksh/templates/yaksh/question.html16
-rw-r--r--yaksh/views.py6
-rw-r--r--yaksh/xmlrpc_clients.py3
4 files changed, 24 insertions, 15 deletions
diff --git a/yaksh/grader.py b/yaksh/grader.py
index ef349e0..db15e59 100644
--- a/yaksh/grader.py
+++ b/yaksh/grader.py
@@ -96,7 +96,7 @@ class Grader(object):
Returns
-------
- A tuple: (success, error message, weight).
+ A tuple: (success, error, weight).
"""
self.setup()
@@ -135,7 +135,7 @@ class Grader(object):
prev_handler = create_signal_handler()
success = False
test_case_success_status = [False] * len(test_case_instances)
- error = ""
+ error = []
weight = 0.0
# Do whatever testing needed.
@@ -148,7 +148,7 @@ class Grader(object):
if test_case_success:
weight += mark_fraction
- error += err + "\n"
+ error.append(err)
test_case_success_status[idx] = test_case_success
success = all(test_case_success_status)
@@ -157,16 +157,16 @@ class Grader(object):
test_case_instance.teardown()
except TimeoutException:
- error = self.timeout_msg
+ error.append(self.timeout_msg)
except OSError:
msg = traceback.format_exc(limit=0)
- error = "Error: {0}".format(msg)
- except Exception as e:
+ error.append("Error: {0}".format(msg))
+ except Exception:
exc_type, exc_value, exc_tb = sys.exc_info()
tb_list = traceback.format_exception(exc_type, exc_value, exc_tb)
if len(tb_list) > 2:
del tb_list[1:3]
- error = "Error: {0}".format("".join(tb_list))
+ error.append("Error: {0}".format("".join(tb_list)))
finally:
# Set back any original signal handler.
set_original_signal_handler(prev_handler)
diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html
index 74ac786..c3babaa 100644
--- a/yaksh/templates/yaksh/question.html
+++ b/yaksh/templates/yaksh/question.html
@@ -209,11 +209,19 @@ function call_skip(url)
</div>
{% if question.type == "code" %}
<div class="panel-footer">
+
{% if error_message %}
- <p> Output Message</p>
- <div class="alert alert-danger" role="alert">
- <textarea style="width:100%" class="error" readonly="yes">{{ error_message }}</textarea>
- </div>
+ {% for error in error_message %}
+ {% if error == "Correct answer" %}
+ <div class="panel panel-success">
+ {% else %}
+ <div class="panel panel-danger">
+ {% endif %}
+ <div class="panel-heading">Testcase No. {{ forloop.counter }}</div>
+ <div class="panel-body"><pre><code>{{ error }}</code></pre></div>
+ </div>
+ {% endfor %}
+
{% endif %}
</div>
{% endif %}
diff --git a/yaksh/views.py b/yaksh/views.py
index 89274df..c330a75 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -493,9 +493,9 @@ def check(request, q_id, attempt_num=None, questionpaper_id=None):
question.get_maximum_test_case_weight()) \
if question.partial_grading and question.type == 'code' else question.points
new_answer.correct = correct
- new_answer.error = result.get('error')
+ new_answer.error = json.dumps(result.get('error'))
else:
- new_answer.error = result.get('error')
+ new_answer.error = json.dumps(result.get('error'))
new_answer.marks = (question.points * result['weight'] /
question.get_maximum_test_case_weight()) \
if question.partial_grading and question.type == 'code' else 0
@@ -1036,7 +1036,7 @@ def grade_user(request, quiz_id=None, user_id=None, attempt_number=None):
user = User.objects.get(id=user_id)
data = AnswerPaper.objects.get_user_data(user, questionpaper_id,
attempt_number
- )
+ )
context = {'data': data, "quiz_id": quiz_id, "users": user_details,
"attempts": attempts, "user_id": user_id
diff --git a/yaksh/xmlrpc_clients.py b/yaksh/xmlrpc_clients.py
index bb8260d..fbcd6a5 100644
--- a/yaksh/xmlrpc_clients.py
+++ b/yaksh/xmlrpc_clients.py
@@ -69,7 +69,8 @@ class CodeServerProxy(object):
except ConnectionError:
result = json.dumps({'success': False,
'weight': 0.0,
- 'error': 'Unable to connect to any code servers!'})
+ 'error': ['Unable to connect to any code servers!']
+ })
return result
def _get_server(self):