cancel
Showing results for 
Search instead for 
Did you mean: 

Quiz Application issues

Former Member
0 Kudos

Hi Friends,

Iam trying to build a quiz application with 50 questions ( each question in a UI Group). Instead of using 50 questions I am using 50 groups in a single view. I am doing this because the NEXT and BACK buttons are constant and only questions keeps on changing by clicking NEXT button.

In the implementation, onActionNext, I am using WD Visibility property to make only one group to be visible at a time.

Also the display of questions are not Sequential. It depends upon the user answer for previous question.

How do I achieve the Back Button functionality?

Could you please suggest be how does the Context to be designed.

Thanks in Advance

Jaya

Accepted Solutions (0)

Answers (5)

Answers (5)

snehal_kendre
Active Contributor
0 Kudos

HI Sudha,

Armin's solution is best for your application.

Here as you said moving to next question is depends upon answer of previous question.

Then implement as Armin said

then apply your logic here to move next question.

And at the same time store the lead selection of current question. so whenever you want to go back you can just write

wdContext.nodeQuestions().moveTo(leadselction value of currentquestion);

e.g. current question is Q1. store its leadselection as prv_leadselection.

after Q1 you move to Qn as per your logic.

if you want to go back

wdContext.nodeQuestions().moveTo(prv_leadselction);

Former Member
0 Kudos

Using 50 groups sounds rather silly to me. How do you store the questions and answers in the context?

Example:


Questions (node, cardinality=0:n)
- text (string)
- Answers (node, cardinality=0:n, singleton=false)
- text (string)

To store a question with its answers in this context structure, you can use code like this:


IQuestionsElement q = wdContext.createAndAddQuestionsElement();
q.setText("How do I solve this problem?");
IAnswersElement a1 = q.nodeAnswers().createAndAddAnswersElement();
a1.setText("By reading SDN posts");
IAnswersElement a2 = q.nodeAnswers().createAndAddAnswersElement();
a2.setText("By thinking myself");

A simple UI could look like this:


QuestionGroup (Group)
- Header: QuestionGroupHeader (Caption), "text" -> Questions.text
- Child: AnswersCheckBoxGroup (CheckBoxGroup), "texts" -> Questions.Answers.text

This will give you a Group with the question text as header and a check-box for each possible answer.

To switch to a question, just move the lead selection of node "Questions":


wdContext.nodeQuestions().moveTo(i);

Armin

former_member197348
Active Contributor
0 Kudos

Hello Jaya!

Welcome to SDN!

Actually for this kind of scenarios we use Dynamic programming since there are 50 UI elements of same kind. If you want to work with with Static UI elements only you can also work like this:

Try this: Make all group IDs sequential. e.g Group1,Group2..etc.

Set the Visible property of the all groups is None

Create 2 context attributes indexCurr, indexPrev type Integer .

Create actions for NEXT and BACK buttons.

in wdDoInit() method write this.

wdContext.currentContextElement().setIndexCurr(1);
wdContext.currentContextElement().setIndexPrev(1);

In onAactionBack() implementation write this code:

if(wdContext.currentContextElement().getIndexCurr()>1)
wdContext.currentContextElement().setIndexCurr
(wdContext.currentContextElement().getIndexCurr()-1);

In onAactionNext() implementation write this code:

if(wdContext.currentContextElement().getIndexCurr()<50)
wdContext.currentContextElement().setIndexCurr
(wdContext.currentContextElement().getIndexCurr()+1);

in wdDoModifyView() method write this code.

String prevId = "Group"+wdContext.currentContextElement().getIndexPrev();
IWDGroup hideGroup = (IWDGroup)view.getElement(prevId );
hideGroup.setVisible(WDVisibility.NONE);
 
String currId = "Group"+wdContext.currentContextElement().getIndexCurr();
 IWDGroup dispGroup = (IWDGroup)view.getElement(currId );
 dispGroup.setVisible(WDVisibility.VISIBLE);
 wdContext.currentContextElement().setIndexPrev
(wdContext.currentContextElement().getIndexCurr());

Regards,

Siva

Edited by: Siva Rama Krushna on Jul 24, 2008 3:52 PM

Former Member
0 Kudos

Hi,

Rather than using 50 groups you can use one group to display all the questions in quiz, one group the question is a text view bind to context attribute, the options should be radio button group binded to context node. once you click on next , you can retrive the next question and set of answers to be bind to the context. the result should be calculated.

Regards,

Naga Raju

Former Member
0 Kudos

.

Edited by: Fabian Häusler on Jul 24, 2008 3:14 PM