summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradityacp2016-09-20 16:09:54 +0530
committeradityacp2016-09-20 16:09:54 +0530
commita689afd85ef3f0e4ddb8255e06c50f400bebd165 (patch)
treef8ca17861d321fc46e3f7bd1dfb61cbd1589440a
parent4d8a0b41935ecc182c90acf34e7696a207a664f6 (diff)
downloadonline_test-a689afd85ef3f0e4ddb8255e06c50f400bebd165.tar.gz
online_test-a689afd85ef3f0e4ddb8255e06c50f400bebd165.tar.bz2
online_test-a689afd85ef3f0e4ddb8255e06c50f400bebd165.zip
used create method instead of get_or_create to create course
-rw-r--r--yaksh/models.py18
1 files changed, 9 insertions, 9 deletions
diff --git a/yaksh/models.py b/yaksh/models.py
index 870d8b9..d176c57 100644
--- a/yaksh/models.py
+++ b/yaksh/models.py
@@ -159,9 +159,9 @@ class Course(models.Model):
def create_demo(self, user):
course = Course.objects.filter(creator=user, name="Yaksh Demo course")
if not course:
- course, c_status= Course.objects.get_or_create(name="Yaksh Demo course",
- enrollment="open",
- creator=user)
+ course = Course.objects.create(name="Yaksh Demo course",
+ enrollment="open",
+ creator=user)
quiz = Quiz()
demo_quiz = quiz.create_demo_quiz(course)
demo_ques = Question()
@@ -514,7 +514,7 @@ class Quiz(models.Model):
return True if self.prerequisite else False
def create_demo_quiz(self, course):
- demo_quiz = Quiz.objects.get_or_create(start_date_time=timezone.now(),
+ demo_quiz = Quiz.objects.create(start_date_time=timezone.now(),
end_date_time=timezone.now() + timedelta(176590),
duration=30, active=True,
attempts_allowed=-1,
@@ -656,15 +656,15 @@ class QuestionPaper(models.Model):
return prerequisite._is_questionpaper_passed(user)
def create_demo_que_ppr(self, demo_quiz):
- question_paper = QuestionPaper.objects.get_or_create(quiz=demo_quiz[0],
- total_marks=5.0,
- shuffle_questions=True
- )
+ question_paper = QuestionPaper.objects.create(quiz=demo_quiz,
+ total_marks=5.0,
+ shuffle_questions=True
+ )
questions = Question.objects.filter(active=True,
summary="Yaksh Demo Question")
# add fixed set of questions to the question paper
for question in questions:
- question_paper[0].fixed_questions.add(question)
+ question_paper.fixed_questions.add(question)
def __unicode__(self):
return "Question Paper for " + self.quiz.description