Stucking on redirecting to next question

Hi team, 

i am trying to create a Quiz Application by importing a question from excel sheet and get the question in interface. For each page one question must come when clicking next question q.no -2 must come in this I used only interface it is redirecting but In process model 1 st question only coming and the node is ending. give some suggestions for how to overcome this issue.

  Discussion posts and replies are publicly visible

  • Can you add some more information on how your data is stored, interface and process model is structured?

  • 0
    Certified Senior Developer

    Hi  ,

    could you elaborate more to better understand.

    As per my understanding when you click on next button the process is ending instead of next question on the screen, i suspect you have used 'submit:true()' parameter in the next button. so the process is ending. Make sure 'submit:false' if you are using userinput task in the process.

  • a!localVariables(
    local!batchSize: 1,
    local!totalQuestions : 89,

    local!currentIndex: 1,
    local!pagingInfo: a!pagingInfo(
    startIndex: local!currentIndex,
    batchSize: local!batchSize
    ),
    local!exams: a!queryEntity(
    entity: cons!OQA_excelData_Cons,
    query: a!query(
    pagingInfo: local!pagingInfo
    )
    ),
    local!currentQuestion: if(
    local!currentIndex <= local!totalQuestions,
    index(local!exams.data, 1),
    null
    ),
    local!score : 0,

    a!formLayout(
    contents: {
    a!sectionLayout(
    contents: {
    a!textField(
    value: local!currentQuestion.Qno,
    readOnly: true
    ),
    a!textField(
    label: "Question",
    value: local!currentQuestion.Questions,
    readOnly: true
    ),
    a!paragraphField(
    label: "Options",
    value: local!currentQuestion.Options,
    readOnly: true
    ),
    a!textField(
    label: "Answer",
    value: local!currentQuestion.SelectedAnswer,
    saveInto: local!currentQuestion.SelectedAnswer,
    required: true
    )
    },
    showWhen: ri!showChild = false
    ),
    rule!OQA_score_interface( showChild: ri!showChild = true, scores: ri!score),

    a!columnsLayout(
    columns: {

    a!columnLayout(
    contents: {
    a!buttonArrayLayout(
    buttons: {
    a!buttonWidget(

    label: if(
    local!currentIndex < local!totalQuestions - 1,
    "Next",
    "Submit"
    ),
    iconPosition: "END",
    saveInto: {
    if(
    local!currentIndex < local!totalQuestions,
    a!save(
    local!currentIndex,
    local!currentIndex + 1
    ),
    {}
    ),
    a!save(
    local!score,
    if(
    local!currentQuestion.SelectedAnswer = local!currentQuestion.Answers,
    local!score + 1,
    local!score
    )
    ),
    a!save(
    ri!score,
    if(
    local!currentQuestion.SelectedAnswer = local!currentQuestion.Answers,
    local!score ,
    local!score
    )
    ),
    a!save(
    ri!showChild,
    if(
    local!currentIndex = local!totalQuestions,
    true,
    false
    )
    ),

    a!save(
    ri!score,
    ri!scores.score
    ),
    a!save(
    ri!report_data.CanidateName,
    loggedInUser()
    ),
    a!save(
    ri!report_data.score,
    ri!score
    )

    },
    submit: true,
    style: "OUTLINE",
    confirmMessage: if(
    local!currentIndex = local!totalQuestions,
    "Your test has been completed. Your score is " & local!score,
    null
    )
    )
    },
    align: "END",
    marginBelow: "NONE"
    )
    }
    )
    }
    )
    }
    )
    )    --------- this is my code in this last save into in this part 

    a!save(
    ri!report_data.CanidateName,
    loggedInUser()
    ),
    a!save(
    ri!report_data.score,
    ri!score
    )

    I have to store score and name for this I need to use process model in process model 1 st question only coming next the node is ending I can't  able to create a processmodel. 

  • i didn't use process model but i want to use it.in interface next question redirecting is happening but not in processmodel node it is not opening it is ending in 1 question itself.

  • a!localVariables(
      local!batchSize: 1,
      local!totalQuestions : 89,
      
      local!currentIndex: 1,
      local!pagingInfo: a!pagingInfo(
        startIndex: local!currentIndex,
        batchSize: local!batchSize
      ),
      local!exams: a!queryEntity(
        entity: cons!OQA_excelData_Cons,
        query: a!query(
          pagingInfo: local!pagingInfo
        )
      ),
      local!currentQuestion: if(
        local!currentIndex <= local!totalQuestions,
        index(local!exams.data, 1), 
        null
      ),
      local!score : 0,
    
      a!formLayout(
        contents: {
          a!sectionLayout(
            contents: {
              a!textField(
                value: local!currentQuestion.Qno,
                readOnly: true
              ),
              a!textField(
                label: "Question",
                value: local!currentQuestion.Questions,
                readOnly: true
              ),
              a!paragraphField(
                label: "Options",
                value: local!currentQuestion.Options,
                readOnly: true
              ),
              a!textField(
                label: "Answer",
                value: local!currentQuestion.SelectedAnswer,
                saveInto: local!currentQuestion.SelectedAnswer,
                required: true
              )
            },
            showWhen: ri!showChild = false
          ),
          rule!OQA_score_interface( showChild: ri!showChild = true, scores:  ri!score),
    
          a!columnsLayout(
            columns: {
    
              a!columnLayout(
                contents: {
                  a!buttonArrayLayout(
                    buttons: {
                      a!buttonWidget(
    
                        label: if(
                          local!currentIndex < local!totalQuestions - 1,
                          "Next",
                          "Submit"
                        ),
                        iconPosition: "END",
                        saveInto: {
                          if(
                            local!currentIndex < local!totalQuestions,
                            a!save(
                              local!currentIndex,
                              local!currentIndex + 1
                            ),
                            {}
                          ),
                          a!save(
                            local!score,
                            if(
                              local!currentQuestion.SelectedAnswer = local!currentQuestion.Answers,
                              local!score + 1,
                              local!score
                            )
                          ),
                          a!save(
                            ri!score,
                            if(
                              local!currentQuestion.SelectedAnswer = local!currentQuestion.Answers,
                              local!score  ,
                              local!score
                            )
                          ),
                          a!save(
                            ri!showChild,
                            if(
                              local!currentIndex  = local!totalQuestions,
                              true,
                              false
                            )
                          ),
    
                          a!save(
                            ri!score,
                            ri!scores.score
                          ),
                          a!save(
                            ri!report_data.CanidateName,
                            loggedInUser()
                          ),
                          a!save(
                            ri!report_data.score,
                            ri!score
                          )
    
    
    
                        },
                        submit: true,
                        style: "OUTLINE",
                        confirmMessage: if(
                          local!currentIndex = local!totalQuestions,
                          "Your test has been completed. Your score is " & local!score,
                          null
                        )
                      )
                    },
                    align: "END",
                    marginBelow: "NONE"
                  )
                }
              )
            }
          )
        }
      )
    )

  • +1
    Certified Senior Developer
    in reply to balamanchari murugadas

    Remove the submit true value and pass it as true only when it is on the last question.

  • Add the same condition on submit, like you have on confirmation message

  • submit: local!currentIndex = local!totalQuestions,   like this right 

  • Yes. And to be sure it always works, make sure to wrap them in toInteger()