summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradityacp2018-01-19 15:58:06 +0530
committeradityacp2018-01-19 17:01:44 +0530
commitbfc3f08d5da08f774e76aa169a50f8e7847ff6ed (patch)
tree7405617e9351e724db5269e55d915ad6cbaff01d
parent6da1f77a6a1a2bffb85d5395f2703f186b18cb4a (diff)
downloadonline_test-bfc3f08d5da08f774e76aa169a50f8e7847ff6ed.tar.gz
online_test-bfc3f08d5da08f774e76aa169a50f8e7847ff6ed.tar.bz2
online_test-bfc3f08d5da08f774e76aa169a50f8e7847ff6ed.zip
Change in views and templates
- Add active field for exercise form - Fix views test case for creating exercise - Show question paper for exercise
-rw-r--r--yaksh/forms.py2
-rw-r--r--yaksh/templates/yaksh/add_exercise.html46
-rw-r--r--yaksh/templates/yaksh/add_quiz.html44
-rw-r--r--yaksh/test_views.py2
-rw-r--r--yaksh/views.py7
5 files changed, 63 insertions, 38 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py
index 8399bc9..9fd2eaa 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -176,7 +176,7 @@ class UserLoginForm(forms.Form):
class ExerciseForm(forms.ModelForm):
class Meta:
model = Quiz
- fields = ['description', 'view_answerpaper']
+ fields = ['description', 'view_answerpaper', 'active']
class QuizForm(forms.ModelForm):
diff --git a/yaksh/templates/yaksh/add_exercise.html b/yaksh/templates/yaksh/add_exercise.html
index dac35d4..77e3ee8 100644
--- a/yaksh/templates/yaksh/add_exercise.html
+++ b/yaksh/templates/yaksh/add_exercise.html
@@ -14,17 +14,41 @@
{% block content %}
<form name=frm id=frm action="" method="post" >
- {% csrf_token %}
- <center>
- <table class="span1 table">
- {{ form.as_table }}
- </table>
- <br/><br/>
- </center>
+ {% csrf_token %}
+ <center>
+ <table class="span1 table">
+ {{ form.as_table }}
+ </table>
+ <br/><br/>
+ </center>
+ <center><button class="btn" type="submit" id="submit" name="save_exercise"> Save
+ </button>
- <center><button class="btn" type="submit" id="submit" name="questionpaper"> Save
- </button>
-
- <button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/courses/");'>Cancel</button> </center>
+ <button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/courses/");'>Cancel</button> </center>
</form>
+{% if exercise and course_id %}
+ {% if exercise.questionpaper_set.get.id %}
+ <center>
+ <h4>You can check the quiz by attempting it in the following modes:</h4>
+ <a href="{{URL_ROOT}}/exam/manage/designquestionpaper/{{ exercise.id }}/{{exercise.questionpaper_set.get.id}}/{{course_id}}" class="btn btn-primary">View Question Paper</a>
+ <button class="btn" type="button" name="button" onClick='usermode("{{URL_ROOT}}/exam/manage/usermode/{{exercise.id}}/{{course_id}}/");'>User Mode</button>
+
+ <button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/godmode/{{exercise.id}}/{{course_id}}/");'>
+ God Mode</button>
+ <a data-toggle="collapse" data-target="#help">
+ <span class="glyphicon glyphicon-info-sign">Help</span></a>
+ <div id="help" class="collapse">
+ <br/>
+ <ul>
+ <li><b>User Mode:</b> Attempt quiz the way normal users will attempt i.e. -
+ <ul>
+ <li><i>Quiz will have the same duration as that of the original quiz.</li>
+ <li>Quiz won't start if the course is inactive or the quiz time has expired.</li>
+ <li>You will be notified about quiz prerequisites.(You can still attempt the quiz though)</i></li>
+ </ul>
+ </p>
+ <li> <b>God Mode:</b> Attempt quiz without any time or eligibilty constraints.</p>
+ </div>
+ {% endif %}
+{% endif %}
{% endblock %}
diff --git a/yaksh/templates/yaksh/add_quiz.html b/yaksh/templates/yaksh/add_quiz.html
index bfd8aa1..684f804 100644
--- a/yaksh/templates/yaksh/add_quiz.html
+++ b/yaksh/templates/yaksh/add_quiz.html
@@ -35,32 +35,34 @@
</form>
<br>
-{% if quiz_id and course_id %}
+{% if quiz and course_id %}
+ {% if quiz.questionpaper_set.get.id %}
<center>
<h4>You can check the quiz by attempting it in the following modes:</h4>
- <a href="{{URL_ROOT}}/exam/manage/designquestionpaper/{{ quiz_id }}/{{quiz.questionpaper_set.get.id}}/{{course_id}}" class="btn btn-primary">View Question Paper</a>
- <button class="btn" type="button" name="button" onClick='usermode("{{URL_ROOT}}/exam/manage/usermode/{{quiz_id}}/{{course_id}}/");'>User Mode</button>
-
- <button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/godmode/{{quiz_id}}/{{course_id}}/");'>
- God Mode</button>
+ <a href="{{URL_ROOT}}/exam/manage/designquestionpaper/{{ quiz.id }}/{{quiz.questionpaper_set.get.id}}/{{course_id}}" class="btn btn-primary">View Question Paper</a>
+ <button class="btn" type="button" name="button" onClick='usermode("{{URL_ROOT}}/exam/manage/usermode/{{quiz.id}}/{{course_id}}/");'>User Mode</button>
+
+ <button class="btn" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/godmode/{{quiz.id}}/{{course_id}}/");'>
+ God Mode</button>
<a data-toggle="collapse" data-target="#help">
<span class="glyphicon glyphicon-info-sign">Help</span></a>
- <div id="help" class="collapse">
- <br/>
- <ul>
- <li><b>User Mode:</b> Attempt quiz the way normal users will attempt i.e. -
- <ul>
- <li><i>Quiz will have the same duration as that of the original quiz.</li>
- <li>Quiz won't start if the course is inactive or the quiz time has expired.</li>
- <li>You will be notified about quiz prerequisites.(You can still attempt the quiz though)</i></li>
- </ul>
- </p>
- <li> <b>God Mode:</b> Attempt quiz without any time or eligibilty constraints.</p>
- </div>
- {% endif %}
- <style type="text/css">
+ <div id="help" class="collapse">
+ <br/>
+ <ul>
+ <li><b>User Mode:</b> Attempt quiz the way normal users will attempt i.e. -
+ <ul>
+ <li><i>Quiz will have the same duration as that of the original quiz.</li>
+ <li>Quiz won't start if the course is inactive or the quiz time has expired.</li>
+ <li>You will be notified about quiz prerequisites.(You can still attempt the quiz though)</i></li>
+ </ul>
+ </p>
+ <li> <b>God Mode:</b> Attempt quiz without any time or eligibilty constraints.</p>
+ </div>
+ {% endif %}
+{% endif %}
+<style type="text/css">
#rendered_text{
width: 550px;
}
- </style>
+</style>
{% endblock %}
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index dad5e89..0b43079 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -1230,6 +1230,7 @@ class TestAddQuiz(TestCase):
kwargs={'quiz_id': self.exercise.id}),
data={
'description': 'updated demo exercise',
+ 'active': True
}
)
@@ -1257,6 +1258,7 @@ class TestAddQuiz(TestCase):
response = self.client.post(reverse('yaksh:add_exercise'),
data={
'description': "Demo Exercise",
+ 'active': True
}
)
quiz_list = Quiz.objects.all().order_by('-id')
diff --git a/yaksh/views.py b/yaksh/views.py
index 4ff1032..98cd010 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -320,9 +320,7 @@ def add_quiz(request, quiz_id=None, course_id=None):
return my_redirect("/exam/manage/courses/")
else:
- quiz = Quiz.objects.get(id=quiz_id) if quiz_id else None
form = QuizForm(instance=quiz)
- context["quiz_id"] = quiz_id
context["course_id"] = course_id
context["quiz"] = quiz
context["form"] = form
@@ -347,7 +345,7 @@ def add_exercise(request, quiz_id=None, course_id=None):
if course_id:
course = get_object_or_404(Course, pk=course_id)
if not course.is_creator(user) and not course.is_teacher(user):
- raise Http404('This quiz does not belong to you')
+ raise Http404('This Course does not belong to you')
context = {}
if request.method == "POST":
@@ -371,9 +369,8 @@ def add_exercise(request, quiz_id=None, course_id=None):
return my_redirect("/exam/manage/courses/")
else:
- quiz = Quiz.objects.get(id=quiz_id) if quiz_id else None
form = ExerciseForm(instance=quiz)
- context["quiz_id"] = quiz_id
+ context["exercise"] = quiz
context["course_id"] = course_id
context["form"] = form
return my_render_to_response(