protected void gridViewQuestions_SelectedIndexChanged(object sender, EventArgs e) { lblDeleteQuestionId.Text = gridViewQuestions.SelectedRow.Cells[1].Text; ClassQuestions LoadData = new ClassQuestions(); LoadData.LoadQuestionsToViewOrUpdate(this); }
protected void gridViewQuestions_PageIndexChanging(object sender, GridViewPageEventArgs e) { ClassQuestions loadQuestions = new ClassQuestions(); loadQuestions.SearchQuestion(ddQuestionSearch, txQuestionSearch, gridViewQuestions, ddModules); gridViewQuestions.PageIndex = e.NewPageIndex; gridViewQuestions.DataBind(); }
protected void btnDeleteQuestion_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(lblDeleteQuestionId.Text)) { ClassQuestions deleteQuestion = new ClassQuestions(); deleteQuestion.DeleteQuestions(lblDeleteQuestionId); string messageString = lblDeleteQuestionId.Text + " has successfully deleted."; ClientScript.RegisterStartupScript(this.GetType(), "Successful", "alert('" + messageString + "'); window.location='Questions.aspx';", true); } }
protected void btnUpdateQuestionSubmit_Click(object sender, EventArgs e) { Label lblUpdatedBy = this.Master.FindControl("lblLoggedInUser") as Label; ClassQuestions updateQuestion = new ClassQuestions(); updateQuestion.UpdateQuestion(this, lblUpdatedBy); string messageString = txUpdateQuestionId.Text + " has successfully updated."; ClientScript.RegisterStartupScript(this.GetType(), "Successful", "alert('" + messageString + "'); window.location='Questions.aspx';", true); }
protected void ddModules_SelectedIndexChanged(object sender, EventArgs e) { if (ddModules.SelectedIndex == 0) { txAddModuleId.Text = ""; } else { txAddModuleId.Text = ddModules.SelectedValue; } ClassQuestions loadQuestions = new ClassQuestions(); loadQuestions.LoadQuestionsList(ddModules, gridViewQuestions); }
public void change_Questions() { Button[] btn = { btnA, btnB, btnC, btnD }; foreach (var i in btn) { i.BackColor = Color.LemonChiffon; } //string[] aq = new string[4]; int count = questions.Count; int index = rand.Next(questions.Count); // ClassQuestions d = d.Answer; // if() //wrightWrong(); if (count > 0) {//settinu up random values of Questions int getIndex = index; q = questions.ElementAt(getIndex); //setting up random values of Options //filling up Options // ClassQuestions cQ = proxy.getQuestion(q); List <string> opt = proxy.getOptions(q); string quetions = cQ.Question; txtQuestions.Text = quetions; btnA.Text = opt.ElementAt(0); btnB.Text = opt.ElementAt(1); btnC.Text = opt.ElementAt(2); btnD.Text = opt.ElementAt(3); questions.RemoveAt(getIndex); } else { MessageBox.Show("Game Completed", "Congrats", MessageBoxButtons.OK); this.Hide(); var score = new Scores(); score.Closed += (s, args) => this.Close(); score.Show(); } }
private void LoadTestClass() { string xmlfil = Server.MapPath("test.xml"); XmlDocument doc = new XmlDocument(); doc.Load(xmlfil); testlista = new List<ClassQuestions>(); XmlNodeList xmlLista = doc.SelectNodes("/test/testquestion"); try { foreach (XmlNode nod in xmlLista) { ClassQuestions test = new ClassQuestions (nod.Attributes["id"].Value, nod["nr"].InnerText, nod["amountofanswers"].InnerText, nod["question"].InnerText, nod["group"].InnerText, (nod["amountofrightanswers"].InnerText) ); ClassAnswers answer = new ClassAnswers(); ClassRightAnswer rightanswer = new ClassRightAnswer(); test.Id = nod.Attributes["id"].Value; test.Nr = nod["nr"].Value; test.Group = nod["group"].InnerText; test.Question = nod["question"].InnerText; test.AmountOfAnswers = nod["amountofanswers"].Value; test.Group = nod["group"].InnerText; test.AmountOfRightAnswers = nod["amountofrightanswers"].Value; if (test.AmountOfAnswers == "1") { answer.Answer1 = nod["answer1"].InnerText; } else if (test.AmountOfAnswers == "2") { answer.Answer1 = nod["answer1"].InnerText; answer.Answer2 = nod["answer2"].InnerText; } else if (test.AmountOfAnswers == "3") { answer.Answer1 = nod["answer1"].InnerText; answer.Answer2 = nod["answer2"].InnerText; answer.Answer3 = nod["answer3"].InnerText; } else if (test.AmountOfAnswers == "4") { answer.Answer1 = nod["answer1"].InnerText; answer.Answer2 = nod["answer2"].InnerText; answer.Answer3 = nod["answer3"].InnerText; answer.Answer4 = nod["answer4"].InnerText; } else { return; } if (test.AmountOfRightAnswers == "1") { rightanswer.Rightanswer1 = nod["rightanswer1"].InnerText; } else if (test.AmountOfRightAnswers == "2") { rightanswer.Rightanswer1 = nod["rightanswer1"].InnerText; rightanswer.Rightanswer2 = nod["rightanswer2"].InnerText; } else { return; //Response.Write("Felmeddelande: Här gick något fel vid hämtade av rätt svar, kontakta din IT support!"); } testlista.Add(test); test.answerlist.Add(answer); test.rightanswerlist.Add(rightanswer); } //Repeater1.DataSource = testlista; //Repeater1.DataBind(); } catch (Exception e) { Response.Write("e"); } }
protected void btnQuestionSearch_Click(object sender, EventArgs e) { ClassQuestions searchQuestion = new ClassQuestions(); searchQuestion.SearchQuestion(ddQuestionSearch, txQuestionSearch, gridViewQuestions, ddModules); }
protected void Page_Load(object sender, EventArgs e) { ClassQuestions generateId = new ClassQuestions(); txAddQuestionId.Text = generateId.GenerateQuestionId(); }