diff options
author | Prabhu Ramachandran | 2017-01-16 23:20:33 +0530 |
---|---|---|
committer | GitHub | 2017-01-16 23:20:33 +0530 |
commit | c3205b84ebd1796d98e140952802cdc0baad19a7 (patch) | |
tree | 4b63a64417776c95e12f2af75411075e6c0e7bd0 /yaksh/models.py | |
parent | 899b2c4a347a6e7c4391dedce163a7ae0c4e8634 (diff) | |
parent | 987efbcba6e9976d1351a35454a62d6b8305009d (diff) | |
download | online_test-c3205b84ebd1796d98e140952802cdc0baad19a7.tar.gz online_test-c3205b84ebd1796d98e140952802cdc0baad19a7.tar.bz2 online_test-c3205b84ebd1796d98e140952802cdc0baad19a7.zip |
Merge pull request #176 from maheshgudi/hook_evaluator
Hook evaluator
Diffstat (limited to 'yaksh/models.py')
-rw-r--r-- | yaksh/models.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/yaksh/models.py b/yaksh/models.py index ca41885..ad61872 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -4,6 +4,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 @@ -1219,5 +1220,31 @@ class McqTestCase(TestCase): class HookTestCase(TestCase): - 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): + return {"test_case_type": "hooktestcase", "hook_code": self.hook_code, + "weight": self.weight} + + def __str__(self): + return u'Hook Testcase | Correct: {0}'.format(self.hook_code) + |