/// <summary> /// sets the question gap list /// </summary> public void SetQuestionGapList() { QuestionGapList = new List <QuestionGap>(); QuestionLabel.Wait(3); QuestionGapWebElementList = QuestionGapsDropdowns.WaitForElements(5); if (Driver.WrappedDriver.GetType() == typeof(DummyDriver)) { List <IWebElement> list = new List <IWebElement>(); DummyWebElement dummy1 = new DummyWebElement(); DummyWebElement dummy2 = new DummyWebElement(); DummyWebElement dummy3 = new DummyWebElement(); dummy1.FakeAttributeClass = "This morning, I went to the "; dummy2.FakeAttributeClass = "and bought some milk and eggs. I knew it was going to rain, but I forgot my "; dummy3.FakeAttributeClass = "and ended up getting "; list = new List <IWebElement> { dummy1, dummy2, dummy3 }; QuestionGapWebElementList = new ReadOnlyCollection <IWebElement>(list); } int index = 0; foreach (var webElement in QuestionGapWebElementList) { Report.Write("QuestionGap index: '" + index); var answerLineItem = new QuestionGap(index); QuestionGapList.Add(answerLineItem); index++; } }
public void StartAnimation() { LayoutIfNeeded(); Animate(1.5, () => { _rootView.RemoveConstraint(_rootView.Constraints.ElementAt(19)); this.AddConstraints(RegisterButton.AtBottomOf(this, 50f), QuestionLabel.Above(RegisterButton, 25f)); LayoutIfNeeded(); }); }
public async Task <bool> AddLabelAsync(QuestionLabel label) { label.ID = Guid.NewGuid().ToString(); await db.QuestionLabels.AddAsync(label); var result = await db.SaveChangesAsync(); if (result > 0) { return(true); } else { return(false); } }
public async Task <bool> Insert(LabelDTO newLabel) { if (newLabel != null) { QuestionLabel labelToAdd = new QuestionLabel() { LabelText = newLabel.LabelText, Question = await questionRepository.GetAsync(newLabel.QuestionID) }; return(await questionRepository.AddLabelAsync(labelToAdd)); } else { return(false); } }
public void Animate() { Device.BeginInvokeOnMainThread(async() => { QuestionLabel.Scale = 0; OptionAFrame.Scale = 0; OptionBFrame.Scale = 0; OptionCFrame.Scale = 0; OptionDFrame.Scale = 0; await QuestionLabel.ScaleTo(1, 160); await OptionAFrame.ScaleTo(1, 160); await OptionBFrame.ScaleTo(1, 160); await OptionCFrame.ScaleTo(1, 160); await OptionDFrame.ScaleTo(1, 160); }); }
void ReleaseDesignerOutlets() { if (AnswerSlider != null) { AnswerSlider.Dispose(); AnswerSlider = null; } if (MaxLabel != null) { MaxLabel.Dispose(); MaxLabel = null; } if (MinLabel != null) { MinLabel.Dispose(); MinLabel = null; } if (ProgressView != null) { ProgressView.Dispose(); ProgressView = null; } if (QuestionLabel != null) { QuestionLabel.Dispose(); QuestionLabel = null; } if (SliderProgressView != null) { SliderProgressView.Dispose(); SliderProgressView = null; } }
void ShowingUp() { TextBox.Hide(); QuestionIndex.Hide(); TypesOfAnswers.Hide(); AnswerTypeLabel.Hide(); AnswersLabel.Hide(); SelectionOfAnswers.Hide(); AnswerTextBoxLabel.Hide(); AnswerTextBox.Hide(); CorrectAnswerChecker.Hide(); ExampleButton1.Hide(); ExampleButton2.Hide(); TextBox.ReadOnly = false; if (ModeSelection.SelectedItem != null && FunctionSelection.SelectedItem != null) { QuestionLabel.Show(); if (mode == 0) { TextBox.Show(); if (function == 1) { TextBox.ReadOnly = true; } else { TypesOfAnswers.Show(); AnswerTypeLabel.Show(); ExampleButton1.Show(); ExampleButton2.Show(); } if (function > 0) { QuestionIndex.Show(); } } else if (mode == 1) { TextBox.Show(); TextBox.ReadOnly = true; AnswersLabel.Show(); SelectionOfAnswers.Show(); QuestionIndex.Show(); if (QuestionIndex.Value >= Questions.Count) { QuestionIndex.Value = 0; } else { TextBox.Text = Questions[(int)QuestionIndex.Value].Text; } if (function == 0 || function == 2) { AnswerTextBoxLabel.Show(); AnswerTextBox.Show(); CorrectAnswerChecker.Show(); } else { TextBox.ReadOnly = false; } } } }
void ReleaseDesignerOutlets() { if (AnswerButton1 != null) { AnswerButton1.Dispose(); AnswerButton1 = null; } if (AnswerButton2 != null) { AnswerButton2.Dispose(); AnswerButton2 = null; } if (AnswerButton3 != null) { AnswerButton3.Dispose(); AnswerButton3 = null; } if (AnswerButton4 != null) { AnswerButton4.Dispose(); AnswerButton4 = null; } if (congratulationsLabel != null) { congratulationsLabel.Dispose(); congratulationsLabel = null; } if (displayHighScoreLabel != null) { displayHighScoreLabel.Dispose(); displayHighScoreLabel = null; } if (finalScoreLabel != null) { finalScoreLabel.Dispose(); finalScoreLabel = null; } if (highScoreLabel != null) { highScoreLabel.Dispose(); highScoreLabel = null; } if (QuestionLabel != null) { QuestionLabel.Dispose(); QuestionLabel = null; } if (questionNumberLabel != null) { questionNumberLabel.Dispose(); questionNumberLabel = null; } if (QuestionNumberLabel2 != null) { QuestionNumberLabel2.Dispose(); QuestionNumberLabel2 = null; } if (QuestionTimerProgressBar != null) { QuestionTimerProgressBar.Dispose(); QuestionTimerProgressBar = null; } if (returnHomeButton != null) { returnHomeButton.Dispose(); returnHomeButton = null; } if (yourScoreLabel != null) { yourScoreLabel.Dispose(); yourScoreLabel = null; } }
public async Task <IActionResult> Create(List <IFormFile> files, string studio, string studio2, string studio3, string question_tags, [Bind("IsArchived,Id,Title,Description,IdUser,Date")] Question question) { User actualUser = null; if (!string.IsNullOrEmpty(HttpContext.Session.GetString(UsersController.ACTIVE_USERNAME))) { actualUser = model.GetUser(HttpContext.Session.GetString(UsersController.ACTIVE_USERNAME)); question.UserId = actualUser.ID; } if (ModelState.IsValid) { _context.Add(question); if (!string.IsNullOrEmpty(studio)) { var st = await _context.Studio.FirstOrDefaultAsync(m => m.Name == studio); if (!string.IsNullOrEmpty(question_tags)) { string[] tagsStr = question_tags.Split(","); foreach (string t in tagsStr) { var tag = await _context.Label.FirstOrDefaultAsync(m => m.Tag == t); if (tag == null) { tag = new Label(); tag.Tag = t; _context.Add(tag); } tag.NumberOfTimes++; var questionLabel = new QuestionLabel { LabelId = tag.Id, QuestionId = question.Id }; _context.Add(questionLabel); } } var st1 = await _context.Studio.FirstOrDefaultAsync(m => m.Name == studio); var questionStudio = new QuestionStudio { StudioId = st1.Id, QuestionId = question.Id }; _context.Add(questionStudio); if (studio2 != studio) { var st2 = await _context.Studio.FirstOrDefaultAsync(m => m.Name == studio2); var questionStudio2 = new QuestionStudio { StudioId = st2.Id, QuestionId = question.Id }; _context.Add(questionStudio2); } if (studio3 != studio && studio3 != studio2) { var st3 = await _context.Studio.FirstOrDefaultAsync(m => m.Name == studio3); var questionStudio3 = new QuestionStudio { StudioId = st3.Id, QuestionId = question.Id }; _context.Add(questionStudio3); } await _context.SaveChangesAsync(); var filePath = Path.Combine(_hostingEnvironment.WebRootPath, "uploads", question.Id + ""); if (Directory.Exists(filePath)) { Directory.Delete(filePath, true); } Directory.CreateDirectory(filePath); foreach (var formFile in files) { filePath = Path.Combine(_hostingEnvironment.WebRootPath, "uploads", question.Id + "", Path.GetFileName(formFile.FileName)); if (formFile.Length > 0) { using (var stream = new FileStream(filePath, FileMode.Create)) { await formFile.CopyToAsync(stream); } } } SendEmailStudio(question, st); } return(RedirectToAction(nameof(Index))); } return(View(question)); }
public async Task <IActionResult> Create(string action, List <IFormFile> files, string studio, string studio2, string studio3, string question_tags, [Bind("IsArchived,Id,Title,Description,IdUser,Date,question_tags")] Question question) { string user = SetActiveUser(); if (action == "Suggestions") { Suggestion(question.Title, question.Description); String[] q = { question.Title, question.Description }; TempData["question"] = q; } else if (action == "Ask now") { List <Studio> studios = new List <Studio>(); User actualUser = null; if (!string.IsNullOrEmpty(user)) { actualUser = model.GetUser(user); actualUser.QUESTIONS_ASKED++; question.UserId = actualUser.ID; } else { return(RedirectToAction("Index", "Users", new { message = "Inicie sesión" })); } if (ModelState.IsValid) { _context.Add(question); if (!string.IsNullOrEmpty(studio)) { //var st = await _context.Studio.FirstOrDefaultAsync(m => m.Name == studio); if (!string.IsNullOrEmpty(question_tags)) { string[] tagsStr = question_tags.Split(","); foreach (string t in tagsStr) { var tag = await _context.Label.FirstOrDefaultAsync(m => m.Tag == t); if (tag == null) { tag = new Label(); tag.Tag = t; _context.Add(tag); } tag.NumberOfTimes++; var questionLabel = new QuestionLabel { LabelId = tag.Id, QuestionId = question.Id }; _context.Add(questionLabel); } } var st1 = await _context.Studio.FirstOrDefaultAsync(m => m.Name == studio); var questionStudio = new QuestionStudio { StudioId = st1.Id, QuestionId = question.Id }; studios.Add(st1); _context.Add(questionStudio); if (studio2 != studio) { var st2 = await _context.Studio.FirstOrDefaultAsync(m => m.Name == studio2); var questionStudio2 = new QuestionStudio { StudioId = st2.Id, QuestionId = question.Id }; studios.Add(st2); _context.Add(questionStudio2); } if (studio3 != studio && studio3 != studio2) { var st3 = await _context.Studio.FirstOrDefaultAsync(m => m.Name == studio3); var questionStudio3 = new QuestionStudio { StudioId = st3.Id, QuestionId = question.Id }; studios.Add(st3); _context.Add(questionStudio3); } await _context.SaveChangesAsync(); var filePath = Path.Combine(_hostingEnvironment.WebRootPath, "uploads", question.Id + ""); if (Directory.Exists(filePath)) { Directory.Delete(filePath, true); } Directory.CreateDirectory(filePath); foreach (var formFile in files) { filePath = Path.Combine(_hostingEnvironment.WebRootPath, "uploads", question.Id + "", Path.GetFileName(formFile.FileName)); if (formFile.Length > 0) { using (var stream = new FileStream(filePath, FileMode.Create)) { await formFile.CopyToAsync(stream); } } } SendEmailStudio(question, studios); } return(RedirectToAction(nameof(Index))); } } return(RedirectToAction(nameof(Create))); }