Example #1
0
        private void AnalyzeEmotion(double happyPc, double sadPc, double neutralPc)
        {
            if (sadPc >= 0.3) // roughly 1/3 unhappy, give teacher time to explain
                              // for unhappy students again or engage some activities
            {
                LessonHelper.SendPausedStatusToServer("paused");
                LessonHelper.PauseLesson();
                LessonHelper.ResumeSpeak();
                Synthesizer.Speak("Well, since some of you are not sure of this topic, let Mr Nizam explain again. ");
            } // Ok, happy or neutral
            else
            {
                Debug.WriteLine("Before Pause Lesson");
                LessonHelper.PauseLesson();
                Debug.WriteLine("After pause lesson");
                LessonHelper.ResumeSpeak();

                Synthesizer.Speak("Wow, most of you understand the topic! Let us continue with the lesson. ");
                //LessonHelper.SendEmotionFeedBackToServer("survey-happy");
                Debug.WriteLine("After speak the feedback");
                //LessonHelper.Wait(2000);

                //Debug.WriteLine("After wait 2 seconds");
                LessonHelper.ResumeLesson();

                Debug.WriteLine("After resume");
            }
        }
        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;
                }
            }
        }
Example #3
0
        public void AskRandomStudent(List <StudentHistoryDTO> list)
        {
            var rdm    = new Random();
            int rdmNum = rdm.Next(1, 11);

            if (GlobalFlowControl.Lesson.ChosenStudent != null ||
                rdmNum <= 8)
            {
                //ask
                Debug.WriteLine("ASKING STUDENT");

                StudentHistoryDTO student;

                if (GlobalFlowControl.Lesson.ChosenStudent != null)
                {
                    student = list.FirstOrDefault(x =>
                                                  x.Student_id == GlobalFlowControl.Lesson.ChosenStudent);

                    if (GlobalFlowControl.Lesson.IsStudentChosenBefore(student.Student_id) == false)
                    {
                        GlobalFlowControl.Lesson.ChosenStudentList.Add(student.Student_id);
                    }
                }
                else
                {
                    int randNum;

                    // All students have their all turns to be asked (approached) by robot
                    if (GlobalFlowControl.Lesson.ChosenStudentList.Count
                        == list.Count)
                    {
                        GlobalFlowControl.Lesson.ChosenStudentList.Clear();
                    }
                    do
                    {
                        randNum = rdm.Next(0, list.Count);
                        Debug.WriteLine("Random Student: " + randNum);
                    } while (GlobalFlowControl.Lesson.IsStudentChosenBefore(list[randNum].Student_id));


                    student = list[randNum];

                    GlobalFlowControl.Lesson.ChosenStudentList.Add(student.Student_id);
                }

                string speech = student.UserAccountFullName + "! ";
                int    num    = rdm.Next(0, 5);
                switch (num)
                {
                case 0:
                    speech += "Can you share what is your answer?";
                    break;

                case 1:
                    speech += "Did you have your own answer? Is this question easy or difficult?";
                    break;

                case 2:
                    speech += "What did you choose as your answer for this question?";
                    break;

                case 3:
                    speech += "What do you think about this question?";
                    break;

                case 4:
                    speech += "Can you share your answer to the class and explain why did you choose it?";
                    break;
                }
                //Get position of student
                var position = TablePositionHelper.FindTablePosByStdId(student.Student_id);

                if (position != null)
                {
                    GlobalFlowControl.Lesson.ApproachStudent = position;

                    //Go to student
                    LessonHelper.InsertCommand("gountil", position);
                    LessonHelper.InsertCommand("speak", speech);
                    LessonHelper.InsertCommand("asking", "1");

                    bool   studentResult = student.ResultInBinaryString.Last() == '1';
                    string resultSpeech  = "";

                    if (studentResult)
                    {
                        switch (num)
                        {
                        case 0:
                        case 1:
                            resultSpeech = "Excellent ";
                            break;

                        case 2:
                        case 3:
                            resultSpeech = "Not bad ";
                            break;

                        case 4:
                            resultSpeech = "Very good ";
                            break;
                        }
                        resultSpeech += student.Student_id + "! Your answer is correct!";
                    }
                    else
                    {
                        resultSpeech = "Sorry " + student.Student_id + ". Your answer is not correct!";
                    }

                    LessonHelper.InsertCommand("speak", resultSpeech);
                }
            }


            AnalyzeStudentPerformance(AssessPerformance);
        }
Example #4
0
        private void AnalyzeStudentPerformance(List <StudentHistoryDTO> list)
        {
            var rdm    = new Random();
            var rdmNum = rdm.Next(1, 4); // generate random number 1-3

            int incorrectCnt = StudentsPerformanceHelper.GetNumberOfInCorrectStudent(list);
            int correctCnt   = StudentsPerformanceHelper.GetNumberOfCorrectStudent(list);

            var speech = "";

            if (correctCnt == 0)
            {
                var x = rdm.Next(0, 3);
                switch (x)
                {
                case 0:
                    speech = "I am very sad now, because no one got any correct answer for this question. ";
                    break;

                case 1:
                    speech = "No one is correct. Is it because this question too difficult? ";
                    break;

                case 2:
                    speech = "Sorry to say this, but none of you had a correct answer. ";
                    break;
                }
                speech += "Come on guys, don't give up. ";

                LessonHelper.InsertPraise(speech);


                return;
            }
            else
            {
                var x = rdm.Next(0, 3);
                if (incorrectCnt == 0)
                {
                    switch (x)
                    {
                    case 0:
                        speech = "Brilliant! No one did any mistake for this question. ";
                        break;

                    case 1:
                        speech = "Amazing! Everybody answers are correct. ";
                        break;

                    case 2:
                        speech = "Incredible! All of you got the correct answer. ";
                        break;
                    }

                    speech += "Everyone, please clap your hands";
                    LessonHelper.InsertPraise(speech);
                    return;
                }
                else if (correctCnt >= incorrectCnt)
                {
                    switch (x)
                    {
                    case 0:
                        speech = "Well, I am every happy to see many of you got correct answer. ";
                        break;

                    case 1:
                        speech = "Great! Most of you did a good job! ";
                        break;

                    case 2:
                        speech = "Good job everybody, most of you are correct. ";
                        break;
                    }
                }
            }

            var numOfFullScore = StudentsPerformanceHelper.GetNumOfFullScore(list);

            if (numOfFullScore != 0)
            {
                speech += $"Awesome, we have {numOfFullScore.ToString()} students with full score! ";
            }

            switch (rdmNum)
            {
            case 1:
                speech += GetTopStudentsPraise(list);
                break;

            case 2:

                speech += GetTopStudentsPraise(list);

                break;

            case 3:
                speech += GetTopStudentsPraise(list);
                break;
            }

            LessonHelper.InsertPraise(speech);
        }
Example #5
0
        private void SyncHelper_StatusChanged(object sender, StatusEventArgs e)
        {
            var status = e.Status;

            LessonStatusHelper.LessonStatus = status;

            //if (_prevState != status.LessonState)
            //    _prevState = status.LessonState;
            //else return;

            if (status.LessonState != null)
            {
                if (status.LessonState.Contains("starting") &&
                    GlobalFlowControl.Lesson.Starting == false)
                {
                    this.Invoke(new Action(() => { picClose.Visible = false; }));
                    var    lessonStt = status.LessonState.Split('-');
                    var    teacherId = lessonStt[1];
                    string voiceName = "Voice 1";
                    if (lessonStt.Length > 2)
                    {
                        voiceName = lessonStt[2];
                    }
                    string className = null;

                    if (lessonStt.Length > 3)
                    {
                        className = lessonStt[3];
                    }

                    GlobalFlowControl.Lesson.Name = status.LessonName;

                    LessonHelper.SaveLessonHistory(status.LessonName, teacherId, className);
                    LessonHelper.LessonId = status.LessonId;

                    //this.Invoke(new MethodInvoker(() => this.Hide()));

                    if (InvokeRequired)
                    {
                        this.Invoke(new Action(() =>
                                               LessonHelper.Start(status.LessonName, Convert.ToInt32(status.LessonSlide), voiceName)));
                        return;
                    }
                }
                else if (status.LessonState == "pause" || status.LessonState == "asking")
                {
                    Debug.WriteLine("PAUSING");
                    LessonHelper.PauseLesson();
                }
                else if (status.LessonState == "continue")
                {
                    Debug.WriteLine("Continue from server");
                    LessonHelper.ResumeLesson();
                }
                else if (status.LessonState == "end")
                {
                    try
                    {
                        if (InvokeRequired)
                        {
                            this.Invoke(new Action(() => {
                                picClose.Visible = true;
                                LessonHelper.EndLesson();
                            }));
                            return;
                        }
                    }
                    catch { }
                }

                if (status.MediaCompleted != null)
                {
                    if (status.MediaCompleted == "true")
                    {
                        LessonHelper.MediaEnded();
                        status.MediaCompleted = null;
                        WebHelper.UpdateStatus(status);
                    }
                }
            }
        }
Example #6
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     LessonHelper.ForceStop();
     SyncHelper.StatusChanged       -= SyncHelper_StatusChanged;
     SyncHelper.RobotCommandChanged -= SyncHelper_RobotCommandChanged;
 }