diff options
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/hook_evaluator.py | 2 | ||||
-rw-r--r-- | yaksh/models.py | 21 |
2 files changed, 21 insertions, 2 deletions
diff --git a/yaksh/hook_evaluator.py b/yaksh/hook_evaluator.py index c125b21..891192c 100644 --- a/yaksh/hook_evaluator.py +++ b/yaksh/hook_evaluator.py @@ -36,7 +36,7 @@ class HookEvaluator(BaseEvaluator): Returns a tuple (success, error, test_case_weight) success - Boolean, indicating if code was executed successfully, correctly - weight - Float, indicating total weight of all successful test cases + mark_fraction - Float, indicating fraction of the weight to a test case error - String, error message if success is false returns (True, "Correct answer", 1.0) : If the student script passes all 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): |