This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

need help with design of quiz applet

 
Ranch Hand
Posts: 4714
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a quiz applet. I looked at Jxam source. He originally created the questions and answers in a database. He then read them into a vector which he serialized.
All my questions will be multiple choice, with the same number of choices and with one correct answer. I plan for 3 difficulty levels. Questions chosen at random.
What are my options? How would you do it?
[This message has been edited by Randall Twede (edited February 02, 2001).]
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Randell
I might be able to help.
I'd developed a quiz application for the company i'm working
and i did it the same way as Jxam ie writing to Oracle Database and reading into a vector and passing to the frame from The Servlet.
You can contact me by mail for any help <pravin_rp@hotmail.com>.
Regards,
Pravin
 
Randall Twede
Ranch Hand
Posts: 4714
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Pravin Actually, it seems, Jxam serialized the vector and sent it with the applet. Whereas it seems you did it on the server side using the actual database. I could do that as well. I am looking to find my options. So I hope for more responses as well.
One point. Jxam was zipped and required a download. That is not tolerable for me.
My applet can be much simpler than Jxam. there is no total score or explaining the right answers. All I must do is add 10000 to the balance for their session for each correct answer.
http://javaguy.yi.org

[This message has been edited by Randall Twede (edited February 03, 2001).]
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Obvious choices include whether to do the whole thing at the server and just present a series of HTML pages, or to have an applet which gets sent a subset of the questions and presents them all, or have an applet which gets sent all the questions and chooses which ones to present.
Other choices include whether to send the answers with the questions and validate them on the client, or check each answer back with the server, or check all the answers with the server in one go at the end of the "exam".
As for transmission of questions and answers you can use one of the built-in java formats such as a serialized Vector or "properties" format, you could use a protocol of your own devising or you could use XML. You could even dynamically build and compile a customized applet which "knows" the questions and answers so they are transferred using the applet download.
Do any of these opions seem appealing to you? If so, we can look at the ones you like in more detail.
 
Randall Twede
Ranch Hand
Posts: 4714
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The quiz is optional so I dont think the visitor will mind too much if I use his machine(applet). My first thought is to send all the questions and answers and let the applet decide. Will that slow down the loading? I dont think it would too much.
I want the user to be able to quit the quiz at any time, so answers must be validated individually. My first thought is to do it on the client.


As for transmission of questions and answers you can use one of the built-in java formats such as a serialized Vector or "properties" format, you could use a protocol of your own devising or you could use XML. You could even dynamically build and compile a customized applet which "knows" the questions and answers so they are transferred using the applet download.


This is what I really wanted help with. I suppose each method has its advantage. How can my applet use XML? I am thinking the question bank can change and it would be good not to have to recompile when it does.
I also have to add their "winnings" to their balance in their session. But I can probably figure that out myself.
 
Randall Twede
Ranch Hand
Posts: 4714
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A serialized collection in codebase folder might be best.
If I make all questions and answers a part of the applet itself, I will have to recompile when question bank changes. Doable but not desireable. Probably easiest for me to implement though.
I'm not sure about customized applet. Might be a way to go.
Having the applet get questions and answers from an XML file(or even .txt file for that matter) in codebase folder might be best approach.
Good thing nobody is breathing down my neck wanting it yesterday
One concideration is that I dont have Apache configured ideally. The way it is almost everything is served up by tomcat, including most of the static pages, so less requests to the server is better.

[This message has been edited by Randall Twede (edited February 03, 2001).]
 
Randall Twede
Ranch Hand
Posts: 4714
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Different question. Inside the applet I am thinking of using a HashMap with a String(question) as the key and an Array(answers) for the value. I could then use keyset() method to get a set from which I could randomly choose a question. Actually 3 Hashmaps, one for each difficulty level. Does that sound like a good plan?
[This message has been edited by Randall Twede (edited February 03, 2001).]
 
Randall Twede
Ranch Hand
Posts: 4714
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still wanting comments and recommendations, but this is what I am thinking.
I will create the Q&A bank in Notepad(.txt)
I will write a seperate application to read the .txt file and ceate, assign and serialize the HashMap.
The Applet will read the serialized HashMap containing all Q&A.
I can use .txt because all questions have the same number of possible answers. Will use readln().
[This message has been edited by Randall Twede (edited February 04, 2001).]
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read the questions from a text file into a vector using the BufferedReader's readline method. So each line is an element in the vector. Then I iterate through the vector to present the questions to the user interface. I shall put the source up for download as soon as I finish fine tuning it. It may not be of much use to you because my objectives were different, I wrote this just to test if the whole thing could be achieved in under 500 lines. I got it done in under 450 lines. Creating the user interface took up most of it. So if you are using an IDE the whole thing can be achieved by writing approximately 50 lines of code.
Rgds
Sahir
[This message has been edited by Sahir Shah (edited February 05, 2001).]
 
Randall Twede
Ranch Hand
Posts: 4714
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sahir,
It sounds like you did the same thing I am thinking is best.
I write in Notepad but use Forte to compile(they should have named it Snail).
Oh, but you didnt serialize the vector. I dont have to either
[This message has been edited by Randall Twede (edited February 05, 2001).]
 
Sahir Shah
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Watch out for Internet Explorer (Microsoft Virtual Machine) compatibility though . By the way what is a good font for questions that contain code. Sans Serif makes it look goofy.
 
Randall Twede
Ranch Hand
Posts: 4714
9
Scala Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sahir,
I would choose a common font. I dont know what would look good though. My Applet is almost done. I hope HashMap will not be a problem for browser, but it looks like it might. Figures, now that I have coded it
It looks like my Applet will be less than 200 lines.
you can see what I have so far here: http://www.javaranch.com/ubb/Forum33/HTML/001566.html

[This message has been edited by Randall Twede (edited February 05, 2001).]
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!