diff options
author | prathamesh | 2015-04-07 13:39:47 +0530 |
---|---|---|
committer | prathamesh | 2015-04-07 13:39:47 +0530 |
commit | bd5b1e21c4d837dab410f9a3eb332d7af3d0185a (patch) | |
tree | 99b4fb8ff258fe8ed496dd7100a0c5e23b6e7319 /testapp/exam/forms.py | |
parent | 28415b148617057674d85aee9a2d3aaac36bf0d2 (diff) | |
download | online_test-bd5b1e21c4d837dab410f9a3eb332d7af3d0185a.tar.gz online_test-bd5b1e21c4d837dab410f9a3eb332d7af3d0185a.tar.bz2 online_test-bd5b1e21c4d837dab410f9a3eb332d7af3d0185a.zip |
Multiple attempts and file upload question type.
Can have multiple attempts for a quiz.
Can also specify time lag between two successive attempts for a given
quiz.
Students can upload their code through the interface.
The code will be saved in the folder named after their roll number.
And the file name will be the question id.
Diffstat (limited to 'testapp/exam/forms.py')
-rw-r--r-- | testapp/exam/forms.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index f04fdb3..1f12a3b 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -27,11 +27,17 @@ question_types = ( ("mcq", "Multiple Choice"), ("mcc", "Multiple Correct Choices"), ("code", "Code"), + ("upload", "Assignment Upload"), ) 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 @@ -131,7 +137,7 @@ class QuizForm(forms.Form): super(QuizForm, self).__init__(*args, **kwargs) quizzes = [('', 'Select a prerequisite quiz')] quizzes = quizzes + \ - list(Quiz.objects.values_list('id','description')) + list(Quiz.objects.values_list('id', 'description')) self.fields['prerequisite'] = forms.CharField(required=False, widget=forms.Select(choices=quizzes)) @@ -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() |