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/demo_templates/yaml_question_template | 90 +++++++++++++++++++++++++++++ yaksh/static/yaksh/js/show_question.js | 4 ++ yaksh/templates/yaksh/showquestions.html | 86 ++++++++++++++++++++++----- yaksh/urls.py | 4 +- yaksh/views.py | 17 ++++++ 5 files changed, 187 insertions(+), 14 deletions(-) create mode 100644 yaksh/demo_templates/yaml_question_template (limited to 'yaksh') diff --git a/yaksh/demo_templates/yaml_question_template b/yaksh/demo_templates/yaml_question_template new file mode 100644 index 0000000..4de9274 --- /dev/null +++ b/yaksh/demo_templates/yaml_question_template @@ -0,0 +1,90 @@ +--- +# Yaml Template for writing questions +# Always keep the name of this file as questions_dump.yaml +# Zip this file with necessary dependent files. + +active: true +# question status = true or false + +description: "Write a function product(a,b) which will take + two integers and return the product of it.
+ " +# Entire question description. + +files: [] +# [[file name, zip_extract_status=true or false]] + +language: python +# bash, scilab, python, c/c++, java + +points: 1.0 +# marks in float + +snippet: "def sum(a,b):" +# adds in the student's code area + +summary: Product of two numbers +# one line short Summary +testcase: +- test_case_type: standardtestcase + test_case: assert sum(3,5) == 15 + test_case_args: "" + weight: 1.0 +#testcase 1 + +- test_case_type: standardtestcase + test_case: assert sum(10,10) == 100 + test_case_args: "" + weight: 1.0 +#testcase 2 + +# for standard testcase: + # - test_case_type: standardtestcase + # test_case: test case in the selected language + # test_case_args: command line args (only for bash) + # weight: weightage for each course + +# for stdIO testcase: + # - test_case_type: stdiobasedtestcase + # expected_input: Standard input given to the students' code. (Optional) + # expected_input: Standard output expected from the students' code. + # weight: weightage for each course + +# for MCQ/MCC testcase: + # - test_case_type: mcqtestcase + # options: MCQ/MCC option. + # correct: true or false. + +# for Hook testcase: + # - test_case_type: hooktestcase + # hook_code: Selected language code written by moderator (Optional) + # weight: weightage for each course + +# for Integer testcase: + # - test_case_type: integertestcase + # correct: Correct integer value + +# for Float testcase: + # - test_case_type: floattestcase + # correct: Correct float value + # error_margin: Margin of error allowed + +# for String testcase: + # - test_case_type: stringtestcase + # correct: Exact string to be compared + # string_check: lower or exact.(case insensitive or sensitive) + +type: code +# mcq, Single Correct Choice, +# mcc, Multiple Correct Choices, +# code, Code Question, +# upload, Assignment Upload, +# integer, Answer in Integer, +# string, Answer in String, +# float, Answer in Float + +grade_assignment_upload: false +# Grade uploaded assignment (works with hook)true or false + +partial_grading: false +# partial grading with respect to each testcase. diff --git a/yaksh/static/yaksh/js/show_question.js b/yaksh/static/yaksh/js/show_question.js index e3ed1cc..7cfbf4c 100644 --- a/yaksh/static/yaksh/js/show_question.js +++ b/yaksh/static/yaksh/js/show_question.js @@ -37,3 +37,7 @@ function confirm_edit(frm) else return true; } +$(document).ready(function() + { + $("#questions-table").tablesorter({sortList: [[]]}); + }); \ No newline at end of file diff --git a/yaksh/templates/yaksh/showquestions.html b/yaksh/templates/yaksh/showquestions.html index a136ddf..78be301 100644 --- a/yaksh/templates/yaksh/showquestions.html +++ b/yaksh/templates/yaksh/showquestions.html @@ -2,31 +2,62 @@ {% block title %} Questions {% endblock %} -{% block pagetitle %} List of Questions {% endblock pagetitle %} +{% block pagetitle %} Questions {% endblock pagetitle %} {% block script %} + {% endblock %} {% block content %} - -

Upload ZIP file for adding questions

+
+ +
+ +
+ Download Template +
+

Or

{% csrf_token %} -{{ upload_form.as_p }} - + {{ upload_form.as_p }} +
+

And

+
+
+ + + +
+
+{% csrf_token %} {% if message %} -

{{ message }}

+{%if message == "Questions Uploaded Successfully"%} +
+× + {{ message }} +
+{%else %} +
+ × + {{ message }} +
+{% endif %} {% endif %} {% if msg %} -

{{ msg }}

+
+ × + {{ msg }} +
{% endif %} -

- -{% csrf_token %}
Filters
@@ -46,17 +77,46 @@ Upload File
{% if questions %}
Select All
+ + + + + + + + + + + + + {% for i in questions %} -  {{ i }}
+ + + + + + + {% endfor %} + +
Select Summary Language Type Marks
+ +{{i.summary|capfirst}}{{i.language|capfirst}}{{i.type|capfirst}}{{i.points}}
{% endif %}

+
   {% if questions %}       {% endif %} +
-{% endblock %} +
+
+
+ +{% endblock %} \ No newline at end of file diff --git a/yaksh/urls.py b/yaksh/urls.py index 5270068..87ee655 100644 --- a/yaksh/urls.py +++ b/yaksh/urls.py @@ -105,5 +105,7 @@ urlpatterns = [ url(r'^manage/download/user_assignment/(?P\d+)/(?P\d+)/(?P\d+)/$', views.download_assignment_file, name="download_user_assignment"), url(r'^manage/download/quiz_assignments/(?P\d+)/$', - views.download_assignment_file, name="download_quiz_assignment") + views.download_assignment_file, name="download_quiz_assignment"), + url(r'^manage/courses/download_yaml_template/', + views.download_yaml_template, name="download_yaml_template"), ] 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