Ejemplo n.º 1
0
def ask_questions(request):
    questions = []
    # 20 from each source.
    for source in SOURCES:
        questions.extend(UserTestQuestion.objects.filter(
          language=en, source=source).order_by('asked', '?')[:20])
    choices = VALUES.items()
    choices.sort()
    choices.reverse()
    random.shuffle(questions)
    for q in questions:
        q.asked += 1
        q.save()
    return render_to_response('usertest/ask.html', locals())
Ejemplo n.º 2
0
def inferences_from_file(filename):
    f = open(filename)
    got = []
    for line in file:
        line = line.strip()
        if not line: continue
        got.append(eval(line))
    return got

def ask_questions(request):
    questions = []
    # 20 from each source.
    for source in SOURCES:
        questions.extend(UserTestQuestion.objects.filter(
          language=en, source=source).order_by('asked', '?')[:20])
    choices = VALUES.items()
    choices.sort()
    choices.reverse()
    random.shuffle(questions)
    for q in questions:
        q.asked += 1
        q.save()
    return render_to_response('usertest/ask.html', locals())

from sys import maxint
def temp_user(done_before=False):
    prefix = 'usertest10_use_'
    if done_before: prefix = 'usertest10_skip_'
    username = prefix + str(random.randint(0, 10000000))
    password = '******'
    return User.objects.create_user(username, '', password)