summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yaksh/static/yaksh/js/show_question.js10
-rw-r--r--yaksh/templates/yaksh/showquestions.html32
-rw-r--r--yaksh/views.py12
3 files changed, 42 insertions, 12 deletions
diff --git a/yaksh/static/yaksh/js/show_question.js b/yaksh/static/yaksh/js/show_question.js
index e3ed1cc..a154558 100644
--- a/yaksh/static/yaksh/js/show_question.js
+++ b/yaksh/static/yaksh/js/show_question.js
@@ -37,3 +37,13 @@ function confirm_edit(frm)
else
return true;
}
+
+function append_tag(tag){
+ var tag_name = document.getElementById("question_tags");
+ if (tag_name.value != null){
+ tag_name.value = tag.value+", "+tag_name.value;
+ }
+ else{
+ tag_name.value = tag.value;
+ }
+}
diff --git a/yaksh/templates/yaksh/showquestions.html b/yaksh/templates/yaksh/showquestions.html
index 6e1ea6e..8b7fbf1 100644
--- a/yaksh/templates/yaksh/showquestions.html
+++ b/yaksh/templates/yaksh/showquestions.html
@@ -38,25 +38,40 @@ Upload File <span class="glyphicon glyphicon-open"></span></button>
<div class="col-md-3">
{{ form.marks }}
</div>
-</div>
<br>
- <button class="btn btn-primary" type="button" onClick='location.replace("{{URL_ROOT}}");'>
- Clear Filters</button>
-<br><br>
+<h4 style="padding-left: 20px;">Or</h4>
+
+<h4 style="padding-left: 20px;">Search using Tags: </h4>
+</div>
<!-- Searching Tags -->
{% csrf_token %}
- <div class="col-md-16">
+ <div class="col-md-14">
<div class="input-group">
<span class="input-group-addon" id="basic-addon1">Search Questions </span>
- <input type="text" name="question_tags" class="form-control"
+ <input type="text" id="question_tags" name="question_tags" class="form-control"
placeholder="Search using comma separated Tags">
<span class="input-group-btn">
<button class="btn btn-default" type="submit">Search</button>
- <button class="btn btn-default" onclick='location.replace("{{URL_ROOT}}/exam/manage/questions/");'>
- Cancel</button>
</span>
+ <div class="col-md-6">
+ <select class="form-control" id="sel1" onchange="append_tag(this);">
+ {% if all_tags %}
+ <option value="" disabled selected>Available Tags</option>
+ {% for tag in all_tags %}
+ <option>
+ {{tag}}
+ </option>
+ {% endfor %}
+ {% else %}
+ <option value="" disabled selected>No Available Tags</option>
+ {% endif %}
+ </select>
+ </div>
</div>
</div>
+<br><br>
+<button class="btn btn-primary" type="button" onClick='location.replace("{{URL_ROOT}}");'>
+ Clear Filters</button>
<div id="filtered-questions">
{% if not search_result %}
@@ -67,6 +82,7 @@ Upload File <span class="glyphicon glyphicon-open"></span></button>
{% endfor %}
{% endif %}
{% else %}
+<h5><input id="checkall" type="checkbox"> Select All </h5>
{% for i in search_result %}
<input type="checkbox" name="question" value="{{ i.id }}">&nbsp;&nbsp;<a href="{{URL_ROOT}}/exam/manage/addquestion/{{ i.id }}">{{ i }}</a><br>
{% endfor %}
diff --git a/yaksh/views.py b/yaksh/views.py
index 4096da3..42e92e0 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -1048,16 +1048,20 @@ def show_all_questions(request):
if request.POST.get('question_tags'):
question_tags = request.POST.getlist("question_tags")
- all_tags = []
+ search_tags = []
for tags in question_tags:
- all_tags.extend(re.split('[; |, |\*|\n]',tags))
- search_result = Question.objects.filter(tags__name__in=all_tags)\
- .distinct()
+ search_tags.extend(re.split('[; |, |\*|\n]',tags))
+ search_result = Question.objects.filter(tags__name__in=search_tags,
+ user=user).distinct()
context['search_result'] = search_result
questions = Question.objects.filter(user_id=user.id, active=True)
form = QuestionFilterForm(user=user)
+ user_tags = Question.objects.filter(user=user)\
+ .values_list('tags', flat=True).distinct()
+ all_tags = Tag.objects.filter(id__in = user_tags)
upload_form = UploadFileForm()
+ context['all_tags'] = all_tags
context['papers'] = []
context['question'] = None
context['questions'] = questions