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.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.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_dev = 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_dev = 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_dev = 0.1
   user_cat_test.save()
   end_test = user_cat_test.endTest()
   self.assertEquals(end_test,False)
Ejemplo n.º 2
0
    def test_user_item_bank_update(self):
        user = User.objects.create_user("john", "*****@*****.**", "johnpassword")
        user.save()

        # create structures
        cat_test = CatTest()
        cat_test.name = "Short Test"
        cat_test.save()
        domain = Domain.objects.get(pk=1)
        item_bank = ItemBank()
        item_bank.name = "Fractions"
        item_bank.topic = "Addition"
        item_bank.domain = domain
        item_bank.template = ItemBankTemplate.objects.get(pk=1)
        item_bank.question_type = QuestionType.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()
        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 = 6
        user_cat_test.right = 4
        user_cat_test.time_taken = 240
        user_cat_test.save()
        user_item_bank.update(user_cat_test)
        self.assertEquals(user_item_bank.tests, 1)
        self.assertEquals(user_item_bank.questions, 6)
        self.assertEquals(user_item_bank.correct, 4)
        self.assertEquals(user_item_bank.time_taken, 240)
        self.assertEquals(user_item_bank.time_taken_str, "0:04:00")
Ejemplo n.º 3
0
 def test_start_old_cat_view(self):
   #test that if a user has done more than one test the right one is being updated           
   user = User.objects.create_user('john', '*****@*****.**', 'johnpassword')
   user.save()
   self.client.login(username='******', password='******')
   #create structures
   cat_test = CatTest()
   cat_test.name = "Short Test"
   cat_test.save()
   domain = Domain.objects.get(pk=1)
   item_bank = ItemBank()
   item_bank.question_type = QuestionType.objects.get(pk=1)
   item_bank.name = "Fractions"
   item_bank.topic = "Addition"
   item_bank.domain = domain
   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()
   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 = 6
   user_cat_test.save()
   user_cat_test = UserCatTest()
   response = self.client.get('/start/', {'item_bank_id': item_bank.id, 'cat_test_id':cat_test.id})
   ucts = UserCatTest.objects.filter(user=user)
   self.assertEquals(len(ucts),2)
   ucts = ucts.order_by('-id')
   self.assertEquals(ucts[0].items,0)