diff options
author | mahesh | 2017-04-21 03:12:10 +0530 |
---|---|---|
committer | mahesh | 2017-06-14 12:45:07 +0530 |
commit | a37b9b082ef9c89bd8f06844afad5db691e25995 (patch) | |
tree | 35e651edc10f1f3a3572f088ed67d6cb068b9572 /yaksh/views.py | |
parent | ebc8a2af6d4fdf52a9703701a97a3abfaf66ed06 (diff) | |
download | online_test-a37b9b082ef9c89bd8f06844afad5db691e25995.tar.gz online_test-a37b9b082ef9c89bd8f06844afad5db691e25995.tar.bz2 online_test-a37b9b082ef9c89bd8f06844afad5db691e25995.zip |
added search tag feature in showquestions
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index c10ba6a..4096da3 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -29,6 +29,7 @@ try: from StringIO import StringIO as string_io except ImportError: from io import BytesIO as string_io +import re # Local imports. from yaksh.models import get_model_class, Quiz, Question, QuestionPaper, QuestionSet, Course from yaksh.models import Profile, Answer, AnswerPaper, User, TestCase, FileUpload,\ @@ -1045,6 +1046,15 @@ def show_all_questions(request): else: context["msg"] = "Please select atleast one question to test" + if request.POST.get('question_tags'): + question_tags = request.POST.getlist("question_tags") + all_tags = [] + for tags in question_tags: + all_tags.extend(re.split('[; |, |\*|\n]',tags)) + search_result = Question.objects.filter(tags__name__in=all_tags)\ + .distinct() + context['search_result'] = search_result + questions = Question.objects.filter(user_id=user.id, active=True) form = QuestionFilterForm(user=user) upload_form = UploadFileForm() |