summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authormaheshgudi2018-07-10 19:18:06 +0530
committermaheshgudi2018-07-10 19:18:06 +0530
commit727bcd630f30445e767583ceb65fdbf3ff65c2a0 (patch)
tree95f0fa4417ebed0ef2ef12660850f1b5e5fd68bb /yaksh
parent4eb754c2e71922819de7390d1b4993a21763de3e (diff)
downloadonline_test-727bcd630f30445e767583ceb65fdbf3ff65c2a0.tar.gz
online_test-727bcd630f30445e767583ceb65fdbf3ff65c2a0.tar.bz2
online_test-727bcd630f30445e767583ceb65fdbf3ff65c2a0.zip
Can directly upload yaml questions without zip
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/views.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 3341aca..21b9d2d 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -1413,12 +1413,15 @@ def show_all_questions(request):
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
questions_file = request.FILES['file']
- file_name = questions_file.name.split('.')
- if file_name[-1] == "zip":
- ques = Question()
+ file_extension = questions_file.name.split('.')[-1]
+ ques = Question()
+ if file_extension == "zip":
files, extract_path = extract_files(questions_file)
context['message'] = ques.read_yaml(extract_path, user,
files)
+ elif file_extension in ["yaml", "yml"]:
+ questions = questions_file.read()
+ context['message'] = ques.load_questions(questions, user)
else:
message = "Please Upload a ZIP file"
context['message'] = message