From d53feb82cdd74e25045171acf70e513729ba993c Mon Sep 17 00:00:00 2001
From: adityacp
Date: Fri, 15 Apr 2016 11:40:25 +0530
Subject: rebase changes
---
yaksh/forms.py | 11 +++-
yaksh/models.py | 3 ++
yaksh/templates/yaksh/showquestions.html | 13 +++++
yaksh/urls.py | 5 ++
yaksh/views.py | 90 +++++++++++++++++++++++++++++---
5 files changed, 113 insertions(+), 9 deletions(-)
(limited to 'yaksh')
diff --git a/yaksh/forms.py b/yaksh/forms.py
index 16f82fb..37741b9 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -152,7 +152,7 @@ class QuestionForm(forms.ModelForm):
class Meta:
model = Question
- fields = '__all__'
+ exclude = ['user']
class RandomQuestionForm(forms.Form):
@@ -165,8 +165,9 @@ class RandomQuestionForm(forms.Form):
class QuestionFilterForm(forms.Form):
def __init__(self, *args, **kwargs):
+ user = kwargs.pop("user")
super(QuestionFilterForm, self).__init__(*args, **kwargs)
- questions = Question.objects.all()
+ questions = Question.objects.filter(user_id=user)
points_list = questions.values_list('points', flat=True).distinct()
points_options = [('select', 'Select Marks')]
points_options.extend([(point, point) for point in points_list])
@@ -188,6 +189,7 @@ class CourseForm(forms.ModelForm):
model = Course
fields = ['name', 'active', 'enrollment']
+
class ProfileForm(forms.ModelForm):
""" profile form for students and moderators """
@@ -205,3 +207,8 @@ class ProfileForm(forms.ModelForm):
super(ProfileForm, self).__init__(*args, **kwargs)
self.fields['first_name'].initial = user.first_name
self.fields['last_name'].initial = user.last_name
+
+
+class UploadFileForm(forms.Form):
+ file = forms.FileField()
+
diff --git a/yaksh/models.py b/yaksh/models.py
index 561b334..c76d655 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -173,6 +173,9 @@ class Question(models.Model):
# Tags for the Question.
tags = TaggableManager(blank=True)
+ # user for particular question
+ user = models.ForeignKey(User, related_name="user")
+
def consolidate_answer_data(self, test_cases, user_answer):
test_case_data_dict = []
question_info_dict = {}
diff --git a/yaksh/templates/yaksh/showquestions.html b/yaksh/templates/yaksh/showquestions.html
index ca51d1a..ba96728 100644
--- a/yaksh/templates/yaksh/showquestions.html
+++ b/yaksh/templates/yaksh/showquestions.html
@@ -10,6 +10,18 @@
{% endblock %}
{% block manage %}
+
+{% if questions %}
+Download Questions
+{% endif %}
+
+