summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authoradityacp2017-03-10 11:10:09 +0530
committeradityacp2017-03-10 11:10:09 +0530
commit2955c57b10c33a12b9c6def60169ee2105ca20e4 (patch)
treedfe44e031ecc48a794fc01d333f3b89d41a10a86 /yaksh/views.py
parentce7238aef6d5080d8f7ea79b96c9569bf191f0b8 (diff)
downloadonline_test-2955c57b10c33a12b9c6def60169ee2105ca20e4.tar.gz
online_test-2955c57b10c33a12b9c6def60169ee2105ca20e4.tar.bz2
online_test-2955c57b10c33a12b9c6def60169ee2105ca20e4.zip
Changes in models and views
- Display error message if questions_dump.json is not found in zip file - Provide a sample zip file to for easy zip file creation
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 63653e6..02019f4 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -20,7 +20,6 @@ import pytz
from taggit.models import Tag
from itertools import chain
import json
-import zipfile
import six
# Local imports.
from yaksh.models import get_model_class, Quiz, Question, QuestionPaper, QuestionSet, Course
@@ -31,6 +30,7 @@ from yaksh.forms import UserRegisterForm, UserLoginForm, QuizForm,\
QuestionFilterForm, CourseForm, ProfileForm, UploadFileForm,\
get_object_form, FileForm, QuestionPaperForm
from .settings import URL_ROOT
+from django.conf import settings
from yaksh.models import AssignmentUpload
from .file_utils import extract_files
@@ -894,7 +894,8 @@ def show_all_questions(request):
if request.POST.get('delete') == 'delete':
data = request.POST.getlist('question')
if data is not None:
- questions = Question.objects.filter(id__in=data, user_id=user.id, active=True)
+ questions = Question.objects.filter(id__in=data, user_id=user.id,
+ active=True)
for question in questions:
question.active = False
question.save()
@@ -907,7 +908,8 @@ def show_all_questions(request):
if file_name[-1] == "zip":
ques = Question()
files, extract_path = extract_files(questions_file)
- ques.read_json(extract_path, user, files)
+ context['message'] = ques.read_json(extract_path, user,
+ files)
else:
message = "Please Upload a ZIP file"
context['message'] = message
@@ -947,6 +949,17 @@ def show_all_questions(request):
return my_render_to_response('yaksh/showquestions.html', context,
context_instance=ci)
+@login_required
+def download_demo_questions(request):
+ user = request.user
+ if not is_moderator(user):
+ raise Http404("You are not allowed to download!")
+ f_path = os.path.join(settings.FIXTURE_DIRS, "demo_questions.zip")
+ zip_file = open(f_path, "rb")
+ response = HttpResponse(zip_file, content_type='application/zip')
+ response['Content-Disposition'] = '''attachment;\
+ filename=demo_questions.zip'''
+ return response
@login_required
def user_data(request, user_id, questionpaper_id=None):