Exemple #1
0
def new_sub():
    name = input('Input subject name: ')
    fp.s_txt()
    name = name.lower().capitalize()
    if valid.yes_no('Is "' + name + '" the correct subject name') == 'y':
        os.mkdir('subjects\\' + name + '\\')
    return name
Exemple #2
0
def yes_no(question):
    print(question + '?')
    fp.s_txt()
    yesno = ''
    while yesno not in ('y', 'n', 'yes', 'no'):
        print('Please enter yes or no. (y or n)')
        yesno = input().lower()
    return yesno[:1]
Exemple #3
0
def addQuestion(sub, qz, qType):
    while 1:
        q = input('Type ' + qType + ' question: ')
        fp.s_txt()
        if valid.yes_no('Is "' + q + '" the question you want to add') == 'y':
            with open('subjects\\' + str(sub) + '\\' + str(qz) + '\\' + str(qType.lower()) + '\\' + str(qType.lower()) + 'qs.txt', 'a') as f:
                f.write(str(q) + '\n')
                f.close()
            break
    addAnswer(sub, qz, qType)
Exemple #4
0
def addAnswer(sub, qz, qType):
    if qType == 'Tf':
        print('Enter the Answer(T/F)')
        with open('subjects\\' + sub + '\\' + qz + '\\tf\\as\\tfas.txt',
                  'a') as f:
            f.write(valid.in_choices(['True', 'False']) + '\n')
            f.close()
    else:
        qNum = fp.lines_in('subjects\\' + sub + '\\' + qz + '\\' + qType +
                           '\\' + qType.lower() + 'qs')
        f = open(
            'subjects\\' + sub + '\\' + qz + '\\' + qType + '\\as\\' +
            qType.lower() + 'a' + str(qNum) + '.txt', 'w')
        for i in range(4):
            while 1:
                if i == 0:
                    fp.s_txt()
                    ans = input('Enter the CORRECT answer:')
                    fp.s_txt()
                else:
                    fp.s_txt()
                    ans = input('Enter a FALSE answer:')
                    fp.s_txt()
                if valid.yes_no('Is "' + ans +
                                '" the answer you want to add') == 'y':
                    f.write(ans + '\n')
                    break
        f.close()
Exemple #5
0
def in_choices(choices, prompt='Please choose '):
    x = str
    clen = 0
    ##    longc = 0
    for c in choices:
        ##        if c > longc:
        ##            longc = c
        clen += len(c) + 4
    while x not in choices:
        print(prompt + str(choices))
        fp.s_txt(1 + len(prompt) + clen)
        x = input()
        x = x.lower().capitalize()
        #print(x)
        fp.s_txt(len(x) + 2)
        print()
    return x
Exemple #6
0
def prnt_score(c, totQs, xwrong, ywrong):
    score = (c/totQs) * 100
    fp.s_txt()
    print('You answered ' + str(c) + '/' + str(totQs) + ' correctly.')
    print('Your score is: ' + str(round(score, 1)) + '%!')
    fp.s_txt()
    # If the score is perfect, dont ask to review, dont show qs wrong
    if score == 100:
        rev = 'n'
    else:
        print('You answered', len(xwrong), 'multiple choice questions',
          'incorrectly:\n', str(xwrong))
        fp.s_txt()
        print('You answered', len(ywrong), 'T/F questions incorrectly:\n',
          str(ywrong))
        fp.s_txt()
        rev = valid.yes_no('Review the questions answered incorrectly')
        fp.s_txt()
    return rev
Exemple #7
0
def main():
    # Run until broken, I think this may be my fav method of keeprunning
    tfa1 = open("tfa1.txt", "w")
    tfa1.write("True")
    tfa1.close()
    while True:
        '''Use the menu to choose the subject to study'''
        #sub = menu()
        while 1:
            sub = new_menu()
            if sub == 'New':
                sub = new_sub()
            else:
                break
        while 1:
            quiz = new_menu(sub, 1)
            if quiz == 'New':
                quiz = new_quiz(sub)
            else:
                break
        '''Ask all questions from that subject's folders'''
        c, totQs, xwrong, ywrong = ask_q_set(sub, quiz)
        
        '''When player is out of questions print the % correct'''
        '''Ask to review incorrect questions'''
        rev = prnt_score(c, totQs, xwrong, ywrong)
        if rev == 'y':
            while len(xwrong) > 0 or len(ywrong) > 0:
                c, totQs, xwrong, ywrong = ask_q_set(sub, rev, xwrong, ywrong)
                rev = prnt_score(c, totQs, xwrong, ywrong)
                if rev == 'n':
                    break

        '''Ask to run again'''
        run = valid.yes_no('Continue studying')
        fp.s_txt()
        if run == 'n':
            break
            sys.exit()
Exemple #8
0
def menu():
    subs = get_subjects()
    fp.s_txt()
    print('Choose which subject you would like to study:')
    fp.s_txt(46)
    sub = valid.in_choices(subs)
    fp.s_txt()
    return sub
Exemple #9
0
def main():
    # Run until broken, I think this may be my fav method of keeprunning
    while True:
        '''Use the menu to choose the subject to study'''
        sub = menu()
        '''Ask all questions from that subject's folders'''
        c, totQs, xwrong, ywrong = ask_q_set(sub)
        
        '''When player is out of questions print the % correct'''
        '''Ask to review incorrect questions'''
        rev = prnt_score(c, totQs, xwrong, ywrong)
        if rev == 'y':
            while len(xwrong) > 0 or len(ywrong) > 0:
                c, totQs, xwrong, ywrong = ask_q_set(sub, rev, xwrong, ywrong)
                rev = prnt_score(c, totQs, xwrong, ywrong)
                if rev == 'n':
                    break

        '''Ask to run again'''
        run = valid.yes_no('Continue studying')
        fp.s_txt()
        if run == 'n':
            break
            sys.exit()
Exemple #10
0
def ask_q_set(sub, rev = 'n', xrlist = [], yrlist = []):
    # Questions answeres incorrectly from corresponding lists.
    xwrong = []
    ywrong = []
    # Current question
    currQ = 1
    # Number answered correctly
    c = 0
    # Set location of subject question type folder.
    xloc = 'subjects\\' + sub + '\\mc'
    yloc = 'subjects\\' + sub + '\\tf'
    if os.path.exists(xloc):
    # Set number of questions in each file
        xLines = fp.lines_in(xloc + '\\mcqs')
    if os.path.exists(yloc):
        yLines = fp.lines_in(yloc + '\\tfqs')    

    if rev == 'y':
        '''Use the questions answered incorrectly as the question list'''
        x = xrlist
        y = yrlist
        totQs = len(xrlist) + len(yrlist)
    else:
        # Create lists of range of nums according to qs in file
        x = list(range(1, xLines + 1))
        y = list(range(1, yLines + 1))
        # Add qs to total number of questions
        totQs = xLines + yLines
        
    '''Run until all questions are asked.'''
    while len(x) > 0 or len(y) > 0:
        '''Print Q# out of totQs'''
        fp.s_txt(24)
        print('Question ' + str(currQ), 'out of ' + str(totQs) + ':')
        fp.s_txt(24)
        
        '''Get list to choose q from'''
        qlist = q_list(x, y)
    
        if qlist == 0:
            '''select the nxtq number,'''
            nxtq = q_select(x, xLines)
            '''remove the nxtq number from the respective q list'''
            x.remove(nxtq)
            qloc = xloc + '\\mcqs'
            answers, choices, cans = mc_ans_build(xloc, nxtq)
        else:
            nxtq = q_select(y, yLines)
            y.remove(nxtq)
            qloc = yloc + '\\tfqs'
            answers, choices, cans = tf_ans_build(yloc, nxtq)
##        print('CANS = ' + str(cans))
        '''Ask the question'''
        q_ask(nxtq, qloc)
        '''Print the answers'''
        q_ans_disp(answers)
        '''Get the user's answer'''
        uans = get_usr_ans(choices)
        
        '''Compare answers, if user answer is correct, increment correct'''
        if uans == cans:
            c += 1
        elif qlist == 0:
            xwrong.append(nxtq)
        else:
            ywrong.append(nxtq)
        currQ += 1
    return c, totQs, xwrong, ywrong
Exemple #11
0
def menu(erev, sub = ' ', qz = 0):
    if qz == 0:
        subs = get_subjects()
        if erev == 'Edit':
            subs.append('New')
        fp.s_txt()
        print('Choose which subject you would like to ' + erev.lower() + ':')
        erev.capitalize()
        print('Type new for new subject.')
        fp.s_txt(46)
        sub = valid.in_choices(subs)
        fp.s_txt()
        return sub
    else:
        quizzes = get_quizzes(sub)
        if erev == 'Edit':
            quizzes.append('New')
        fp.s_txt()
        print('Choose which quiz you would like to ' + erev.lower() + ':')
        erev.capitalize()
        print('Type new for new quiz.')
        fp.s_txt(46)
        quiz = valid.in_choices(quizzes)
        fp.s_txt()
        return quiz
Exemple #12
0
def edit_study():
    fp.s_txt()
    if valid.in_choices(['Study', 'Edit']) == 'Study':
        return 'Study'
    else:
        return 'Edit'
Exemple #13
0
def new_menu(sub = ' ', qz = 0, erev = 'review'):
    if qz == 0:
        subs = get_subjects()
        subs.append('New')
        fp.s_txt()
        print('Choose which subject you would like to ' + erev + ':')
        print('Type new for new subject.')
        fp.s_txt(46)
        sub = valid.in_choices(subs)
        fp.s_txt()
        return sub
    else:
        quizzes = get_quizzes(sub)
        quizzes.append('New')
        fp.s_txt()
        print('Choose which quiz you would like to ' + erev + ':')
        print('Type new for new quiz.')
        fp.s_txt(46)
        quiz = valid.in_choices(quizzes)
        fp.s_txt()
        return quiz