This content has been marked as final. Show 22 replies
797836 wrote:Sir, yes Sir!
Now tell me how we can do the randomization
and how we can label the questions which is been answered?This depends on your data storrage. Ideally you'd have a database holding the questions. Then you could simpla add a table that stores the question ID, the user id and the ID of the answer (when given). this way you can later track wich user passed and wich failed.
The minimal solution is to put a bean in the session context of the application server, but then the information will be lost when the session expires.
To make it clear, I am working on a project that requires me to create a class containing 20 questions and then I have to randomly select 5 questions with the respective answers in objectives (4 of them)Is there some good reason why you didn't mention that 11 days ago when you first asked for help? Or is it possible that you are still discovering requirements? In which case asking for a solution is considerably premature.
797836 wrote:Excellent. Being a proper developer you should now be capable to pick it up and implement it. Or at least be able to come up with a start.
Thanks. Honestly I was working on the requirements as we havent got the exact requirement which we are looking for.Now we got the exact picture of what we need to do.
Thanks. This is the design i am looking at:-
public class Question (mapped to the Question table)
private Integer questionId;
private Integer userId; // FK of User table
private String questionDesc;
private Integer answerId; // FK of Answer table
private List<Answer> answerDesc; // FK of Answer table
private String category ; // FK of Category table (Java,.NET, etc)
public class Answer
private Integer answerId;
private String answerDesc;
Now here the Question object will hold the details of the answers as well.
Hence for a particular User who has logged in based on this expertise in a particular category (Java, .net, etc) the questions and the answers will be displayed. Here the
QuestionId UserId QuestioonDesc AnswerId AnswerDesc Category
100 200 What is JVM? 1 aaa,bbb,ccc,ddd Java
For the above question option 1 is correct which is aaa. Whether the above is right? or is there any better way to design the tables? . please clarify. Thanks.
After 400+ posts, isn't it time to learn how to put formatted code?
You should have a marker in your Answer Table that indicates correct ones.
<tt>userId</tt> should not be part of the Question table unless each user gets it verry own set of questions.
And bye the risk of repeeting myself:
I'd crate another table that connects users, questions and the answer given by the user:
UserAnswer( userId, questionId, answerId)
Thanks TPD. Here the answerId will display the 4 objectives(that is the 4 answer options for the questions?) if not how we can map the multiple answers (in this case 4 for a question) and also mentioning the correct answer among the four in answer table? please clarify. Whether the multiple answers for the question should be separated by a comma as i shown in the previous example? Please clarify.