From a37b9b082ef9c89bd8f06844afad5db691e25995 Mon Sep 17 00:00:00 2001 From: mahesh Date: Fri, 21 Apr 2017 03:12:10 +0530 Subject: added search tag feature in showquestions --- yaksh/views.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'yaksh/views.py') 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() -- cgit From 3d43d3d423f6589688ba313ca961360280157543 Mon Sep 17 00:00:00 2001 From: mahesh Date: Fri, 9 Jun 2017 16:13:24 +0530 Subject: searches for tagged questions --- yaksh/views.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'yaksh/views.py') 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 -- cgit From f308f6e4ffb3fefc42552570fd8cf852d643cd6f Mon Sep 17 00:00:00 2001 From: mahesh Date: Wed, 14 Jun 2017 12:45:02 +0530 Subject: removes Question queryset from tag searching --- yaksh/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'yaksh/views.py') diff --git a/yaksh/views.py b/yaksh/views.py index 42e92e0..cf2097b 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1057,8 +1057,7 @@ def show_all_questions(request): 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() + user_tags = questions.values_list('tags', flat=True).distinct() all_tags = Tag.objects.filter(id__in = user_tags) upload_form = UploadFileForm() context['all_tags'] = all_tags -- cgit