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.
5 7214
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. - Vector answers = new Vector();
-
Vector questions= new Vector();
-
questions.add("question1");
-
answers.add("answer1");
-
questions.add("question2");
-
answers.add("answer2");
-
questions.add("question3");
-
answers.add("answer3");
-
...
-
System.out.println("The first answer is: " + answers .elementAt(0));
-
System.out.println("The second question is: " + questions.elementAt(1));
You could also try with Properties: - Properties questionsAndAnswers = new Properties();
-
questionsAndAnswers.setProperty("question1", "answer1");
-
questionsAndAnswers.setProperty("question2", "answer2");
-
questionsAndAnswers.setProperty("question3", "answer3");
-
...
-
System.out.println("The first answer is: " + questionsAndAnswers.getProperty("question1"));
or you can use string-arrays: - String [][] questionsAndAnswers = {{"question1", "answer1"}, {"question2", "answer2"}, {"question3", "answer3"}};
-
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:
... - <student>
-
<name>newbie</name>
-
<answerList>
-
<answer>answer1</answer>
-
<answer>answer2</answer>
-
<answer>answer3</answer>
-
</answerList>
-
</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?
...
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.
JosAH 11,448
Recognized Expert MVP
Are those questions multiple choice questions (easy) or are they supposed to
be 'open end' questions (very difficult)?
kind regards,
Jos
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
1.) you can use a Vector. - Vector answers = new Vector();
-
Vector questions= new Vector();
-
questions.add("question1");
-
answers.add("answer1");
-
questions.add("question2");
-
answers.add("answer2");
-
questions.add("question3");
-
answers.add("answer3");
-
...
-
System.out.println("The first answer is: " + answers .elementAt(0));
-
System.out.println("The second question is: " + questions.elementAt(1));
You could also try with Properties: - Properties questionsAndAnswers = new Properties();
-
questionsAndAnswers.setProperty("question1", "answer1");
-
questionsAndAnswers.setProperty("question2", "answer2");
-
questionsAndAnswers.setProperty("question3", "answer3");
-
...
-
System.out.println("The first answer is: " + questionsAndAnswers.getProperty("question1"));
or you can use string-arrays: - String [][] questionsAndAnswers = {{"question1", "answer1"}, {"question2", "answer2"}, {"question3", "answer3"}};
-
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:
... - <student>
-
<name>newbie</name>
-
<answerList>
-
<answer>answer1</answer>
-
<answer>answer2</answer>
-
<answer>answer3</answer>
-
</answerList>
-
</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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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 do not match my
needs. Does anyone have a suggestion?
Todd
|
by: Spammay Blockay |
last post by:
Does anybody know of a solid Java-based email list management product?
- Tim
--
|
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 similar the
"make/makefile" system, but somewhat more
generic/powerful/flexible/higher-level/etc, so that if you have a
sequence (maybe even some simple conditional branches and loops) of
system tasks to perform, you can more easily visualize...
|
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 US!).
I have about one month to create this application.
Has anyone created a client-server application interfacing images as BLOBS
to an MSDE database before? I have previously done this with VB6 - and it
|
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 "Authentication Failure". I did
check the packets and it actually send out the message and server responds
back with the failure message.
My code looks like
proxyobj.Credentials = new NetworkCredential("id", "password");...
| |
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 to hold patient
information for research purposes. What I'm trying to do is create a
form-based query system that will be easier (and less dangerous) for my
future users to use to search the patient information.
Let me outline the specifics,...
|
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. Excellent results screen (customizable) which can be printed right
away.
b. 3/5 simultaneously run quizes along with a authentication system.
c. Should be able to handle MCQs (multiple choice questions) along with
|
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 to build a dynamic SQL query and the subsequent results will be used to fill the report for the chosen columns. The application being used in WebSphere Portals.
Though my search in google for the same gave many tools like JasperReports,...
|
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 any mechanism
where we can extend the same form based authentication to java based
web pages?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |