473,322 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

How to create Java based quiz system? need ideas

3
Hello everyone,

One of my course works is to implement a java based quiz system. the program consists of two modules one for the teacher to create, set questions , answers and the number of questions to be published, and the other one is to allow the student to run the quiz. the data for the quiz is stored in text files and the correct answers are encrypted. everytime the students take a quiz the result has to be stored and a report containing the number of questions were answered correctly and the number of questions were answered incorrectly to be included for the teacher to view later.

Would really appreciate some suggestions regarding the following questions.

1. I am not entirly sure what data structure to use in order to link each question with the right answer?

2. Whether to store the correct answers in a seperate file or in the same file as the questions and their associated answers?

3. How to Structure the database file?

Thanks for all your replys in advance.
Nov 20 '07 #1
5 7184
chaarmann
785 Expert 512MB
Hello everyone,

One of my course works is to implement a java based quiz system. the program consists of two modules one for the teacher to create, set questions , answers and the number of questions to be published, and the other one is to allow the student to run the quiz. the data for the quiz is stored in text files and the correct answers are encrypted. everytime the students take a quiz the result has to be stored and a report containing the number of questions were answered correctly and the number of questions were answered incorrectly to be included for the teacher to view later.

Would really appreciate some suggestions regarding the following questions.

1. I am not entirly sure what data structure to use in order to link each question with the right answer?

2. Whether to store the correct answers in a seperate file or in the same file as the questions and their associated answers?

3. How to Structure the database file?

Thanks for all your replys in advance.
1.) you can use a Vector.
Expand|Select|Wrap|Line Numbers
  1. Vector answers = new Vector();
  2. Vector questions= new Vector();
  3. questions.add("question1");
  4. answers.add("answer1");
  5. questions.add("question2");
  6. answers.add("answer2");
  7. questions.add("question3");
  8. answers.add("answer3");
  9. ...
  10. System.out.println("The first answer is: " + answers .elementAt(0));
  11. System.out.println("The second question is: " + questions.elementAt(1));
You could also try with Properties:
Expand|Select|Wrap|Line Numbers
  1. Properties questionsAndAnswers = new Properties();
  2. questionsAndAnswers.setProperty("question1", "answer1");
  3. questionsAndAnswers.setProperty("question2", "answer2");
  4. questionsAndAnswers.setProperty("question3", "answer3");
  5. ...
  6. System.out.println("The first answer is: " + questionsAndAnswers.getProperty("question1"));
or you can use string-arrays:
Expand|Select|Wrap|Line Numbers
  1. String [][] questionsAndAnswers = {{"question1", "answer1"}, {"question2", "answer2"}, {"question3", "answer3"}};
  2. System.out.println("The first answer is: " + questionsAndAnswers[0][1]);
2.) store them in a separate file. One file for the original question and answer. And one file for each student for all the answers a student has given.
If you mix all data in one file, you will have problems if you want to modify/delete some data later on.

3.) Use XML. Then here is already a java-method that you can use to read and save all the data for you. (read about SAX and DOM). XML is industrial standard. A lot of programs can read it or create it and so you can use the data for everything. You can display the file directly into your browser, convert it to a table for a database, edit it comfortably etc.
For example:
...
Expand|Select|Wrap|Line Numbers
  1. <student>
  2. <name>newbie</name>
  3. <answerList>
  4.     <answer>answer1</answer>
  5.     <answer>answer2</answer>
  6.     <answer>answer3</answer>
  7. </answerList>
  8. </student>
4.) Now I have a question:
It's not quite clear why you post this question in this forum if this task was given by a teacher for your programming course. If others solve it for you, then you don't learn. I hope the answers gave to you are getting you started. But try yourself as much as you can. Next time, post some code from your own tries where you got stuck. Have you tried already or just copied the task onto the forum without trying or thinking/reading yourself?
Nov 20 '07 #2
r035198x
13,262 8TB
...

3. How to Structure the database file?

...
What database file?

1.) you can use a Vector.
Vectors are not the right approach here. Besides they being old, they do not store a mapping relationship. A Map is much better.
Nov 20 '07 #3
JosAH
11,448 Expert 8TB
Are those questions multiple choice questions (easy) or are they supposed to
be 'open end' questions (very difficult)?

kind regards,

Jos
Nov 20 '07 #4
pefok
3
Thanks for all your replys .

By the database i mean the test files one of which holds the quizzes and one of which is holds the correct answers and has to be encrypted.

The questions are multi-choice with four answers to each question and one correct answer.

I am kinda thinking towards array list , What do you think?

Many thanks
Nov 27 '07 #5
pefok
3
1.) you can use a Vector.
Expand|Select|Wrap|Line Numbers
  1. Vector answers = new Vector();
  2. Vector questions= new Vector();
  3. questions.add("question1");
  4. answers.add("answer1");
  5. questions.add("question2");
  6. answers.add("answer2");
  7. questions.add("question3");
  8. answers.add("answer3");
  9. ...
  10. System.out.println("The first answer is: " + answers .elementAt(0));
  11. System.out.println("The second question is: " + questions.elementAt(1));
You could also try with Properties:
Expand|Select|Wrap|Line Numbers
  1. Properties questionsAndAnswers = new Properties();
  2. questionsAndAnswers.setProperty("question1", "answer1");
  3. questionsAndAnswers.setProperty("question2", "answer2");
  4. questionsAndAnswers.setProperty("question3", "answer3");
  5. ...
  6. System.out.println("The first answer is: " + questionsAndAnswers.getProperty("question1"));
or you can use string-arrays:
Expand|Select|Wrap|Line Numbers
  1. String [][] questionsAndAnswers = {{"question1", "answer1"}, {"question2", "answer2"}, {"question3", "answer3"}};
  2. System.out.println("The first answer is: " + questionsAndAnswers[0][1]);
2.) store them in a separate file. One file for the original question and answer. And one file for each student for all the answers a student has given.
If you mix all data in one file, you will have problems if you want to modify/delete some data later on.

3.) Use XML. Then here is already a java-method that you can use to read and save all the data for you. (read about SAX and DOM). XML is industrial standard. A lot of programs can read it or create it and so you can use the data for everything. You can display the file directly into your browser, convert it to a table for a database, edit it comfortably etc.
For example:
...
Expand|Select|Wrap|Line Numbers
  1. <student>
  2. <name>newbie</name>
  3. <answerList>
  4.     <answer>answer1</answer>
  5.     <answer>answer2</answer>
  6.     <answer>answer3</answer>
  7. </answerList>
  8. </student>
4.) Now I have a question:
It's not quite clear why you post this question in this forum if this task was given by a teacher for your programming course. If others solve it for you, then you don't learn. I hope the answers gave to you are getting you started. But try yourself as much as you can. Next time, post some code from your own tries where you got stuck. Have you tried already or just copied the task onto the forum without trying or thinking/reading yourself?




Thanks alot for your suggestions chaarmann,

I have been trying but I would like to use the best suited data structure before submitting it , I have been thinking about using XML but not allowed to do so , I have been trying with array list and it looks promising , I agree with what you are saying trying and learning from it.
Nov 27 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Todd Cary | last post by:
I would like to have an Open Source HTML editor on a Web site so the user can create HTML based text. Google brings up too many matches when I type in "Browser HTML editor Java Open Source" that...
7
by: Spammay Blockay | last post by:
Does anybody know of a solid Java-based email list management product? - Tim --
10
by: Hung Jung Lu | last post by:
Hi, Does anyone know whether there is any generic GUI-based build system around? (Python-based would be great. Also, for now I am only looking for Windows OS.) By "build system" I mean something...
0
by: Liddle Feesh | last post by:
Good afternoon m.p.d.l.vb :) I'm looking for some sound system design ideas. I'm planning to build an application in VB.NET that interfaces with MSDE for a local estate agency (realtor in the...
0
by: Soung | last post by:
I'm trying to create a simple test application that can talk with the Java based web service. The problem is everytime I execute my client application it comes back with an error message saying...
5
by: SeanCly10 | last post by:
Hi all. I don't want to sound like a complete idiot here, but I'm somewhat limited in my coding knowledge, and I need some advice and help. I'm working on a database that will eventually be used...
3
by: Raqueeb Hassan | last post by:
Hello, I was helping one of my friend's school on setting up a online quiz system. They have the AMP systems to host php+mysql. The quiz script/software should have the following features: a....
0
by: itsraghz | last post by:
Hello people, My present project need is to have an Open Source Java based reporting tool, which would allow the users to customize the fields to be chosen at runtime. The chosen fields are used...
4
by: santosh.tripathy | last post by:
We have a requirement where in a java based web application is getting integrated with the existing .net based web pages. The .net based web pages are secured through forms authentication. Is there...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.