示例#1
0
        public void Deserialize(BinaryReader reader)
        {
            ID    = NetworkHelper.Nthos(reader.ReadUInt16());
            Flags = (DnsPacketFlags)NetworkHelper.Nthos(reader.ReadUInt16());
            ushort questionCount      = NetworkHelper.Nthos(reader.ReadUInt16());
            ushort answerCount        = NetworkHelper.Nthos(reader.ReadUInt16());
            ushort authoritativeCount = NetworkHelper.Nthos(reader.ReadUInt16());
            ushort additionalCount    = NetworkHelper.Nthos(reader.ReadUInt16());

            for (int i = 0; i < questionCount; i++)
            {
                DnsQuestion question = new DnsQuestion();
                question.Deserialize(reader);
                Questions.Add(question);
            }

            for (int i = 0; i < answerCount; i++)
            {
                DnsResourceRecord record = DnsResourceRecord.DeserializeResourceRecord(reader);
                Answers.Add(record);
            }

            for (int i = 0; i < authoritativeCount; i++)
            {
                DnsResourceRecord record = DnsResourceRecord.DeserializeResourceRecord(reader);
                Authoritatives.Add(record);
            }

            for (int i = 0; i < additionalCount; i++)
            {
                DnsResourceRecord record = DnsResourceRecord.DeserializeResourceRecord(reader);
                Additionals.Add(record);
            }
        }
示例#2
0
        public void Initialise(DialogType dialogType, List <T> answers, string title, object content)
        {
            this.SetupHeader(Scheduler, string.Format("{0} - {1}", dialogType, title));
            Content = content;

            for (var index = 0; index < answers.Count; index++)
            {
                var answer = new DialogItemViewModel <T>
                {
                    Response  = answers[index],
                    IsDefault = index == 0,
                    IsCancel  = index == answers.Count - 1
                };
                Answers.Add(answer);
            }

            var lastButton = Answers.LastOrDefault();

            if (lastButton == null)
            {
                return;
            }

            SelectedAnswer = lastButton.Response;
        }
示例#3
0
 public override void CreateAnswers(StreamReader reader)
 {
     Answers.Add(new FBModifiedAnswer()
     {
         result = reader.ReadLine()
     });
 }
示例#4
0
    public void ParseCSV(string[] itemDatas)
    {
        CSVUtility uti = new CSVUtility(itemDatas);

        Question = uti.GetString;
        for (int i = 0; i < 5; i++)
        {
            if (Options == null)
            {
                Options = new List <string>();
            }
            Options.Add(uti.GetString);
        }

        for (int i = 0; i < 5; i++)
        {
            if (Answers == null)
            {
                Answers = new List <string>();
            }
            Answers.Add(uti.GetString);
        }

        for (int i = 0; i < 2; i++)
        {
            if (Notes == null)
            {
                Notes = new List <string>();
            }
            Notes.Add(uti.GetString);
        }
    }
示例#5
0
        public Answers GetAnswers(Question question, string response_id, int occurance = 0)
        {
            Answers answers = new Answers(null);

            try
            {
                string query = $"select * from dsto_answer where [yref_question]='{question.Key}' and [occurance]='{occurance}' and ([yref_questionaire]='{response_id}' or [yref_certification]='{response_id}' or [yref_fieldInspection]='{response_id}') and Deleted=0 order by oid asc";
                var    table = DbInfo.ExecuteSelectQuery(query);
                if (table.Rows.Count > 0)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        Answer answer = new Answer(null);
                        answer.Key             = row["guid"].ToString();
                        answer.OID             = int.Parse(row["OID"].ToString());
                        answer.AnswerText      = row["answertext"].ToString();
                        answer.Deleted         = bool.Parse(row["deleted"].ToString());
                        answer.questionKey     = row["yref_question"].ToString();
                        answer.Occurance       = int.Parse(row["occurance"].ToString());
                        answer.QuestionaireKey = row["yref_questionaire"].ToString();
                        answers.Add(answer);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(answers);
        }
示例#6
0
        public void GetAnswers()
        {
            // declare variables
            DataTable answers;                          // data table to store answers to the questions

            try
            {
                // setup the parameter for the answer
                List <DAParameter> answerParam = new List <DAParameter>
                {
                    new DAParameter("@QuestionId", ParameterDirection.Input, SqlDbType.Int, (object)QuestionId)
                };

                // retrieve answers for the question
                answers = DataRetrieval.QueryDataResults("[ED].[GetQuestionAnswers]", DataRetrieval.ConnectionSql, answerParam);

                if (answers.Rows.Count > 0)
                {
                    // store the answers
                    for (int rowCount = 0; rowCount < answers.Rows.Count; rowCount++)
                    {
                        Answers.Add(new Answer(QuestionId, Int32.Parse(answers.Rows[rowCount]["AnswerId"].ToString()),
                                               answers.Rows[rowCount]["AnswerDesc"].ToString()));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#7
0
        public override void AddManualSamples()
        {
            Samples.Add(new MinimumSwaps2Sample()
            {
                arr = new Int32[] { 4, 3, 1, 2 }
            });
            Answers.Add(new MinimumSwaps2Answer()
            {
                result = 3
            });

            Samples.Add(new MinimumSwaps2Sample()
            {
                arr = new Int32[] { 2, 3, 4, 1, 5 }
            });
            Answers.Add(new MinimumSwaps2Answer()
            {
                result = 3
            });

            Samples.Add(new MinimumSwaps2Sample()
            {
                arr = new Int32[] { 1, 3, 5, 2, 4, 6, 7 }
            });
            Answers.Add(new MinimumSwaps2Answer()
            {
                result = 3
            });
        }
示例#8
0
 public override void AddManualSamples()
 {
     Samples.Add(new RKSumSample()
     {
         N = 1, K = 3, seq = new Int64[] { 3 }
     });
     Answers.Add(new RKSumAnswer()
     {
         a = new Int64[] { 1 }
     });
     Samples.Add(new RKSumSample()
     {
         N = 2, K = 2, seq = new Int64[] { 12, 34, 56 }
     });
     Answers.Add(new RKSumAnswer()
     {
         a = new Int64[] { 6, 28 }
     });
     Samples.Add(new RKSumSample()
     {
         N = 3, K = 2, seq = new Int64[] { 2, 3, 4, 4, 5, 6 }
     });
     Answers.Add(new RKSumAnswer()
     {
         a = new Int64[] { 1, 2, 3 }
     });
 }
示例#9
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);
            }
        }
示例#10
0
 public override void CreateAnswers(System.IO.StreamReader reader)
 {
     Answers.Add(new CoinChangeAnswer()
     {
         w = Convert.ToInt64(reader.ReadLine())
     });
 }
示例#11
0
        public Response(byte[] data)
        {
            Error     = "";
            TimeStamp = DateTime.Now;

            Header = new Header(data);

            using (PersistedReader reader = new PersistedReader(Header.Buffer, Header.Payload))
            {
                for (int intI = 0; intI < Header.QuestionCount; intI++)
                {
                    Questions.Add(new Question(reader));
                }

                for (int intI = 0; intI < Header.AnswersCount; intI++)
                {
                    Answers.Add(new Resource(reader));
                }

                for (int intI = 0; intI < Header.AuthorityCount; intI++)
                {
                    Authorities.Add(new Resource(reader));
                }

                for (int intI = 0; intI < Header.AdditionalCount; intI++)
                {
                    Additionals.Add(new Resource(reader));
                }
            }
        }
示例#12
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;
            }
        }
示例#13
0
 public void SaveAnswers(List <System.Windows.Forms.TextBox> AnsBoxes)
 {
     Answers.Clear();
     foreach (var answ in AnsBoxes) //Перенносим ответы из боксов в список ответов.
     {
         Answers.Add(answ.Text);
     }
 }
示例#14
0
        private async void Answer(object sender, EventArgs args, RecyclerView QuestionsRecView)
        {
            //if correct
            var userAns = Tickets.ElementAt(Position).Answers.FirstOrDefault(o => o.Ans == (sender as TextView).Text);

            (sender as TextView).SetBackgroundColor(userAns.Correct ? Color.Green : Color.Red);

            //if not correct
            QuestionsRecView.GetChildAt(Tickets.ElementAt(Position).Answers.IndexOf(Tickets.ElementAt(Position).Answers.First(o => o.Correct))).FindViewById <TextView>(Resource.Id.AnsTxt).SetBackgroundColor(Color.Green);

            //add user answer
            Answers.Add(userAns.Ans);

            //if not correct
            //correct or incorect count detect
            _ = Tickets.ElementAt(Position).Answers.FirstOrDefault(o => o.Ans == (sender as TextView).Text).Correct ? CorrectAns++ : FailedAns++;

            //disable all answers
            for (int i = 0; i < QuestionsRecView.ChildCount; i++)
            {
                QuestionsRecView.GetChildAt(i).FindViewById <TextView>(Resource.Id.AnsTxt).Enabled = false;
            }

            //cor ans
            CorAns.Text = CorrectAns.ToString();
            //incor ans
            FilAns.Text = FailedAns.ToString();

            // if incorect answers limit set limit -> int MaxIncorectCount = 3 default
            if (FailedAns == MaxIncorrectCount)
            {
                Android.Support.V7.App.AlertDialog.Builder alert = new Android.Support.V7.App.AlertDialog.Builder(this);
                // alert.SetTitle("არადა კაი იყო 😁");
                alert.SetMessage($"შენ ვერ ჩააბარე გამოცდა იმითომ რომ {MaxIncorrectCount} შეკითხვას გაეცი არასწორი პასუხი");

                Dialog dialog = alert.Create();
                dialog.Show();
            }

            Position++;
            NextQuestion.Text = (Position + 1).ToString();

            if (AutoChange.Checked)
            {
                TicketPager.SetCurrentItem(Position, true);
            }

            if (Position == TicketsCount)
            {
                await new AnsweredService().SaveUserAnswersAsync(Tickets, Answers);

                var endUi = new Intent(this, typeof(EndActivity));
                endUi.PutExtra("TicketsCount", TicketsCount);
                StartActivity(endUi);

                ClearUi();
            }
        }
示例#15
0
        public override void AddManualSamples()
        {
            Samples.Add(new CountTripletsSample()
            {
                arr = new List <long> {
                    1, 2, 4, 6, 3, 8, 6, 12, 24, 24
                }, r = 2
            });
            Answers.Add(new CountTripletsAnswer()
            {
                res = 7
            });


            Samples.Add(new CountTripletsSample()
            {
                arr = new List <long> {
                    1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
                }, r = 1
            });
            Answers.Add(new CountTripletsAnswer()
            {
                res = 161700
            });

            Samples.Add(new CountTripletsSample()
            {
                arr = new List <long> {
                    1, 2, 2, 4
                }, r = 2
            });
            Answers.Add(new CountTripletsAnswer()
            {
                res = 2
            });

            Samples.Add(new CountTripletsSample()
            {
                arr = new List <long> {
                    1, 3, 9, 9, 27, 81
                }, r = 3
            });
            Answers.Add(new CountTripletsAnswer()
            {
                res = 6
            });

            Samples.Add(new CountTripletsSample()
            {
                arr = new List <long> {
                    1, 5, 5, 25, 125
                }, r = 5
            });
            Answers.Add(new CountTripletsAnswer()
            {
                res = 4
            });
        }
示例#16
0
 private void InitTextFill()
 {
     Question = "Type Question here!";
     for (int i = 0; i < 4; i++)
     {
         Answers.Add("Type Answer here!");
         BoolAnswers.Add(false);
     }
 }
示例#17
0
        public override void CreateAnswers(StreamReader reader)
        {
            ArrayManipulationAnswer ans = new ArrayManipulationAnswer()
            {
                MaxValue = Convert.ToInt64(reader.ReadLine())
            };

            Answers.Add(ans);
        }
示例#18
0
        public override void CreateAnswers(StreamReader reader)
        {
            CountTripletsAnswer ans = new CountTripletsAnswer()
            {
                res = Convert.ToInt64(reader.ReadLine())
            };

            Answers.Add(ans);
        }
示例#19
0
        public override void CreateAnswers(System.IO.StreamReader reader)
        {
            GreedyMaxMinAnswer ans = new GreedyMaxMinAnswer()
            {
                result = Convert.ToInt32(reader.ReadLine())
            };

            Answers.Add(ans);
        }
 public QuizQuestion(string[] question)
 {
     Question = question[0];
     Answers.Add(question[1]);
     Answers.Add(question[2]);
     Answers.Add(question[3]);
     Answers.Add(question[4]);
     CorrectAnswer = FindCorrectAnswer(Answers);
 }
示例#21
0
        public override void CreateAnswers(System.IO.StreamReader reader)
        {
            SpecialStringAgainAnswer ans = new SpecialStringAgainAnswer()
            {
                result = Convert.ToInt64(reader.ReadLine())
            };

            Answers.Add(ans);
        }
示例#22
0
        public override void CreateAnswers(StreamReader reader)
        {
            FairCutAnswer ans = new FairCutAnswer()
            {
            };

            Int64.TryParse(reader.ReadLine(), out ans.result);
            Answers.Add(ans);
        }
示例#23
0
        public override void CreateAnswers(System.IO.StreamReader reader)
        {
            TemplateProblemAnswer ans = new TemplateProblemAnswer()
            {
            };

            Int32.TryParse(reader.ReadLine(), out ans.result);
            Answers.Add(ans);
        }
示例#24
0
        public override void CreateAnswers(StreamReader reader)
        {
            GreedyFloristAnswer ans = new GreedyFloristAnswer()
            {
                result = Convert.ToInt32(reader.ReadLine())
            };

            Answers.Add(ans);
        }
示例#25
0
        public override void CreateAnswers(System.IO.StreamReader reader)
        {
            ReverseShuffleMergeAnswer ans = new ReverseShuffleMergeAnswer()
            {
                result = reader.ReadLine()
            };

            Answers.Add(ans);
        }
示例#26
0
        public void AddAnswer(DnsResourceRecord record)
        {
            if (record == null)
            {
                throw new ArgumentNullException(nameof(record));
            }

            Answers.Add(record);
        }
示例#27
0
        public override void CreateAnswers(StreamReader reader)
        {
            CommonChildAnswer ans = new CommonChildAnswer()
            {
                result = Convert.ToInt32(reader.ReadLine())
            };

            Answers.Add(ans);
        }
示例#28
0
        public override void GenSamples()
        {
            Int32 n = rnd.Next();

            Samples.Add(new List <Int32>()
            {
                n
            });
            Answers.Add(n);
        }
示例#29
0
 public override void CreateAnswers(StreamReader reader)
 {
     while (!reader.EndOfStream)
     {
         Answers.Add(new AbbreviateAnswer()
         {
             Answer = reader.ReadLine()
         });
     }
 }
示例#30
0
        public CommentDto(Comment comment, Dictionary <string, string> userPhotoMap)
        {
            InitProperties(comment, userPhotoMap);
            IsDeleted = comment.IsDeleted;

            foreach (Answer answer in comment.Answers)
            {
                Answers.Add(new CommentDto(answer, userPhotoMap));
            }
        }