summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorankitjavalkar2016-10-13 15:11:05 +0530
committerankitjavalkar2016-10-13 18:55:14 +0530
commitd33e97e4081037d92f89c7ae5742f74411b51931 (patch)
tree5a5f9b294e4cbf19a560786bdd8e47a93a961dec /yaksh/views.py
parent3d1d4a50524301d03526e4857844d0e6e4536527 (diff)
downloadonline_test-d33e97e4081037d92f89c7ae5742f74411b51931.tar.gz
online_test-d33e97e4081037d92f89c7ae5742f74411b51931.tar.bz2
online_test-d33e97e4081037d92f89c7ae5742f74411b51931.zip
Fix variable name in for loop
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py86
1 files changed, 3 insertions, 83 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 1b977f9..270a47c 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -916,9 +916,9 @@ def show_all_questions(request):
data = request.POST.getlist('question')
if data is not None:
questions = Question.objects.filter(id__in=data, user_id=user.id, active=True)
- for q in questions:
- q.active = False
- q.save()
+ for question in questions:
+ question.active = False
+ question.save()
if request.POST.get('upload') == 'upload':
form = UploadFileForm(request.POST, request.FILES)
@@ -1085,86 +1085,6 @@ def grade_user(request, quiz_id=None, user_id=None, attempt_number=None):
)
-<<<<<<< HEAD
-=======
-@csrf_exempt
-def ajax_questionpaper(request, query):
- """
- During question paper creation, ajax call made to get question details.
- """
-
- user = request.user
- if query == 'marks':
- question_type = request.POST.get('question_type')
- questions = Question.objects.filter(type=question_type, user=user, active=True)
- marks = questions.values_list('points').distinct()
- return my_render_to_response('yaksh/ajax_marks.html', {'marks': marks})
- elif query == 'questions':
- question_type = request.POST['question_type']
- marks_selected = request.POST['marks']
- fixed_questions = request.POST.getlist('fixed_list[]')
- fixed_question_list = ",".join(fixed_questions).split(',')
- random_questions = request.POST.getlist('random_list[]')
- random_question_list = ",".join(random_questions).split(',')
- question_list = fixed_question_list + random_question_list
- questions = list(Question.objects.filter(type=question_type,
- points=marks_selected,
- user=user,
- active=True)
- )
- questions = [question for question in questions \
- if not str(question.id) in question_list]
- return my_render_to_response('yaksh/ajax_questions.html',
- {'questions': questions})
-
-
-@login_required
-def design_questionpaper(request):
- user = request.user
- ci = RequestContext(request)
-
- if not is_moderator(user):
- raise Http404('You are not allowed to view this page!')
-
- if request.method == 'POST':
- fixed_questions = request.POST.getlist('fixed')
- random_questions = request.POST.getlist('random')
- random_number = request.POST.getlist('number')
- is_shuffle = request.POST.get('shuffle_questions', False)
- if is_shuffle == 'on':
- is_shuffle = True
-
- question_paper = QuestionPaper(shuffle_questions=is_shuffle)
- quiz = Quiz.objects.order_by("-id")[0]
- tot_marks = 0
- question_paper.quiz = quiz
- question_paper.total_marks = tot_marks
- question_paper.save()
- if fixed_questions:
- fixed_questions_ids = ",".join(fixed_questions)
- fixed_questions_ids_list = fixed_questions_ids.split(',')
- for question_id in fixed_questions_ids_list:
- question_paper.fixed_questions.add(question_id)
- if random_questions:
- for random_question, num in zip(random_questions, random_number):
- qid = random_question.split(',')[0]
- question = Question.objects.get(id=int(qid))
- marks = question.points
- question_set = QuestionSet(marks=marks, num_questions=num)
- question_set.save()
- for question_id in random_question.split(','):
- question_set.questions.add(question_id)
- question_paper.random_questions.add(question_set)
- question_paper.update_total_marks()
- question_paper.save()
- return my_redirect('/exam/manage/courses')
- else:
- form = RandomQuestionForm()
- context = {'form': form, 'questionpaper':True}
- return my_render_to_response('yaksh/design_questionpaper.html',
- context, context_instance=ci)
-
->>>>>>> Minor fixes: Hide question instead of deletion
@login_required
def view_profile(request):
""" view moderators and users profile """