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
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')
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()
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
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
def get_usr_ans(choices): '''Passes argument choices to func in_choices in the valid module''' uans = valid.in_choices(choices) '''Change validated char into proper num for compare''' if uans == 'A': uans = 0 elif uans == 'B': uans = 1 elif uans == 'C': uans = 2 else: uans = 3 return uans
def get_usr_ans(qtype): '''Sets the possible choices(tuple) depending on question type''' if qtype == 'tfq': choices = ('A', 'B') else: choices = ('A', 'B', 'C', 'D') '''Calls in_choices() func from valid module''' '''Pass a list/tuple, ask for input until input is in that list/tuple''' uans = valid.in_choices(choices) '''Change validated char into proper num for compare''' if uans == 'A': uans = 0 elif uans == 'B': uans = 1 elif uans == 'C': uans = 2 else: uans = 3 return uans
def menu(): subs = get_subjects() print('Choose which subject you would like to study:') sub = valid.in_choices(subs, 'Subjects: ') return sub
def edit_study(): fp.s_txt() if valid.in_choices(['Study', 'Edit']) == 'Study': return 'Study' else: return 'Edit'