Exemplo n.º 1
0
def main():
    run = 'y'
##    # Location of the mcqs.txt file
    mcqloc = 'subjects\\python\\mc\\mcqs'
##    # Total number of multiple choice questions
    MCQS = fp.lines_in(mcqloc)
##    # Location of the tfqs.txt file
    tfqloc = 'subjects\\python\\tf\\tfqs'
##    # Total number of T/F questions
    TFQS = fp.lines_in(tfqloc)
##    # Total number of questions constant
    TOTALQS = MCQS + TFQS
    # Questions list, remove num once asked
    mcqs = list(range(1, MCQS + 1))
    tfqs = list(range(1, TFQS + 1))

    while run == 'y':

        ask_q_set(tfqs, mcqs, TFQS, MCQS, tfqloc, mcqloc)

        '''When player is out of questions print the % correct'''
        prnt_score(correct, TOTALQS, tfwrong, mcwrong)
        
        '''Ask to review incorrect questions'''
        review = valid.yes_no('Review the questions answered incorrectly')
        
        '''Ask to run again'''
        run = valid.yes_no('Run Again')
Exemplo n.º 2
0
def main():
    samesub, sameqz = 'n', 'n'
    while 1:
        erev = edit_study()
        if samesub == 'n':
            sub = menu(erev)
            if sub == 'New':
                sub = new_sub()
        if sameqz == 'n':
            qz = menu(erev, sub, 1)
            if qz == 'New':
                qz = new_quiz(sub)
        if erev == 'Edit':
            while 1:
                addQuestion(sub, qz, valid.in_choices(['Mc', 'Tf']))
                if valid.yes_no('Add another question') == 'n':
                    break
        else:
            c, totQs, xwrong, ywrong = ask_q_set(sub, qz)
            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, qz, rev, xwrong, ywrong)
                    rev = prnt_score(c, totQs, xwrong, ywrong)
                    if rev == 'n':
                        break
        if valid.yes_no('Continue studying') == 'n':
            break
        else:
            samesub = valid.yes_no('Study same subject')
            sameqz = valid.yes_no('Study same quiz')
Exemplo n.º 3
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
Exemplo n.º 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()
Exemplo n.º 5
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)
Exemplo n.º 6
0
def prnt_score(c, totQs, xwrong, ywrong):
    score = (c / totQs) * 100
    print('You answered ' + str(c) + '/' + str(totQs) + ' correctly.')
    print('Your score is: ' + str(round(score, 1)) + '%!')
    # 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))
        print('You answered', len(ywrong), 'T/F questions incorrectly:\n',
              str(ywrong))
        rev = valid.yes_no('Review the questions answered incorrectly')
    return rev
Exemplo n.º 7
0
def main():
    while True:
        sub = 'python'
        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')
        if run == 'n':
            break
            sys.exit()
Exemplo n.º 8
0
def main():
    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')
        if run == 'n':
            break
            sys.exit()
Exemplo n.º 9
0
def new_quiz(sub):
    while 1:
        name = input('Input quiz name: ')
        if valid.yes_no('Is "' + name + '" the correct quiz name') == 'y':
            os.mkdir('subjects\\' + sub + '\\' + name)
            os.mkdir('subjects\\' + sub + '\\'  + name + '\\mc')
            f = open('subjects\\' + sub + '\\'  + name + '\\mc\\mcqs.txt', 'w')
            f.close()
            os.mkdir('subjects\\' + sub + '\\'  + name + '\\mc\\as')
            os.mkdir('subjects\\' + sub + '\\'  + name + '\\tf')
            f = open('subjects\\' + sub + '\\'  + name + '\\tf\\tfqs.txt', 'w')
            f.close()
            os.mkdir('subjects\\' + sub + '\\'  + name + '\\tf\\as')
            f = open('subjects\\' + sub + '\\'  + name + '\\tf\\as\\tfcs.txt', 'w')
            f.write('True\nFalse\n')
            f.close()
            f = open('subjects\\' + sub + '\\'  + name + '\\tf\\as\\tfas.txt', 'w')
            f.close()
            break
    return name
Exemplo n.º 10
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()