From 66e8f39bb390b3ec2547d82512349fabf67e3d7c Mon Sep 17 00:00:00 2001 From: mahesh Date: Mon, 31 Jul 2017 17:22:54 +0530 Subject: Adds yaml serialization to download and upload questions --- yaksh/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index c10ba6a..7e73a28 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1015,7 +1015,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" -- cgit From d5332431f7c042e7e16183f76dee70269bbebded Mon Sep 17 00:00:00 2001 From: mahesh Date: Thu, 3 Aug 2017 02:07:47 +0530 Subject: Modifies UI for questions section --- yaksh/views.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 7e73a28..68253bc 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1590,3 +1590,20 @@ 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__), "demo_templates", + "yaml_question_template" + ) + with open(template_path, 'r') as f: + yaml_str = f.read() + response = HttpResponse(yaml_str, content_type='text/yaml') + response['Content-Disposition'] = 'attachment; filename="questions_dump.yaml"' + + return response + -- cgit From 30b48c30abebf75ed4b51fd034600e0c7d58c95b Mon Sep 17 00:00:00 2001 From: mahesh Date: Fri, 25 Aug 2017 01:33:08 +0530 Subject: Fixes order in demo_questions.zip - Template yaml is now generated on the fly. - Removes yaml_question_template files. - Fixes order for yaml file inside demo_questions.zip --- yaksh/views.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 81d180b..3c7df4d 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1622,13 +1622,14 @@ 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__), "demo_templates", - "yaml_question_template" + template_path = os.path.join(os.path.dirname(__file__), "fixtures", + "demo_questions.zip" ) - with open(template_path, 'r') as f: - yaml_str = f.read() - response = HttpResponse(yaml_str, content_type='text/yaml') - response['Content-Disposition'] = 'attachment; filename="questions_dump.yaml"' + 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 -- cgit