Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How do I setup a Countdown Timer in a Swing App  RSS feed

 
Olumide Alabi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Olumide Alabi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
>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
 
Olumide Alabi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Olumide Alabi
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!!
 
santhosh kr
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator







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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!