예제 #1
0
        private void ProcessCommands()
        {
            if (Code != null)
            {
                List <RobotCommand> _commands    = new List <RobotCommand>();
                string[]            CommandLines = Code.Split(';');
                foreach (var cmdLine in CommandLines)
                {
                    if (!String.IsNullOrEmpty(cmdLine.Trim()))
                    {
                        var cmdInfo = cmdLine.Trim().Split(new[] { '/' }, 2);
                        if (cmdInfo[0].ToLower() == "teacherid")
                        {
                            TeacherId = cmdInfo[1];
                        }
                        if (cmdInfo[0].ToLower() == "subject")
                        {
                            Subject = cmdInfo[1];
                        }

                        RobotCommand cmd = new RobotCommand(cmdInfo[0], cmdInfo[1]);
                        CheckForQuiz(cmd);
                        _commands.Add(cmd);
                    }
                }
                Commands = _commands;
            }
        }
예제 #2
0
        public void InsertCommand(string cmdType, string cmdValue)
        {
            var robotCommand = new RobotCommand(cmdType, cmdValue);

            //_commands.Insert(commandIteration + 1, robotCommand);
            _commands.Add(robotCommand);
        }
예제 #3
0
        private void CheckForQuiz(RobotCommand cmd)
        {
            switch (cmd.Type.ToLower())
            {
            case "quizformat":
                if (cmd.Value.ToLower() == "mcq")
                {
                    _question.Type = 0;
                }
                else if (cmd.Value.ToLower() == "text")
                {
                    _question.Type = 1;
                }
                break;

            case "question":
                _question.Query = cmd.Value;
                break;

            case "optiona":
                _question.ChoiceA = cmd.Value;
                break;

            case "optionb":
                _question.ChoiceB = cmd.Value;
                break;

            case "optionc":
                _question.ChoiceC = cmd.Value;
                break;

            case "optiond":
                _question.ChoiceD = cmd.Value;
                break;

            case "answer":
                _question.Answer = cmd.Value;
                break;

            case "timeout":
                _question.TimeOut = Convert.ToInt32(cmd.Value);
                break;

            case "points":
                _question.Points = Convert.ToInt32(cmd.Value);
                break;

            case "start":
                if (cmd.Value.ToLower() == "quiz")
                {
                    Question = _question;
                }
                break;
            }
        }
예제 #4
0
        private void CommandHandler()
        {
            var quiz = new Quiz();

            for (commandIteration = 0; commandIteration < _commands.Count; commandIteration++)
            {
                while (LessonHelper.PauseRequested)
                {
                    Thread.Sleep(500);
                }

                CurrentCommand = _commands[commandIteration];
                var cmd = CurrentCommand.Type;
                var val = CurrentCommand.Value;

                UpdateCommand(cmd.ToLower(), val);

                Debug.WriteLine(cmd + "/" + val);


                switch (cmd.ToLower())
                {
                case "speak":
                    Speak(val);
                    break;

                case "speakasync":
                    SpeakAsync(val);
                    break;

                case "playaudio":
                    AudioHelper.PlayAudio(val);
                    break;

                case "myspeech":
                    MySpeech(val);
                    break;

                case "myspeechasync":
                    MySpeechAsync(val);
                    break;

                case "move":
                    Move(val);
                    break;

                case "wait":
                    Wait(Convert.ToInt32(val));
                    break;

                case "playmedia":
                    PlayMedia(val);
                    break;

                case "quizformat":
                    quiz.QuizFormat = val;
                    break;

                case "answer":
                    quiz.Answer = val;
                    break;

                case "timeout":
                    quiz.TimeOut = val;
                    break;

                case "gesture":
                    UpperBodyHelper.DoGestures(val);
                    break;

                case "start":
                    if (val.ToLower() == "quiz")
                    {
                        LessonHelper.QuestionNumber += 1;
                        quiz.QuestionNumber          = LessonHelper.QuestionNumber;
                        StartQuiz(quiz);

                        LessonStatusHelper.LessonStatus.CurQuiz = null;
                        //Wait(Convert.ToInt32(quiz.TimeOut) * 1000 + QUIZ_BUFFER_SECONDS * 1000);

                        Wait(QUIZ_BUFFER_SECONDS * 800);
                        // This QUIZ BUFFER TO give extra time for all student submit the answer

                        Debug.WriteLine("Stopping quiz");
                        StopQuiz();

                        Wait(QUIZ_BUFFER_SECONDS * 1000);

                        var now = DateTime.Now;

                        Debug.WriteLine(now + " : QUIZ COMPLETED");

                        // This QUIZ BUFFER TO give extra time for teacher send student result to robot
                    }
                    else if (val.ToLower() == "emotion-survey")
                    {
                        TakeEmotionSurvey();
                    }
                    break;

                case "gountil":
                    BaseHelper.GoUntilReachedGoalOrCanceled(val);
                    break;

                case "asking":
                    var status = LessonStatusHelper.LessonStatus;
                    if (Convert.ToInt32(val) == 1)
                    {
                        status.LessonState = "asking";
                    }
                    else
                    {
                        status.LessonState = "notAsking";
                    }
                    WebHelper.UpdateStatus(status);
                    Wait(1500);
                    break;

                case "lesson":
                    if (val == "pause")
                    {
                        LessonHelper.SendPausedStatusToServer("paused");
                        LessonHelper.PauseLesson();
                    }
                    else if (val == "continue")
                    {
                        LessonHelper.SendPausedStatusToServer("resumed");
                        LessonHelper.ResumeLesson();
                    }
                    break;

                case "robot":
                    if (val == "pickup-std")
                    {
                        RandomAskStudentQuestion();
                    }
                    break;

                default:
                    //MessageBox.Show($"Unknown Type: {cmd}");
                    break;
                }
            }
        }