From f050dd919d5719874aafadf0a674d816a25bc9eb Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Wed, 29 Apr 2020 22:11:19 +0530 Subject: Fix: #696 --- yaksh/forms.py | 3 +++ yaksh/models.py | 3 +++ yaksh/static/yaksh/js/add_question.js | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/yaksh/forms.py b/yaksh/forms.py index 216f5c2..1cd1291 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -298,6 +298,9 @@ class QuestionForm(forms.ModelForm): self.fields['language'].widget.attrs.update( {'class': 'custom-select'} ) + self.fields['topic'].widget.attrs.update( + {'class': 'custom-select'} + ) self.fields['type'].widget.attrs.update( {'class': 'custom-select'} ) diff --git a/yaksh/models.py b/yaksh/models.py index 9bcb132..d67a8e3 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -49,6 +49,7 @@ languages = ( ("java", "Java Language"), ("scilab", "Scilab"), ("r", "R"), + ("other", "Other") ) question_types = ( @@ -1292,6 +1293,8 @@ class Question(models.Model): language = models.CharField(max_length=24, choices=languages) + topic = models.CharField(max_length=50, blank=True, null=True) + # The type of question. type = models.CharField(max_length=24, choices=question_types) diff --git a/yaksh/static/yaksh/js/add_question.js b/yaksh/static/yaksh/js/add_question.js index 6cd8b48..1358710 100644 --- a/yaksh/static/yaksh/js/add_question.js +++ b/yaksh/static/yaksh/js/add_question.js @@ -192,3 +192,30 @@ function autosubmit() } } + +$(document).ready(() => { + let option = $('#id_language').val(); + if(option === 'other') { + $('#id_topic').closest('tr').show(); + } else { + $('#id_topic').closest('tr').hide(); + } + $('#id_language').change(function() { + let value = $(this).val(); + if (value === "other") { + $('#id_topic').closest('tr').show(); + $('#id_type').children("option[value='code']").hide(); + } else { + $('#id_topic').closest('tr').hide(); + $('#id_type').children("option[value='code']").show(); + } + }); + $('#id_type').change(function() { + let value = $(this).val(); + if (value === "code") { + $('#id_language').children("option[value='other']").hide(); + } else { + $('#id_language').children("option[value='other']").show(); + } + }) +}); \ No newline at end of file -- cgit From 31e8b94b8ebf74d77cc8596411c6acfa2112f949 Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Mon, 4 May 2020 16:25:50 +0530 Subject: Show question topic and language in quiz --- yaksh/forms.py | 2 +- yaksh/static/yaksh/css/custom.css | 7 ++++++ yaksh/templates/yaksh/question.html | 45 ++++++++++++++++++++----------------- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/yaksh/forms.py b/yaksh/forms.py index 1cd1291..3c4d664 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -299,7 +299,7 @@ class QuestionForm(forms.ModelForm): {'class': 'custom-select'} ) self.fields['topic'].widget.attrs.update( - {'class': 'custom-select'} + {'class': form_input_class, 'placeholder': 'Topic name'} ) self.fields['type'].widget.attrs.update( {'class': 'custom-select'} diff --git a/yaksh/static/yaksh/css/custom.css b/yaksh/static/yaksh/css/custom.css index 3979e3e..a9c8e27 100644 --- a/yaksh/static/yaksh/css/custom.css +++ b/yaksh/static/yaksh/css/custom.css @@ -117,4 +117,11 @@ body, .dropdown-menu { .description { font-size: 16px; +} + +/* --------------------------------------------------- + Quiz qusetion style +----------------------------------------------------- */ +#question_card { + border: none; } \ No newline at end of file diff --git a/yaksh/templates/yaksh/question.html b/yaksh/templates/yaksh/question.html index 92d591f..640003b 100644 --- a/yaksh/templates/yaksh/question.html +++ b/yaksh/templates/yaksh/question.html @@ -107,10 +107,10 @@ function call_skip(url) form.submit(); } init_val = '{{ last_attempt|escape_quotes|safe }}'; -lang = "{{ question.language }}" -course_id = "{{course.id}}" -module_id = "{{module.id}}" -question_type = "{{ question.type }}" +lang = "{{ question.language }}"; +course_id = "{{course.id}}"; +module_id = "{{module.id}}"; +question_type = "{{ question.type }}"; {% endblock script %} @@ -146,39 +146,42 @@ question_type = "{{ question.type }}"
{% csrf_token %} -
+
-
-
- {{ question.summary }} +
+
+

{{ question.summary }}

-
+
+ {% if question.language == "other" %} + Topic: {{question.topic}} + {% else %} + Language: {{question.language}} + {% endif %} {% if question.type == "mcq" %} - SINGLE CORRECT CHOICE + Type: SINGLE CORRECT CHOICE {% elif question.type == "mcc" %} - MULTIPLE CORRECT CHOICES + Type: MULTIPLE CORRECT CHOICES {% elif question.type == "code" %} - PROGRAMMING + Type: PROGRAMMING {% elif question.type == "upload" %} - ASSIGNMENT UPLOAD + Type: ASSIGNMENT UPLOAD {% elif question.type == "integer" %} - FILL IN THE BLANKS WITH INTEGER ANSWER + Type: FILL IN THE BLANKS WITH INTEGER ANSWER {% elif question.type == "string" %} - FILL IN THE BLANKS WITH STRING ANSWER + Type: FILL IN THE BLANKS WITH STRING ANSWER {% if testcase.string_check == "lower" %}
(CASE INSENSITIVE) {% else %}
(CASE SENSITIVE) {% endif %} {% elif question.type == "float" %} - FILL IN THE BLANKS WITH FLOAT ANSWER + Type: FILL IN THE BLANKS WITH FLOAT ANSWER {% elif question.type == "arrange" %} - ARRANGE THE OPTIONS IN CORRECT ORDER + Type: ARRANGE THE OPTIONS IN CORRECT ORDER {% endif %} -
-
- - {{ question.points }} Marks + + Marks: {{ question.points }}
-- cgit