summaryrefslogtreecommitdiff
path: root/yaksh
diff options
context:
space:
mode:
authoradityacp2016-04-15 11:46:27 +0530
committeradityacp2016-05-04 22:47:34 +0530
commit7a4438b7572f828c88958c12b2cd9666784f1bb5 (patch)
tree27af06249d4a4630a9a0f9bd1ed250ee5bc1ce90 /yaksh
parentd53feb82cdd74e25045171acf70e513729ba993c (diff)
downloadonline_test-7a4438b7572f828c88958c12b2cd9666784f1bb5.tar.gz
online_test-7a4438b7572f828c88958c12b2cd9666784f1bb5.tar.bz2
online_test-7a4438b7572f828c88958c12b2cd9666784f1bb5.zip
further rebase changes
Diffstat (limited to 'yaksh')
-rw-r--r--yaksh/forms.py2
-rw-r--r--yaksh/views.py13
2 files changed, 8 insertions, 7 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py
index 37741b9..c5bec4c 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -167,7 +167,7 @@ class QuestionFilterForm(forms.Form):
def __init__(self, *args, **kwargs):
user = kwargs.pop("user")
super(QuestionFilterForm, self).__init__(*args, **kwargs)
- questions = Question.objects.filter(user_id=user)
+ questions = Question.objects.filter(user_id=user.id)
points_list = questions.values_list('points', flat=True).distinct()
points_options = [('select', 'Select Marks')]
points_options.extend([(point, point) for point in points_list])
diff --git a/yaksh/views.py b/yaksh/views.py
index 1d79a4c..81b2a60 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -186,14 +186,16 @@ def add_question(request, question_id=None):
'formset': test_case_formset},
context_instance=ci)
else:
- d = Question.objects.get(id=question_id)
+ d = Question.objects.get(id=question_id, user_id=user.id)
form = QuestionForm(request.POST, instance=d)
test_case_formset = add_or_delete_test_form(request.POST, d)
if 'save_question' in request.POST:
qtn = form.save(commit=False)
+ qtn.user = user
+ qtn.save()
test_case_formset = TestCaseFormSet(request.POST, prefix='test', instance=qtn)
form.save()
- question = Question.objects.get(id=question_id)
+ question = Question.objects.get(id=question_id, user_id=user.id)
if test_case_formset.is_valid():
test_case_formset.save()
return my_redirect("/exam/manage/questions")
@@ -217,7 +219,7 @@ def add_question(request, question_id=None):
'formset': test_case_formset},
context_instance=ci)
else:
- d = Question.objects.get(id=question_id)
+ d = Question.objects.get(id=question_id, user_id=user.id)
form = QuestionForm(instance=d)
test_case_formset = TestCaseFormSet(prefix='test', instance=d)
@@ -816,7 +818,7 @@ def show_all_questions(request):
data = request.POST.getlist('question')
if data is not None:
for i in data:
- question = Question.objects.get(id=i).delete()
+ question = Question.objects.get(id=i, user_id=user.id).delete()
questions = Question.objects.filter(user_id=user.id)
form = QuestionFilterForm(user=user)
upload_form = UploadFileForm()
@@ -1002,7 +1004,7 @@ def design_questionpaper(request):
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))
+ question = Question.objects.get(id=int(qid), user_id=user.id)
marks = question.points
question_set = QuestionSet(marks=marks, num_questions=num)
question_set.save()
@@ -1206,7 +1208,6 @@ def upload_questions(request):
if not is_moderator(user):
raise Http404('You are not allowed to view this page!')
-
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():