summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authoradityacp2020-02-18 13:29:24 +0530
committeradityacp2020-02-18 13:29:24 +0530
commit2db246f7abb2b8781e60673edec9912166621f4c (patch)
treee5b8ed04dc4c8fd28c401216313d1968d0d59edb /yaksh/models.py
parent8b0fb468fd94565b359f3c5bf2f2b694e7a9c97a (diff)
downloadonline_test-2db246f7abb2b8781e60673edec9912166621f4c.tar.gz
online_test-2db246f7abb2b8781e60673edec9912166621f4c.tar.bz2
online_test-2db246f7abb2b8781e60673edec9912166621f4c.zip
Change forms, views, models, templates
- Fix UI in add question page - Add test case form for question formset with custom attributes - Add a model method in question class to get question test cases based on type and language of the question - Retain the state of the list view and grid view in courses page - Requested students list will be shown on top in the course detail page
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index efd4fd7..e9c025f 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -1268,6 +1268,42 @@ class Question(models.Model):
# Solution for the question.
solution = models.TextField(blank=True)
+ tc_code_types = {
+ "python": [
+ ("standardtestcase", "Standard TestCase"),
+ ("stdiobasedtestcase", "StdIO TestCase"),
+ ("hooktestcase", "Hook TestCase")
+ ],
+ "c": [
+ ("standardtestcase", "Standard TestCase"),
+ ("stdiobasedtestcase", "StdIO TestCase"),
+ ("hooktestcase", "Hook TestCase")
+ ],
+ "cpp": [
+ ("standardtestcase", "Standard TestCase"),
+ ("stdiobasedtestcase", "StdIO TestCase"),
+ ("hooktestcase", "Hook TestCase")
+ ],
+ "java": [
+ ("standardtestcase", "Standard TestCase"),
+ ("stdiobasedtestcase", "StdIO TestCase"),
+ ("hooktestcase", "Hook TestCase")
+ ],
+ "r": [
+ ("standardtestcase", "Standard TestCase"),
+ ("hooktestcase", "Hook TestCase")
+ ],
+ "bash": [
+ ("standardtestcase", "Standard TestCase"),
+ ("stdiobasedtestcase", "StdIO TestCase"),
+ ("hooktestcase", "Hook TestCase")
+ ],
+ "scilab": [
+ ("standardtestcase", "Standard TestCase"),
+ ("hooktestcase", "Hook TestCase")
+ ]
+ }
+
def consolidate_answer_data(self, user_answer, user=None):
question_data = {}
metadata = {}
@@ -1469,6 +1505,24 @@ class Question(models.Model):
files, extract_path = extract_files(zip_file_path)
self.read_yaml(extract_path, user, files)
+ def get_test_case_options(self):
+ options = None
+ if self.type == "code":
+ options = self.tc_code_types.get(self.language)
+ elif self.type == "mcq" or self.type == "mcc":
+ options = [("mcqtestcase", "Mcq TestCase")]
+ elif self.type == "integer":
+ options = [("integertestcase", "Integer TestCase")]
+ elif self.type == "float":
+ options = [("floattestcase", "Float TestCase")]
+ elif self.type == "string":
+ options = [("stringtestcase", "String TestCase")]
+ elif self.type == "arrange":
+ options = [("arrangetestcase", "Arrange TestCase")]
+ elif self.type == "upload":
+ options = [("hooktestcase", "Hook TestCase")]
+ return options
+
def __str__(self):
return self.summary