Exemplo n.º 1
0
 public AnswerController(IQuestion questionImplementation, IAnswer answerImplementation, UserManager <ApplicationUser> userManager, IApplicationUser applicationUserImplementation)
 {
     _questionImplementation        = questionImplementation;
     _answerImplementation          = answerImplementation;
     _userManager                   = userManager;
     _applicationUserImplementation = applicationUserImplementation;
 }
Exemplo n.º 2
0
        public void Clear()
        {
            AnswerOrder = 0;

            _answer = null;
            State   = QuestionState.Unanswered;
        }
Exemplo n.º 3
0
 public HomeController(IUser _IUser, ISubject _ISubject, IQuestion _IQuestion, IAnswer _IAnswer)
 {
     _User     = _IUser;
     _Subject  = _ISubject;
     _Question = _IQuestion;
     _Answer   = _IAnswer;
 }
Exemplo n.º 4
0
      public void DeleteAnswerComment(int deleteCommentID, int GivenAnswerId)
      {
          IAnswer answer = _loader.GetAnswerList($"Select * From answer Where answer_id = {Convert.ToString(GivenAnswerId)} ")[0];

          _loader.DeleteDataRow($"DELETE FROM askmate_answer_comment WHERE comment_id = {deleteCommentID} and answer_id = {GivenAnswerId}");
          Response.Redirect($"QuestionDetails/{answer.QuestionID}");
      }
Exemplo n.º 5
0
 private void GetoutAnswer(string answerString, IAnswer firstanAnswer)
 {
     this.Forum.Output.AppendLine(string.Format(Messages.Header, answerString, firstanAnswer.Id));
     this.Forum.Output.AppendLine(string.Format(Messages.Author, firstanAnswer.Author.Username));
     this.Forum.Output.AppendLine(string.Format(Messages.Body, answerString, firstanAnswer.Body));
     this.Forum.Output.AppendLine(string.Format(Messages.DashesSeparator));
 }
Exemplo n.º 6
0
        private void AnswerCleared(object sender, RoutedEventArgs e)
        {
            Control sourceControl = (Control)e.Source;
            IAnswer answer        = (IAnswer)sourceControl.DataContext;

            answer.Checked = false;
        }
Exemplo n.º 7
0
 public void OnRemovedAnswer(IAnswer answer)
 {
     if (currentAnswers.Remove(answer) == false)
     {
         throw new InvalidOperationException("Cannot remove something that was not added");
     }
 }
Exemplo n.º 8
0
 public void AddCard(String title, IQuestion question, IAnswer answer)
 {
     this.PackOfCards.Add(new Card()
     {
         Title = title, Question = question, Answer = answer
     });
 }
Exemplo n.º 9
0
        private static void AddWithChildrenColored(IAnswer response, List <ConsoleOutput> returnValue)
        {
            foreach (var type in MasterColors.Keys)
            {
                if (type.IsAssignableFrom(response.GetType()))
                {
                    returnValue.Add(new ConsoleOutput(MasterColors[type], response.Text + " "));
                    break;
                }
            }

            if (response.Children != null)
            {
                foreach (var child in response.Children)
                {
                    foreach (var type in ChildColors.Keys)
                    {
                        if (type.IsAssignableFrom(child.GetType()))
                        {
                            returnValue.Add(new ConsoleOutput(ChildColors[type], child.Text + " "));
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        public static AnswerVM ToVM(IAnswer iThis)
        {
            var rVM = new AnswerVM();

            Mapping.Map(iThis, rVM);
            return(rVM);
        }
Exemplo n.º 11
0
        public static AnswerViewModel ToModel(this IAnswer answer)
        {
            var answerVm = new AnswerViewModel
            {
                Code       = answer.Code,
                CreatedBy  = answer.CreatedBy,
                CreatedOn  = answer.CreatedOn,
                Directions = answer.Directions,
                Header     = answer.Header,
                Id         = answer.Id,
                IsActive   = answer.IsActive,
                OptionText = answer.OptionText,
                QuestionId = answer.QuestionId,
                Score      = answer.Score,
                SortOrder  = answer.SortOrder,
                Status     = answer.Status,
                Trailer    = answer.Trailer,
                UpdatedBy  = answer.UpdatedBy,
                UpdatedOn  = answer.UpdatedOn
            };

            var childQuestionsIds = answer.AnswerChildQuestions.Select(childQuestion => childQuestion.QuestionId).ToList();

            answerVm.ChildQuestionIds = childQuestionsIds;

            return(answerVm);
        }
 public Exercise(Guid id, IAnswer answer, IQuestion question, List <Guid> usedCardsIds)
 {
     Id           = id;
     Answer       = answer;
     Question     = question;
     UsedCardsIds = usedCardsIds;
 }
 public Exercise(IAnswer answer, IQuestion question)
 {
     Id           = Guid.NewGuid();
     Answer       = answer;
     Question     = question;
     UsedCardsIds = new List <Guid>();
 }
Exemplo n.º 14
0
 public OptionController(IQuestion _IQuestion, ISubject _ISubject, IAnswer _IAnswer, IOption _IOption)
 {
     _Question = _IQuestion;
     _Subject  = _ISubject;
     _Answer   = _IAnswer;
     _Option   = _IOption;
 }
Exemplo n.º 15
0
 public HomeController()
 {
     repo          = new ContactUsRepo();
     repoAns       = new AnswerRepo();
     slideshowRepo = new SlideshowRepo();
     newsRepo      = new NewsRepo();
 }
Exemplo n.º 16
0
        public override void Execute()
        {
            int answerId = int.Parse(this.Data[1]);

            if (!this.Forum.IsLogged)
            {
                throw new CommandException(Messages.NotLogged);
            }
            else if (this.Forum.CurrentQuestion == null)
            {
                throw new CommandException(Messages.NoQuestionOpened);
            }
            else if (!this.Forum.Answers.Any(a => a.Id == answerId))
            {
                throw new CommandException(Messages.NoAnswer);
            }
            else if (this.Forum.CurrentUser != this.Forum.CurrentQuestion.Author && this.Forum.CurrentUser != this.Forum.Users[0])
            {
                throw new CommandException(Messages.NoPermission);
            }

            IAnswer oldAnswer     = this.Forum.Answers.First(a => a.Id == answerId);
            IAnswer newBestAnswer = new BestAnswer(oldAnswer.Id, oldAnswer.Body, oldAnswer.Author);

            this.Forum.Answers.Add(newBestAnswer);
            this.Forum.CurrentQuestion.Answers.Add(newBestAnswer);

            this.Forum.Answers.Remove(oldAnswer);
            this.Forum.CurrentQuestion.Answers.Remove(oldAnswer);

            StringBuilder bestAnswerResult = new StringBuilder();

            bestAnswerResult.AppendFormat(Messages.BestAnswerSuccess, answerId);
            this.Forum.Output.AppendLine(bestAnswerResult.ToString());
        }
Exemplo n.º 17
0
 public void AddAnswer(IAnswer answer)
 {
     if (answer != null)
     {
         _answers.Add(answer);
     }
 }
Exemplo n.º 18
0
        public IAnswer SelectFirstConcept(
            Func <StatementT, IConcept> resultConceptSelector,
            Func <ILanguage, String> answerFormat,
            Func <StatementT, IDictionary <String, IKnowledge> > getParameters)
        {
            ProcessChildrenIfNeed();

            IAnswer answer = null;

            var statement = Statements.FirstOrDefault();

            if (statement != null)
            {
                answer = new ConceptAnswer(
                    resultConceptSelector(statement),
                    new FormattedText(
                        answerFormat,
                        getParameters(statement)),
                    new Explanation(Statements.OfType <IStatement>()));

                answer.Explanation.Expand(AdditionalTransitives);
            }

            if (answer == null)
            {
                var childAnswer = ChildAnswers.FirstOrDefault();
                if (childAnswer != null)
                {
                    childAnswer.Answer.Explanation.Expand(childAnswer.TransitiveStatements);
                    answer = childAnswer.Answer;
                }
            }

            return(answer ?? Answer.CreateUnknown());
        }
Exemplo n.º 19
0
      public void ConfirmEditedAnswerComment(int EditedCommentID, int EditedCommentAnswerID, [FromForm(Name = "EditComment")] string editedcomment)
      {
          IAnswer answer = _loader.GetAnswerList($"Select * From answer Where answer_id = {Convert.ToString(EditedCommentAnswerID)} ")[0];

          _loader.UpdateDataRow($"Update askmate_answer_comment SET comment_message = '{editedcomment}',edited_number = edited_number + 1 Where comment_id = {Convert.ToString(EditedCommentID)} and answer_id = {Convert.ToString(EditedCommentAnswerID)}");
          Response.Redirect($"QuestionDetails/{answer.QuestionID}");
      }
Exemplo n.º 20
0
 public void SetupNewCard()
 {
     this.ActiveCardIndex = this.GenerateNextCardIndex();
     // this.UserAnswer = (IAnswer)Activator.CreateInstance(this.CardPack[this.ActiveCardIndex].Answer.GetAnswerType(),
     //                                                     new object[] { "Your answer comes here" });
     this.QuizPhase  = AnswerPhase.CkeckAnswer;
     this.UserAnswer = this.UserAnswerGenerator(this.CardPack[this.ActiveCardIndex].Answer);
 }
 public bool IsTheSameAs(IAnswer otherAnswer)
 {
     if (!(otherAnswer is ChoiceAnswer))
     {
         return(false);
     }
     return(Answer == ((ChoiceAnswer)otherAnswer).Answer);
 }
Exemplo n.º 22
0
        internal VisualAnswer(IAnswer answer, string currentDirectory)
        {
            if (answer == null)
                throw new ArgumentNullException("answer");

            _answer = answer;
            _currentDirectory = string.IsNullOrEmpty(currentDirectory) ? string.Empty : currentDirectory;
        }
Exemplo n.º 23
0
 public AnswerViewModel(IAnswer answerService, IComment commentService, ICollection collection,
                        ISocial socialService) : this()
 {
     _answerService  = answerService;
     _commentService = commentService;
     _collection     = collection;
     _social         = socialService;
 }
Exemplo n.º 24
0
        public void CreateAnswerMethodShouldCreateAnIncorrectAnswerWithGivenText()
        {
            var     answerText = "This is an incorrect answer";
            var     factory    = new Factory();
            IAnswer answer     = factory.CreateAnswer(answerText, false);

            Assert.IsFalse(answer.IsCorrect);
        }
Exemplo n.º 25
0
        public void CreateAnswerMethodShouldCreateAValidAnswer()
        {
            var     answerText = "This is a correct answer";
            var     factory    = new Factory();
            IAnswer answer     = factory.CreateAnswer(answerText, true);

            Assert.IsNotNull(answer);
        }
Exemplo n.º 26
0
        public void CreateAnswerMethodShouldCreateATypeOfAnswer()
        {
            var     answerText = "This is a correct answer";
            var     factory    = new Factory();
            IAnswer answer     = factory.CreateAnswer(answerText, true);

            Assert.IsInstanceOfType(answer, typeof(Answer));
        }
Exemplo n.º 27
0
        public static SortingTicket AddTicket(this IAnswer answ, int ticketN)
        {
            var comp = answ.gameObject.AddComponent <SortingTicket>();

            comp.data   = answ.gameObject.GetComponent <LetterObjectView>().Data;
            comp.number = ticketN;
            return(comp);
        }
Exemplo n.º 28
0
        private void MakeAnswerBestAnswer(IQuestion question, IAnswer answer)
        {
            this.RemoveCurrentAnswerFromDatabase(question, answer);

            var bestAnswer = new BestAnswer(answer.Id, answer.Body, answer.Author);

            this.AddBestAnswerToDatabase(question, bestAnswer);
        }
Exemplo n.º 29
0
        private void MakeAnswerBestAnswer(IQuestion question, IAnswer answer)
        {
            this.RemoveCurrentAnswerFromDatabase(question, answer);

            var bestAnswer = new BestAnswer(answer.Id, answer.Body, answer.Author);

            this.AddBestAnswerToDatabase(question, bestAnswer);
        }
Exemplo n.º 30
0
        public void CreateAnswerMethodShouldCreateAnAnswerWithGivenText()
        {
            var     answerText = "This is a correct answer";
            var     factory    = new Factory();
            IAnswer answer     = factory.CreateAnswer(answerText, true);

            Assert.AreSame(answer.AnswerText, answerText);
        }
Exemplo n.º 31
0
 public StringQuestion(string questName, string questDescription, ICollection <IAnswer <string> > answers,
                       IAnswer <string> correctAnswer)
 {
     QuestName        = questName;
     QuestDescription = questDescription;
     _answers         = answers;
     _correctAnswer   = correctAnswer;
 }
Exemplo n.º 32
0
        public override void Execute()
        {
            this.Forum.CurrentQuestion = null;

            var questions = this.Forum.Questions;

            if (questions.Count == 0)
            {
                this.Forum.Output.AppendLine(string.Format(Messages.NoQuestions));
            }
            else
            {
                var sortedQuestions = questions.OrderBy(q => q.Id);
                foreach (var question in sortedQuestions)
                {
                    var questionString = "Question";
                    GetoutQuestion(questionString, question);

                    var answers = question.Answers.OrderBy(a => a.Id).ToList();
                    if (answers.Count == 0)
                    {
                        this.Forum.Output.AppendLine(string.Format(Messages.NoAnswers));
                    }
                    else
                    {
                        this.Forum.Output.AppendLine(string.Format(Messages.Answers));
                        IAnswer firstanAnswer   = null;
                        var     foundBestAnswer = false;

                        foreach (var answer in answers)
                        {
                            if (answer is BestAnswer)
                            {
                                firstanAnswer   = answer;
                                foundBestAnswer = true;
                            }
                        }

                        var answerString = "Answer";

                        if (foundBestAnswer)
                        {
                            this.Forum.Output.AppendLine(string.Format(Messages.StarsSeparator));
                            GetoutAnswer(answerString, firstanAnswer);
                            this.Forum.Output.AppendLine(string.Format(Messages.StarsSeparator));
                        }

                        foreach (var answer in answers)
                        {
                            if (answer != firstanAnswer)
                            {
                                GetoutAnswer(answerString, answer);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 33
0
        public bool CheckAnswer(IAnswer answer)
        {
            if (answer == null)
                throw new ArgumentNullException("answer", "answer is null.");
            if (answer.GetType() != typeof(TextAnswer))
                throw new InvalidOperationException("Exact text answer required.");

            return CheckAnswer((TextAnswer)answer);
        }
 private void ExchangeAnswers(IAnswer curentBestAnswer, IAnswer answer)
 {
     var i = this.Forum.CurrentQuestion.Answers.IndexOf(curentBestAnswer);
     this.Forum.CurrentQuestion.Answers.RemoveAt(i);
     this.Forum.CurrentQuestion.Answers.Insert(i, answer);
     i = this.Forum.Answers.IndexOf(curentBestAnswer);
     this.Forum.Answers.RemoveAt(i);
     this.Forum.Answers.Insert(i, answer);
 }
Exemplo n.º 35
0
        static void Main(string[] args)
        {
            _solver = new DivideLambAnswer();

            for(int i = 0; i< test_cases; i++)
            {
                Console.WriteLine("Test #{0} - Input: {1}, Answer = {2}", i + 1, tests[i], _solver.answer(tests[i]));
            }
            Console.ReadKey();
        }
Exemplo n.º 36
0
        public bool CheckAnswer(IAnswer answer)
        {
            if (State != HuntState.InProgress)
                throw new InvalidOperationException("Game not in progress.");

            var result = CurrentRiddle.CheckAnswer(answer);
            if (result == true)
                ++currentRiddle;
            return result;
        }
        public static string PrintAnswer(IAnswer answer)
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("[ Answer ID: {0} ]", answer.Id)
                .AppendLine()
                .AppendFormat("Posted by: {0}", answer.Author.Username)
                .AppendLine()
                .AppendFormat("Answer Body: {0}", answer.Body)
                .AppendLine()
                .Append("--------------------");

            return sb.ToString();
        }
Exemplo n.º 38
0
 public bool ContainsAnswer(IAnswer answer)
 {
     return _answers.Keys.ToList().Contains(answer);
 }
Exemplo n.º 39
0
 public void AddAnswer(IAnswer answer)
 {
     this.Answers.Add(answer);
 }
Exemplo n.º 40
0
 private void AssertAnswer(IDeal deal, IApproval app, IAnswer answer)
 {
     var actureAnswer = WorkFlowManager.WorkFlowFactory.GetAnswer(deal.Id, app.Id);
     Assert.AreEqual(deal.Id, actureAnswer.DealId);
     Assert.AreEqual(app.Id, actureAnswer.ApprovalId);
     Assert.AreEqual(answer.QuestionId, actureAnswer.QuestionId);
     Assert.AreEqual(answer.Answer, actureAnswer.Answer);
 }
Exemplo n.º 41
0
 public FacadeOpenweathermap(IAnswer answer)
 {
     _answer = answer;
 }
Exemplo n.º 42
0
 public void Init()
 {
     _answerImpl = new AnswerImpl();
 }
Exemplo n.º 43
0
 public async Task<int> UpdateAsync(IAnswer answer)
 {
     try
     {
         return await Repository.UpdateAsync<AnswerEntity>(AutoMapper.Mapper.Map<AnswerEntity>(answer));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 44
0
 public void SelectAnswer(IAnswer answer)
 {
     if (AnswersSelected == _maxSelectedAnswersRange.UpperBound)
         throw new AnswerSelectingException("Too many answers selected.");
     if (answer == null)
         throw new ArgumentNullException("answer");
     if (!_answers.ContainsKey(answer))
         throw new ArgumentOutOfRangeException("answer");
     if (_answers[answer]) return;
     _answers[answer] = true;
     AnswersSelected++;
 }
Exemplo n.º 45
0
 public IAnswer SaveAnswer(IAnswer answer)
 {
     return answer;
 }
Exemplo n.º 46
0
 private void GetoutAnswer(string answerString, IAnswer firstanAnswer)
 {
     this.Forum.Output.AppendLine(string.Format(Messages.Header, answerString, firstanAnswer.Id));
     this.Forum.Output.AppendLine(string.Format(Messages.Author, firstanAnswer.Author.Username));
     this.Forum.Output.AppendLine(string.Format(Messages.Body, answerString, firstanAnswer.Body));
     this.Forum.Output.AppendLine(string.Format(Messages.DashesSeparator));
 }
Exemplo n.º 47
0
 public bool RemoveAnswer(IAnswer answer)
 {
     if (answer == null)
         throw new ArgumentNullException("answer");
     return _answers.Remove(answer);
 }
Exemplo n.º 48
0
        /// <summary>
        /// Writes the response entry.
        /// </summary>
        /// <param name="responseHeaderId">The response header id.</param>
        /// <param name="section">The section.</param>
        /// <param name="question">The question.</param>
        /// <param name="answer">The answer.</param>
        /// <param name="responseText">The response text.</param>
        private void WriteResponseEntry(int responseHeaderId, ISection section, IQuestion question, IAnswer answer, string responseText)
        {
            var surveyRepository = new SurveyRepository();
            var response = surveyRepository.CreateResponse(responseHeaderId, 1);
            response.SurveyId = this.SurveyId;
            response.SurveyText = this.Text;
            response.ShowSurveyText = this.ShowText;
            response.TitleOption = this.TitleOption;
            response.SectionText = section.Text;
            response.SectionRelativeOrder = section.RelativeOrder;
            response.ShowSectionText = false;
            response.SectionId = section.SectionId;
            response.SectionRelativeOrder = section.RelativeOrder;
            response.SectionFormatOption = this.SectionFormatOption;
            response.QuestionId = question.QuestionId;
            response.QuestionText = question.Text;
            response.QuestionRelativeOrder = question.RelativeOrder;
            response.QuestionFormatOption = this.QuestionFormatOption;
            response.ControlType = question.ControlType;
            if (answer != null)
            {
                response.AnswerId = answer.AnswerId;
                response.AnswerText = answer.Text;
                response.AnswerRelativeOrder = answer.RelativeOrder;
                response.AnswerIsCorrect = answer.IsCorrect;
            }

            response.UserResponse = responseText;

            surveyRepository.SubmitChanges();

            Debug.WriteLine(response.ResponseId);
        }
Exemplo n.º 49
0
 public async Task<int> UpdateAsync(IAnswer answer)
 {
     return await Repository.UpdateAsync(answer);
 }
Exemplo n.º 50
0
 private void RemoveCurrentAnswerFromDatabase(IQuestion question, IAnswer answer)
 {
     question.Answers.Remove(answer);
     this.Forum.Answers.Remove(answer);
 }
Exemplo n.º 51
0
 private void AddBestAnswerToDatabase(IQuestion question, IAnswer answer)
 {
     question.Answers.Add(answer);
     this.Forum.Answers.Add(answer);
 }
Exemplo n.º 52
0
 public bool AddAnswer(IAnswer answer)
 {
     if (answer == null)
         throw new ArgumentNullException("answer");
     if (!_answers.ContainsKey(answer))
     {
         _answers.Add(answer, false);
         return true;
     }
     return false;
 }
Exemplo n.º 53
0
 public void UnselectAnswer(IAnswer answer)
 {
     if (answer == null)
         throw new ArgumentNullException("answer");
     if (!_answers.ContainsKey(answer))
         throw new ArgumentOutOfRangeException("answer");
     if (!_answers[answer]) return;
     _answers[answer] = false;
     AnswersSelected--;
 }
Exemplo n.º 54
0
        /// <summary>
        /// Finds the response.
        /// </summary>
        /// <param name="answer">The answer.</param>
        /// <returns>A user response entered by the user.</returns>
        public UserResponse FindResponse(IAnswer answer)
        {
            foreach (UserResponse r in this.Responses)
            {
                if (r.RelationshipKey.Equals(answer.RelationshipKey))
                {
                    return r;
                }
            }

            return null;
        }
Exemplo n.º 55
0
 public async Task<int> AddAsync(IAnswer answer)
 {
     return await Repository.AddAsync(answer);
 }