diff options
author | ankitjavalkar | 2016-04-26 19:37:42 +0530 |
---|---|---|
committer | ankitjavalkar | 2016-05-05 19:19:00 +0530 |
commit | c557e19470a389aaac569516ed56e1c5b453fd88 (patch) | |
tree | 9e4ac79d2ece44f434aa0625d58e198e6875102c /yaksh/forms.py | |
parent | 5684b1b19fcb383f494f0bfc04ad1bb760abce74 (diff) | |
download | online_test-c557e19470a389aaac569516ed56e1c5b453fd88.tar.gz online_test-c557e19470a389aaac569516ed56e1c5b453fd88.tar.bz2 online_test-c557e19470a389aaac569516ed56e1c5b453fd88.zip |
Add views, forms and templates (with JS) for new test cases:
- Add a view and template to list out test cases for particular question
- Add a view and template to add/edit test cases
Diffstat (limited to 'yaksh/forms.py')
-rw-r--r-- | yaksh/forms.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py index 1375d10..9ffef5e 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -1,8 +1,10 @@ from django import forms -from yaksh.models import Profile, Quiz, Question, TestCase, Course +from yaksh.models import Profile, Quiz, Question, TestCase, Course, StandardTestCase, StdoutBasedTestCase from django.contrib.auth import authenticate from django.contrib.auth.models import User +from django.contrib.contenttypes.models import ContentType + from taggit.managers import TaggableManager from taggit.forms import TagField from django.forms.models import inlineformset_factory @@ -30,8 +32,8 @@ question_types = ( test_case_types = ( ("standardtestcase", "Standard Testcase"), - # ("argument_based", "Multiple Correct Choices"), ("stdoutbasedtestcase", "Stdout Based Testcase"), + ("mcqtestcase", "MCQ Testcase"), ) UNAME_CHARS = letters + "._" + digits @@ -41,6 +43,22 @@ attempts = [(i, i) for i in range(1, 6)] attempts.append((-1, 'Infinite')) days_between_attempts = ((j, j) for j in range(401)) +def get_object_form(model, exclude_fields=None): + ctype = ContentType.objects.get(app_label="yaksh", model=model) + # ctype = ContentType.objects.get(pk=type_id) + model_class = ctype.model_class() + class _ObjectForm(forms.ModelForm): + # def __init__(self, *args, **kwargs): + # if "question" in kwargs: + # question = kwargs.pop("question") + # else: + # question = None + # self.fields["question"] = question + class Meta: + model = model_class + exclude = exclude_fields + return _ObjectForm + class UserRegisterForm(forms.Form): """A Class to create new form for User's Registration. |