1 from . import UserInterface
4 class CommandLineInterface (UserInterface):
7 question = self.get_question()
10 print(question.prompt)
16 a = answer.strip().lower()
17 if a in ['q', 'quit']:
20 if a in ['?', 'help']:
22 print(question.prompt)
26 correct = self.process_answer(question=question, answer=answer)
32 def display_results(self):
34 for question in self.quiz:
35 for answer in self.answers.get(question.id, []):
36 self.display_result(question=question, answer=answer)
39 def display_result(self, question, answer):
44 print('question: {}'.format(question.prompt))
45 print('you answered: {}'.format(answer['answer']))
46 print('which was: {}'.format(correct))
49 def display_totals(self):
50 answered = self.answers.get_answered(questions=self.quiz)
51 correctly_answered = self.answers.get_correctly_answered(
54 lc = len(correctly_answered)
55 print('answered {} of {} questions'.format(la, len(self.quiz)))
56 print(('of the answered questions, {} ({:.2f}) were answered correctly'
57 ).format(lc, float(lc)/la))