implemented extra filter on string patterns. now string patterns will not be split like other pattersns
authornishanth
Thu, 22 Apr 2010 12:17:21 +0530
changeset 50 0842b3439c3e
parent 49 3643f59f141e
child 51 80df28feac72
implemented extra filter on string patterns. now string patterns will not be split like other pattersns
question_bank.xml
quiz/management/commands/seed_que.py
quiz/utils.py
--- a/question_bank.xml	Thu Apr 22 06:23:53 2010 +0530
+++ b/question_bank.xml	Thu Apr 22 12:17:21 2010 +0530
@@ -391,13 +391,19 @@
 
 <question>
 <description>
-What is the largest integer value that can be represented natively by Python?
+What is the largest integer value that can be represented by Python?
 </description>
 <time_limit>
 30
 </time_limit>
+<options>
+No Limit
+2**32
+2**32 - 1
+None of the above
+</options>
 <expected_answer>
-correct manually
+No Limit
 </expected_answer>
 </question>
 
@@ -464,8 +470,14 @@
 <time_limit>
 30
 </time_limit>
+<options>
+40
+tttttttttttttttttttttttttttttttttttttttt
+t40
+Error
+</options>
 <expected_answer>
-correct manually
+tttttttttttttttttttttttttttttttttttttttt
 </expected_answer>
 </question>
 
@@ -480,7 +492,8 @@
 30
 </time_limit>
 <expected_answer>
-correct manually
+"a, b, c"
+'a, b, c'
 </expected_answer>
 </question>
 
@@ -576,12 +589,14 @@
 </time_limit>
 <expected_answer>
 error
+Error
+ERROR
 </expected_answer>
 </question>
 
 <question>
 <description>
-What is the value of func(1) where
+What is the value of func(1), if
 </description>
 <code>
 def func(x, y=10):
@@ -591,18 +606,23 @@
 60
 </time_limit>
 <expected_answer>
-2 10
-2 , 10
+2 20
 </expected_answer>
 </question>
 
 <question>
 <description>
-How many items can a function return 
+How many items can a function return ?
 </description>
 <time_limit>
 30
 </time_limit>
+<options>
+One
+Multiple
+Two
+None
+</options>
 <expected_answer>
 Multiple
 </expected_answer>
--- a/quiz/management/commands/seed_que.py	Thu Apr 22 06:23:53 2010 +0530
+++ b/quiz/management/commands/seed_que.py	Thu Apr 22 12:17:21 2010 +0530
@@ -20,7 +20,6 @@
 
         description_node = question.getElementsByTagName("description")[0]
         description = (description_node.childNodes[0].data).strip()
-        print description
 
         time_limit_node = question.getElementsByTagName("time_limit")[0]
         time_limit = time_limit_node.childNodes[0].data
--- a/quiz/utils.py	Thu Apr 22 06:23:53 2010 +0530
+++ b/quiz/utils.py	Thu Apr 22 12:17:21 2010 +0530
@@ -14,7 +14,10 @@
 
         expected_ans = answer.question.expected_ans
 
-        ans_regex_patterns = [ r"\s*".join(ans_pattern.split()) for ans_pattern in expected_ans.split("\n") ]
+        ans_regex_patterns = []
+        for ans_pattern in expected_ans.split("\n"):
+            ans_regex_patterns.append( r"\s*".join(ans_pattern.split()) if not re.match(r"""^[",']""", ans_pattern) else ans_pattern )
+
         for pattern in ans_regex_patterns:
             if re.findall(pattern, answer.submitted_ans):
                 answer.is_correct = True