Пример #1
0
 def test_add_identical_items(self):
   fb = FractionBank()
   fb.name = "Bank 0 to 4"
   fb.date_created = datetime.date(2012,03,07)
   fb.save()
   st = 0
   en = 4
   i = fb.fill(st,en)
   fbfs = FractionBankFraction.objects.all()
   
   fqb = FractionQuestionBank()
   fqb.name = "Addition 2"
   fqb.fraction_bank = fb
   fqb.date_created = datetime.date(2012,03,07)
   fqb.save()
   
   fq = FractionQuestion()
   fq.f1 = fbfs[0].fraction
   fq.f2 = fbfs[1].fraction
   oper = Oper.objects.get(pk=1)
   ans = fq.f1.oper(fq.f2,oper)
   ans.save()
   oper = Oper.objects.get(pk=1)     
   fq.oper = oper
   fq.answer = ans
   fq.save()
   
   #Add question once           
   fqb.add_question(fq)
   #Try and add same again
   fqb.add_question(fq)
   #Should fail gracefully and only one question in bank
   fbq = FractionBankQuestion.objects.all()
   self.assertEquals(len(fbq),1)
Пример #2
0
 def test_creation(self):
   fb = FractionBank()
   fb.name = "Bank 1"
   fb.date_created = datetime.date(2012,03,07)
   fb.save()
   st = 0
   en = 10
   i = fb.fill(st,en)
   fbfs = FractionBankFraction.objects.all()
   
   fqb = FractionQuestionBank()
   fqb.name = "Addition 100"
   fqb.fraction_bank = fb
   fqb.date_created = datetime.date(2012,03,07)
   fqb.save()
   
   fq = FractionQuestion()
   fq.f1 = fbfs[0].fraction
   fq.f2 = fbfs[1].fraction
   oper = Oper.objects.get(pk=1)
   ans = fq.f1.oper(fq.f2,oper)
   ans.save()
   oper = Oper.objects.get(pk=1)      
   fq.oper = oper
   fq.answer = ans
   fq.save()
   
   fbq = FractionBankQuestion()
   fbq.fraction_question_bank = fqb
   fbq.question = fq
   fbq.save()
   
   fbq = FractionBankQuestion.objects.all()[0]
   self.assertEquals(fbq.question.answer,ans)
Пример #3
0
 def test_creation(self):
   fb = FractionBank()
   fb.name = "Bank 1"
   fb.date_created = datetime.date(2012,03,07)
   fb.save()
   fqb = FractionQuestionBank()
   fqb.name = "Addition 100"
   fqb.fraction_bank = fb
   fqb.date_created = datetime.date(2012,03,07)
   fqb.save()
   fqb = FractionQuestionBank.objects.all()[0]
   self.assertEquals(fqb.fraction_bank.name,'Bank 1')
Пример #4
0
 def test_add_random_questions(self):
   fb = FractionBank()
   fb.name = "Bank 0 to 9"
   fb.date_created = datetime.date(2012,03,07)
   fb.save()
   st = 0
   en = 9
   i = fb.fill(st,en)    
   fqb = FractionQuestionBank()
   fqb.name = "Addition"
   fqb.fraction_bank = fb
   fqb.date_created = datetime.date(2012,03,07)
   fqb.save()
   oper = Oper.objects.get(pk=1)      
   n = 5
   fqb.add_n_questions(n,oper)
   fbq = FractionBankQuestion.objects.all()
   self.assertEquals(len(fbq),n)