diff options
author | Palaparthy Adityachandra | 2020-05-18 16:29:04 +0530 |
---|---|---|
committer | GitHub | 2020-05-18 16:29:04 +0530 |
commit | 5c57dd3ab185d5d0ad39240180e98d4a3131daa5 (patch) | |
tree | a6ba3348f82f596a9d54b5a3cc63aa1eff83229b /yaksh | |
parent | db456ca53778c720ee597e3fcf7814c623bc32fd (diff) | |
parent | 61d4096697a84873473ad28afb0dc79f211a54b3 (diff) | |
download | online_test-5c57dd3ab185d5d0ad39240180e98d4a3131daa5.tar.gz online_test-5c57dd3ab185d5d0ad39240180e98d4a3131daa5.tar.bz2 online_test-5c57dd3ab185d5d0ad39240180e98d4a3131daa5.zip |
Merge pull request #697 from CruiseDevice/change-create_question
Fix: #696
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/forms.py | 3 | ||||
-rw-r--r-- | yaksh/models.py | 3 | ||||
-rw-r--r-- | yaksh/static/yaksh/css/custom.css | 7 | ||||
-rw-r--r-- | yaksh/static/yaksh/js/add_question.js | 27 | ||||
-rw-r--r-- | yaksh/templates/yaksh/question.html | 45 |
5 files changed, 63 insertions, 22 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py index 216f5c2..3c4d664 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': form_input_class, 'placeholder': 'Topic name'} + ) self.fields['type'].widget.attrs.update( {'class': 'custom-select'} ) diff --git a/yaksh/models.py b/yaksh/models.py index b64ac77..7d4dd98 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 = ( @@ -1298,6 +1299,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/css/custom.css b/yaksh/static/yaksh/css/custom.css index 697361d..f995c61 100644 --- a/yaksh/static/yaksh/css/custom.css +++ b/yaksh/static/yaksh/css/custom.css @@ -125,4 +125,9 @@ body, .dropdown-menu { .description { font-size: 16px; } ->>>>>>> 53a0c4ad3e733f3960000527f83565f2fd8fc412 +/* --------------------------------------------------- + Quiz question style +----------------------------------------------------- */ +#question_card { + border: none; +} 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 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 }}"; </script> {% endblock script %} @@ -146,39 +146,42 @@ question_type = "{{ question.type }}" <form id="code" action="{% url 'yaksh:check' question.id paper.attempt_number module.id paper.question_paper.id course.id %}" method="post" enctype="multipart/form-data"> {% csrf_token %} <input type=hidden name="question_id" id="question_id" value="{{ question.id }}"></input> - <div class="card"> + <div class="card" id="question_card"> <div class="card-header"> - <div class="row"> - <div class="col-md-6"> - {{ question.summary }} + <div> + <div> + <h2>{{ question.summary }}</h2> </div> - <div class="col-md-4"> + <div> + {% if question.language == "other" %} + <small class="text text-muted"><strong>Topic:</strong> <span class="badge badge-primary">{{question.topic}}</small></span> + {% else %} + <small class="textx text-muted"><strong>Language:</strong> <span class="badge badge-primary">{{question.language}}</span></small> + {% endif %} {% if question.type == "mcq" %} - SINGLE CORRECT CHOICE + <small class="text text-muted"><strong>Type:</strong> <span class="badge badge-primary">SINGLE CORRECT CHOICE</span></small> {% elif question.type == "mcc" %} - MULTIPLE CORRECT CHOICES + <small class="text text-muted"><strong>Type:</strong> <span class="badge badge-primary">MULTIPLE CORRECT CHOICES</span></small> {% elif question.type == "code" %} - PROGRAMMING + <small class="text text-muted"><strong>Type:</strong> <span class="badge badge-primary">PROGRAMMING</span></small> {% elif question.type == "upload" %} - ASSIGNMENT UPLOAD + <small class="text text-muted"><strong>Type:</strong> <span class="badge badge-primary">ASSIGNMENT UPLOAD</span></small> {% elif question.type == "integer" %} - FILL IN THE BLANKS WITH INTEGER ANSWER + <small class="text text-muted"><strong>Type:</strong> <span class="badge badge-primary">FILL IN THE BLANKS WITH INTEGER ANSWER</span></small> {% elif question.type == "string" %} - FILL IN THE BLANKS WITH STRING ANSWER + <small class="text text-muted"><strong>Type:</strong> <span class="badge badge-primary">FILL IN THE BLANKS WITH STRING ANSWER</span></small> {% if testcase.string_check == "lower" %} <br>(CASE INSENSITIVE) {% else %} <br>(CASE SENSITIVE) {% endif %} {% elif question.type == "float" %} - FILL IN THE BLANKS WITH FLOAT ANSWER + <small class="text text-muted"><strong>Type:</strong> <span class="badge badge-primary">FILL IN THE BLANKS WITH FLOAT ANSWER</span></small> {% elif question.type == "arrange" %} - ARRANGE THE OPTIONS IN CORRECT ORDER + <small class="text text-muted"><strong>Type:</strong> <span class="badge badge-primary">ARRANGE THE OPTIONS IN CORRECT ORDER</span></small> {% endif %} - </div> - <div class="col-md-2"> - <span class="badge badge-info"> - {{ question.points }} Marks + <span class="badge badge-info pull-right"> + <small><strong>Marks: {{ question.points }}</strong></small> </span> </div> </div> |