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 start_test(request):
  #check for log in
  if not request.user.is_authenticated():
    return HttpResponseRedirect('/accounts/login/?next=%s' % request.path)
  user = request.user    
  #Get post info
  if request.method == 'GET':
    item_bank_id = request.GET['item_bank_id']
    cat_test_id = request.GET['cat_test_id']
    #Retrieve item bank
    item_bank = ItemBank.objects.get(pk=item_bank_id)
    cat_test = CatTest.objects.get(pk=cat_test_id)
    uib = UserItemBank.objects.get(user=user,item_bank=item_bank)	
    #New user_cat_test
    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.ability = uib.ability
    user_cat_test.stand_dev = uib.ability_stand_dev	
    user_cat_test.save()
    
  #Create cat_test for user with info from item bank
  return render_to_response('start_test.html', {"item_bank": item_bank,"cat_test":cat_test})