Ejemplo n.º 1
0
def study_section(chunk,selection):
    section = chunk['sections'][selection[0]]
    p_count=len(section['paragraphs'])
    section['points'] = (0, 0)
    if 'studied' not in section:
        section['studied']=(0,p_count)
    print "************************"
    print
    print
    talker.print_and_talk(section['full_title'])
    talker.print_and_talk("You have studied",section['studied'][0],"paragraphs out of",section['studied'][1])

    for i,paragraph in enumerate(section['paragraphs']):
        print
        for line in paragraph:
            talker.print_and_talk(line)
        print
        talker.ask('Hit enter when ready.')
        # for i in range(30):
        #    print '.'
        new_points = study_text(paragraph)
        if new_points is None:
            return
        if i+1>section['studied'][0]:
            section['studied']=(i+1,p_count)
        old_points = section.get('points', (0, 0))
        section['points'] = (old_points[0] + new_points[0], old_points[1] + new_points[1])
        chunk_o_learning.update_chunk(chunk)
Ejemplo n.º 2
0
def learn_all_the_things():
    done = False
    while not done:
        answer = talker.ask('What subject do you want to learn about?:')
        if answer == "I'm done":
            done = True
        else:
            study_subject(answer.lower())
Ejemplo n.º 3
0
def ask_list(items):
    in_choice = True
    while in_choice:
        for i, v in enumerate(items):
            print i, v
        selection = talker.ask("What is your choice? (q to quit)")
        if selection.upper() == 'Q':
            return None
        selection = int(selection)
        if selection < 0 or selection >= len(items):
            talker.print_and_talk("That was not a valid selection.  Please select again.")
        else:
            return items[selection],selection
Ejemplo n.º 4
0
def study_questions(questions, rate):
    if len(questions) < 1:
        return 0, 0
    points = 0
    to_use = max(1, math.trunc(len(questions) * rate))
    total_points = to_use
    if total_points > 1:
        talker.print_and_talk("I will ask " + str(total_points) + " questions.")
    else:
        talker.print_and_talk("I will ask " + str(total_points) + " question.")
    for question in random.sample(questions, to_use):
        talker.print_and_talk_clozure(question['clozure'])
        answer = talker.ask('Fill in the blank:')
        if answer == "I'm done":
            return None
        if answer.lower() == question['word'].lower():
            talker.print_and_talk("You are correct!")
            points += 1
        else:
            talker.print_and_talk("Sorry, I was looking for:", question['word'])
    talker.print_and_talk("You got ", points, "points out of", total_points)
    return points, total_points