From 34fb6b71ce5fcbd9a5537b305504cadaeb86d9a3 Mon Sep 17 00:00:00 2001
From: ankitjavalkar
Date: Fri, 29 Apr 2016 11:23:07 +0530
Subject: - Modify question - answer validation in views - Modify show_question
to include test_cases in template context - Modify question display template
- Minor changes in forms and urls for proper rebasing
---
yaksh/models.py | 12 ++++++----
yaksh/settings.py | 14 ++++++------
yaksh/templates/yaksh/question.html | 18 +++++++--------
yaksh/urls.py | 2 +-
yaksh/views.py | 44 +++++++++++++++++++++++++++++++++----
5 files changed, 65 insertions(+), 25 deletions(-)
(limited to 'yaksh')
diff --git a/yaksh/models.py b/yaksh/models.py
index d15fdf2..fa4121d 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -250,6 +250,7 @@ class Question(models.Model):
return json.dumps(question_data)
+<<<<<<< HEAD
def dump_into_json(self, question_ids, user):
questions = Question.objects.filter(id__in = question_ids, user_id = user.id)
questions_dict = []
@@ -270,15 +271,18 @@ class Question(models.Model):
question['user'] = user
Question.objects.get_or_create(**question)
- def get_test_cases(self):
+ def get_test_cases(self, **kwargs):
test_case_ctype = ContentType.objects.get(app_label="yaksh", model=self.test_case_type)
- test_cases = test_case_ctype.get_all_objects_for_this_type(question=self)
+ test_cases = test_case_ctype.get_all_objects_for_this_type(question=self, **kwargs)
return test_cases
- def get_test_case(self, test_case_id):
+ # def get_test_case(self, test_case_id):
+ # test_case_ctype = ContentType.objects.get(app_label="yaksh", model=self.test_case_type)
+ # test_case = test_case_ctype.get_object_for_this_type(question=self, id=test_case_id)
+ def get_test_case(self, **kwargs):
test_case_ctype = ContentType.objects.get(app_label="yaksh", model=self.test_case_type)
- test_case = test_case_ctype.get_object_for_this_type(question=self, id=test_case_id)
+ test_case = test_case_ctype.get_object_for_this_type(question=self, **kwargs)
return test_case
diff --git a/yaksh/settings.py b/yaksh/settings.py
index aaf6226..f8baa2c 100644
--- a/yaksh/settings.py
+++ b/yaksh/settings.py
@@ -20,12 +20,12 @@ SERVER_TIMEOUT = 2
URL_ROOT = ''
code_evaluators = {
- "python": {"standardtestcase": "yaksh.python_assertion_evaluator.PythonAssertionEvaluator",
- "stdoutbasedtestcase": "yaksh.python_stdout_evaluator.PythonStdoutEvaluator"
+ "python": {"standardtestcase": "python_assertion_evaluator.PythonAssertionEvaluator",
+ "stdoutbasedtestcase": "python_stdout_evaluator.PythonStdoutEvaluator"
},
- "c": {"standardtestcase": "yaksh.cpp_code_evaluator.CppCodeEvaluator"},
- "cpp": {"standardtestcase": "yaksh.cpp_code_evaluator.CppCodeEvaluator"},
- "java": {"standardtestcase": "yaksh.java_code_evaluator.JavaCodeEvaluator"},
- "bash": {"standardtestcase": "yaksh.bash_code_evaluator.BashCodeEvaluator"},
- "scilab": {"standardtestcase": "yaksh.scilab_code_evaluator.ScilabCodeEvaluator"},
+ "c": {"standardtestcase": "cpp_code_evaluator.CppCodeEvaluator"},
+ "cpp": {"standardtestcase": "cpp_code_evaluator.CppCodeEvaluator"},
+ "java": {"standardtestcase": "java_code_evaluator.JavaCodeEvaluator"},
+ "bash": {"standardtestcase": "bash_code_evaluator.BashCodeEvaluator"},
+ "scilab": {"standardtestcase": "scilab_code_evaluator.ScilabCodeEvaluator"},
}
diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html
index e542fe9..8a67818 100644
--- a/yaksh/templates/yaksh/question.html
+++ b/yaksh/templates/yaksh/question.html
@@ -165,8 +165,14 @@ function call_skip(url)
{% if question.type == "mcq" %}
- {% for option in question.options.strip.splitlines %}
- {{option}}
+ {% for test_case in test_cases %}
+ {{ test_case.options }}
+ {% endfor %}
+ {% endif %}
+ {% if question.type == "mcc" %}
+ {% for test_case in test_cases %}
+ {{ test_case.options }}
+
{% endfor %}
{% endif %}
{% if question.type == "upload" %}
@@ -174,12 +180,6 @@ function call_skip(url)