public AnswerController(IQuestion questionImplementation, IAnswer answerImplementation, UserManager <ApplicationUser> userManager, IApplicationUser applicationUserImplementation) { _questionImplementation = questionImplementation; _answerImplementation = answerImplementation; _userManager = userManager; _applicationUserImplementation = applicationUserImplementation; }
public void Clear() { AnswerOrder = 0; _answer = null; State = QuestionState.Unanswered; }
public HomeController(IUser _IUser, ISubject _ISubject, IQuestion _IQuestion, IAnswer _IAnswer) { _User = _IUser; _Subject = _ISubject; _Question = _IQuestion; _Answer = _IAnswer; }
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}"); }
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)); }
private void AnswerCleared(object sender, RoutedEventArgs e) { Control sourceControl = (Control)e.Source; IAnswer answer = (IAnswer)sourceControl.DataContext; answer.Checked = false; }
public void OnRemovedAnswer(IAnswer answer) { if (currentAnswers.Remove(answer) == false) { throw new InvalidOperationException("Cannot remove something that was not added"); } }
public void AddCard(String title, IQuestion question, IAnswer answer) { this.PackOfCards.Add(new Card() { Title = title, Question = question, Answer = answer }); }
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; } } } } }
public static AnswerVM ToVM(IAnswer iThis) { var rVM = new AnswerVM(); Mapping.Map(iThis, rVM); return(rVM); }
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>(); }
public OptionController(IQuestion _IQuestion, ISubject _ISubject, IAnswer _IAnswer, IOption _IOption) { _Question = _IQuestion; _Subject = _ISubject; _Answer = _IAnswer; _Option = _IOption; }
public HomeController() { repo = new ContactUsRepo(); repoAns = new AnswerRepo(); slideshowRepo = new SlideshowRepo(); newsRepo = new NewsRepo(); }
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()); }
public void AddAnswer(IAnswer answer) { if (answer != null) { _answers.Add(answer); } }
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()); }
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}"); }
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); }
internal VisualAnswer(IAnswer answer, string currentDirectory) { if (answer == null) throw new ArgumentNullException("answer"); _answer = answer; _currentDirectory = string.IsNullOrEmpty(currentDirectory) ? string.Empty : currentDirectory; }
public AnswerViewModel(IAnswer answerService, IComment commentService, ICollection collection, ISocial socialService) : this() { _answerService = answerService; _commentService = commentService; _collection = collection; _social = socialService; }
public void CreateAnswerMethodShouldCreateAnIncorrectAnswerWithGivenText() { var answerText = "This is an incorrect answer"; var factory = new Factory(); IAnswer answer = factory.CreateAnswer(answerText, false); Assert.IsFalse(answer.IsCorrect); }
public void CreateAnswerMethodShouldCreateAValidAnswer() { var answerText = "This is a correct answer"; var factory = new Factory(); IAnswer answer = factory.CreateAnswer(answerText, true); Assert.IsNotNull(answer); }
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)); }
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); }
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); }
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); }
public StringQuestion(string questName, string questDescription, ICollection <IAnswer <string> > answers, IAnswer <string> correctAnswer) { QuestName = questName; QuestDescription = questDescription; _answers = answers; _correctAnswer = correctAnswer; }
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); } } } } } }
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); }
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(); }
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(); }
public bool ContainsAnswer(IAnswer answer) { return _answers.Keys.ToList().Contains(answer); }
public void AddAnswer(IAnswer answer) { this.Answers.Add(answer); }
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); }
public FacadeOpenweathermap(IAnswer answer) { _answer = answer; }
public void Init() { _answerImpl = new AnswerImpl(); }
public async Task<int> UpdateAsync(IAnswer answer) { try { return await Repository.UpdateAsync<AnswerEntity>(AutoMapper.Mapper.Map<AnswerEntity>(answer)); } catch (Exception ex) { throw ex; } }
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++; }
public IAnswer SaveAnswer(IAnswer answer) { return answer; }
public bool RemoveAnswer(IAnswer answer) { if (answer == null) throw new ArgumentNullException("answer"); return _answers.Remove(answer); }
/// <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); }
public async Task<int> UpdateAsync(IAnswer answer) { return await Repository.UpdateAsync(answer); }
private void RemoveCurrentAnswerFromDatabase(IQuestion question, IAnswer answer) { question.Answers.Remove(answer); this.Forum.Answers.Remove(answer); }
private void AddBestAnswerToDatabase(IQuestion question, IAnswer answer) { question.Answers.Add(answer); this.Forum.Answers.Add(answer); }
public bool AddAnswer(IAnswer answer) { if (answer == null) throw new ArgumentNullException("answer"); if (!_answers.ContainsKey(answer)) { _answers.Add(answer, false); return true; } return false; }
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--; }
/// <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; }
public async Task<int> AddAsync(IAnswer answer) { return await Repository.AddAsync(answer); }