diff options
author | CruiseDevice | 2018-11-11 01:03:11 +0530 |
---|---|---|
committer | CruiseDevice | 2019-01-28 13:07:02 +0530 |
commit | ae5e8ca5eb5d47afb14ba83e665de6f10e46bdac (patch) | |
tree | 3a275aa025fc294dbee88fab3e354305378882c9 /yaksh | |
parent | 53e43a65f0b47557da035597f37b4ee9a9d5e290 (diff) | |
download | online_test-ae5e8ca5eb5d47afb14ba83e665de6f10e46bdac.tar.gz online_test-ae5e8ca5eb5d47afb14ba83e665de6f10e46bdac.tar.bz2 online_test-ae5e8ca5eb5d47afb14ba83e665de6f10e46bdac.zip |
Fix #525
- Categorize questions into objectives, blanks, upload and programming.
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/static/yaksh/css/exam.css | 8 | ||||
-rw-r--r-- | yaksh/static/yaksh/css/yakshcustom.css | 2 | ||||
-rw-r--r-- | yaksh/templates/exam.html | 77 | ||||
-rw-r--r-- | yaksh/templatetags/custom_filters.py | 5 | ||||
-rw-r--r-- | yaksh/views.py | 58 |
5 files changed, 114 insertions, 36 deletions
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,10 +1,5 @@ {% extends "base.html" %} {% load custom_filters %} - - - - -{% load custom_filters %} {% block nav %} <div class="container-fluid yakshnav"> <nav class="navbar fixed-top navbar-expand-lg yakshheading yakshnav"> @@ -83,28 +78,56 @@ <p class="text-center">Question(s) left: <b>{{ paper.questions_left }}</b></p> </div> <br> - <div class=""> - <div class=""> - <div class=""> - {% 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 %} - ---> - <b> {% for question in questions_by_type %} {{question.id}} {%endfor%} </b> - <br> - {%endfor%} - </div> - </div> - </div> - + <table class = "table table-bordered table-sm"> + <thead> + <tr> + <th>Category</th> + <th>Question No.</th> + </tr> + </thead> + <tbody> + {% if index.objectives_index %} + <tr> + <td> + Objectives: + </td> + <td> + {{index.objectives_index|join:", "}} + </td> + </tr> + {% endif %} + {% if index.blanks_index %} + <tr> + <td> + Blanks: + </td> + <td> + {{index.blanks_index|join:", "}} + </td> + </tr> + {% endif %} + {% if index.upload_index %} + <tr> + <td> + Upload: + </td> + <td> + {{index.upload_index|join:", "}} + </td> + </tr> + {% endif %} + {% if index.programming_index %} + <tr> + <td> + Programming: + </td> + <td> + {{index.programming_index|join:", "}} + </td> + </tr> + {% endif %} + </tbody> + </table> </div> <!--end of sidebar --> <a href="#sidebar" data-toggle="collapse" id="sidebaricon"><i class="fa fa-navicon fa-lg"></i></a> 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 @@ -85,10 +85,5 @@ def replace_spaces(name): @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: |