Esempio n. 1
0
        void ExecuteLoadAnswersCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Answers.Clear();
                var answers     = Question.Answers;
                int asciiLetter = 65;
                foreach (var answer in answers)
                {
                    answer.AnswerLetter = (char)asciiLetter;
                    asciiLetter++;
                    Answers.Add(answer);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 2
0
        /*Create the Answers list of AnswerCards, which the listview binds to. Generates four AnswerCards, with a Card and Correct properties, indicating if
         * this is the right answer. Each loop checks if the random card from the full list of cards of the deck is the correct choice, from the randomly
         * chosen card in the hand shown in the carousel view (The GetHand method is generalized so each game can use it, making it a little harder to
         * then also generate AnswerCards). Then that card is removed from Cards so there are no duplicates (This means we have to call the DB for a full
         * list of cards each time..). Then finally, checks to see if the actual answer has been one of the randomly selected, if not it adds it in a random
         * Position. Maybe it would be better to add the actual answer first, but it needs to be in a random position, so the Answers list needs to be populated
         * before that.*/
        private void Setup()
        {
            Answers.Clear();
            RandomNumber = Random.Next(0, Cards.Count);
            Cards        = CardDatabase.GetCards();
            var NotYet = true;

            for (var i = 0; i < 4; i++)
            {
                RandomNumber = Random.Next(0, Cards.Count);
                var Card = Cards[RandomNumber];
                if (!Card.Answer.Equals(Hand[index].Answer))
                {
                    Answers.Add(new AnswerCard(Card, false));
                    Cards.Remove(Card);
                }
                else
                {
                    Answers.Add(new AnswerCard(Card, true));
                    Cards.Remove(Card);
                    NotYet = false;
                }
            }

            if (NotYet)
            {
                RandomNumber          = Random.Next(0, Answers.Count);
                Answers[RandomNumber] = new AnswerCard(Hand[index], true);
            }
        }
Esempio n. 3
0
 public void SaveAnswers(List <System.Windows.Forms.TextBox> AnsBoxes)
 {
     Answers.Clear();
     foreach (var answ in AnsBoxes) //Перенносим ответы из боксов в список ответов.
     {
         Answers.Add(answ.Text);
     }
 }
Esempio n. 4
0
 public void UpdateAnswers(IReadOnlyCollection <ScoringApplicationAnswer> answers)
 {
     Answers.Clear();
     foreach (var answer in answers)
     {
         SetAnswer(answer.QuestionId, answer.Value);
     }
 }
Esempio n. 5
0
        private void ClearUi()
        {
            Position   = 0;
            CorrectAns = 0;
            FailedAns  = 0;

            CorAns.Text       = "0";
            FilAns.Text       = "0";
            NextQuestion.Text = "0";

            Answers.Clear();
        }
Esempio n. 6
0
        private void SynchronizeAnswersCollections()
        {
            if (Answers.Any())
            {
                Answers.Clear();
            }

            foreach (var answer in Question.Answers)
            {
                Answers.Add(answer);
            }
        }
Esempio n. 7
0
        public override void Initialize(string[] answerSet, int answerCount)
        {
            MaxAnswer = answerCount;
            for (int i = 0; i < AnswerButtons.Length; i++)
            {
                int maxNumber = answerSet.Length;
                if (maxNumber % 4 != 0)
                {
                    maxNumber += 2;
                }

                if (i < answerSet.Length)
                {
                    AnswerButtons[i].gameObject.SetActive(true);

                    //최적화 문제 있음
                    AnswerButtons[i].GetComponentInChildren <Text>().text = answerSet[i];
                }
                else
                {
                    if (i < maxNumber)
                    {
                        AnswerButtons[i].gameObject.SetActive(true);
                    }
                    else
                    {
                        AnswerButtons[i].gameObject.SetActive(false);
                    }
                }
            }

            //선택 및 모양 초기화
            Answers.Clear();
            foreach (Button target in AnswerButtons)
            {
                target.colors = new ColorBlock()
                {
                    normalColor      = Color.black,
                    highlightedColor = Color.black,
                    pressedColor     = Color.gray,
                    selectedColor    = Color.black,
                    disabledColor    = Color.gray,
                    colorMultiplier  = 1,
                    fadeDuration     = 0.1f
                };
            }

            CurrentPage = 0;
            IsMoving    = false;
            InitializePagePosition();   //currentPage 값이 이상할 수 있으니 움직임과 상관 없이 위치 결정
        }
Esempio n. 8
0
        public void Dispose()
        {
            Questions.Clear();
            Answers.Clear();
            Authorities.Clear();
            Additionals.Clear();

            Questions   = null;
            Answers     = null;
            Authorities = null;
            Additionals = null;

            Header?.Dispose();
            Error = null;
        }
Esempio n. 9
0
        private void ParseXML(XDocument pollXml)
        {
            Answers.Clear();
            IpAddresses.Clear();

            Question = pollXml.Element("poll").Element("question").Attribute("text").Value;
            foreach (var answer in pollXml.Element("poll").Elements("answer"))
            {
                Answers.Add(new AnswerItem(answer.Attribute("text").Value, int.Parse(answer.Value)));
            }
            foreach (var ipaddr in pollXml.Element("poll").Elements("ipaddr"))
            {
                IpAddresses.Add(new IpAddressItem(ipaddr.Value,
                                                  DateTime.ParseExact(ipaddr.Attribute("dateEntered").Value,
                                                                      "yyyy/MM/dd HH:mm",
                                                                      CultureInfo.InvariantCulture)));
            }
        }
Esempio n. 10
0
        protected async Task ExecuteLoadAnswersCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Answers.Clear();
                var    id       = QuestionViewModel.Question.Id;
                object responce = await AnswersService.DoAnswersGetRequest(id);

                if (responce is ErrorMessage)
                {
                    ErrorMessage error = responce as ErrorMessage;
                    Debug.WriteLine(error.ErrorCode + " " + error.ErrorDescription);
                }
                else
                {
                    var answers = responce as IEnumerable <Answer>;
                    foreach (var answer in answers)
                    {
                        Answers.Add(new AnswerViewModel(answer));
                    }
                }

                OnPropertyChanged("IsExpanded");
                //MessagingCenter.Send<AnswersViewModel>(this, "AnswersLoaded");
            }
            catch (Exception ex)
            {
                Debug.WriteLine("[!] ExecuteLoadAnswersCommand --- " + ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        private void DeleteRow(object row)
        {
            if (row is QuestionVM question)
            {
                //_Context.Questions.Remove(question.ToModel);
                Questionnaire.QuestionList.Remove(Questionnaire.QuestionList.Where(q => q.Id == question.Id).Single());
                Questionnaire.ToModel.QuestionList.Remove(question.ToModel);
                RaisePropertyChanged(nameof(Questionnaire));
                //AllQuestions.Remove(AllQuestions.Where(q=>q.Id == question.Id).Single());
                //RaisePropertyChanged(nameof(AllQuestions));
                Answers.Clear();
            }
            else if (row is AnswerVM answer)
            {
                _Context.Answers.Remove(answer.ToModel);
                Answers.Remove(answer);
                RaisePropertyChanged(nameof(Questionnaire));
            }

            CanExecuteChanged();
        }
Esempio n. 12
0
        /// <summary>
        /// updates model by current questions
        /// </summary>
        private void updateByCurentQuestion()
        {
            Answers.Clear();
            //last question in question link is actual
            Question rootQuestion = QuestionLink.Last();

            if (rootQuestion == null)
            {
                ActualQuestion = "K dispozícii nie sú žiadne otázky.";
                return;
            }
            ActualQuestion = rootQuestion.Text;
            //actualise answers by current question
            foreach (KeyValuePair <int, Model.Answer> answ in rootQuestion.PossibleAnswers.Where(a => rootQuestion.getQuestionByAnswer(a.Key) != null))
            {
                Answers.Add(new Answer()
                {
                    Id     = answ.Key,
                    Text   = answ.Value.MainText,
                    Detail = answ.Value.Detail
                });
            }
        }
Esempio n. 13
0
        private void button1_Click(object sender, EventArgs e)
        {
            Test testNum = new Test();
            bool mardus;

            mardus = testNum.Testn(Convert.ToInt16(ranAmount.Text));
            int         gCD;
            MardusClass myClass = new MardusClass();

            if (mardus == true)
            {
                int[] list = myClass.getRandom(Convert.ToInt16(ranAmount.Text));
                Answers.Clear();
                int checkSpace;
                for (int i = 0; i < list.Length; i++)
                {
                    Answers.AppendText(Convert.ToString(list[i] + " "));
                    checkSpace = i % 5;
                    if (checkSpace == 0)
                    {
                        Answers.AppendText("\n");
                    }
                }



                stat tstNums = new stat();

                gCD = tstNums.GCD(list);
                MessageBox.Show(Convert.ToString("The greatest CD is: " + gCD));
            }
            else
            {
                MessageBox.Show("Please make sure that the number that was entered is betwwen 5 and 20");
            }
        }
        public PassingTheTestViewModel(PageService pageService, UserService userService, TestsRestClient testsClient, AnswersRestClient answersClient, StudentsRestClient studentsClient, QuestionsRestClient questionsClient, StudentAnswersRestClient studentAnswersClient)
        {
            _pageService = pageService;
            _userService = userService;

            _testsClient          = testsClient;
            _answersClient        = answersClient;
            _studentsClient       = studentsClient;
            _questionsClient      = questionsClient;
            _studentAnswersClient = studentAnswersClient;

            if (TestId != null)
            {
                Test = HttpResponseMessageConverter.GetResult <dynamic>(_testsClient.GetTestById((int)TestId));

                InitTimer();
                FormQuestions();

                ActiveQuestion = Questions[0];

                Answers.Clear();
                Answers = new ObservableCollection <dynamic>(HttpResponseMessageConverter.GetResult <List <dynamic> >(_answersClient.GetAnswersByQuestionId(Convert.ToInt32(ActiveQuestion.id))));
            }
        }
        public async Task ExecuteLoadQuestionDetailCommandAsync()
        {
            if (IsBusy)
            {
                return;
            }

            ProgressDialogManager.LoadProgressDialog("Loading...");

            try
            {
                IsBusy = true;
                var question = await ParseAccess.GetQuestion(questionId);

                var state     = "Closed";
                var stateFlag = question.Get <int>("stateFlag");

                if (stateFlag == (int)RequestState.Active)
                {
                    state = "Active";
                }
                else if (stateFlag == (int)RequestState.InProgress)
                {
                    state = "In Progress";
                }

                var topicObjects = question.Get <IList <ParseObject> >("topics");
                var topics       = new List <string>();
                foreach (var topic in topicObjects)
                {
                    topics.Add(topic.Get <string>("topicText"));
                }

                var ownerObject = question.Get <ParseObject>("createdBy");

                var owner = new User
                {
                    ObjectId  = ownerObject.ObjectId,
                    FirstName = ownerObject.Get <string>("firstName"),
                    LastName  = ownerObject.Get <string>("lastName"),
                    Username  = ownerObject.Get <string>("username")
                };
                Question = new Question()
                {
                    Title     = question.Get <string>("title"),
                    Body      = question.Get <string>("body"),
                    ObjectId  = question.ObjectId,
                    Topics    = topics,
                    CreatedAt = question.CreatedAt.Value + RestService.TimeDiff,
                    Owner     = owner,
                    State     = state
                };

                Answers.Clear();
                var answers = await ParseAccess.LoadAnswers(question);

                foreach (var answer in answers)
                {
                    ParseUser userObject = answer.Get <ParseUser>("createdBy");
                    var       user       = new User
                    {
                        ObjectId  = userObject.ObjectId,
                        FirstName = userObject.Get <string>("firstName"),
                        LastName  = userObject.Get <string>("lastName"),
                        Username  = userObject.Get <string>("username")
                    };

                    DateTime now = RestService.GetServerTime();
                    var      a   = new Answer
                    {
                        Body      = answer.Get <string>("body"),
                        CreatedBy = user,
                        TimeAgo   = HelperFunctions.TimeAgo(answer.UpdatedAt.Value, now)
                    };
                    Answers.Add(a);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
            }
            finally
            {
                IsBusy = false;
                ProgressDialogManager.DisposeProgressDialog();
            }
        }
Esempio n. 16
0
 public void Clear()
 {
     Answers.Clear();
 }
Esempio n. 17
0
 private void OnDisable()
 {
     Answers.Clear();
 }