protected void sortAnswerRadioButton_OnCheckedChanged(object sender, EventArgs e) { var radioButton = (RadioButton)sender; AnswersSortValue.Value = radioButton.Text.ToLower(); AnswersList.DataBind(); }
protected void AnswerSubmitButton_OnClick(object sender, EventArgs e) { var logginedUser = HttpContext.Current.User.Identity; if (logginedUser.IsAuthenticated) // only logedin users can answer to question { int questionId; if (int.TryParse(Request.QueryString["QuestionID"], out questionId) && questionId > 0) { using (var control = new AnswerController()) { control.AnswerToQuestion(questionId, AnswerBodyTextBox.Text); } AnswerBodyTextBox.Text = ""; QuestionDetailFormView.DataBind(); AnswersList.DataBind(); } else { ErrorMessage.InnerText = "Please try again later"; ErrorDiv.Visible = true; } } else { var currentUrl = HttpUtility.UrlEncode(Request.Url.PathAndQuery); Response.Redirect($"~/Login.aspx?ReturnUrl={currentUrl}"); } }
protected void AcceptAnswer_OnClick(object sender, EventArgs e) { var linkButton = (LinkButton)sender; var answerId = int.Parse(linkButton.CommandArgument); using (var control = new AnswerController()) { control.SetAcceptedAnswer(answerId); } AnswersList.DataBind(); }
private void Page_Load(object sender, EventArgs e) { Submit.Text = Translate.Text("submit"); ThankYouLiteral.Text = Translate.Text("thankyouLiteral"); poll = new Poll(DataSourceItem); if (!IsPostBack) { AnswersList.DataSource = poll.PossibleAnswers; //AnswersList.SelectedValue = null; AnswersList.DataBind(); } }
private DifficultyData QuestionsMissing(string difficulty) { // hardoreasy difficultyData = new DifficultyData(); difficultyData.questions = questionsList; difficultyData.isHard = true; // question questionsList[0] = new QuestionsList(); questionsList[0].answers = answersList; questionsList[0].question = "There are no " + difficulty + " questions"; // answer answersList[0] = new AnswersList(); answersList[0].answer = "Click"; answersList[0].isTrue = true; // return return(difficultyData); }
public void FillQuestionnaire() { Console.WriteLine("Write your nickname:"); string userName = Console.ReadLine(); Answer answer = new Answer(userName, MainQuestionnaire); AnswersList.Add(answer); int id = 0; foreach (var question in MainQuestionnaire.QuestionsList) { Console.WriteLine(); bool boolAnswer = AskQuestion(question); answer.AddUsersAnswer(id, boolAnswer); id++; } }
protected void AnswerVote_OnClick(object sender, EventArgs e) { string username; var logginedUser = HttpContext.Current.User.Identity; var vote = (LinkButton)sender; var answerId = int.Parse(vote.CommandArgument); using (var control = new AnswerController()) { username = control.GetAnswerAutherEmail(answerId); } if (logginedUser.IsAuthenticated) // only logedin users can vote to answers { if (logginedUser.Name != username) // nobody can't vote his/her answer { using (var control = new AnswerController()) { control.ManageVote( vote.ID.ToLower().Contains("up") ? AnswerController.VoteType.Up : AnswerController.VoteType.Down, answerId); } } else { ErrorMessage.InnerText = "You can not vote yourself."; ErrorDiv.Visible = true; } AnswersList.DataBind(); } else { var currentUrl = HttpUtility.UrlEncode(Request.Url.PathAndQuery); Response.Redirect($"~/Login.aspx?ReturnUrl={currentUrl}"); } }
protected void AnswerSubmitCommentButton_OnClick(object sender, EventArgs e) { var logginedUser = HttpContext.Current.User.Identity; if (logginedUser.IsAuthenticated) // only logedin users can comment on answers { var submitButton = (Button)sender; var answerId = int.Parse(submitButton.CommandArgument); var commentTextBox = (TextBox)submitButton.Parent.FindControl("AnswerCommentBody"); using (var control = new AnswerController()) { control.AddComment(answerId, commentTextBox.Text); } AnswersList.DataBind(); } else { var currentUrl = HttpUtility.UrlEncode(Request.Url.PathAndQuery); Response.Redirect($"~/Login.aspx?ReturnUrl={currentUrl}"); } }
public void AddTestData() { Answer answer = new Answer("Pepe", MainQuestionnaire); answer.AddUsersAnswer(0, true); answer.AddUsersAnswer(1, true); answer.AddUsersAnswer(2, true); answer.AddUsersAnswer(3, true); AnswersList.Add(answer); answer = new Answer("KekW", MainQuestionnaire); answer.AddUsersAnswer(0, false); answer.AddUsersAnswer(1, true); answer.AddUsersAnswer(2, false); answer.AddUsersAnswer(3, false); AnswersList.Add(answer); answer = new Answer("4Head", MainQuestionnaire); answer.AddUsersAnswer(0, false); answer.AddUsersAnswer(1, true); answer.AddUsersAnswer(2, true); answer.AddUsersAnswer(3, true); AnswersList.Add(answer); }
protected void AnswersList_OnPagePropertiesChanging(object sender, PagePropertiesChangingEventArgs e) { //set current page startindex, max rows and rebind to false AnswersDataPager.SetPageProperties(e.StartRowIndex, e.MaximumRows, false); AnswersList.DataBind(); }
private void FillEasyAnswers(int numberAnswers, AnswersList[] answers, int i, int j) { int index; List <int> randSelect; switch (numberAnswers) { case 1: // Create instance answers[0] = new AnswersList(); // Assign answers answers[0].answer = questionList[i].docs[j].answer; break; case 2: // Create list for random select randSelect = new List <int>() { 0, 1 }; index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].answer; answers[randSelect[index]].isTrue = true; randSelect.RemoveAt(index); index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].wrong1; answers[randSelect[index]].isTrue = false; randSelect.RemoveAt(index); break; case 3: // Create list for random select randSelect = new List <int>() { 0, 1, 2 }; index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].answer; answers[randSelect[index]].isTrue = true; randSelect.RemoveAt(index); index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].wrong1; answers[randSelect[index]].isTrue = false; randSelect.RemoveAt(index); index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].wrong2; answers[randSelect[index]].isTrue = false; randSelect.RemoveAt(index); break; case 4: // Create list for random select randSelect = new List <int>() { 0, 1, 2, 3 }; index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].answer; answers[randSelect[index]].isTrue = true; randSelect.RemoveAt(index); index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].wrong1; answers[randSelect[index]].isTrue = false; randSelect.RemoveAt(index); index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].wrong2; answers[randSelect[index]].isTrue = false; randSelect.RemoveAt(index); index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].wrong3; answers[randSelect[index]].isTrue = false; randSelect.RemoveAt(index); break; case 5: // Create list for random select randSelect = new List <int>() { 0, 1, 2, 3, 4 }; index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].answer; answers[randSelect[index]].isTrue = true; randSelect.RemoveAt(index); index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].wrong1; answers[randSelect[index]].isTrue = false; randSelect.RemoveAt(index); index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].wrong2; answers[randSelect[index]].isTrue = false; randSelect.RemoveAt(index); index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].wrong3; answers[randSelect[index]].isTrue = false; randSelect.RemoveAt(index); index = Random.Range(0, randSelect.Count); answers[randSelect[index]] = new AnswersList(); answers[randSelect[index]].answer = questionList[i].docs[j].wrong4; answers[randSelect[index]].isTrue = false; randSelect.RemoveAt(index); break; } }
public void Add <T>(T model) { var theType = model.GetType().Name; switch (theType) { case "User": UsersList.Add(model as User); return; case "News": NewsesList.Add(model as Dal.Models.News); return; case "Category": CategoriesList.Add(model as Category); return; case "Magazine": MagazinesList.Add(model as Magazine); return; case "SmartLink": SmartLinksList.Add(model as SmartLink); return; case "Comment": CommentsList.Add(model as Comment); return; case "Visit": VisitsList.Add(model as Visit); return; case "NewsLetter": NewsLettersList.Add(model as NewsLetter); return; case "Slider": SlidersList.Add(model as Slider); return; case "Slide": SlidesList.Add(model as Slide); return; case "UserMagazine": UserMagazinesList.Add(model as UserMagazine); return; case "State": StatesList.Add(model as State); return; case "City": CitiesList.Add(model as City); return; case "Media": MediasList.Add(model as Media); return; case "Report": ReportsList.Add(model as Report); return; case "Vote": VotesList.Add(model as Vote); return; case "Advertise": AdvertisesList.Add(model as Advertise); return; case "AdCategory": AdCategoriesList.Add(model as AdCategory); return; case "Galery": GaleriesList.Add(model as Galery); return; case "GaleryImage": GaleryImagesList.Add(model as GaleryImage); return; case "Image": ImagesList.Add(model as Image); return; case "KeyPoint": KeyPointsList.Add(model as KeyPoint); return; case "KeyPointsContainer": KeyPointsContainersList.Add(model as KeyPointsContainer); return; case "Quiz": QuizesList.Add(model as Quiz); return; case "Question": QuestionsList.Add(model as Question); return; case "Answer": AnswersList.Add(model as Answer); return; case "Option": OptionList.Add(model as Option); return; case "ItemList": ItemsListList.Add(model as ItemList); return; default: throw new Exception("The type " + theType + " is not supported."); } }