summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorankitjavalkar2019-02-19 11:29:28 +0530
committerGitHub2019-02-19 11:29:28 +0530
commit8b5674dbd170307f5acac63fa1c53fd94dbe990e (patch)
tree9e6a3f33c4cfcf5cc97774706e7046c37f680cd7
parentb71b517173cac8b4f266f36d0cbc918551b3ee73 (diff)
parent4b535014a5af1612a81e8ee691e47ef154fa6cae (diff)
downloadonline_test-8b5674dbd170307f5acac63fa1c53fd94dbe990e.tar.gz
online_test-8b5674dbd170307f5acac63fa1c53fd94dbe990e.tar.bz2
online_test-8b5674dbd170307f5acac63fa1c53fd94dbe990e.zip
Merge pull request #577 from CruiseDevice/preview_question_paper_in_quiz
Add Preview QuestionPaper button in Quiz view page
-rw-r--r--yaksh/templates/yaksh/add_quiz.html7
-rw-r--r--yaksh/test_models.py4
-rw-r--r--yaksh/test_views.py12
-rw-r--r--yaksh/views.py2
4 files changed, 17 insertions, 8 deletions
diff --git a/yaksh/templates/yaksh/add_quiz.html b/yaksh/templates/yaksh/add_quiz.html
index c955e65..0762f10 100644
--- a/yaksh/templates/yaksh/add_quiz.html
+++ b/yaksh/templates/yaksh/add_quiz.html
@@ -37,8 +37,13 @@
{% if quiz and course_id %}
{% if quiz.questionpaper_set.get.id %}
<center>
+ <a href="{{URL_ROOT}}/exam/manage/designquestionpaper/{{ quiz.id }}/{{quiz.questionpaper_set.get.id}}/{{course_id}}" class="btn btn-primary">Edit Question Paper</a>
+ <a href="{{URL_ROOT}}/exam/manage/preview_questionpaper/{{quiz.questionpaper_set.get.id}}" class="btn btn-primary" target="_blank">
+ Preview Question Paper
+ </a>
+ <br>
+ <br>
<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 btn-outline-info" type="button" name="button" onClick='usermode("{{URL_ROOT}}/exam/manage/usermode/{{quiz.id}}/{{course_id}}/");'>User Mode</button>
<button class="btn btn-outline-info" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/godmode/{{quiz.id}}/{{course_id}}/");'>
diff --git a/yaksh/test_models.py b/yaksh/test_models.py
index 53ee656..374fb29 100644
--- a/yaksh/test_models.py
+++ b/yaksh/test_models.py
@@ -2144,9 +2144,9 @@ class FileUploadTestCases(unittest.TestCase):
)
def test_get_file_name(self):
- print((self.file_upload.file.path))
self.assertEqual(self.file_upload.get_filename(), self.filename)
def tearDown(self):
- os.remove(self.file_upload.file.path)
+ if os.path.isfile(self.file_upload.file.path):
+ os.remove(self.file_upload.file.path)
self.file_upload.delete()
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 274bcda..70c54e3 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -5017,19 +5017,25 @@ class TestQuestionPaper(TestCase):
)
self.assertEqual(response.status_code, 404)
- def test_preview_qustionpaper_without_quiz_owner(self):
+ def test_preview_questionpaper_without_quiz_owner(self):
self.client.login(
username=self.teacher.username,
password=self.teacher_plaintext_pass
)
- # Should raise an HTTP 404 response
+ # Should pass successfully
response = self.client.get(
reverse('yaksh:preview_questionpaper',
kwargs={"questionpaper_id": self.question_paper.id}
)
)
- self.assertEqual(response.status_code, 404)
+ self.assertEqual(response.status_code, 200)
+ self.assertTemplateUsed(response, 'yaksh/preview_questionpaper.html')
+ self.assertEqual(
+ response.context['questions'],
+ self.questions_list
+ )
+ self.assertEqual(response.context['paper'], self.question_paper)
def test_mcq_attempt_right_after_wrong(self):
""" Case:- Check if answerpaper and answer marks are updated after
diff --git a/yaksh/views.py b/yaksh/views.py
index 6c7a12e..1ea7a22 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -2825,8 +2825,6 @@ def preview_questionpaper(request, questionpaper_id):
if not is_moderator(user):
raise Http404('You are not allowed to view this page!')
paper = QuestionPaper.objects.get(id=questionpaper_id)
- if not paper.quiz.creator == user:
- raise Http404('This questionpaper does not belong to you')
context = {
'questions': paper._get_questions_for_answerpaper(),
'paper': paper,