diff options
author | King | 2018-07-12 13:01:00 -0700 |
---|---|---|
committer | GitHub | 2018-07-12 13:01:00 -0700 |
commit | f61742f04f417cfb60576f9904afd0dc5c537b3c (patch) | |
tree | ffb6fe127dde126e1ee88852c137895de754708f /yaksh/views.py | |
parent | 3d9b15c8f8df3c313045cc32f6d4aefaec6f378f (diff) | |
parent | 70839496c9e3151f59152498dbca0a3d787bdff2 (diff) | |
download | online_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.py | 9 |
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 |