Ejemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                string userid    = "nlubold";
                int    sessionid = 1;

                List <int> problemStep       = SQLProblemStepTracker.ReadProbStep(userid);
                int        problem           = problemStep[0];
                int        nextproblem       = problem + 1;
                int        step              = problemStep[1];
                int        problemimgkey     = problemStep[2];
                int        answerKey         = problemStep[3];
                int        newanswer         = problemStep[4];
                int        numautoresponses  = problemStep[5];
                int        nextstepanswerkey = 0;
                int        numAutoResponses  = 0;

                if (step == 0)
                {
                    step = 1;
                }

                nextstepanswerkey = SQLProblemStepTracker.CalculateNewAnswerKey(1, answerKey, step);
                newanswer         = step;
                SQLProblemStepTracker.UpdateProbStep(userid, sessionid, problem, step, problemimgkey, nextstepanswerkey, newanswer, numAutoResponses);
            }
            catch (Exception error)
            {
                SQLLog.InsertLog(DateTime.Now, error.Message, error.ToString(), "UpdateAnswer.ashx.cs", 0, "nlubold");
            }
        }
Ejemplo n.º 2
0
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         string data = context.Request.Params["log"];    // Get transcript (if there is one)
         SQLLog.InsertLog(DateTime.Now, "From ProblemPage", data, "ErrorLogger.ashx.cs", 0, "nlubold");
     }
     catch (Exception error)
     {
         SQLLog.InsertLog(DateTime.Now, error.Message, error.ToString(), "ErrorLogger.ashx.cs", 0, "nlubold");
     }
 }
Ejemplo n.º 3
0
        protected void ValidateUser(object sender, EventArgs e)
        {
            try
            {
                int loginResult = -1;

                string username = Login1.UserName;
                string password = Login1.Password;

                loginResult = SQLLogin.ValidateLogin(username, password);

                switch (loginResult)
                {
                case 0:
                    Login1.FailureText = "Username and/or password is incorrect. (Error Code: 0)";
                    break;

                case 1:
                    //FormsAuthentication.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet);
                    FormsAuthentication.SetAuthCookie(Login1.UserName, Login1.RememberMeSet);
                    Response.Redirect("default.aspx", false);
                    break;

                default:
                    Login1.FailureText = "Username and/or password is incorrect. (Error Code: Unknown)";
                    break;
                }


                // Update problem step to first problem and first step but don't reset preset gender/condition info.
                int    sessionid        = 1;
                int    problemid        = 1;
                int    stepid           = 0;
                int    stepanswerkey    = 1;
                int    newanswer        = 0;
                int    numautoresponses = 0;
                int    problemimgkey    = 2; // key to the first image in the database
                int    numturns         = 0;
                string problemSet       = "A";
                SQLProblemStepTracker.UpdateProbStep(username, sessionid, problemid, stepid, problemimgkey, stepanswerkey, newanswer, numautoresponses, numturns);
                //SQLConditionGenderInfo.UpdateConditionGender(username, "nonsocial", "female", "192.168.1.208", "none", problemSet,"text");
            }
            catch (Exception eSql)
            {
                SQLLog.InsertLog(DateTime.Now, eSql.Message, eSql.StackTrace, "Login.aspx.c", 1);
            }
        }
Ejemplo n.º 4
0
        protected void ValidateUser(object sender, EventArgs e)
        {
            try
            {
                int loginResult = -1;

                string username = Login1.UserName;
                string password = Login1.Password;

                loginResult = SQLLogin.ValidateLogin(username, password);

                switch (loginResult)
                {
                case 0:
                    Login1.FailureText = "Username and/or password is incorrect. (Error Code: 0)";
                    break;

                case 1:
                    //FormsAuthentication.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet);
                    FormsAuthentication.SetAuthCookie(Login1.UserName, Login1.RememberMeSet);
                    Response.Redirect("default.aspx", false);
                    break;

                default:
                    Login1.FailureText = "Username and/or password is incorrect. (Error Code: Unknown)";
                    break;
                }

                // **************************** MODIFY **********************************************************
                // * Need to pull session id from user record and update and to update problem/steps for new session

                int sessionid        = 1;
                int problemid        = 1;
                int stepid           = 0;
                int stepanswerkey    = 1;
                int newanswer        = 0;
                int numautoresponses = 0;
                int problemimgkey    = 2; // key to the first image in the database
                int numturns         = 0;
                SQLProblemStepTracker.UpdateProbStep(username, sessionid, problemid, stepid, problemimgkey, stepanswerkey, newanswer, numautoresponses, numturns);
            }
            catch (Exception eSql)
            {
                SQLLog.InsertLog(DateTime.Now, eSql.Message, eSql.StackTrace, "Login.aspx.c", 1);
            }
        }
Ejemplo n.º 5
0
        protected void Submit(object sender, EventArgs e)
        {
            string gender       = Request.Form["selectGender"];
            string condition    = Request.Form["selectCondition"];
            string path         = Request.PhysicalApplicationPath;
            string userid       = HttpContext.Current.User.Identity.Name;
            string robotAddress = robotIP.Value;

            try
            {
                SQLConditionGenderInfo.UpdateConditionGender(userid, condition, gender, robotAddress);
                Response.Redirect("default.aspx", false);
            }
            catch (Exception error)
            {
                SQLLog.InsertLog(DateTime.Now, error.Message, error.ToString(), "UpdateStep.ashx.cs", 0, userid);
            }
        }
Ejemplo n.º 6
0
        protected void Submit(object sender, EventArgs e)
        {
            string gender       = Request.Form["selectGender"];
            string agent        = Request.Form["selectAgent"];
            string condition    = Request.Form["selectCondition"];
            string enttype      = Request.Form["selectEntrainment"];
            string problemSet   = Request.Form["selectProblemSet"];
            string voiceText    = Request.Form["selectVoiceText"];
            string path         = Request.PhysicalApplicationPath;
            string userid       = HttpContext.Current.User.Identity.Name;
            string robotAddress = robotIP.Value;

            if (voiceText == "text" && condition.Contains("entrain"))
            {
                string script = "alert('You cannot select both text output and entrainment. Please select social or non-social if you want to use a text-based agent.');";
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(submitbutton, this.GetType(), "Test", script, true);
            }
            else if (agent == "false" && voiceText == "text")
            {
                string script = "alert('You cannot select both text output and a robot version. Please select agent if you want to use a text.');";
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(submitbutton, this.GetType(), "Test", script, true);
            }
            else
            {
                try
                {
                    SQLConditionGenderInfo.UpdateConditionGender(userid, condition, gender, robotAddress, enttype, problemSet, voiceText);
                    SQLAgent.SetAgent(agent, userid);
                    Response.Redirect("default.aspx", false);
                }
                catch (Exception error)
                {
                    SQLLog.InsertLog(DateTime.Now, error.Message, error.ToString(), "UpdateStep.ashx.cs", 0, userid);
                }
            }
        }
Ejemplo n.º 7
0
        public void ProcessRequest(HttpContext context)
        {
            // General variables
            DateTime            timeStart = DateTime.Now;
            string              path      = context.Request.PhysicalApplicationPath;
            string              userid    = HttpContext.Current.User.Identity.Name;
            Tuple <string, int> imageInfo = new Tuple <string, int>("", 2);
            string              page      = "";

            // Variables important to the speaker's state
            string     audioFile         = path + "data\\userAudio\\blob.wav";
            string     transcript        = "";
            string     dialogueAct       = "";
            int        speakerSpoke      = 0;
            List <int> problemStep       = new List <int>();                                                                // [0] is problem, [1] is the step, and [2] is the image key loaded for this step, [3] is the answer pattern
            int        sessionid         = 1;                                                                               // ************************* FIX THIS ********
            int        nextstepanswerkey = 0;

            // Variables important to Nico's state
            Tuple <string, int, string> nicoResponse;                                                                           // string => Nico's response, int is the movement code, string contains whether Nico is 'answering', 'confirming', or 'not answering'

            try
            {
                problemStep = SQLProblemStepTracker.ReadProbStep(userid);                                                   // Get current step
                int    problem          = problemStep[0];
                int    step             = problemStep[1];
                int    probImg          = problemStep[2];
                int    answerKey        = problemStep[3];
                int    numAutoResponses = problemStep[5];
                int    numturns         = problemStep[6];
                string clickstep        = "none";
                int    newanswer        = 0;

/*
 *              if (step == 0)
 *              {
 *                  step = 1;
 *              }
 */
                transcript = context.Request.Params["transcript"];    // Get transcript (if there is one)
                page       = context.Request.Params["page_loc"];

                if (context.Request.Files.Count > 0)                                                                       // Write out audio file (if it's there)
                {
                    HttpFileCollection files = context.Request.Files;
                    //audioFile = writeFile(files, path, userid, timeStart);
                }
                if (transcript == "problem start")
                {
                    speakerSpoke = 0;
                    clickstep    = "problem start";
                    step         = 1;
                }
                else if (transcript == "no response")
                {
                    speakerSpoke      = 0;
                    clickstep         = "null";
                    numAutoResponses += 1;
                    transcript        = "Triggered Speech " + numAutoResponses.ToString();
                }
                else if (transcript == "HELLO FIRST TIME")
                {
                    speakerSpoke = 0;
                    clickstep    = "hello nico start";
                }
                else if ((transcript != "") && (transcript != null))                                                             // Is there a transcript? If there is get the speaker's dialogue act
                {
                    dialogueAct  = estimateDialogueAct(transcript);
                    speakerSpoke = 1;                                                                                           // Set that the speaker actually spoke this turn
                }
                else
                {
                    speakerSpoke = 2;
                    transcript   = "transcript empty or null";
                }

                nicoResponse = ResponseGeneration.NicoResponse(path, problemStep, speakerSpoke, transcript, timeStart, page, userid, audioFile);     // Generate and initiate Nico's response
                SQLUserState.UpdateSpeakerState(userid, dialogueAct, transcript, speakerSpoke, problemStep, timeStart, clickstep, numAutoResponses); // Write out speaker state info
                SQLNicoState.UpdateNicoState(userid, nicoResponse, problemStep, timeStart);                                                          // Write out Nico's state info & update problem/step


                // Nico response: string => Nico's response, int is the movement code, the boolean indicates whether Nico answered the step
                // To update the step, we check if Nico answered the question.

                numturns += 1;
                if (nicoResponse.Item3 == "answering")
                {
                    nextstepanswerkey = SQLProblemStepTracker.CalculateNewAnswerKey(1, answerKey, step, userid);                // Passing 1 as first argument because Nico DID answer this step
                    newanswer         = step;
                    SQLProblemStepTracker.UpdateProbStep(userid, sessionid, problem, step, probImg, nextstepanswerkey, newanswer, numAutoResponses, numturns);
                }
                else
                {
                    nextstepanswerkey = answerKey;                                                                                 // current answer key
                    SQLProblemStepTracker.UpdateProbStep(userid, sessionid, problem, step, probImg, nextstepanswerkey, newanswer, numAutoResponses, numturns);
                }
            }
            catch (Exception error)
            {
                SQLLog.InsertLog(DateTime.Now, error.Message, error.ToString(), "DialogueEngine.ashx.cs", 0, userid);
            }

            string transResponse = "Saved User Wav File!";

            context.Response.ContentType = "audio/wav";
            context.Response.AppendHeader("Access-Control-Allow-Origin", "*");
            context.Response.AppendHeader("Access-Control-Allow-Headers", "x-requested-with");
            context.Response.Write(transResponse);
        }
Ejemplo n.º 8
0
        protected void ValidateUser(object sender, EventArgs e)
        {
            try
            {
                int loginResult = -1;

                string username = Login1.UserName;
                string password = Login1.Password;

                loginResult = SQLLogin.ValidateLogin(username, password);

                switch (loginResult)
                {
                case 0:
                    Login1.FailureText = "Username and/or password is incorrect. (Error Code: 0)";
                    break;

                case 1:
                    //OLD: FormsAuthentication.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet);
                    //SHANG: FormsAuthentication.SetAuthCookie(Login1.UserName, Login1.RememberMeSet);

                    FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, Login1.UserName,                  // user name
                                                                                         DateTime.Now,                        //creation
                                                                                         DateTime.Now.AddDays(30),            //Expiration (you can set it to 1 month
                                                                                         Login1.RememberMeSet, string.Empty); // additional informations

                    string encryptedTicket           = FormsAuthentication.Encrypt(authTicket);
                    System.Web.HttpCookie authCookie = new System.Web.HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                    if (authTicket.IsPersistent)
                    {
                        authCookie.Expires = authTicket.Expiration;
                    }
                    System.Web.HttpContext.Current.Response.Cookies.Add(authCookie);

                    Response.Redirect("default.aspx", false);
                    break;

                default:
                    Login1.FailureText = "Username and/or password is incorrect. (Error Code: Unknown)";
                    break;
                }


                // Update problem step to first problem and first step but don't reset preset gender/condition info.
                int    sessionid        = 1;
                int    problemid        = 1;
                int    stepid           = 0;
                int    stepanswerkey    = 1;
                int    newanswer        = 0;
                int    numautoresponses = 0;
                int    problemimgkey    = 2; // key to the first image in the database
                int    numturns         = 0;
                string problemSet       = "A";
                SQLProblemStepTracker.UpdateProbStep(username, sessionid, problemid, stepid, problemimgkey, stepanswerkey, newanswer, numautoresponses, numturns);
                //SQLConditionGenderInfo.UpdateConditionGender(username, "nonsocial", "female", "192.168.1.208", "none", problemSet,"text");
            }
            catch (Exception eSql)
            {
                SQLLog.InsertLog(DateTime.Now, eSql.Message, eSql.StackTrace, "Login.aspx.c", 1);
            }
        }
Ejemplo n.º 9
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                string userid    = "nlubold";
                int    sessionid = 1;
                int    maxprobs  = 4;

                List <int> problemStep      = SQLProblemStepTracker.ReadProbStep(userid);
                int        problem          = problemStep[0];
                int        nextproblem      = problem + 1;
                int        step             = problemStep[1];
                int        nextStep         = step + 1;
                int        priorStep        = step - 1;
                int        problemimgkey    = problemStep[2];
                int        answerKey        = problemStep[3];
                int        newanswer        = problemStep[4];
                int        numautoresponses = problemStep[5];

                // Variables important to Nico's state
                string   path      = HttpRuntime.AppDomainAppPath;
                DateTime now       = DateTime.Now;
                string   clickstep = "";

                string response = "continue";

                string clicked = context.Request.Params["button_info"];
                switch (clicked)
                {
                case "next":
                    problemStep[1] = nextStep;
                    newanswer      = 0;

                    clickstep = "step" + step.ToString() + "_" + nextStep.ToString();
                    SQLProblemStepTracker.UpdateProbStep(userid, sessionid, problem, nextStep, problemimgkey, answerKey, newanswer, numautoresponses);

                    break;

                case "prior":
                    problemStep[1] = priorStep;
                    newanswer      = 0;

                    clickstep = "step" + step.ToString() + "_" + priorStep.ToString();
                    SQLProblemStepTracker.UpdateProbStep(userid, sessionid, problem, priorStep, problemimgkey, answerKey, newanswer, numautoresponses);

                    break;

                case "problem":
                    if (nextproblem > maxprobs)
                    {
                        response = "end of session";
                    }
                    else
                    {
                        step      = 1;
                        answerKey = 1;
                        newanswer = 0;
                        SQLProblemStepTracker.UpdateProbStep(userid, sessionid, nextproblem, step, problemimgkey, answerKey, newanswer, numautoresponses);
                    }

                    break;

                default:

                    break;
                }

                context.Response.ContentType = "text/HTML";
                context.Response.Write(response);
            }
            catch (Exception error)
            {
                SQLLog.InsertLog(DateTime.Now, error.Message, error.ToString(), "UpdateStep.ashx.cs", 0, "nlubold");
            }
        }
Ejemplo n.º 10
0
        public void ProcessRequest(HttpContext context)
        {
            string userid = HttpContext.Current.User.Identity.Name;

            try
            {
                int    sessionid = 1;
                int    maxprobs  = 9;
                string page      = "ProblemPage";


                List <int> problemStep      = SQLProblemStepTracker.ReadProbStep(userid);
                int        problem          = problemStep[0];
                int        nextproblem      = problem + 1;
                int        step             = problemStep[1];
                int        nextStep         = step + 1;
                int        priorStep        = step - 1;
                int        problemimgkey    = problemStep[2];
                int        answerKey        = problemStep[3];
                int        newanswer        = problemStep[4];
                int        numautoresponses = problemStep[5];
                int        numturns         = problemStep[6];



                if (step == 0)
                {
                    step     = 1;
                    nextStep = 2;
                }

                // Variables important to Nico's state
                Tuple <string, int, string> nicoResponse;                                                                      // string => Nico's response, int is the movement code, string is whether nico is answering
                string   path      = HttpRuntime.AppDomainAppPath;
                string   useraudio = path + "data\\userAudio\\blob.wav";
                DateTime now       = DateTime.Now;
                string   clickstep = "";

                string response = "continue";

                string clicked = context.Request.Params["button_info"];
                switch (clicked)
                {
                case "next":
                    problemStep[1] = nextStep;
                    newanswer      = 0;
                    numturns       = 0;

                    clickstep    = "step_" + step.ToString() + "_" + nextStep.ToString();
                    nicoResponse = ResponseGeneration.NicoResponse(path, problemStep, 0, "next step", now, page, userid, useraudio);
                    SQLUserState.UpdateSpeakerState(userid, "", "", 0, problemStep, now, clickstep, numautoresponses);              // Write out speaker state info
                    SQLNicoState.UpdateNicoState(userid, nicoResponse, problemStep, now);                                           // Write out Nico's state info & update problem/step

                    SQLProblemStepTracker.UpdateProbStep(userid, sessionid, problem, nextStep, problemimgkey, answerKey, newanswer, numautoresponses, numturns);

                    break;

                case "prior":
                    problemStep[1] = priorStep;
                    newanswer      = 0;
                    numturns       = 0;

                    clickstep    = "step_" + step.ToString() + "_" + priorStep.ToString();
                    nicoResponse = ResponseGeneration.NicoResponse(path, problemStep, 0, "prior step", now, page, userid, useraudio);
                    SQLUserState.UpdateSpeakerState(userid, "", "", 0, problemStep, now, clickstep, numautoresponses);              // Write out speaker state info
                    SQLNicoState.UpdateNicoState(userid, nicoResponse, problemStep, now);                                           // Write out Nico's state info & update problem/step

                    SQLProblemStepTracker.UpdateProbStep(userid, sessionid, problem, priorStep, problemimgkey, answerKey, newanswer, numautoresponses, numturns);

                    break;

                case "problem":
                    if (nextproblem > maxprobs)
                    {
                        response = "end of session";
                    }
                    else
                    {
                        step           = 1;
                        answerKey      = 1;
                        newanswer      = 0;
                        problemStep[0] = nextproblem;
                        numturns       = 0;

                        clickstep = "problem_" + problem.ToString() + "_" + nextproblem.ToString();

                        nicoResponse = ResponseGeneration.NicoResponse(path, problemStep, 0, "problem start", now, page, userid, useraudio);
                        SQLUserState.UpdateSpeakerState(userid, "", "", 0, problemStep, now, clickstep, numautoresponses);              // Write out speaker state info
                        SQLNicoState.UpdateNicoState(userid, nicoResponse, problemStep, now);                                           // Write out Nico's state info & update problem/step


                        SQLProblemStepTracker.UpdateProbStep(userid, sessionid, nextproblem, step, problemimgkey, answerKey, newanswer, numautoresponses, numturns);
                    }

                    break;

                default:

                    break;
                }

                context.Response.ContentType = "text/HTML";
                context.Response.Write(response);
            }
            catch (Exception error)
            {
                SQLLog.InsertLog(DateTime.Now, error.Message, error.ToString(), "UpdateStep.ashx.cs", 0, userid);
            }
        }