diff options
author | Prabhu Ramachandran | 2016-09-08 16:25:41 +0530 |
---|---|---|
committer | GitHub | 2016-09-08 16:25:41 +0530 |
commit | bcf46d1462c35e9c8df2509a31ac3200383976fc (patch) | |
tree | 10426f74b6c578e53e5002f0314bb484a04b41c4 | |
parent | dc4437c52ee1266af9a69d091952d9f6b19ca584 (diff) | |
parent | 06daf67b7a579c113d17eacd4bfb0651ab169be4 (diff) | |
download | online_test-bcf46d1462c35e9c8df2509a31ac3200383976fc.tar.gz online_test-bcf46d1462c35e9c8df2509a31ac3200383976fc.tar.bz2 online_test-bcf46d1462c35e9c8df2509a31ac3200383976fc.zip |
Merge pull request #131 from adityacp/fix_quiz_UI
Fix quiz templates
-rw-r--r-- | yaksh/code_evaluator.py | 12 | ||||
-rw-r--r-- | yaksh/evaluator_tests/test_python_evaluation.py | 8 | ||||
-rw-r--r-- | yaksh/templates/yaksh/question.html | 44 |
3 files changed, 36 insertions, 28 deletions
diff --git a/yaksh/code_evaluator.py b/yaksh/code_evaluator.py index 2fb429f..e139b55 100644 --- a/yaksh/code_evaluator.py +++ b/yaksh/code_evaluator.py @@ -108,9 +108,17 @@ class CodeEvaluator(object): except TimeoutException: err = self.timeout_msg + except OSError: + msg = traceback.format_exc(limit=0) + err = "Error: {0}".format(msg) except Exception: - err = "Error: {0}".format(traceback.format_exc(limit=0)) - + 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] + else: + pass + err = "Error: {0}".format("".join(tb_list)) finally: # Set back any original signal handler. set_original_signal_handler(prev_handler) diff --git a/yaksh/evaluator_tests/test_python_evaluation.py b/yaksh/evaluator_tests/test_python_evaluation.py index e46b21f..3c07907 100644 --- a/yaksh/evaluator_tests/test_python_evaluation.py +++ b/yaksh/evaluator_tests/test_python_evaluation.py @@ -117,7 +117,7 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): result = get_class.evaluate(**kwargs) err = result.get("error").splitlines() self.assertFalse(result.get("success")) - self.assertEqual(2, len(err)) + self.assertEqual(3, len(err)) for msg in name_error_msg: self.assertIn(msg, result.get("error")) @@ -139,7 +139,7 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): result = get_class.evaluate(**kwargs) err = result.get("error").splitlines() self.assertFalse(result.get("success")) - self.assertEqual(2, len(err)) + self.assertEqual(969, len(err)) for msg in recursion_error_msg: self.assertIn(msg, result.get("error")) @@ -162,7 +162,7 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): result = get_class.evaluate(**kwargs) err = result.get("error").splitlines() self.assertFalse(result.get("success")) - self.assertEqual(2, len(err)) + self.assertEqual(3, len(err)) for msg in type_error_msg: self.assertIn(msg, result.get("error")) @@ -186,7 +186,7 @@ class PythonAssertionEvaluationTestCases(unittest.TestCase): result = get_class.evaluate(**kwargs) err = result.get("error").splitlines() self.assertFalse(result.get("success")) - self.assertEqual(2, len(err)) + self.assertEqual(4, len(err)) for msg in value_error_msg: self.assertIn(msg, result.get("error")) diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index 9a0f899..9e1f734 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -102,6 +102,10 @@ function call_skip(url) </div> </div> </div> +<form id="logout" action="{{URL_ROOT}}/exam/quit/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/" method="post" class="pull-right"> + {% csrf_token %} + <button class="btn" type="submit" name="quit">Quit Exam</button> +</form> <div class = "container"> <div class="sidebar"> <p>Question Navigator </p> @@ -124,27 +128,18 @@ function call_skip(url) </div> </div> <div class="span13"> - <h4><u> {{ question.summary }} </u><font class=pull-right>(Marks : {{ question.points }}) </font></h4><br> + <h4><u> {{ question.summary }} </u><font class=pull-right>(Marks : {{ question.points }}) </font> + </h4> + <h4><font size=3 face=arial> {{ question.language|title }} {{ question.type|title }} Question</font></h4><br> <font size=3 face=arial> {{ question.description|safe }} </font> - <br><font size=3 face=arial> Language: {{ question.language }} </font><br> {% if files %} <h4>Files to download for this question</h4> - {% for file in files %} - {% if file.question_id == question.id %} - <h5><a href="{{file.file.url}}">{{file.file.name}}</a></h5> + {% for f_name in files %} + {% if f_name.question_id == question.id %} + <h5><a href="{{f_name.file.url}}">{{f_name.file.name}}</a></h5> {% endif %} {% endfor %} {% endif %} - {% if question.type == "code" %} - <br><h4>Output:</h4></br> - {% if error_message %} - <div class="alert alert-error"> - <textarea class="error" readonly="yes">{{ error_message }}</textarea> - {% else %} - <textarea class="error_msg" readonly="yes" placeholder="Please submit your answer below"></textarea> - {% endif %} - </div> - {% endif %} <br> <p id="status"></p> <form id="code" action="{{URL_ROOT}}/exam/{{ question.id }}/check/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/" method="post" enctype="multipart/form-data"> @@ -176,10 +171,20 @@ function call_skip(url) {% if question.type == "code" %} <h4>Program:</h4> - <textarea name="answer" id="answer"></textarea> -<br> + <textarea name="answer" id="answer"></textarea> + <br> {% endif %} + {% if question.type == "code" %} + <br><h4>Output:</h4><br> + {% if error_message %} + <div class="alert alert-error"> + <textarea class="error" readonly="yes">{{ error_message }}</textarea> + {% else %} + <textarea class="error_msg" readonly="yes"></textarea> + {% endif %} + </div> + {% endif %} {% if question.type == "mcq" or question.type == "mcc"%} <br><button class="btn" type="submit" name="check" id="check">Submit Answer</button> @@ -195,7 +200,6 @@ function call_skip(url) {% endif %} </form> </div> - <!-- Modal --> <div class="modal fade " id="upload_alert" > <div class="modal-dialog"> @@ -212,10 +216,6 @@ function call_skip(url) </div> </div> </div> - <form id="logout" action="{{URL_ROOT}}/exam/quit/{{ paper.attempt_number }}/{{ paper.question_paper.id }}/" method="post" class="pull-right"> - {% csrf_token %} - <button class="btn" type="submit" name="quit">Quit Exam</button> - </form> <script> // Codemirror object, language modes and initial content |