summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
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 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