Verifying User Properties During Test

Script to check username, password and mother's maiden name (custom property) during the test taking.

try{

eb_TestWatcher = {
    verificationNeedChecked: false,
    verificationNeeded: false,
    verified : false,
    constructed: null,
    questionShown : function(index, widg){
        if(this.verificationNeedChecked && !this.verificationNeeded){return;}
        if(!this.verificationNeedChecked){
          if(widg.viewController.test.customProperties && widg.viewController.test.customProperties.length > 0){
            for(var i=0; i<widg.viewController.test.customProperties.length; i++){
               if(widg.viewController.test.customProperties[i].name == 'ID_VERIFY' && widg.viewController.test.customProperties[i].value == 'true'){
                  this.verificationNeeded = true;
                  break;
               }
            }
          }
          this.verificationNeedChecked = true;
        }
        if(!this.verificationNeeded){return;}
        if(this.verified){return;}
        var num = widg.viewController.test.testQuestions.length;
        if(index >= num/2){
           if(!this.constructed){
              this.constructed = $(document.createElement('div'));
this.constructed.html("<b>Please enter details to help us verify your identity</b><br/>Username: <br/> <input type='text' id='vr_userName'/><br/> Password: <br/> <input type='password' id='vr_password'/><br/>Mother's maiden name: <br/> <input type='text' id='vr_motherName'/>");
           }
           var me = this;
           this.constructed.dialog(
              {
                 autoOpen: false, modal: true,
                 buttons: {
                   Verify: function() {me.verify();}
                 }
              }
           ).dialog("open");
        }
    },
    verify: function() {
        var me = this;
        if($("#vr_userName").val() == ""){alert("Please enter username"); return;}
        if($("#vr_password").val() == ""){alert("Please enter password"); return;}
        if($("#vr_motherName").val() == ""){alert("Please enter mother's maiden name"); return;}
        $.post("../site/profile.do", {dispatch:"verify",
          "params":JSON.stringify({username:$("#vr_userName").val(), password: $("#vr_password").val(), mMaidenName:$("#vr_motherName").val()})},
          function(data){
             if(data.status == "success"){alert("Thanks, your details are verified, please proceed"); me.verified = true; me.constructed.dialog("close"); }else{alert("Sorry, details not verified "+data.msg)}
          }
          , "json");

    }
}


}catch(er){}

 


Rating: