コード例 #1
0
 public AnswerController(IQuestion questionImplementation, IAnswer answerImplementation, UserManager <ApplicationUser> userManager, IApplicationUser applicationUserImplementation)
 {
     _questionImplementation        = questionImplementation;
     _answerImplementation          = answerImplementation;
     _userManager                   = userManager;
     _applicationUserImplementation = applicationUserImplementation;
 }
コード例 #2
0
        public void Clear()
        {
            AnswerOrder = 0;

            _answer = null;
            State   = QuestionState.Unanswered;
        }
コード例 #3
0
 public HomeController(IUser _IUser, ISubject _ISubject, IQuestion _IQuestion, IAnswer _IAnswer)
 {
     _User     = _IUser;
     _Subject  = _ISubject;
     _Question = _IQuestion;
     _Answer   = _IAnswer;
 }
コード例 #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}");
      }
コード例 #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));
 }
コード例 #6
0
        private void AnswerCleared(object sender, RoutedEventArgs e)
        {
            Control sourceControl = (Control)e.Source;
            IAnswer answer        = (IAnswer)sourceControl.DataContext;

            answer.Checked = false;
        }
コード例 #7
0
 public void OnRemovedAnswer(IAnswer answer)
 {
     if (currentAnswers.Remove(answer) == false)
     {
         throw new InvalidOperationException("Cannot remove something that was not added");
     }
 }
コード例 #8
0
 public void AddCard(String title, IQuestion question, IAnswer answer)
 {
     this.PackOfCards.Add(new Card()
     {
         Title = title, Question = question, Answer = answer
     });
 }
コード例 #9
0
ファイル: ConsoleView.cs プロジェクト: ohomola/gears
        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;
                        }
                    }
                }
            }
        }
コード例 #10
0
ファイル: CSTMapper.cs プロジェクト: nick-codesatori/CST2
        public static AnswerVM ToVM(IAnswer iThis)
        {
            var rVM = new AnswerVM();

            Mapping.Map(iThis, rVM);
            return(rVM);
        }
コード例 #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);
        }
コード例 #12
0
 public Exercise(Guid id, IAnswer answer, IQuestion question, List <Guid> usedCardsIds)
 {
     Id           = id;
     Answer       = answer;
     Question     = question;
     UsedCardsIds = usedCardsIds;
 }
コード例 #13
0
 public Exercise(IAnswer answer, IQuestion question)
 {
     Id           = Guid.NewGuid();
     Answer       = answer;
     Question     = question;
     UsedCardsIds = new List <Guid>();
 }
コード例 #14
0
 public OptionController(IQuestion _IQuestion, ISubject _ISubject, IAnswer _IAnswer, IOption _IOption)
 {
     _Question = _IQuestion;
     _Subject  = _ISubject;
     _Answer   = _IAnswer;
     _Option   = _IOption;
 }
コード例 #15
0
ファイル: HomeController.cs プロジェクト: hamkairama/Sbh
 public HomeController()
 {
     repo          = new ContactUsRepo();
     repoAns       = new AnswerRepo();
     slideshowRepo = new SlideshowRepo();
     newsRepo      = new NewsRepo();
 }
コード例 #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());
        }
コード例 #17
0
ファイル: Paragraph.cs プロジェクト: Ju-Pierlot/GameBook
 public void AddAnswer(IAnswer answer)
 {
     if (answer != null)
     {
         _answers.Add(answer);
     }
 }
コード例 #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());
        }
コード例 #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}");
      }
コード例 #20
0
ファイル: QnAModel.cs プロジェクト: Akomer/Thesis
 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);
 }
コード例 #21
0
 public bool IsTheSameAs(IAnswer otherAnswer)
 {
     if (!(otherAnswer is ChoiceAnswer))
     {
         return(false);
     }
     return(Answer == ((ChoiceAnswer)otherAnswer).Answer);
 }
コード例 #22
0
ファイル: VisualAnswer.cs プロジェクト: KBurov/Testing
        internal VisualAnswer(IAnswer answer, string currentDirectory)
        {
            if (answer == null)
                throw new ArgumentNullException("answer");

            _answer = answer;
            _currentDirectory = string.IsNullOrEmpty(currentDirectory) ? string.Empty : currentDirectory;
        }
コード例 #23
0
 public AnswerViewModel(IAnswer answerService, IComment commentService, ICollection collection,
                        ISocial socialService) : this()
 {
     _answerService  = answerService;
     _commentService = commentService;
     _collection     = collection;
     _social         = socialService;
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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));
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #31
0
 public StringQuestion(string questName, string questDescription, ICollection <IAnswer <string> > answers,
                       IAnswer <string> correctAnswer)
 {
     QuestName        = questName;
     QuestDescription = questDescription;
     _answers         = answers;
     _correctAnswer   = correctAnswer;
 }
コード例 #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);
                            }
                        }
                    }
                }
            }
        }
コード例 #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);
        }
コード例 #34
0
 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);
 }
コード例 #35
0
ファイル: Program.cs プロジェクト: johanne/BlogTutorial
        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();
        }
コード例 #36
0
ファイル: Hunt.cs プロジェクト: pebblecode/hangover-hunt
        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;
        }
コード例 #37
0
        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();
        }
コード例 #38
0
ファイル: Question.cs プロジェクト: RavingRabbit/Labs
 public bool ContainsAnswer(IAnswer answer)
 {
     return _answers.Keys.ToList().Contains(answer);
 }
コード例 #39
0
 public void AddAnswer(IAnswer answer)
 {
     this.Answers.Add(answer);
 }
コード例 #40
0
ファイル: TestSalesTeam.cs プロジェクト: MyRSG/COAT
 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);
 }
コード例 #41
0
 public FacadeOpenweathermap(IAnswer answer)
 {
     _answer = answer;
 }
コード例 #42
0
ファイル: AnswerTest.cs プロジェクト: sahbijabnouni/quiz
 public void Init()
 {
     _answerImpl = new AnswerImpl();
 }
コード例 #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;
     }
 }
コード例 #44
0
ファイル: Question.cs プロジェクト: RavingRabbit/Labs
 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++;
 }
コード例 #45
0
ファイル: TestDataFacoty.cs プロジェクト: MyRSG/COAT
 public IAnswer SaveAnswer(IAnswer answer)
 {
     return answer;
 }
コード例 #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));
 }
コード例 #47
0
ファイル: Question.cs プロジェクト: RavingRabbit/Labs
 public bool RemoveAnswer(IAnswer answer)
 {
     if (answer == null)
         throw new ArgumentNullException("answer");
     return _answers.Remove(answer);
 }
コード例 #48
0
ファイル: Survey.cs プロジェクト: krishna23456/Engage-Survey
        /// <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);
        }
コード例 #49
0
 public async Task<int> UpdateAsync(IAnswer answer)
 {
     return await Repository.UpdateAsync(answer);
 }
コード例 #50
0
 private void RemoveCurrentAnswerFromDatabase(IQuestion question, IAnswer answer)
 {
     question.Answers.Remove(answer);
     this.Forum.Answers.Remove(answer);
 }
コード例 #51
0
 private void AddBestAnswerToDatabase(IQuestion question, IAnswer answer)
 {
     question.Answers.Add(answer);
     this.Forum.Answers.Add(answer);
 }
コード例 #52
0
ファイル: Question.cs プロジェクト: RavingRabbit/Labs
 public bool AddAnswer(IAnswer answer)
 {
     if (answer == null)
         throw new ArgumentNullException("answer");
     if (!_answers.ContainsKey(answer))
     {
         _answers.Add(answer, false);
         return true;
     }
     return false;
 }
コード例 #53
0
ファイル: Question.cs プロジェクト: RavingRabbit/Labs
 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--;
 }
コード例 #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;
        }
コード例 #55
0
 public async Task<int> AddAsync(IAnswer answer)
 {
     return await Repository.AddAsync(answer);
 }