public AnswersCommentPopupPage(QuestionsAnswers answers, Action <AnswersComment> result, AnswersComment answersComment = null) { this.answers = answers; this.result = result; this.answersComment = answersComment; InitializeComponent(); BindingContext = new AnswersDetailsViewModel(answers); if (answersComment != null) { this.Comment.Text = answersComment.Content; } this.Comment.Focus(); }
public QuestionsAnswersPopupPage(Questions questions, Action <QuestionsAnswers> result, QuestionsAnswers questionsAnswers = null) { this.questions = questions; this.questionsAnswers = questionsAnswers; this.result = result; InitializeComponent(); BindingContext = new QuestionsDetailsViewModel(questions); if (questionsAnswers != null) { this.Comment.Text = questionsAnswers.Answer; } this.Comment.Focus(); }
public void AddQuestion(QuestionsAnswers qanda, int workId, string userName) { var user = GetCurrentUser(userName); var work = GetWork(workId); // default after question is created qanda.Type = QandAType.Question; qanda.Owner = user; qanda.OrderNr = 0; qanda.Work = work; Ctx.QuestionsAnswers.Add(qanda); SaveChanges(); }
public async Task <List <QuestionsAnswers> > ReloadAnswersAsync() { try { LoadStatus = LoadMoreStatus.StausLoading; var result = await StoreManager.QuestionsDetailsService.GetAnswersAsync(questions.Qid, pageIndex, pageSize); if (result.Success) { var questionsAnswers = JsonConvert.DeserializeObject <List <QuestionsAnswers> >(result.Message.ToString()); if (questionsAnswers.Count > 0) { if (pageIndex == 1) { QuestionsAnswers.Clear(); } QuestionsAnswers.AddRange(questionsAnswers); pageIndex++; if (questionsAnswers.Count < pageSize) { LoadStatus = LoadMoreStatus.StausEnd; } else { LoadStatus = LoadMoreStatus.StausDefault; } } else { LoadStatus = pageIndex > 1 ? LoadMoreStatus.StausEnd : LoadMoreStatus.StausNodata; } } else { Crashes.TrackError(new Exception() { Source = result.Message }); LoadStatus = LoadMoreStatus.StausError; } } catch (Exception ex) { Crashes.TrackError(ex); LoadStatus = LoadMoreStatus.StausError; } return(QuestionsAnswers); }
public QuestionsAnswersPopupPage(Questions questions, Action <QuestionsAnswers> result, QuestionsAnswers questionsAnswers = null) { InitializeComponent(); Xamarin.Forms.PlatformConfiguration.iOSSpecific.Page.SetUseSafeArea(this, true); this.questions = questions; this.questionsAnswers = questionsAnswers; this.result = result; BindingContext = new QuestionsDetailsViewModel(questions); if (questionsAnswers != null) { this.Comment.Text = questionsAnswers.Answer; } this.Comment.Focus(); ViewModel.IsBusy = false; }
public AnswersDetailsViewModel(QuestionsAnswers answers) { this.answers = answers; Title = answers.UserName + "的回答"; AnswersDetails = new AnswersDetailsModel() { UserName = answers.AnswerUserInfo.UserName, IconDisplay = answers.AnswerUserInfo.IconDisplay, UserDisplay = answers.UserDisplay, IsBest = answers.IsBest, Answer = answers.AnswerDisplay, DiggDisplay = answers.DiggCount > 0 ? answers.DiggCount.ToString() : "推荐", CommentDisplay = answers.CommentCounts > 0 ? answers.CommentCounts.ToString() : "评论" }; }
public AnswersCommentPopupPage(QuestionsAnswers answers, Action <AnswersComments> result, AnswersComments answersComment = null) { InitializeComponent(); Xamarin.Forms.PlatformConfiguration.iOSSpecific.Page.SetUseSafeArea(this, true); this.answers = answers; this.result = result; this.answersComment = answersComment; BindingContext = new AnswersDetailsViewModel(answers); if (answersComment != null) { this.Comment.Text = answersComment.Content; } this.Comment.Focus(); ViewModel.IsBusy = false; }
/** Loads contents of the file provided by the user into questions/answers list */ private void loadFileButton_Click(object sender, EventArgs e) { QuestionsAnswers.ShowDialog(); String QaFileContents = File.ReadAllText(QuestionsAnswers.FileName); if (QaFileContents.Length <= 0) { Help help = new Help(); help.changeHelpMessage("Something went wrong with the file"); help.ShowDialog(); } else { String[] qa = prepareFileContent(QaFileContents); divideContentOfTheFileIntoQuestionsAndAnswers(qa); } }
public void EditComment(QuestionsAnswers comment) { var book = QuestionsAnswers.Where(b => b.AnswerID == comment.AnswerID).FirstOrDefault(); if (book == null) { QuestionsAnswers.Add(comment); QuestionsDetails.CommentDisplay = (questions.AnswerCount + 1).ToString(); } else { var index = QuestionsAnswers.IndexOf(book); QuestionsAnswers[index] = comment; } if (LoadStatus == LoadMoreStatus.StausNodata) { LoadStatus = LoadMoreStatus.StausEnd; } }
// GET: QuestionsAnswers public async Task <ActionResult> Play(Guid id) { ViewBag.QuizId = id; QuestionsAnswers model = new QuestionsAnswers(); model.Questions = await questionsRepo.GetQuestionsByQuiz(id); List <Answers> list = new List <Answers>(); foreach (Questions question in model.Questions) { foreach (var item in await answersRepo.GetAnswersByQuestion(question.QuestionID)) { list.Add(item); } } model.Answers = list; return(View(model)); }
private void ClosePopupPage(string result) { if (result != null) { if (questionsAnswers == null) { questionsAnswers = new QuestionsAnswers(); questionsAnswers.AnswerUserInfo = new QuestionUserInfo() { UserID = UserSettings.Current.SpaceUserId, IconName = UserSettings.Current.Avatar, UCUserID = UserSettings.Current.UserId, UserName = UserSettings.Current.DisplayName, QScore = UserSettings.Current.Score }; questionsAnswers.Qid = questions.Qid; } questionsAnswers.Answer = result; questionsAnswers.DateAdded = DateTime.Now; this.result.Invoke(questionsAnswers); } PopupNavigation.PopAsync(); }
public AnswersDetailsPage(QuestionsAnswers answers) { this.answers = answers; InitializeComponent(); BindingContext = new AnswersDetailsViewModel(answers); }
private void LoadNextQuestion() { if (SelectedPicture == null || SelectedPicture.UriSource == null) { MessageBox.Show("Du måste välja en bild till frågan!"); return; } if (string.IsNullOrEmpty(QuestionText)) { MessageBox.Show("Du måste skriva en fråga!"); return; } if (string.IsNullOrEmpty(Alternative1Text) || string.IsNullOrEmpty(Alternative2Text) || string.IsNullOrEmpty(Alternative3Text)) { MessageBox.Show("Du måste skriva alla 3 svars alternativ!"); return; } if (Alt1Correct == false && Alt2Correct == false && Alt3Correct == false) { MessageBox.Show("Du måste välja vad som är rätt svar!"); return; } SelectedQuestion++; if (QuestionsAnswers.Count < SelectedQuestion) { QuestionsAnswers.Add(new QuestionData()); SelectedPicture = new BitmapImage(); Pictures.Add(new BitmapImage()); QuestionText = ""; Alternative1Text = ""; Alternative2Text = ""; Alternative3Text = ""; Alt1Correct = false; Alt2Correct = false; Alt3Correct = false; } else { SelectedPicture = Pictures[SelectedQuestion - 1]; QuestionText = QuestionsAnswers[SelectedQuestion - 1].Question; Alternative1Text = QuestionsAnswers[SelectedQuestion - 1].AlternativeOne; Alternative2Text = QuestionsAnswers[SelectedQuestion - 1].AlternativeTwo; Alternative3Text = QuestionsAnswers[SelectedQuestion - 1].AlternativeThree; var CA = QuestionsAnswers[SelectedQuestion - 1].Answer; if (CA == Alternative1Text) { Alt1Correct = true; Alt2Correct = false; Alt3Correct = false; } else if (CA == Alternative2Text) { Alt2Correct = true; Alt1Correct = false; Alt3Correct = false; } else if (CA == Alternative3Text) { Alt3Correct = true; Alt1Correct = false; Alt2Correct = false; } else { Alt1Correct = false; Alt2Correct = false; Alt3Correct = false; } } DeleteQuestionCommand.RaiseCanExecuteChanged(); }
private void SaveQuestions() { if (Pictures[QuestionsAnswers.Count - 1].UriSource == null || BackgroundPicture.UriSource == null || QuestionsAnswers[QuestionsAnswers.Count - 1].Question == null || QuestionsAnswers[QuestionsAnswers.Count - 1].AlternativeOne == null || QuestionsAnswers[QuestionsAnswers.Count - 1].AlternativeTwo == null || QuestionsAnswers[QuestionsAnswers.Count - 1].AlternativeThree == null || HeaderText == null || QuestionsAnswers[QuestionsAnswers.Count - 1].Answer == null) { MessageBox.Show("Du måste fylla ialla fält eller ta bort den påbörjade frågan innan du exporterar."); return; } string dummyFileName = "Spara här"; SaveFileDialog sf = new SaveFileDialog(); sf.FileName = dummyFileName; var result = sf.ShowDialog(); if ((bool)result) { string savePath = Path.GetDirectoryName(sf.FileName); var index = 1; foreach (var pic in Pictures) { if (pic.UriSource != null) { var extension = Path.GetExtension(pic.UriSource.AbsolutePath.ToLower()); switch (extension) { case ".jpg": case ".jpeg": { FileStream stream = new FileStream(Path.Combine(savePath, index + extension), FileMode.Create); BitmapEncoder encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(pic)); encoder.Save(stream); stream.Dispose(); index++; break; } case ".png": { FileStream stream = new FileStream(Path.Combine(savePath, index + extension), FileMode.Create); BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(pic)); encoder.Save(stream); stream.Dispose(); index++; break; } case ".bmp": { FileStream stream = new FileStream(Path.Combine(savePath, index + extension), FileMode.Create); BitmapEncoder encoder = new BmpBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(pic)); encoder.Save(stream); stream.Dispose(); index++; break; } case ".gif": { FileStream stream = new FileStream(Path.Combine(savePath, index + extension), FileMode.Create); BitmapEncoder encoder = new GifBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(pic)); encoder.Save(stream); stream.Dispose(); index++; break; } } } } var backgroundExtension = Path.GetExtension(BackgroundPicture.UriSource.AbsoluteUri.ToLower()); switch (backgroundExtension) { case ".jpg": case ".jpeg": { FileStream stream = new FileStream(Path.Combine(savePath, "background" + "#" + HeaderText + backgroundExtension), FileMode.Create); BitmapEncoder encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(BackgroundPicture)); encoder.Save(stream); stream.Dispose(); break; } case ".png": { FileStream stream = new FileStream(Path.Combine(savePath, "background" + "#" + HeaderText + backgroundExtension), FileMode.Create); BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(BackgroundPicture)); encoder.Save(stream); stream.Dispose(); break; } case ".bmp": { FileStream stream = new FileStream(Path.Combine(savePath, "background" + "#" + HeaderText + backgroundExtension), FileMode.Create); BitmapEncoder encoder = new BmpBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(BackgroundPicture)); encoder.Save(stream); stream.Dispose(); break; } case ".gif": { FileStream stream = new FileStream(Path.Combine(savePath, "background" + "#" + HeaderText + backgroundExtension), FileMode.Create); BitmapEncoder encoder = new GifBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(BackgroundPicture)); encoder.Save(stream); stream.Dispose(); break; } } var json = JsonConvert.SerializeObject(QuestionsAnswers.ToArray()); File.WriteAllText(Path.Combine(savePath, "questions.json"), json); initializeApplication(); } }
// Function to get the question with answers public void getNewQuestion(bool gotRight) { // get random answer for this test if its the start or the player got the answer right if (gotRight) { if (GameManager.instance.isTutorial) { nextForTutorial = true; } // remove the question so the player will not get the same one, only when playing if (!GameManager.instance.isPractice) { switch (currentDifficulty) { case DifficultyType.EASY: easyQuestions.Remove(currQuestion); break; case DifficultyType.MEDIUM: mediumQuestions.Remove(currQuestion); break; case DifficultyType.HARD: hardQuestions.Remove(currQuestion); break; } } // get another difficulty currentDifficulty = questions.Dequeue(); currentRightAnswer = GameManager.instance.totalAnsweredQuestion; } // find randomizer based on queue int randomQuestionIdx; QuestionsAnswers question; switch (currentDifficulty) { case DifficultyType.EASY: randomQuestionIdx = Random.Range(0, easyQuestions.Count); question = easyQuestions[randomQuestionIdx]; break; case DifficultyType.MEDIUM: randomQuestionIdx = Random.Range(0, mediumQuestions.Count); question = mediumQuestions[randomQuestionIdx]; break; case DifficultyType.HARD: randomQuestionIdx = Random.Range(0, hardQuestions.Count); question = hardQuestions[randomQuestionIdx]; break; default: randomQuestionIdx = Random.Range(0, easyQuestions.Count); question = easyQuestions[randomQuestionIdx]; break; } if (gotRight) { // put back at the queue questions.Enqueue(currentDifficulty); } currQuestion = question; questionUI.text = question.getQuestion(); // put Audio clip to the question if there is one or clear the audio clip if doesn't AudioSource audioSrc = questionUI.gameObject.GetComponent <AudioSource>(); audioSrc.clip = question.getAudio(); for (int i = 0; i < question.getAnswerCount(); i++) { possibleAnswersText[i].text = question.getAnswerAtIndex(i).answer; } disableOrEnabledAnswers(true); GameManager.instance.isNewQuestion = true; kotoTower.StartCoroutine(kotoTower.openKotoTower()); }