Example #1
0
 def test_create_and_save(self):
     cat_test = CatTest()
     cat_test.name = "short"
     cat_test.save()
     user = User.objects.create_user("john", "*****@*****.**", "johnpassword")
     user.save()
     domain = Domain()
     domain.name = "Number"
     domain.create_date = datetime.datetime(2012, 03, 06)
     domain.save()
     item_bank = ItemBank()
     item_bank.name = "Fractions"
     item_bank.topic = "Addition"
     item_bank.domain = domain
     item_bank.create_date = datetime.datetime(2012, 03, 06)
     item_bank.save()
     user_item_bank = UserItemBank()
     user_item_bank.user = user
     user_item_bank.item_bank = item_bank
     user_item_bank.save()
     ibq = ItemBankQuestion()
     ibq.item_bank = item_bank
     ibq.save()
     user_cat_test = UserCatTest()
     user_cat_test.user = user
     user_cat_test.item_bank = item_bank
     user_cat_test.cat_test = cat_test
     user_cat_test.save()
     cat_test_item = CatTestItem()
     cat_test_item.user_cat_test = user_cat_test
     cat_test_item.item_bank_question = ibq
     cat_test_item.save()
     cat_test_item = CatTestItem.objects.all()[0]
     self.assertEquals(cat_test_item.user_cat_test, user_cat_test)
     self.assertEquals(cat_test_item.item_bank_question, ibq)
Example #2
0
 def test_create_and_save(self):
   cat_test = CatTest()
   cat_test.name = "short"
   cat_test.save()
   user = User.objects.create_user('john', '*****@*****.**', 'johnpassword')
   user.save()
   domain = Domain()
   domain.name = "Number"
   domain.create_date = datetime.datetime(2012,03,06)
   domain.save()
   item_bank = ItemBank()
   item_bank.name = "Fractions"
   item_bank.topic = "Addition"
   item_bank.domain = domain
   item_bank.question_type = QuestionType.objects.get(pk=1)
   item_bank.template = ItemBankTemplate.objects.get(pk=1)
   item_bank.save()
   user_item_bank = UserItemBank()
   user_item_bank.user = user
   user_item_bank.item_bank = item_bank
   user_item_bank.save()
   ibq = ItemBankQuestion()
   ibq.item_bank = item_bank
   ibq.save()
   user_cat_test = UserCatTest()
   user_cat_test.user = user
   user_cat_test.item_bank = item_bank
   user_cat_test.cat_test = cat_test
   user_cat_test.save()
   cat_test_item = CatTestItem()
   cat_test_item.user_cat_test = user_cat_test
   cat_test_item.item_bank_question = ibq
   cat_test_item.time_taken = 12
   cat_test_item.save()
   answer = FractionWithConstant()
   answer.const = 1
   answer.denom = 2
   answer.num = 3
   answer.save()
   ctifa = CatTestItemFractionAnswer()
   ctifa.cat_test_item = cat_test_item
   ctifa.fraction = answer
   ctifa.save()
   ctifa = CatTestItemFractionAnswer.objects.filter(cat_test_item = cat_test_item)[0]
   self.assertEquals(ctifa.fraction,answer)
Example #3
0
 def test_create_and_save(self):
   cat_test = CatTest()
   cat_test.name = "short"
   cat_test.save()
   user = User.objects.create_user('john', '*****@*****.**', 'johnpassword')
   user.save()
   domain = Domain()
   domain.name = "Number"
   domain.create_date = datetime.datetime(2012,03,06)
   domain.save()
   item_bank = ItemBank()
   item_bank.name = "Fractions"
   item_bank.topic = "Addition"
   item_bank.domain = domain
   item_bank.question_type = QuestionType.objects.get(pk=1)
   item_bank.template = ItemBankTemplate.objects.get(pk=1)
   item_bank.save()
   user_item_bank = UserItemBank()
   user_item_bank.user = user
   user_item_bank.item_bank = item_bank
   user_item_bank.save()
   ibq = ItemBankQuestion()
   ibq.item_bank = item_bank
   ibq.save()
   user_cat_test = UserCatTest()
   user_cat_test.user = user
   user_cat_test.item_bank = item_bank
   user_cat_test.cat_test = cat_test
   user_cat_test.save()
   cat_test_item = CatTestItem()
   cat_test_item.user_cat_test = user_cat_test
   cat_test_item.item_bank_question = ibq
   cat_test_item.time_taken = 12
   ibq.usage +=1
   ibq.save()      
   cat_test_item.save()
   cat_test_item = CatTestItem.objects.all()[0]
   self.assertEquals(cat_test_item.user_cat_test,user_cat_test)
   self.assertEquals(cat_test_item.item_bank_question,ibq)
   self.assertEquals(cat_test_item.time_taken,12)
   self.assertEquals(cat_test_item.item_bank_question.usage,1)