Forums Register Login

How do I setup a Countdown Timer in a Swing App

+Pie Number of slices to send: Send
Hi,
I'm working on a Test Delivery Engine where I populate Questions & Answer Options from an Access Database. It's supposed to be an exam preparation tool. I have the following issues that I would like you guys to help me out with.

1. I need to track correct and wrong answers without storing them in the DB. The DB is supposed to be read only for the clients. It just stores the Questions, 5 Options i.e A-E and the correct option.

I tried using a counter that increments for correct answers and decrements for wrong answers but I got funny results because students are allowed to go back and forth during the test.

2. I need to set a timer for the tests. So the students can have a feel of the exam scenario.

3. I have a fairly large question pool and I want to randomize the questions so that they don't appear in the same order every time. I also want to ensure that for each test instance, questions that have already been answered don't get loaded again.

Thanx.
+Pie Number of slices to send: Send
this might be one way

create a class Question, it will contain:
the question
the 5 options
the correct answer
a variable to hold the user's answer

each row from the db will be an instance of Question
store these instances in an arraylist
shuffle the arraylist prior to starting
at the finish, iterate the arraylist counting user answers - correct/wrong/no answer

here's a simple countdown timer, you'd need to build in a process to stop
the 'exam' and display the results, when 00 : 00 is reached

+Pie Number of slices to send: Send
Thanks Micheal, I think the timer bit is just what the Doctor ordered, I'll try it out and let you know what's up. How do I build in a process to stop
the 'exam' and display the results, when 00 : 00 is reached

My database is already structured to hold
the question
the 5 options
the correct answer

I don't want to store the user's answer in the database beacuse I don't want the students to be able 2 write to the DB. Maybe you could gimme some sample code on how the Question Class should look like.

I'd also like help with the arraylist, the whole shuffling and Iteration thing. Arrays just aren't my strong point.

Thanx man.
[ November 11, 2004: Message edited by: Olumide Alabi ]
+Pie Number of slices to send: Send
>How do I build in a process to stop
>the 'exam' and display the results, when 00 : 00 is reached

you may have buttons back and next to toggle between the questions, and a
finish button tied to a method displayResults(), to calculate the resuts.

When 00 : 00 is reached, x = 0, so in the timer check for x == 0
if so, disable back/next buttons and call displayResults()


>I don't want to store the user's answer in the database

it will be stored in the instance of Question class relevant to the
question being answered. Once all the data from the db has been loaded into
instances of Question, the db should be closed.

> I'd also like help with the arraylist, the whole shuffling and Iteration thing

ArrayList()

Collections() - look up shuffle()

to iterate the arraylist, it could be as simple as a for loop.

that should be enough to get you started.

if you have problems, post:
the code you've tried
explain what you expect the output to be
explain what the output is, or what the error messages are
+Pie Number of slices to send: Send
Thanx Man,
I'll get right to it and let you know what happens. If I run into any brick walls, I'll definitely get in touch.
Thanx again.
+Pie Number of slices to send: Send
I've basically solved all the issues concerning this program though I had to store the user's answers in the database and compute from there 'cos I couldn't get around it. Right now, My biggest issue is still shuffling the questions.

Appart from that, nowe that the project is nearing completion, I need to know how I can encrypt the DB because it's an Access DB. I'd like to protect the time, energy, money and other resources that have gone into it. Because if some1 can copy the database all he has to do is write his own GUI and he can resell it freely.

Somebody please help!!!
+Pie Number of slices to send: Send







This code that has been given for creating a countdown timer is working.
The project i am working on is also an examination application.
But how to call this function from inside of another frame using a button click and the timer still runs without restarting if that same button is clicked multiple times?
I've tried this code inside a button action area


is this code correct ?
the timer didn't show up on button click when i used this code
please help.
Because those who mind don't matter and those who matter don't mind - Seuss. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 8051 times.
Similar Threads
Sun Certification exam scoring - partial credit?
Failed SCEA Part1 (56%)
Reg HFEJB mock exam
K&B (LearnKey) Tests
mock question response right? (II)
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 19:35:30.