diff options
Diffstat (limited to 'testapp/exam')
-rw-r--r-- | testapp/exam/forms.py | 7 | ||||
-rw-r--r-- | testapp/exam/views.py | 16 |
2 files changed, 21 insertions, 2 deletions
diff --git a/testapp/exam/forms.py b/testapp/exam/forms.py index 1788a08..e622b88 100644 --- a/testapp/exam/forms.py +++ b/testapp/exam/forms.py @@ -18,6 +18,7 @@ UNAME_CHARS = letters + "._" + digits PWD_CHARS = letters + punctuation + digits class UserRegisterForm(forms.Form): + """A Class to create new form for User's Registration. It has the various fields and functions required to register a new user to the system""" username = forms.CharField(max_length=30, help_text='Letters, digits, period and underscores only.') @@ -88,6 +89,8 @@ class UserRegisterForm(forms.Form): return u_name, pwd class UserLoginForm(forms.Form): + """Creates a form which will allow the user to log into the system.""" + username = forms.CharField(max_length = 30) password = forms.CharField(max_length=30, widget=forms.PasswordInput()) @@ -105,6 +108,8 @@ class UserLoginForm(forms.Form): return user class QuizForm(forms.Form): + """Creates a form to add or edit a Quiz. It has the related fields and functions required.""" + start_date = forms.DateField(initial=datetime.date.today) duration = forms.IntegerField() active = forms.BooleanField(required = False) @@ -124,6 +129,8 @@ class QuizForm(forms.Form): new_quiz.save() class QuestionForm(forms.Form): + """Creates a form to add or edit a Question. It has the related fields and functions required.""" + summary = forms.CharField(max_length = 128) description = forms.CharField(widget = forms.Textarea(attrs={'cols': 20, 'rows': 3})) points = forms.FloatField() diff --git a/testapp/exam/views.py b/testapp/exam/views.py index 6eea338..2803538 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -93,6 +93,8 @@ def user_register(request): context_instance=RequestContext(request)) def edit_quiz(request): + """Edit the list of quizzes seleted by the user for editing.""" + user = request.user if not user.is_authenticated() or user.groups.filter(name='moderator').count() == 0 : raise Http404('You are not allowed to view this page!') @@ -114,6 +116,7 @@ def edit_quiz(request): return my_redirect("/exam/manage/showquiz/") def edit_question(request): + """Edit the list of quizzes seleted by the user for editing.""" user = request.user if not user.is_authenticated() or user.groups.filter(name='moderator').count() == 0 : raise Http404('You are not allowed to view this page!') @@ -142,6 +145,7 @@ def edit_question(request): def add_question(request,question_id=None): """To add a new question in the database. Create a new question and store it.""" + user = request.user if not user.is_authenticated() or user.groups.filter(name='moderator').count() == 0 : raise Http404('You are not allowed to view this page!') @@ -192,6 +196,8 @@ def add_question(request,question_id=None): def add_quiz(request,quiz_id=None): + """To add a new quiz in the database. Create a new question and store it.""" + user = request.user if not user.is_authenticated() or user.groups.filter(name='moderator').count() == 0 : raise Http404('You are not allowed to view this page!') @@ -237,6 +243,7 @@ def add_quiz(request,quiz_id=None): def prof_manage(request): """Take credentials of the user with professor/moderator rights/permissions and log in.""" + user = request.user if user.is_authenticated() and user.groups.filter(name='moderator').count() > 0: return render_to_response('manage.html',{}) @@ -340,6 +347,7 @@ def question(request, q_id): def show_question(request, q_id): """Show a question if possible.""" + if len(q_id) == 0: msg = 'Congratulations! You have successfully completed the quiz.' return complete(request, msg) @@ -347,7 +355,7 @@ def show_question(request, q_id): return question(request, q_id) def check(request, q_id): - + """Checks the answers of the user for particular question""" user = request.user if not user.is_authenticated(): @@ -432,8 +440,8 @@ def complete(request,reason = None): return my_redirect('/exam/') def monitor(request, quiz_id=None): - """Monitor the progress of the papers taken so far.""" + user = request.user if not user.is_authenticated() or user.groups.filter(name='moderator').count() == 0: raise Http404('You are not allowed to view this page!') @@ -479,6 +487,7 @@ def get_user_data(username): def show_all_users(request): """Shows all the users who have taken various exams/quiz.""" + user = request.user if not user.is_authenticated() or user.groups.filter(name='moderator').count() == 0: raise Http404('You are not allowed to view this page !') @@ -489,6 +498,7 @@ def show_all_users(request): def show_all_quiz(request): """Generates a list of all the quizzes that are currently in the database.""" + user = request.user if not user.is_authenticated() or user.groups.filter(name='moderator').count() == 0: raise Http404('You are not allowed to view this page !') @@ -548,6 +558,7 @@ def show_all_quiz(request): def show_all_questions(request): """Show a list of all the questions currently in the databse.""" + user = request.user if not user.is_authenticated() or user.groups.filter(name='moderator').count() == 0 : raise Http404("You are not allowed to view this page !") @@ -608,6 +619,7 @@ def show_all_questions(request): def user_data(request, username): """Render user data.""" + current_user = request.user if not current_user.is_authenticated() or current_user.groups.filter(name='moderator').count() == 0: raise Http404('You are not allowed to view this page!') |