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

Parents
  • 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. 

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

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

  • a!localVariables(
      local!batchSize: 1,
      local!totalQuestions : 4,
      
      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,
                           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: local!currentIndex = local!totalQuestions,
                        style: "OUTLINE",
                        confirmMessage: if(
                          local!currentIndex = local!totalQuestions,
                          "Your test has been completed. Your score is " & ri!score,
                          null
                        )
                      )
                    },
                    align: "END",
                    marginBelow: "NONE"
                  )
                }
              )
            }
          )
        }
      )
    )
    in this in local variable I am getting score but  when I am trying to save in to  rule input the score value is not coming 

  • That is because you saved it first on line 84 and then you updated it on line 97.

  •       want to store in database it's not getting store it is giving error like this     

    An error occurred while trying to write to the entity "reportData_entity" [id=9f6550f9-4c37-4bd3-8ab3-92b6cf0c0e7c@3448, type=OQA_Report_Data (id=3982)] (data store: OQA_N_excelData). Details: javax.persistence.PersistenceException: org.hibernate.TypeMismatchException: Provided id of the wrong type for class OQAReportDataDT3422. Expected: class java.lang.Integer, got class java.util.ArrayList: org.hibernate.TypeMismatchException: Provided id of the wrong type for class OQAReportDataDT3422. Expected: class java.lang.Integer, got class java.util.ArrayList Data: TypedValue[it=3982,v={<null>,BalaManchari,2}]

  • There is a type mismatch. A column seems to have received an array in place of an integer value. Verify your mapping again in the Datastore and look for a type mismatch in the value. 

  •  i mapped correctly i believe but its giving error in variable the data is getting store but its getting error

  • 0
    Certified Senior Developer
    in reply to balamanchari murugadas

    I guess you need to set your process variable to Multiple and also in the Data tab as well check the multiple option. Is it defined as an array in your rule input on interface? (Hope I am not reading the error incorrectly)

  • Superb! Now when you have done it, please take a moment to verify the answers that worked for you to close the thread. 

Reply Children