summaryrefslogtreecommitdiff
path: root/yaksh/models.py
diff options
context:
space:
mode:
authormaheshgudi2017-01-09 15:05:18 +0530
committermaheshgudi2017-01-09 18:10:30 +0530
commit1a8838084cea43525575521e88017f3106d44379 (patch)
treedcab58fbca690997330a36dddfd671f4e99a9ce0 /yaksh/models.py
parentcf4f207f710b9f67e0973a99f5894c4a866bca4c (diff)
downloadonline_test-1a8838084cea43525575521e88017f3106d44379.tar.gz
online_test-1a8838084cea43525575521e88017f3106d44379.tar.bz2
online_test-1a8838084cea43525575521e88017f3106d44379.zip
added default value to hook code in models
Diffstat (limited to 'yaksh/models.py')
-rw-r--r--yaksh/models.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index b859faa..7787e17 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -3,6 +3,7 @@ import json
from random import sample, shuffle
from itertools import islice, cycle
from collections import Counter
+from textwrap import dedent
from django.db import models
from django.db.models import Q
from django.contrib.auth.models import User
@@ -1183,7 +1184,25 @@ class McqTestCase(TestCase):
class HookTestCase(TestCase):
- hook_code = models.TextField()
+ hook_code = models.TextField(default=dedent\
+ ("""\
+ def check_answer(user_answer):
+ ''' Evaluates user answer to return -
+ success - Boolean, indicating if code was executed correctly
+ mark_fraction - Float, indicating fraction of the
+ weight to a test case
+ error - String, error message if success is false'''
+ success = False
+ err = "Incorrect Answer" # Please make the error message more specific
+ mark_fraction = 0.0
+
+ # write your code here
+
+ return success, err, mark_fraction
+
+ """)
+
+ )
weight = models.FloatField(default=1.0)
def get_field_value(self):