Exemplo n.º 1
0
        protected void questions_Submitted(object sender, QuizQuestions.QuestionsSubmittedEventArgs e)
        {
            var answers      = e.Answers;
            var scoreRequest = new IDMv2.IdentityScoreRequest()
            {
                answer = answers.ToArray(),
                quizId = ViewState["quizId"].ToString()
            };
            var response = LNQuizService.GetProductResponse(scoreRequest, ViewState["transactionId"].ToString());

            this.lblScore.Text  = response.Score;
            this.lblStatus.Text = response.Status.ToString();

            this.QuizQuestions.Visible = false;
            this.pnlResult.Visible     = true;
            this.pnlIntro.Visible      = false;

            switch (response.Status)
            {
            case IDMv2.InstantAuthenticateProductStatus.PASS:
                this.lblAlert.Text = "Thanks you. Your identity has been verified.";
                break;

            case IDMv2.InstantAuthenticateProductStatus.PENDING:
                this.lblAlert.Text           = "Please answer this additional question";
                this.QuizQuestions.Questions = response.BonusQuestions;
                this.QuizQuestions.DataBind();
                this.QuizQuestions.Visible = true;
                break;

            case IDMv2.InstantAuthenticateProductStatus.OMITTED:
                this.lblAlert.Text = "Please answer all the provided questions";
                //TODO: This should never happen, client-side checks should ensure all answers
                this.QuizQuestions.Visible = true;
                break;

            case IDMv2.InstantAuthenticateProductStatus.FAIL:
                this.lblAlert.Text = "We're sorry but we cannot verify your identity.";
                break;

            case IDMv2.InstantAuthenticateProductStatus.UNABLE_TO_GENERATE:
            case IDMv2.InstantAuthenticateProductStatus.NOT_ENOUGH_DATA:
            case IDMv2.InstantAuthenticateProductStatus.IDENTITY_NOT_LOCATED:
                this.lblAlert.Text = "We do not have enough information to generate a quiz.";
                break;

            case IDMv2.InstantAuthenticateProductStatus.TIMED_OUT:
            case IDMv2.InstantAuthenticateProductStatus.ABANDONED:
                this.lblAlert.Text = "Your session has timed out. Please try again.";
                break;

            case IDMv2.InstantAuthenticateProductStatus.SYSTEM_ERROR:
            default:
                this.lblAlert.Text = "An unexpected error occured. Please try again.";
                break;
            }
        }
Exemplo n.º 2
0
        public static QuizResponse GetProductResponse(IDMv2.IdentityScoreRequest request, string transactionId)
        {
            IDMv2.IdentityProofingWSClient client = InitWSClient();

            var proofingRequest = GetRequest(request, transactionId);

            IDMv2.InstantAuthenticateResponse response;
            if (!UseMockResponses)
            {
                response = client.invokeIdentityService(proofingRequest).productResponse.First() as IDMv2.InstantAuthenticateResponse;//TODO: can there be more than one response?
            }
            else
            {
                #region Mock Response
                IDMv2.IdentityProofingResponse proofingResponse;
                XmlSerializer xml            = new XmlSerializer(typeof(IDMv2.IdentityProofingResponse), "http://ns.lexisnexis.com/identity-proofing/1.0");
                var           sampleFilePath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "App_Data", "sampleResponseBonusQuestion.xml");
                using (Stream stream = new FileStream(sampleFilePath, FileMode.Open))
                {
                    proofingResponse = (IDMv2.IdentityProofingResponse)xml.Deserialize(stream);
                }
                response = proofingResponse.productResponse.First() as IDMv2.InstantAuthenticateResponse;
                #endregion
            }

            if (response != null)
            {
                return(new QuizResponse
                {
                    Score = response.quizScore != null ? response.quizScore.score :"0",
                    Status = response.status,
                    Description = response.responseCodes != null && response.responseCodes.Length > 0 ? response.responseCodes.FirstOrDefault().description : "",
                    BonusQuestions = response.questions != null?response.questions.question.ToList() : null
                });
            }
            return(null);
        }
Exemplo n.º 3
0
        public void but_SubmitAnswers_Click(object sender, EventArgs e)
        {
            //Submit the quiz for scoring
            string seeMe = "No.Questions:No.Responses = " + HFnumQnumR.Value.ToString();

            Label1.Text = seeMe;

            //Check the number of questions and responses; you should not permit the user to proceed until all questions are answered
            if (HFnumQnumR.Value != null)
            {
                //Show results
                PanelScoreResults.Visible = true;
                PanelIVResults.Visible    = false;
                PanelIAResults.Visible    = false;
                but_SubmitAnswers.Visible = false;

                TableRow  labelRow  = new TableRow();
                TableCell labelcell = new TableCell();

                TableScoreResults.Rows.Add(labelRow);
                labelRow.Cells.Add(labelcell);
                labelcell.Text = "<b>Scoring Results</b>";


                //Handle the form inputs
                string[] vQuizParms = HFnumQnumR.Value.ToString().ToString().Split(':');
                int      vNumQs     = Convert.ToInt32(vQuizParms[0]);
                int      vNumRs     = Convert.ToInt32(vQuizParms[1]);

                //Bind to settings in web.config; set values for username and password from web.config, too
                IDMv2.IdentityProofingWSClient myIDMv2Client = new IDMv2.IdentityProofingWSClient();
                myIDMv2Client.ClientCredentials.UserName.UserName = TextBox1.Text;
                myIDMv2Client.ClientCredentials.UserName.Password = TextBox2.Text;
                //Note that the nonce in the header is optional

                //New profing request
                IDMv2.IdentityProofingRequest myIDRequest = new IDMv2.IdentityProofingRequest();

                //QuizScoring Object
                IDMv2.IdentityProofingRequest vIDProofingRequest = new IDMv2.IdentityProofingRequest();
                IDMv2.IdentityScoreRequest[]  vScoreRequest      = new IDMv2.IdentityScoreRequest[1];
                IDMv2.IdentityScoreRequest    vThisScoreRequest  = new IDMv2.IdentityScoreRequest();

                vIDProofingRequest.Items             = vScoreRequest;
                vIDProofingRequest.locale            = TextBox5.Text;
                vIDProofingRequest.customerReference = TextBox6.Text;
                vIDProofingRequest.transactionID     = TextBox3.Text;
                vIDProofingRequest.workFlow          = TextBox4.Text;

                IDMv2.IdentityQuizAnswer[] vArrAnswer = new IDMv2.IdentityQuizAnswer[vNumQs];

                //Assign the results to the scoring request
                vThisScoreRequest.answer = vArrAnswer;
                vScoreRequest[0]         = vThisScoreRequest;


                //Loop through each Group and find the selected values
                for (int i = 0; i < vNumQs; i++)
                {
                    string vGroupName = "ctl00$MainContent$QuizResponse" + i.ToString();

                    if (Request.Form[vGroupName] != null)
                    {
                        string[] vQuizAnswers = Request.Form[vGroupName].ToString().ToString().Split(':');
                        vThisScoreRequest.quizId = vQuizAnswers[0].ToString();

                        IDMv2.IdentityQuizAnswer vThisAnswer = new IDMv2.IdentityQuizAnswer();

                        vThisAnswer.questionId = vQuizAnswers[1].ToString();
                        vThisAnswer.choiceId   = vQuizAnswers[2].ToString();
                        vArrAnswer[i]          = vThisAnswer;

                        TableRow  fooRow  = new TableRow();
                        TableCell foocell = new TableCell();

                        TableScoreResults.Rows.Add(fooRow);
                        fooRow.Cells.Add(foocell);
                        foocell.Text = i.ToString() + " :Selected Answers [Quiz:Question:Response]:" + Request.Form[vGroupName].ToString();
                    }
                }



                //Create a new response object; call the service again to request the score
                IDMv2.IdentityProofingResponse myIDProofingResponse = new IDMv2.IdentityProofingResponse();
                myIDProofingResponse = myIDMv2Client.invokeIdentityService(vIDProofingRequest);

                IDMv2.ProductResponse[] vScoreReqResponse = new IDMv2.ProductResponse[1];
                vScoreReqResponse = myIDProofingResponse.productResponse;
                int respCount = myIDProofingResponse.productResponse.Length;

                //Check the type of each response
                for (int k = 0; k < respCount; k++)
                {
                    string[] vCheckProdType = vScoreReqResponse[k].GetType().ToString().Split('.');
                    string   vThisResponse  = vCheckProdType[2];

                    TableRow  foo3Row  = new TableRow();
                    TableCell foo3cell = new TableCell();
                    TableScoreResults.Rows.Add(foo3Row);
                    foo3Row.Cells.Add(foo3cell);
                    foo3cell.Text = vThisResponse;

                    if (vThisResponse == "InstantAuthenticateResponse")
                    {
                        //Show the Score Results
                        IDMv2.InstantAuthenticateResponse vScoringResponse = new IDMv2.InstantAuthenticateResponse();
                        vScoringResponse = vScoreReqResponse[k] as IDMv2.InstantAuthenticateResponse;
                        string vQuizScore  = vScoringResponse.quizScore.score.ToString();
                        string vQuizStatus = vScoringResponse.status.ToString();

                        TableRow  foo2Row  = new TableRow();
                        TableCell foo2cell = new TableCell();
                        TableScoreResults.Rows.Add(foo2Row);
                        foo2Row.Cells.Add(foo2cell);
                        foo2cell.Text = "<b>STATUS: " + vQuizStatus.ToString() + " | SCORE: " + vQuizScore.ToString() + "</b>";
                    }
                }
            }
        }