From ae5e8ca5eb5d47afb14ba83e665de6f10e46bdac Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Sun, 11 Nov 2018 01:03:11 +0530 Subject: Fix #525 - Categorize questions into objectives, blanks, upload and programming. --- yaksh/static/yaksh/css/exam.css | 8 +++- yaksh/static/yaksh/css/yakshcustom.css | 2 - yaksh/templates/exam.html | 77 ++++++++++++++++++++++------------ yaksh/templatetags/custom_filters.py | 5 --- yaksh/views.py | 58 ++++++++++++++++++++++++- 5 files changed, 114 insertions(+), 36 deletions(-) (limited to 'yaksh') diff --git a/yaksh/static/yaksh/css/exam.css b/yaksh/static/yaksh/css/exam.css index b0bb379..e420166 100644 --- a/yaksh/static/yaksh/css/exam.css +++ b/yaksh/static/yaksh/css/exam.css @@ -1,7 +1,13 @@ -table td, table th { border: #ff8295 solid 1px !important; +#assertion td, #assertion th, #stdio td, #stdio th { border: #ff8295 solid 1px !important; word-wrap: break-word !important; white-space: pre-wrap !important; } #stdio, #assertion { table-layout: fixed } +.table{ + border: 1px solid; + background-color: white; + border-spacing: 5px; + border-collapse: collapse; +} diff --git a/yaksh/static/yaksh/css/yakshcustom.css b/yaksh/static/yaksh/css/yakshcustom.css index 86403ac..a9b4349 100644 --- a/yaksh/static/yaksh/css/yakshcustom.css +++ b/yaksh/static/yaksh/css/yakshcustom.css @@ -228,5 +228,3 @@ html { overflow-y: auto; -ms-overflow-style: -ms-autohiding-scrollbar; } - -/*---------------------*/ \ No newline at end of file diff --git a/yaksh/templates/exam.html b/yaksh/templates/exam.html index c452929..8c65e2b 100644 --- a/yaksh/templates/exam.html +++ b/yaksh/templates/exam.html @@ -1,9 +1,4 @@ {% extends "base.html" %} -{% load custom_filters %} - - - - {% load custom_filters %} {% block nav %}
@@ -83,28 +78,56 @@

Question(s) left: {{ paper.questions_left }}


-
-
-
- {% for types in question_types %} - {% get_questions_by_type paper.get_all_ordered_questions types as questions_by_type %} - {% if types == "mcq" %} Single Correct Choice - {% elif types == "mcc" %} Multiple Correct Choice - {% elif types == "code" %} Programming - {% elif types == "upload" %} Assignment Upload - {% elif types == "integer" %} Integer Blanks - {% elif types == "string" %} String Blanks - {% elif types == "float" %} Float Blanks - {% elif types == "arrange" %} Arranging Options - {% endif %} - ---> - {% for question in questions_by_type %} {{question.id}} {%endfor%} -
- {%endfor%} -
-
-
- + + + + + + + + + {% if index.objectives_index %} + + + + + {% endif %} + {% if index.blanks_index %} + + + + + {% endif %} + {% if index.upload_index %} + + + + + {% endif %} + {% if index.programming_index %} + + + + + {% endif %} + +
CategoryQuestion No.
+ Objectives: + + {{index.objectives_index|join:", "}} +
+ Blanks: + + {{index.blanks_index|join:", "}} +
+ Upload: + + {{index.upload_index|join:", "}} +
+ Programming: + + {{index.programming_index|join:", "}} +
diff --git a/yaksh/templatetags/custom_filters.py b/yaksh/templatetags/custom_filters.py index dcae7f9..29f4b59 100644 --- a/yaksh/templatetags/custom_filters.py +++ b/yaksh/templatetags/custom_filters.py @@ -84,11 +84,6 @@ def replace_spaces(name): return name.replace(" ", "_") -@register.simple_tag -def get_questions_by_type(all_questions, question_type): - return [question for question in all_questions if question.type == question_type] - - @register.simple_tag def course_grade(course, user): return course.get_grade(user) diff --git a/yaksh/views.py b/yaksh/views.py index 0f81931..af4eec1 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -561,6 +561,20 @@ def start(request, questionpaper_id=None, attempt_num=None, course_id=None, raise Http404(msg) +def _get_question_by_index(all_ordered_questions, questions_by_type): + return [index+1 for index, item in enumerate(all_ordered_questions) + if item in set(questions_by_type)] + + +def _get_questions_by_type(all_ordered_questions, objective_types): + questions_by_type = [] + for types in objective_types: + for question in all_ordered_questions: + if question.type == types: + questions_by_type.append(question) + return _get_question_by_index(all_ordered_questions, questions_by_type) + + @login_required @email_verified def show_question(request, question, paper, error_message=None, @@ -568,6 +582,7 @@ def show_question(request, question, paper, error_message=None, previous_question=None): """Show a question if possible.""" quiz = paper.question_paper.quiz + questions = paper.questions.all() quiz_type = 'Exam' can_skip = False if previous_question: @@ -616,6 +631,46 @@ def show_question(request, question, paper, error_message=None, module = course.learning_module.get(id=module_id) all_modules = course.get_learning_modules() all_question_types = [types[0] for types in question_types] + types = {} + categories = {} + categories["objectives"] = questions.filter(Q(type="mcq") | + Q(type="mcc") | + Q(type="arrange")) + categories["blanks"] = questions.filter(Q(type="integer") | + Q(type="string") | + Q(type="float")) + categories["programming"] = questions.filter(Q(type="code")) + categories["upload"] = questions.filter(Q(type="upload")) + types["objective_types"] = set([type_.type + for type_ in categories["objectives"]]) + types["blank_types"] = set([type_.type + for type_ in categories["blanks"]]) + types["programming_types"] = set([type_.type + for type_ in categories["programming"]]) + types["upload_types"] = set([type_.type + for type_ in categories["upload"]]) + all_ordered_questions = paper.get_all_ordered_questions() + objectives_index = _get_questions_by_type( + all_ordered_questions, + types["objective_types"] + ) + blanks_index = _get_questions_by_type( + all_ordered_questions, + types["blank_types"] + ) + programming_index = _get_questions_by_type( + all_ordered_questions, + types["programming_types"] + ) + upload_index = _get_questions_by_type( + all_ordered_questions, + types["upload_types"] + ) + index = {} + index["objectives_index"] = objectives_index + index["blanks_index"] = blanks_index + index["programming_index"] = programming_index + index["upload_index"] = upload_index context = { 'question': question, 'paper': paper, @@ -631,7 +686,8 @@ def show_question(request, question, paper, error_message=None, 'delay_time': delay_time, 'quiz_type': quiz_type, 'all_modules': all_modules, - "question_types": all_question_types + "question_types": all_question_types, + "index": index, } answers = paper.get_previous_answers(question) if answers: -- cgit