summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authormaheshgudi2016-09-06 15:14:50 +0530
committermaheshgudi2016-09-06 15:14:50 +0530
commit8b01d249b7ccdff9d75447a6b12eb96641e795e7 (patch)
tree5464e51a2445fd1384c790dac891bcc800e2a2e1 /yaksh
parent848f7945811f1d16bdf8d5e2a99d157d9ed9a18c (diff)
downloadonline_test-8b01d249b7ccdff9d75447a6b12eb96641e795e7.tar.gz
online_test-8b01d249b7ccdff9d75447a6b12eb96641e795e7.tar.bz2
online_test-8b01d249b7ccdff9d75447a6b12eb96641e795e7.zip
changed test cases to reflect changes in addquiz view function
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/test_views.py22
-rw-r--r--yaksh/views.py3
2 files changed, 17 insertions, 8 deletions
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index e232bc0..7d23ce9 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -213,8 +213,11 @@ class TestAddQuiz(TestCase):
"""
If not logged in redirect to login page
"""
- response = self.client.get(reverse('yaksh:add_quiz'), follow=True)
- redirect_destination = '/exam/login/?next=/exam/manage/addquiz/'
+ response = self.client.get(reverse('yaksh:add_quiz',
+ kwargs={'course_id': self.course.id}),
+ follow=True
+ )
+ redirect_destination = '/exam/login/?next=/exam/manage/addquiz/{0}/'.format(self.course.id)
self.assertRedirects(response, redirect_destination)
def test_view_profile_denies_non_moderator(self):
@@ -225,8 +228,11 @@ class TestAddQuiz(TestCase):
username=self.student.username,
password=self.student_plaintext_pass
)
-
- response = self.client.get(reverse('yaksh:add_quiz'), follow=True)
+ course_id = self.course.id
+ response = self.client.get(reverse('yaksh:add_quiz',
+ kwargs={'course_id': self.course.id}),
+ follow=True
+ )
self.assertEqual(response.status_code, 404)
def test_add_quiz_get(self):
@@ -237,7 +243,9 @@ class TestAddQuiz(TestCase):
username=self.user.username,
password=self.user_plaintext_pass
)
- response = self.client.get(reverse('yaksh:add_quiz'))
+ response = self.client.get(reverse('yaksh:add_quiz',
+ kwargs={'course_id': self.course.id})
+ )
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'yaksh/add_quiz.html')
self.assertIsNotNone(response.context['form'])
@@ -252,7 +260,7 @@ class TestAddQuiz(TestCase):
)
tzone = pytz.timezone('UTC')
response = self.client.post(reverse('yaksh:edit_quiz',
- kwargs={'quiz_id': self.quiz.id}),
+ kwargs={'course_id':self.course.id, 'quiz_id': self.quiz.id}),
data={
'start_date_time': '2016-01-10 09:00:15',
'end_date_time': '2016-01-15 09:00:15',
@@ -298,7 +306,7 @@ class TestAddQuiz(TestCase):
)
tzone = pytz.timezone('UTC')
- response = self.client.post(reverse('yaksh:add_quiz'),
+ response = self.client.post(reverse('yaksh:add_quiz', kwargs={"course_id": self.course.id}),
data={
'start_date_time': '2016-01-10 09:00:15',
'end_date_time': '2016-01-15 09:00:15',
diff --git a/yaksh/views.py b/yaksh/views.py
index 0fb2214..dcf6133 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -250,8 +250,9 @@ def add_quiz(request, course_id, quiz_id=None):
"""To add a new quiz in the database.
Create a new quiz and store it."""
user = request.user
+ course = Course.objects.get(id=course_id)
ci = RequestContext(request)
- if not is_moderator(user):
+ if not is_moderator(user) or (user != course.creator and user not in course.teachers.all()):
raise Http404('You are not allowed to view this page!')
context = {}
if request.method == "POST":