Ejemplo n.º 1
0
 def test_endTest(self):
     cat_test = CatTest()
     cat_test.name = "short"
     cat_test.max_items = 10
     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.items = 10
     user_cat_test.save()
     end_test = user_cat_test.endTest()
     self.assertEquals(end_test, True)
     user_cat_test.items = 9
     user_cat_test.save()
     end_test = user_cat_test.endTest()
     self.assertEquals(end_test, False)
     user_cat_test.items = 5
     user_cat_test.stand_err = 0.1
     user_cat_test.save()
     end_test = user_cat_test.endTest()
     self.assertEquals(end_test, True)
     user_cat_test.items = 5
     user_cat_test.stand_err = 2
     user_cat_test.save()
     end_test = user_cat_test.endTest()
     self.assertEquals(end_test, False)
     user_cat_test.items = 2
     user_cat_test.stand_err = 0.1
     user_cat_test.save()
     end_test = user_cat_test.endTest()
     self.assertEquals(end_test, False)
Ejemplo n.º 2
0
 def test_nextQuestion(self):
     cat_test = CatTest()
     cat_test.name = "short"
     cat_test.max_items = 10
     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()
     q = user_cat_test.nextQuestion()
     # One item in bank, one taken
     self.assertEquals(isinstance(q, CatTestItem), True)
     q = user_cat_test.nextQuestion()
     # One item in bank, try to take another, should return None
     self.assertEquals(isinstance(q, CatTestItem), False)
     # Add more questions and see if they are repeated
     for i in range(1, 11):
         ibq = ItemBankQuestion()
         ibq.item_bank = item_bank
         ibq.save()
     for i in range(1, 11):
         q = user_cat_test.nextQuestion()
         print q.item_bank_question.id
     # Add a question of perfect difficulty and see if it is chosen amongst others
     for i in range(1, 11):
         ibq = ItemBankQuestion()
         ibq.item_bank = item_bank
         ibq.save()
     user_cat_test.difficulty = 2
     user_cat_test.stand_err = 0.1
     hibq = ItemBankQuestion()
     hibq.item_bank = item_bank
     hibq.difficulty = 2
     hibq.save()
     q = user_cat_test.nextQuestion()
     self.assertEquals(q.item_bank_question, hibq)
     # Make ability different to all questions and make sure one is chosen
     user_cat_test.difficulty = 2
     user_cat_test.stand_err = 0.1
     q = user_cat_test.nextQuestion()
     self.assertEquals(isinstance(q, CatTestItem), True)