diff options
author | hardythe1 | 2012-02-20 19:51:58 +0530 |
---|---|---|
committer | hardythe1 | 2012-02-20 19:51:58 +0530 |
commit | f6a90c1eb603c9f3b8178102e387025880c0a5ac (patch) | |
tree | da20cd8a42abfa78604d8b3a09512613b9eaa24d /testapp | |
parent | e8ba4ba5301a805194a555f52275407f045b91ab (diff) | |
download | online_test-f6a90c1eb603c9f3b8178102e387025880c0a5ac.tar.gz online_test-f6a90c1eb603c9f3b8178102e387025880c0a5ac.tar.bz2 online_test-f6a90c1eb603c9f3b8178102e387025880c0a5ac.zip |
changes to manage questions
Diffstat (limited to 'testapp')
-rw-r--r-- | testapp/exam/urls.py | 1 | ||||
-rw-r--r-- | testapp/exam/views.py | 62 | ||||
-rw-r--r-- | testapp/templates/exam/add_question.html | 2 | ||||
-rw-r--r-- | testapp/templates/exam/grade_user.html | 6 | ||||
-rw-r--r-- | testapp/templates/exam/monitor.html | 2 | ||||
-rw-r--r-- | testapp/templates/exam/showusers.html | 3 | ||||
-rw-r--r-- | testapp/templates/exam/user_data.html | 8 | ||||
-rw-r--r-- | testapp/templates/manage.html | 4 |
8 files changed, 59 insertions, 29 deletions
diff --git a/testapp/exam/urls.py b/testapp/exam/urls.py index 72c93fa..504a4e6 100644 --- a/testapp/exam/urls.py +++ b/testapp/exam/urls.py @@ -7,6 +7,7 @@ urlpatterns = patterns('exam.views', url(r'^manage/addquestion/$', 'add_question'), url(r'^manage/addquiz/$', 'add_quiz'), url(r'^manage/gradeuser/$', 'show_all_users'), + url(r'^manage/questions/$', 'show_all_questions'), url(r'^register/$', 'user_register'), url(r'^start/$', 'start'), url(r'^quit/$', 'quit'), diff --git a/testapp/exam/views.py b/testapp/exam/views.py index b202ff3..b8233b2 100644 --- a/testapp/exam/views.py +++ b/testapp/exam/views.py @@ -91,23 +91,23 @@ def user_register(request): context_instance=RequestContext(request)) def add_question(request): - - if request.method == "POST": - form = AddQuestionForm(request.POST) - if form.is_valid(): - data = form.cleaned_data - form.save() - return my_redirect("/exam/manage/addquestion/") - - else: - return my_render_to_response('exam/add_question.html', - {'form':form}, - context_instance=RequestContext(request)) - else: - form = AddQuestionForm() - return my_render_to_response('exam/add_question.html', - {'form':form}, - context_instance=RequestContext(request)) + + if request.method == "POST": + form = AddQuestionForm(request.POST) + if form.is_valid(): + data = form.cleaned_data + form.save() + return my_redirect("/exam/manage/questions/") + + else: + return my_render_to_response('exam/add_question.html', + {'form':form}, + context_instance=RequestContext(request)) + else: + form = AddQuestionForm() + return my_render_to_response('exam/add_question.html', + {'form':form}, + context_instance=RequestContext(request)) def add_quiz(request): if request.method == "POST": @@ -355,6 +355,34 @@ def show_all_users(request): print context return my_render_to_response('exam/showusers.html',context,context_instance=RequestContext(request)) +def show_all_questions(request): + if request.method == 'POST': + data = request.POST.getlist('question') + if data == None: + questions = Question.objects.all() + context = {'papers': [], + 'question': None, + 'questions':questions} + return my_render_to_response('exam/showquestions.html', context, + context_instance=RequestContext(request)) + for i in data: + question = Question.objects.get(id=i).delete() + questions = Question.objects.all() + context = {'papers': [], + 'question': None, + 'questions':questions} + return my_render_to_response('exam/showquestions.html', context, + context_instance=RequestContext(request)) + + else: + """Show the list of available quiz""" + questions = Question.objects.all() + context = {'papers': [], + 'question': None, + 'questions':questions} + return my_render_to_response('exam/showquestions.html', context, + context_instance=RequestContext(request)) + def user_data(request, username): """Render user data.""" current_user = request.user diff --git a/testapp/templates/exam/add_question.html b/testapp/templates/exam/add_question.html index ae86ed1..2d42b34 100644 --- a/testapp/templates/exam/add_question.html +++ b/testapp/templates/exam/add_question.html @@ -21,7 +21,7 @@ table th, table td { {{ form.as_table }} </table> <center><button class="btn" type="submit" name="savequestion">Save</button> -<button class="btn" type="reset" name="reset">Clear</button> </center> +<button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/questions/");'>Cancel</button> </center> </form> {% endblock %} diff --git a/testapp/templates/exam/grade_user.html b/testapp/templates/exam/grade_user.html index fa0e516..bad1765 100644 --- a/testapp/templates/exam/grade_user.html +++ b/testapp/templates/exam/grade_user.html @@ -32,7 +32,7 @@ Start time: {{ paper.start_time }} <br/> {% if paper.answers.count %} <h3> Answers </h3><br> <form id="q{{ paper.quiz.id }}_form" - action="{{URL_ROOT}}/exam/grade_user/{{data.user.username}}/" method="post"> + action="{{URL_ROOT}}/exam/manage/grade_user/{{data.user.username}}/" method="post"> {% csrf_token %} {% for question, answers in paper.get_question_answers.items %} <p><strong> @@ -71,11 +71,11 @@ Marks: <input id="q{{ question.id }}" type="text" {% endif %} {# if data.papers #} {% if data.papers.count > 1 %} -<a href="{{URL_ROOT}}/exam/monitor/"> +<a href="{{URL_ROOT}}/exam/manage/monitor/"> Monitor quiz</a> {% else %} {% with data.papers.0 as paper %} -<a href="{{URL_ROOT}}/exam/monitor/{{paper.quiz.id}}/"> +<a href="{{URL_ROOT}}/exam/manage/monitor/{{paper.quiz.id}}/"> Monitor quiz</a> {% endwith %} {% endif %} diff --git a/testapp/templates/exam/monitor.html b/testapp/templates/exam/monitor.html index 4847545..a802de2 100644 --- a/testapp/templates/exam/monitor.html +++ b/testapp/templates/exam/monitor.html @@ -20,7 +20,7 @@ <ul> {% for quiz in quizzes %} -<li><a href="{{URL_ROOT}}/exam/monitor/{{quiz.id}}/">{{ quiz.description }}</a></li> +<li><a href="{{URL_ROOT}}/exam/manage/monitor/{{quiz.id}}/">{{ quiz.description }}</a></li> {% endfor %} </ul> {% endif %} diff --git a/testapp/templates/exam/showusers.html b/testapp/templates/exam/showusers.html index ad9534f..038cb8b 100644 --- a/testapp/templates/exam/showusers.html +++ b/testapp/templates/exam/showusers.html @@ -5,8 +5,9 @@ List of Users {% endblock %} + {% block manage %} {% for name in user %} -<a href="{{URL_ROOT}}/exam/grade_user/{{ name }}">{{ name }}</a><br> +<a href="{{URL_ROOT}}/exam/manage/grade_user/{{ name }}">{{ name }}</a><br> {% endfor %} {% endblock %} diff --git a/testapp/templates/exam/user_data.html b/testapp/templates/exam/user_data.html index b9cbbb5..c835f61 100644 --- a/testapp/templates/exam/user_data.html +++ b/testapp/templates/exam/user_data.html @@ -30,7 +30,7 @@ Last login: {{ data.user.last_login }} </p> {% if data.papers %} -<p><a href="{{URL_ROOT}}/exam/grade_user/{{ data.user.username }}/"> +<p><a href="{{URL_ROOT}}/exam/manage/grade_user/{{ data.user.username }}/"> Grade/correct paper</a> </p> @@ -75,15 +75,15 @@ User IP address: {{ paper.user_ip }} {% endif %} {# if data.papers #} <br /> <hr /> -<a href="{{URL_ROOT}}/exam/grade_user/{{ data.user.username }}/"> +<a href="{{URL_ROOT}}/exam/manage/grade_user/{{ data.user.username }}/"> Grade/correct paper</a> <br/> {% if data.papers.count > 1 %} -<a href="{{URL_ROOT}}/exam/monitor/"> +<a href="{{URL_ROOT}}/exam/manage/monitor/"> Monitor quiz</a> {% else %} {% with data.papers.0 as paper %} -<a href="{{URL_ROOT}}/exam/monitor/{{paper.quiz.id}}/"> +<a href="{{URL_ROOT}}/exam/manage/monitor/{{paper.quiz.id}}/"> Monitor quiz</a> {% endwith %} {% endif %} diff --git a/testapp/templates/manage.html b/testapp/templates/manage.html index c757523..a21e8c4 100644 --- a/testapp/templates/manage.html +++ b/testapp/templates/manage.html @@ -25,8 +25,8 @@ <div class="span4"> <h5>Manage</h5> <ul> - <li><a href="{{ URL_ROOT }}/exam/manage/addquestion">Add Questions</a></li> - <li><a href="{{ URL_ROOT }}/exam/manage/addquiz">Add Quiz</a></li> + <li><a href="{{ URL_ROOT }}/exam/manage/questions">Questions</a></li> + <li><a href="{{ URL_ROOT }}/exam/manage/addquiz">Quizzes</a></li> <li><a href="{{ URL_ROOT }}/exam/manage/gradeuser">Grade User</a></li> <li><a href="{{ URL_ROOT }}/exam/manage/monitor">Monitor</a></li> </ul> |