Posted: 11 Nov 2016 1:36 EST Last activity: 17 Nov 2016 7:43 EST
Multiple Correct Questions -Quiz type Scenario (Using Pega 7.1.6)
Hello, There's a requirement that user selects multiple answers for a question where questions and options are populated dynamically from Questions datatable.The user has to select multiple answers which is to be displayed as a checkbox in UI.Atlast the checked values should be matched with the answers which are present in different Answer Datatable.How to pick the values when the property is checked (Dynamically) ?
>> where questions and options are populated dynamically from Questions datatable
How you control this dynamic logic will help you to decide how to design it. Once you find the logic then you can run an RD by passing required parameter to populate your question and answer option
>> the checked values should be matched with the answers which are present in different Answer Datatable
On click of submit the selected values can be used as an input to the query for the answer table to see whether they are correct or not. And again you can think of using an activity with obj-open kind of logic or an RD with proper parameter passing mechanism,
Hey Santanu, The problem is while displaying the answers from the Questions database table directly in my UI..How can I preferentially select one option (Checkbox) and save it? Do I need to create a different checkbox property for every single option ? If I display the property values directly by referrring the source as QuestionsTable(DataPage) and make it read-only,the values are being displayed but checkbox doesn't work and vice-versa.. If I create different checkbox type properties.How to link them with the options property?
The number of questions that you have on UI will also have an impact on your approach as you will have think of avoiding multiple calls to the Answers data table. In such a scenario, I think we should look for a way to enhance the Questions (and Question options) page list with the "Correct Answers" using a single RD (with joins). During submit, a comparison between "Selected Options" and the "Correct Options" should be possible using a function maybe.
Roughly 10 Questions were present and The answers can be of Multiple correct or single correct.Single correct is done by using Radio buttons and for multiple correct A check box is required which is to be matched in the answers table.The question is how to select multiple answers and check them
Suppose you have a question which has 4 answers - Yes, No, Good , Bad. All these answers are stored in DB. You can retrieve them from DB and populate a custom pagelist (say AnswerOptions) which will be used to capture the answers against the multi-select question (MSQ).
Create a section and drag a repeat grid. Disable heading of the repeat grid. Add two properties (which should be present in the AnswerOption pagelist class) in two columns.
1. SelectedAnswer - This will have a checkbox control associated with it. This will be TrueFalse property.
2. AnswerText - This will have the text of the answer (name Yes, No ,...)
Drag this section in the UI where you are showing the answer options. After submit, check the AnswerOption pagelist and look for "true" values. Those will be your selected answers.
Please note that this approach assumes that you are also generating the Questions dynamically (which means that Questions is a Pagelist and you have AnswerOptions pagelist under it). Cosequently, in order to display such a Question, you would have to use a Repeat Grid where the answer options will be displayed by using a section within a cell of the Repeat Grid.
2. Create another section(secB) and drag it in repeat grid.
3. SecB should contain individual question and its corresponding answers (i.e. options should be presented as repeat grid, first column will be a checkbox control(mapped with pySelected) and the other column should be mapped with options)
So for example we have 10 questions (QuestionSet.pxResults -> 10 entries). So the grid in SecA will be mapped to this. The included section(secB) will have data for each record of QuestionSet.pxResults. In secB, first row will have the question component(say QuestionSet.pxResults(x).question). After this, a repeat grid will have options mapped with this question(say QuestionSet.pxResults(x).options()).
On form submit, we can evaluate the pySelected parts of each options/answers.