Python Forum
I haven't a clue how to implement this logic
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I haven't a clue how to implement this logic
#1
I would like to write a psychology test for the fun of it. It would have ten questions and four multiple choice answers. At the end of the test you could see your score. But the functionality I would like to write into it is the ability to go back to whichever questions the user got wrong and show him what the correct answer was.

I have no clue as to how to do that. One fellow on another forum told me to use a database. But that is not saying much. I would need much more detailed answers.

Please post some suggestions if you have any.
Reply
#2
If you have no clue then maybe you are not up to the task.

However, some clues how I would approach the task:

- have questions, multiple choice answers (including correct answer)
- one at the time output question with choices to screen
- save user input (answer)
- after all questions are asked compare correct answers with user answers
- for every correct answer output to screen appropriate information, for non-correct answers output to screen appropriate message along with user answer and the correct answer.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply
#3
My approach -
Define an Answer class, with the text of the answer, text to be displayed if chosen, flag as to whether this is the right or wrong answer, and flag as to whether this answer was chosen.
Define a Question class, containing the text of the question and containing 4 Answer class items

Instantiate and populate the 40 Answer items and 10 Question items.

Loop through, displaying each question and the text of each answer, asking user to respond. Do validity checks on the responses (if 1-4 don't allow 5 or Moose as responses). Flag the chosen Answer items

When complete, loop through again. If the chosen Answer item is correct, move on. If not, display the response text. During this loop (the grading loop) you can also keep a count of right and wrong answers and give a percent at the end.
Reply
#4
(Apr-02-2020, 09:11 AM)perfringo Wrote: If you have no clue then maybe you are not up to the task.

However, some clues how I would approach the task:

- have questions, multiple choice answers (including correct answer)
- one at the time output question with choices to screen
- save user input (answer)
- after all questions are asked compare correct answers with user answers
- for every correct answer output to screen appropriate information, for non-correct answers output to screen appropriate message along with user answer and the correct answer.

I've never done anything like this. My idea was to have the user completely go through the entire test and after the test is over then telling him or her how many questions were answered correctly and then have a Back button and the test would go back to the specific question he or she got wrong and showed them what the correct answer was.

But I think your method would be simpler. That way it's like show correct answer as you proceed through the test.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I have no clue what I am doing wrong here elroberto 4 1,384 Jun-18-2022, 08:56 PM
Last Post: deanhystad
  Right way to implement interfaces yossiy123 1 1,282 May-12-2022, 10:31 AM
Last Post: Gribouillis
  Can I get a clue about testing please? Mustey 8 3,679 Apr-12-2021, 04:45 PM
Last Post: Larz60+
  how can a variable change if I haven't changed it? niminim 5 3,082 Apr-07-2021, 06:57 PM
Last Post: niminim
Question best way to implement algorithm hamidze 3 2,225 Feb-27-2021, 07:10 PM
Last Post: hamidze
  Trying to implement Best of 3 logic in rock paper scissors game ShAhCh 5 3,376 May-11-2020, 04:31 PM
Last Post: ShAhCh
  Getting syntax error, no clue why KaynRyu 4 3,141 Mar-26-2019, 02:43 PM
Last Post: KaynRyu
  I have no clue whats wrong... Jack_03 1 2,838 Sep-28-2017, 05:36 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020