summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorKing2018-07-12 13:01:00 -0700
committerGitHub2018-07-12 13:01:00 -0700
commitf61742f04f417cfb60576f9904afd0dc5c537b3c (patch)
treeffb6fe127dde126e1ee88852c137895de754708f /yaksh/views.py
parent3d9b15c8f8df3c313045cc32f6d4aefaec6f378f (diff)
parent70839496c9e3151f59152498dbca0a3d787bdff2 (diff)
downloadonline_test-f61742f04f417cfb60576f9904afd0dc5c537b3c.tar.gz
online_test-f61742f04f417cfb60576f9904afd0dc5c537b3c.tar.bz2
online_test-f61742f04f417cfb60576f9904afd0dc5c537b3c.zip
Merge pull request #496 from maheshgudi/questions_yaml
Question upload can take yaml and zip files
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 0aa73b8..c6b1184 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -1434,12 +1434,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