diff options
author | prathamesh | 2014-09-23 14:44:47 +0530 |
---|---|---|
committer | prathamesh | 2014-09-23 14:44:47 +0530 |
commit | 0808861705c08aede6c0dc9e07ac891911a7bbfb (patch) | |
tree | 729d56c50370070b9e08f44f68a3ce91f9235534 /testapp/exam/forms.py | |
parent | 962cee1705509bb595cda51d104ef1ef7cf0b4fd (diff) | |
download | online_test-0808861705c08aede6c0dc9e07ac891911a7bbfb.tar.gz online_test-0808861705c08aede6c0dc9e07ac891911a7bbfb.tar.bz2 online_test-0808861705c08aede6c0dc9e07ac891911a7bbfb.zip |
Models and views modified.
Added number of attempts option for quiz.
Also days lag between two attempts.
added test status and attempt number for the test.
Removed profile foreign key from answer paper models
since user foreign key is present in the answer paper model.
Urls slightly modified to include attemt number for a given quiz.
Diffstat (limited to 'testapp/exam/forms.py')
-rw-r--r-- | testapp/exam/forms.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index 9bfedbe..9d68ce2 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -32,6 +32,12 @@ question_types = ( UNAME_CHARS = letters + "._" + digits PWD_CHARS = letters + punctuation + digits +attempts = [(i, i) for i in range(1, 6)] +attempts.append((-1, 'Infinite')) + +days_between_attempts = ((j, j) for j in range(401)) + + class UserRegisterForm(forms.Form): """A Class to create new form for User's Registration. It has the various fields and functions required to register @@ -143,6 +149,10 @@ class QuizForm(forms.Form): pass_criteria = forms.FloatField(initial=40, help_text='Will be taken as percentage') language = forms.CharField(widget=forms.Select(choices=languages)) + attempts_allowed = forms.IntegerField(widget=forms.Select(choices=attempts)) + time_between_attempts = forms.IntegerField\ + (widget=forms.Select(choices=days_between_attempts), + help_text='Will be in days') def save(self): start_date = self.cleaned_data["start_date"] @@ -152,6 +162,8 @@ class QuizForm(forms.Form): pass_criteria = self.cleaned_data["pass_criteria"] language = self.cleaned_data["language"] prerequisite = self.cleaned_data["prerequisite"] + attempts_allowed = self.cleaned_data["attempts_allowed"] + time_between_attempts = self.cleaned_data["time_between_attempts"] new_quiz = Quiz() new_quiz.start_date = start_date new_quiz.duration = duration @@ -160,6 +172,8 @@ class QuizForm(forms.Form): new_quiz.pass_criteria = pass_criteria new_quiz.language = language new_quiz.prerequisite_id = prerequisite + new_quiz.attempts_allowed = attempts_allowed + new_quiz.time_between_attempts = time_between_attempts new_quiz.save() |