summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/forms.py33
-rw-r--r--yaksh/static/yaksh/js/add_question.js11
-rw-r--r--yaksh/templates/yaksh/add_question.html98
3 files changed, 98 insertions, 44 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py
index 951fcc1..def9c32 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -264,6 +264,33 @@ class QuestionForm(forms.ModelForm):
"""Creates a form to add or edit a Question.
It has the related fields and functions required."""
+ def __init__(self, *args, **kwargs):
+ super(QuestionForm, self).__init__(*args, **kwargs)
+ self.fields['summary'].widget.attrs.update(
+ {'class': form_input_class, 'placeholder': 'Summary'}
+ )
+ self.fields['language'].widget.attrs.update(
+ {'class': 'custom-select'}
+ )
+ self.fields['type'].widget.attrs.update(
+ {'class': 'custom-select'}
+ )
+ self.fields['description'].widget.attrs.update(
+ {'class': form_input_class, 'placeholder': 'Description'}
+ )
+ self.fields['tags'].widget.attrs.update(
+ {'class': form_input_class, 'placeholder': 'Tags'}
+ )
+ self.fields['solution'].widget.attrs.update(
+ {'class': form_input_class, 'placeholder': 'Solution'}
+ )
+ self.fields['snippet'].widget.attrs.update(
+ {'class': form_input_class, 'placeholder': 'Snippet'}
+ )
+ self.fields['min_time'].widget.attrs.update(
+ {'class': form_input_class}
+ )
+
class Meta:
model = Question
exclude = ['user', 'active']
@@ -271,7 +298,11 @@ class QuestionForm(forms.ModelForm):
class FileForm(forms.Form):
file_field = forms.FileField(widget=forms.ClearableFileInput(
- attrs={'multiple': True}),
+ attrs={
+ 'multiple': True,
+ 'class': 'custom-file-input'
+ }
+ ),
required=False)
diff --git a/yaksh/static/yaksh/js/add_question.js b/yaksh/static/yaksh/js/add_question.js
index 0f02aab..2db5301 100644
--- a/yaksh/static/yaksh/js/add_question.js
+++ b/yaksh/static/yaksh/js/add_question.js
@@ -73,9 +73,9 @@ function replaceSelection (input, replaceString)
function textareaformat()
{
- document.getElementById('id_type').setAttribute('class','select-type');
+ document.getElementById('id_type').setAttribute('class','custom-select');
document.getElementById('id_points').setAttribute('class','mini-text');
- document.getElementById('id_tags').setAttribute('class','tag-text');
+ document.getElementById('id_tags').setAttribute('class','form-control');
$("[id*="+'test_case_args'+"]").attr('placeholder',
'Command Line arguments for bash only');
@@ -143,6 +143,13 @@ function textareaformat()
$("#id_grade_assignment_upload").prop("disabled", true);
}
});
+
+ $('#id_file_field').on('change',function(){
+ //get the file name
+ var fileName = $(this).val();
+ //replace the "Choose a file" label
+ $(this).next('.custom-file-label').html(fileName);
+ })
}
function autosubmit()
diff --git a/yaksh/templates/yaksh/add_question.html b/yaksh/templates/yaksh/add_question.html
index 692af48..96917da 100644
--- a/yaksh/templates/yaksh/add_question.html
+++ b/yaksh/templates/yaksh/add_question.html
@@ -1,5 +1,6 @@
{% extends "manage.html" %}
+{% block title %} Add Question {% endblock title %}
{% block pagetitle %} Add Question {% endblock pagetitle %}
{% block css %}
@@ -17,33 +18,45 @@
<div class="yakshwell container">
<form action="{{ URL_ROOT }}/exam/manage/addquestion/{{ question.id }}/" method="post" name=frm onSubmit="return autosubmit();" enctype="multipart/form-data">
{% csrf_token %}
- <center><table class="table table-responsive-sm">
- <tr><td>Summary: <td>{{ qform.summary }}{{ qform.summary.errors }}
- <tr><td> Language: <td> {{qform.language}}{{qform.language.errors}}
- <tr><td> Type: <td> {{ qform.type }}{{qform.type.errors}}
- <tr><td>Points:<td><button class="btn-mini" type="button" onClick="increase(frm);">+</button>{{qform.points }}<button class="btn-mini" type="button" onClick="decrease(frm);">-</button>{{ qform.points.errors }}
- <tr><td><strong>Rendered: </strong><td><p id='my'></p>
- <tr><td>Description: <td>{{ qform.description}} {{qform.description.errors}}
- <tr><td>Tags: <td>{{ qform.tags }}
- <tr><td><strong>Rendered Solution: </strong><td><p id='rend_solution'></p>
- <tr><td>Solution: <td>{{ qform.solution }}
- <tr><td>Snippet: <td>{{ qform.snippet }}
- <tr><td>Minimum Time(in minutes):<td> {{ qform.min_time }}
- <tr><td>Partial Grading: <td>{{ qform.partial_grading }}
- <tr><td>Grade Assignment Upload:<td> {{ qform.grade_assignment_upload }}
- <tr><td> File: <td> {{ fileform.file_field }}{{ fileform.file_field.errors }}
- {% if uploaded_files %}<br><b>Uploaded files:</b><br>Check on delete to delete files,
- extract to extract files and hide to hide files from student(if required)<br>
- {% for file in uploaded_files %}
- <input type="checkbox" name="clear" value="{{file.id}}">&nbsp;delete</input>&nbsp;
- <input type="checkbox" name="extract" value="{{file.id}}" >{% if file.extract %} dont extract{% else %}
- extract{% endif %}</input>&nbsp;&nbsp;
- <input type="checkbox" name="hide" value="{{file.id}}" >{% if file.hide %} show{% else %}
- hide{% endif %}</input>
- <a href="{{file.file.url}}">{{ file.file.name }}</a>
- <br>
- {% endfor %}{% endif %}
- </table></center>
+ <center>
+ <table class="table table-responsive-sm">
+ <tr><td>Summary: <td>{{ qform.summary }}{{ qform.summary.errors }}
+ <tr><td> Language: <td> {{qform.language}}{{qform.language.errors}}
+ <tr><td> Type: <td> {{ qform.type }}{{qform.type.errors}}
+ <tr><td>Points:<td><button class="btn-mini" type="button" onClick="increase(frm);">+</button>{{qform.points }}<button class="btn-mini" type="button" onClick="decrease(frm);">-</button>{{ qform.points.errors }}
+ <tr><td><strong>Rendered: </strong><td><p id='my'></p>
+ <tr><td>Description: <td>{{ qform.description}} {{qform.description.errors}}
+ <tr><td>Tags: <td>{{ qform.tags }}
+ <tr><td><strong>Rendered Solution: </strong><td><p id='rend_solution'></p>
+ <tr><td>Solution: <td>{{ qform.solution }}
+ <tr><td>Snippet: <td>{{ qform.snippet }}
+ <tr><td>Minimum Time(in minutes):<td> {{ qform.min_time }}
+ <tr><td>Partial Grading: <td>{{ qform.partial_grading }}
+ <tr><td>Grade Assignment Upload:<td> {{ qform.grade_assignment_upload }}
+ <tr><td> File: <td>
+ <div class="input-group mb-3">
+ <div class="custom-file">
+ {{ fileform.file_field }}{{ fileform.file_field.errors }}
+ <label class="custom-file-label" for="id_file">
+ Choose file
+ </label>
+ </div>
+ </div>
+ {% if uploaded_files %}
+ <br>
+ <b>Uploaded files:</b><br>
+ Check on delete to delete files,
+ extract to extract files and hide to hide files from student(if required)<br>
+ {% for file in uploaded_files %}
+ <input type="checkbox" name="clear" value="{{file.id}}">&nbsp;delete</input>&nbsp;
+ <input type="checkbox" name="extract" value="{{file.id}}" >{% if file.extract %} dont extract{% else %}extract{% endif %}</input>&nbsp;&nbsp;
+ <input type="checkbox" name="hide" value="{{file.id}}" >{% if file.hide %} show{% else %}hide{% endif %}</input>
+ <a href="{{file.file.url}}">{{ file.file.name }}</a>
+ <br>
+ {% endfor %}
+ {% endif %}
+ </table>
+ </center>
{% for formset in formsets %}
<div class="form-group">
{{ formset.management_form }}
@@ -56,21 +69,24 @@
</div>
{% endfor %}
- <p><label for="case_type">Add Test Case:</label> <select id="case_type" name="case_type" onchange="frm.submit()">
- <option value="" selected="selected">---------</option>
- <option value="standardtestcase">Standard </option>
- <option value="stdiobasedtestcase">StdIO </option>
- <option value="mcqtestcase">MCQ/MCC </option>
- <option value="hooktestcase">Hook </option>
- <option value="integertestcase">Integer </option>
- <option value="stringtestcase"> String </option>
- <option value="floattestcase"> Float </option>
- <option value="arrangetestcase">Arrange options </option>
- </select></p>
+ <div class="form-group">
+ <label for="case_type">Add Test Case:</label>
+ <select id="case_type" class="form-control" name="case_type" onchange="frm.submit()">
+ <option value="" selected="selected">---------</option>
+ <option value="standardtestcase">Standard </option>
+ <option value="stdiobasedtestcase">StdIO </option>
+ <option value="mcqtestcase">MCQ/MCC </option>
+ <option value="hooktestcase">Hook </option>
+ <option value="integertestcase">Integer </option>
+ <option value="stringtestcase"> String </option>
+ <option value="floattestcase"> Float </option>
+ <option value="arrangetestcase">Arrange options </option>
+ </select>
+ </div>
<center>
- <button class="btn btn-success" type="submit" name="save_question">Save</button>
- <button class="btn btn-info" type="button" name="button" onClick='location.replace("{{URL_ROOT}}/exam/manage/questions/");'>Back to Questions</button>
- <button class="btn btn-danger" type="submit" name="delete_files">Delete Selected Files</button>
+ <button class="btn btn-lg btn-success" type="submit" name="save_question">Save</button>
+ <button class="btn btn-lg btn-info" type="button" name="button" onClick='location.replace("{% url 'yaksh:show_questions' %}");'>Back to Questions</button>
+ <button class="btn btn-lg btn-danger" type="submit" name="delete_files">Delete Selected Files</button>
</center>
</form>
</div>