diff options
author | Prabhu Ramachandran | 2017-08-25 08:40:58 +0530 |
---|---|---|
committer | GitHub | 2017-08-25 08:40:58 +0530 |
commit | 9e0f737c25a5156aa884d27357af0aef1145c4b7 (patch) | |
tree | 53ad33f61c239271f62ee2054ad79cb76688645d /yaksh/views.py | |
parent | 9d5c4a01fd7856f1ef8793b75a9734324c254344 (diff) | |
parent | 30b48c30abebf75ed4b51fd034600e0c7d58c95b (diff) | |
download | online_test-9e0f737c25a5156aa884d27357af0aef1145c4b7.tar.gz online_test-9e0f737c25a5156aa884d27357af0aef1145c4b7.tar.bz2 online_test-9e0f737c25a5156aa884d27357af0aef1145c4b7.zip |
Merge pull request #312 from maheshgudi/yaml_questions
Yaml serialized questions
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index 823e506..3c7df4d 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1050,7 +1050,7 @@ def show_all_questions(request): if file_name[-1] == "zip": ques = Question() files, extract_path = extract_files(questions_file) - context['message'] = ques.read_json(extract_path, user, + context['message'] = ques.read_yaml(extract_path, user, files) else: message = "Please Upload a ZIP file" @@ -1615,3 +1615,21 @@ def duplicate_course(request, course_id): 'instructor/administrator.' return complete(request, msg, attempt_num=None, questionpaper_id=None) return my_redirect('/exam/manage/courses/') + +@login_required +@email_verified +def download_yaml_template(request): + user = request.user + if not is_moderator(user): + raise Http404('You are not allowed to view this page!') + template_path = os.path.join(os.path.dirname(__file__), "fixtures", + "demo_questions.zip" + ) + yaml_file = zipfile.ZipFile(template_path, 'r') + template_yaml = yaml_file.open('questions_dump.yaml', 'r') + response = HttpResponse(template_yaml, content_type='text/yaml') + response['Content-Disposition'] = 'attachment;\ + filename="questions_dump.yaml"' + + return response + |