Now I am typing correct answer but i want like I want to select answer if one answer then it must come in radio button to select the correct answer and if multiple answer means check box must to select multiple answer and in data all questions are mixed with single answers questions and multiple answers questions. so how to give radio button and check box
Discussion posts and replies are publicly visible
YOu must be having this identifier in your data somewhere whether it is a single-choice or multi-choice. So you can just check it in a condition and add the field? What problem are you facing in implementing this?
Just like Harshit suggested you need check for the Choices, I wrote a simple expression use it as reference for your implementation
a!localVariables( local!questionsWithAnswers:{ a!map( Question:"Where is TajMahal Located", Options:{"Agra","Pune","Vizag","Delhi"}, Answer:{"Agra"} ), a!map( Question:"Cities in India", Options:{"NY","Paris","Vizag","Delhi"}, Answer:{"Vizag","Delhi"} ) }, local!selectedAnswers, a!forEach( items: local!questionsWithAnswers, expression: {a!richTextDisplayField( value: concat(fv!index,".",fv!item.Question), ), if( count( fv!item.Answer)=1, a!radioButtonField( choiceLabels: fv!item.Options, choiceValues: fv!item.Options, ), a!checkboxField( choiceLabels: fv!item.Options, choiceValues: fv!item.Options ) )} ) )
If the values we are taking from cdt not from record then
It would be the same instead of using a map inside the local variable you call your rule. If it is a record you would have recordType references.In the below code the "isMultiple" defines whether the question has multiple answers or not. I would recommend having two different data bases for questions and Answers. where in the Questions Table you will have a field to Identify whether your question has Multiple answers or a single one. In the answers Data base table you will have a field of the Primary key of Questions Table.
a!localVariables( local!question: rule!CDT_myQuestions(isActive: true()), local!answers: rule!CDT_myAnswers(isActive: true()), a!forEach( items: local!question, expression: a!boxLayout( label: fv!item.Question, contents: { a!textField( value: if( fv!item.isMultiple, "Multiple Choice", "Single Choice" ), readOnly: true ), if( fv!item.isMultiple, a!checkboxField( choiceValues: index( local!answers.id, wherecontains(fv!item, local!answers.questionId), null ), choiceLabels: index( local!answers.Answers, wherecontains(fv!item, local!answers.questionId), null ), ), a!radioButtonField( choiceValues: index( local!answers.id, wherecontains(fv!item, local!answers.questionId), null ), choiceLabels: index( local!answers.Answers, wherecontains(fv!item, local!answers.questionId), null ), ) ) }, marginBelow: "MORE", style: "ACCENT" ) ) )
if we created two data bases then how to know which questions have which options and answers
You will have to map the Primary key of your questions DB to each of your answer in the Answers DB.
Okok but now in question data base only i have to give options..?or in Answer database I have to give options
In question Data base you will have below columns (You can add more as per your requirement)
QUESTION_ID (PRIMARY KEY)
QUESTION_VALUE
QUESTION_TYPE OR IS_MULTIPLE
IS_ACTIVE
In Answers Data base
ANSWER_ID(PRIMARY KEY)
QUESTION_ID(FORIEGN KEY)
ANSWER_VALUE
Thank you for your Quick Responses It was very Useful
Great! Please verify the answers which have worked for you. Thank you.