How do I put data from Roman Nuriks Wizard Pager review into database?

后端 未结 2 1093
醉酒成梦
醉酒成梦 2021-01-25 02:49

Alright so I know this has been asked before but the question and answer both didn\'t help me in my situation. What I need to do is simply get all of the data from the review pa

相关标签:
2条回答
  • 2021-01-25 03:31

    I think this is what you need:

    This is hierarchy of quiz data entered:

    Page List > Branch Page > Branch(Question) > Choice(Single or Multiple)

    String data = mWizardModel.findByKey("Question:Choice").getData().getString(Page.SIMPLE_DATA_KEY);
    

    Example:

    String data = mWizardModel.findByKey("Sandwich:Bread").getData().getString(Page.SIMPLE_DATA_KEY);
    

    Also this is what i did to get all selected answers from Question and also to calculate score,

    Inside

    mNextButton.setOnClickListener

    if (mPager.getCurrentItem() == mCurrentPageSequence.size()) {
                        int score = 0;
                        String q1 = mWizardModel.findByKey("Yes:Question 1")
                                .getData().getString(Page.SIMPLE_DATA_KEY);
                        String q2 = mWizardModel.findByKey("Yes:Question 2")
                                .getData().getString(Page.SIMPLE_DATA_KEY);
                        String q3 = mWizardModel.findByKey("Yes:Question 3")
                                .getData().getString(Page.SIMPLE_DATA_KEY);
                        String q4 = mWizardModel.findByKey("Yes:Question 4")
                                .getData().getString(Page.SIMPLE_DATA_KEY);
                        String q5 = mWizardModel.findByKey("Yes:Question 5")
                                .getData().getString(Page.SIMPLE_DATA_KEY);
                        String q6 = mWizardModel.findByKey("Yes:Question 6")
                                .getData().getString(Page.SIMPLE_DATA_KEY);
                        String q7 = mWizardModel.findByKey("Yes:Question 7")
                                .getData().getString(Page.SIMPLE_DATA_KEY);
                        String q8 = mWizardModel.findByKey("Yes:Question 8")
                                .getData().getString(Page.SIMPLE_DATA_KEY);
                        String q9 = mWizardModel.findByKey("Yes:Question 9")
                                .getData().getString(Page.SIMPLE_DATA_KEY);
                        String q10 = mWizardModel.findByKey("Yes:Question 10")
                                .getData().getString(Page.SIMPLE_DATA_KEY);
    
                        if (q1 == "c3") {
                            score = score + 1;
                        }
                        if (q2 == "c2") {
                            score = score + 1;
                        }
                        if (q3 == "c1") {
                            score = score + 1;
                        }
                        if (q4 == "c4") {
                            score = score + 1;
                        }
                        if (q5 == "c1") {
                            score = score + 1;
                        }
                        if (q6 == "c4") {
                            score = score + 1;
                        }
                        if (q7 == "c2") {
                            score = score + 1;
                        }
                        if (q8 == "c3") {
                            score = score + 1;
                        }
                        if (q9 == "c1") {
                            score = score + 1;
                        }
                        if (q10 == "c4") {
                            score = score + 1;
                        }
                        Toast.makeText(getApplicationContext(), "Score:" + score,
                                Toast.LENGTH_LONG).show();
    
    0 讨论(0)
  • 2021-01-25 03:37

    @Derek Smith I have figured out a way to save the data and it works for me.

    This is my AbstractWizardModel class block:

    @Override
    protected PageList onNewRootPageList() {
    
        return new PageList(
                new LoginInfoPage(this, "Login Information").setRequired(true));
    }
    

    It is similar to the sample provided with Library.

    Now in your MainActivity, write as below:

    String data = mWizardModel.findByKey("LoginInformation").getData().getString(LoginInfoPage.EMAIL_DATA_KEY);
    

    The main thing to retrieve data is "key". In my case, key is "Login Information" which is also your title.

    Hope it helps.

    Regards,

    0 讨论(0)
提交回复
热议问题