Example #1
0
        public void Test_Problem_99_Tutoring()
        {
            HCIReasoner.TutorMode = true;
            var tutor = new HCIReasoner();
            tutor.InitProblem(99);

            //drag input
            const string fact1 = "1+2+3=";
            var queryExpr = tutor.HCILoad(fact1, null, true) as AGQueryExpr;
            Assert.NotNull(queryExpr);

            //In tutor mode, it does not matter if the user selects 
            //query knowledge or not.
            //HCIReasoner.Instance.QueriedKnowledge = queryExpr;
            //query its internal procedures
            string message;
            object output;

            QueryFeedbackState state = tutor.Query(null, out message, out output);
            Assert.True(state == QueryFeedbackState.TutorQueryProcessedHint);

            state = tutor.Query(null, out message, out output);
            Assert.True(state == QueryFeedbackState.TutorQueryProcessedAnswer);

            state = tutor.Query(null, out message, out output);
            Assert.True(state == QueryFeedbackState.TutorQueryProcessedHint);

            state = tutor.Query(null, out message, out output);
            Assert.True(state == QueryFeedbackState.TutorQueryProcessedAnswer);

            state = tutor.Query(null, out message, out output);
            Assert.True(state == QueryFeedbackState.TutorQueryEnded);


            const string userFact = "1+5=6";
            var userEqExpr = tutor.HCILoad(userFact) as AGEquationExpr;
            Assert.NotNull(userEqExpr);

            state = tutor.Query(userEqExpr, out message, out output);
            Assert.True(state == QueryFeedbackState.TutorQueryProcessedVerify);
            Assert.NotNull(message);
            Assert.True(message.Equals(AGTutorMessage.VerifyCorrect));

            const string userFact1 = "5+1=6";
            var userEqExpr1 = tutor.HCILoad(userFact1) as AGEquationExpr;
            Assert.NotNull(userEqExpr1);

            state = tutor.Query(userEqExpr1, out message, out output);
            Assert.True(state == QueryFeedbackState.TutorQueryProcessedVerify);
            Assert.NotNull(message);
            Assert.True(message.Equals(AGTutorMessage.VerifyCorrect));

            const string userFact2 = "3+4=6";
            var userEqExpr2 = tutor.HCILoad(userFact2) as AGEquationExpr;
            Assert.NotNull(userEqExpr2);

            state = tutor.Query(userEqExpr2, out message, out output);
            Assert.True(state == QueryFeedbackState.TutorQueryProcessedVerify);
            Assert.NotNull(message);
            Assert.True(message.Equals(AGTutorMessage.VerifyWrong));

            const string userFact3 = "x-x+6=6";
            var userEqExpr3 = tutor.HCILoad(userFact3) as AGEquationExpr;
            Assert.NotNull(userEqExpr3);

            state = tutor.Query(userEqExpr3, out message, out output);
            Assert.True(state == QueryFeedbackState.TutorQueryProcessedVerify);
            Assert.NotNull(message);
            Assert.True(message.Equals(AGTutorMessage.VerifyCorrect));
        }
Example #2
0
        public void Test_Problem_99_Demonstration()
        {
            //Retrieve authoring behavior graph 
            const int problemIndex = 99;

            var tutor = new HCIReasoner();

            bool result = tutor.InitProblem(problemIndex);
            Assert.True(result);
            //have the user authoring data
            Assert.True(tutor.UserGraph.Nodes.Count == 2);
            Assert.Null(tutor.ObjectGraph);

            HCIReasoner.TutorMode = false;
            tutor.InitMode();
			///////////////////////////////////////////////////////

            const string fact1 = "1+2+3=";
            var queryExpr = tutor.HCILoad(fact1) as AGQueryExpr;
            Assert.NotNull(queryExpr);
            queryExpr.RetrieveRenderKnowledge();
            Assert.True(queryExpr.RenderKnowledge.Count == 1);

            var agEquationExpr = queryExpr.RenderKnowledge[0] as AGEquationExpr;
            Assert.True(agEquationExpr != null);
            agEquationExpr.IsSelected = true; // user select knowledge answer

            //select query knowledge
            tutor.QueriedKnowledge = queryExpr;
            Assert.NotNull(tutor.ObjectGraph);
            Assert.True(tutor.ObjectGraph.Nodes.Count == 2);

            //query its internal procedures
            string message;
            object output;
            QueryFeedbackState state = tutor.Query(null, out message, out output);
            Assert.NotNull(output);
            Assert.True(state == QueryFeedbackState.DemonQueryStarted);
            Assert.True(tutor.TraceLeftCount == 2);

            state = tutor.Query(null, out message, out output);
            Assert.True(state == QueryFeedbackState.DemonQueryProcessed);
            Assert.True(tutor.TraceLeftCount == 1);

            ////////////////////////////////////////////////////////////////////

            const string userFact00 = "3+3";
            var userEqExpr00 = tutor.HCILoad(userFact00, null, true) as IKnowledge;
            Assert.NotNull(userEqExpr00);
            state = tutor.Query(userEqExpr00, out message, out output);
            Assert.True(state == QueryFeedbackState.DemonQueryVerify);
            Assert.NotNull(message);
            Assert.True(message.Equals(AGTutorMessage.VerifyCorrect));

            const string userFact0 = "5+1=6";
            var userEqExpr0 = tutor.HCILoad(userFact0, null, true) as IKnowledge;
            Assert.NotNull(userEqExpr0);
            state = tutor.Query(userEqExpr0, out message, out output);
            Assert.True(state == QueryFeedbackState.DemonQueryVerify);
            Assert.NotNull(message);
            Assert.True(message.Equals(AGTutorMessage.VerifyWrong));

/*            const string userFact1 = "6";
            var userEqExpr1 = tutor.HCILoad(userFact1, null, true) as IKnowledge;
            Assert.NotNull(userEqExpr1);
            state = tutor.Query(userEqExpr1, out message, out output);
            Assert.True(state == QueryFeedbackState.DemonQueryVerify);
            Assert.NotNull(message);
            Assert.True(message.Equals(AGTutorMessage.VerifyCorrect));*/

           /* const string userFact = "3+3=6";
            var userEqExpr = HCIReasoner.Instance.HCILoad(userFact, null, userInput) as IKnowledge;
            Assert.NotNull(userEqExpr);

            state = HCIReasoner.Instance.Query(userEqExpr, out message, out output);
            Assert.True(state == QueryFeedbackState.DemonQueryVerify);
            Assert.NotNull(message);
            Assert.True(message.Equals(AGTutorMessage.VerifyCorrect));

            state = HCIReasoner.Instance.Query(null, out message, out output);
            Assert.True(state == QueryFeedbackState.DemonQueryProcessed);

            state = HCIReasoner.Instance.Query(null, out message, out output);
            Assert.True(state == QueryFeedbackState.DemonQueryEnded);

            state = HCIReasoner.Instance.Query(null, out message, out output);
            Assert.True(state == QueryFeedbackState.DemonQueryEnded);
            Assert.Null(output);

            state = HCIReasoner.Instance.Query(userEqExpr, out message, out output);
            Assert.True(state == QueryFeedbackState.DemonQueryVerify);
            Assert.Null(output);

            state = HCIReasoner.Instance.Query(null, out message, out output);
            Assert.True(state == QueryFeedbackState.DemonQueryProcessed);*/

        }