public void TestInit() { surveydb = Database.GetConnection(); surveyDal = new SurveyDAL(); userDAL = new UserDAL(); questionDAL = new QuestionDAL(); user = new users(); user.User_name = userName; user.User_password = password; HelperDAL.AddUser(user); survey = new surveys(); survey.Name = surveyName; //survey.users = user; survey.User_name = userName; SurveyCode = HelperDAL.GenerateRandomSurveyCode(); survey.Survey_code = SurveyCode; HelperDAL.AddSurvey(survey); question = new questions(); question.Question_name = questionName; question.Surveys_id = survey.Id; question.Input_type_id = 1; this.questionDAL.AddQuestion(question); this.textAnswerDAL = new TextAnswerDAL(); this.textAnswer = new text_answers(); this.textAnswer.User_name = userName; this.textAnswer.Question_id = question.Id; this.textAnswer.Answer = TextAnswerText; }
/** * param name="int" * return : trả lại list question đã được random */ public static List <Question> getRandomListQ(int examID) { var questionDAL = new QuestionDAL(); var listTemp = questionDAL.getListQ(examID); return(listTemp); }
public string GetQuestionsAll() { List <Question> questions = new List <Question>(); questions = QuestionDAL.GetQuestionsAll(); return(JsonConvert.SerializeObject(questions)); }
public static void exportTest(Test t) { Test _test = TestDAL.GetTest(t.Id); List <Question> questions = new List <Question>(); questions = QuestionDAL.GetQuestions(t.Id); XmlTextWriter textWriter = new XmlTextWriter("test_" + _test.Id + ".xml", null); textWriter.WriteStartDocument(); textWriter.WriteStartElement("Test"); textWriter.WriteElementString("ID", _test.Id.ToString()); // <-- These are new textWriter.WriteElementString("Name", _test.Name); textWriter.WriteElementString("Type", _test.TestType); textWriter.WriteElementString("TimeLimit", _test.TimeLimit.ToString()); textWriter.WriteElementString("NumberOfQuestions", questions.Count.ToString()); textWriter.WriteStartElement("Questions"); foreach (Question q in questions) { textWriter.WriteStartElement("Question"); textWriter.WriteElementString("Ask", q.Quest); textWriter.WriteElementString("Get", q.Answer); textWriter.WriteEndElement(); } textWriter.WriteEndElement(); textWriter.WriteEndElement(); textWriter.WriteEndDocument(); textWriter.Close(); }
public void TestInit() { surveydb = Database.GetConnection(); surveyDal = new SurveyDAL(); userDAL = new UserDAL(); questionDAL = new QuestionDAL(); user = new users(); user.User_name = userName; user.User_password = password; HelperDAL.AddUser(user); survey = new surveys(); survey.Name = surveyName; //survey.users = user; survey.User_name = userName; SurveyCode = HelperDAL.GenerateRandomSurveyCode(); survey.Survey_code = SurveyCode; HelperDAL.AddSurvey(survey); question = new questions(); question.Question_name = questionName; question.Surveys_id = survey.Id; question.Input_type_id = 2; this.questionDAL.AddQuestion(question); this.optionChoicesDAL = new OptionChoicesDAL(); this.optionChoice = new option_choices(); this.optionChoice.Question_id = question.Id; this.optionChoice.Option_choices_name = OptionChoiceName; }
public void TestToXml(string id) { Test t = null; List <Question> questions = new List <Question>(); questions = QuestionDAL.GetQuestions(Int32.Parse(id)); t = TestDAL.GetTest(Int32.Parse(id)); if (t != null) { XmlTextWriter xw = new XmlTextWriter(@"" + Directory.GetCurrentDirectory() + "Test_" + id.ToString(), System.Text.Encoding.UTF8); xw.WriteStartDocument(); xw.WriteStartElement("Test"); xw.WriteElementString("TestID", t.Id.ToString()); xw.WriteElementString("Name", t.Name); xw.WriteElementString("Type", t.TestType); xw.WriteElementString("Timelimit", t.TimeLimit.ToString()); xw.WriteStartElement("Questions"); foreach (Question q in questions) { xw.WriteElementString("QuestionID", q.Id.ToString()); xw.WriteElementString("Question", q.Quest); xw.WriteElementString("Answer", q.Answer); } xw.WriteEndElement(); // end Test element xw.WriteEndElement(); } }
protected void btnDeleteQuestion_Click(object sender, EventArgs e) { QuestionDAL qDAL = new QuestionDAL(); qDAL.DeleteFromQuestions(ddlQuestion.SelectedValue); GetViewOfQuestion(); GetViewOfAnswers(); }
protected void GetViewOfQuestion() { ddlQuestion.Items.Clear(); QuestionDAL qDAL = new QuestionDAL(); foreach (QuestionABC question in qDAL.GetAllQuestionsBySubThemeName((string)ddlSubTheme.SelectedValue)) { ddlQuestion.Items.Add(question.QuestionCurrent); } }
protected void btnSinavOlustur_Click(object sender, EventArgs e) { int i = 0; Result result = new Result(); int ExID = 0; Entity.Question question = new Entity.Question(); QuestionDAL questionDal = new QuestionDAL(); foreach (var item in SagPanel.Controls) { if (i == 0)//sınav oluşturup onun ID'sini alcam ve başka bir tabloda sınavın sorularını tutcam. { string title = DropDownListBasliklar.SelectedItem.ToString(); result = exDal.addExam(title, LiteralDescription.Text); ExID = result.returnID; } if (item is TextBox) { TextBox txt = (TextBox)item; if (txt.ID.Substring(0, 4) == "txtS") { question.question = txt.Text; } if (txt.ID.Substring(0, 4) == "txtA") { question.optionA = txt.Text; } if (txt.ID.Substring(0, 4) == "txtB") { question.optionB = txt.Text; } if (txt.ID.Substring(0, 4) == "txtC") { question.optionC = txt.Text; } if (txt.ID.Substring(0, 4) == "txtD") { question.optionD = txt.Text; } } if (item is DropDownList) { question.ExamID = ExID; question.trueOption = ((DropDownList)item).SelectedValue; questionDal.AddQuestion(question); question = new Entity.Question(); } i++; } Response.Redirect("SinavOl.aspx?SinavID=" + ExID.ToString()); }
private void ViewExamBtn_Click(object sender, EventArgs e) { ComboboxItem item = (ComboboxItem)examsCombobox.SelectedItem; int exam_id = Int32.Parse(item.Value.ToString()); examquestions = ExamQuestionDAL.GetExamQuestions(exam_id); for (int i = 0; i < examquestions.Count; i++) { string name = QuestionDAL.GetQuestionTypeName(examquestions[i].Question.Type); dataGridView1.Rows.Add(name, examquestions[i].Question.QuestionText); } }
protected void btnAddQuestion_Click(object sender, EventArgs e) { if (txtbxQuestion.Text != "") { QuestionDAL qDAL = new QuestionDAL(); SubThemeDAL stDAL = new SubThemeDAL(); QuestionABC quest = new QuestionABC(0, txtbxQuestion.Text, stDAL.GetSubThemeIdBySubThemeNameViaStoredProc(ddlSubTheme.SelectedValue)); qDAL.InsertQuestionViaStoredProc(quest); txtbxQuestion.Text = ""; } GetViewOfQuestion(); GetViewOfAnswers(); }
public ExamGeneration() { InitializeComponent(); course = new Course(); adm = new Admin(); adm.Id = 1; exam = new Exam(false, adm); courses = CourseDAL.SelectAll(); for (int i = 0; i < courses.Count; i++) { ComboboxItem item = new ComboboxItem(); item.Text = courses[i].Name; item.Value = courses[i].Id; CourseNameComboBox.Items.Add(item); CourseNameComboBox.SelectedIndex = 0; } updateCourse(); exams = ExamDAL.getAll(adm); for (int i = 0; i < exams.Count; i++) { ComboboxItem item = new ComboboxItem(); item.Text = exams[i].Id.ToString(); item.Value = exams[i].Id; ExamsComboBox.Items.Add(item); ExamsComboBox.SelectedIndex = 0; } QuestionCollection col = QuestionDAL.GetByType(1); MCQnumLabel.Text = col.Count.ToString(); QuestionCollection col2 = QuestionDAL.GetByType(2); TFnumLabel.Text = col2.Count.ToString(); QuestionCollection col3 = QuestionDAL.GetByType(3); EssaynumLabel.Text = col3.Count.ToString(); updateExamSessions(); }
public bool insertQuestion(QuestionEntity question) { QuestionDAL questionDAL = new QuestionDAL(); return(questionDAL.insertQuestion(question)); }
public void SaveUserAnswer(int answerId, int useranswerId, int userId, string currentTime) { QuestionDAL topicDAL = new QuestionDAL(); topicDAL.SaveUserAnswer(answerId, useranswerId, userId, currentTime); }
//for GettblSubjectForDrp drp public List <QuestionEntities> GettblSubjectForDrp() { QuestionDAL topicDAL = new QuestionDAL(); return(topicDAL.GettblSubjectForDrp()); }
public void addQuestion(int testid, String question, String type, String answer) { QuestionDAL.AddQuestion(testid, question, type, answer); }
public void UpdateQuestion(int questionid, string questionstring, string answer) { QuestionDAL.UpdateQuestion(questionid, questionstring, answer); }
public void deleteQuestion(int questionid) { QuestionDAL.DeleteQuestion(questionid); }
private void AddQuestionBtn_Click(object sender, EventArgs e) { Question newQuestion = new Question(); int type = (int)QuestionType.SelectedValue; newQuestion.Type = type; switch (type) { case 1: if (!choiceA.Checked && !choiceB.Checked && !choiceC.Checked && !choiceD.Checked) { MessageBox.Show("Please choose the correct answer"); } else { QuestionAnswer answer1 = new QuestionAnswer(); QuestionAnswer answer2 = new QuestionAnswer(); QuestionAnswer answer3 = new QuestionAnswer(); QuestionAnswer answer4 = new QuestionAnswer(); answer1.Answer = choiceALabel.Text; answer2.Answer = choiceBLabel.Text; answer3.Answer = choiceCLabel.Text; answer4.Answer = choiceDLabel.Text; newQuestion.Answers = new List <QuestionAnswer>(); newQuestion.Answers.Add(answer1); newQuestion.Answers.Add(answer2); newQuestion.Answers.Add(answer3); newQuestion.Answers.Add(answer4); newQuestion.Modelanswer = new QuestionAnswer(); if (choiceA.Checked) { newQuestion.Modelanswer.Answer = choiceALabel.Text; } else if (choiceB.Checked) { newQuestion.Modelanswer.Answer = choiceBLabel.Text; } else if (choiceC.Checked) { newQuestion.Modelanswer.Answer = choiceCLabel.Text; } else { newQuestion.Modelanswer.Answer = choiceDLabel.Text; } } break; case 2: if (!checkTrue.Checked && !checkFalse.Checked) { MessageBox.Show("Please choose the correct answer"); } else { QuestionAnswer trueAnswer = new QuestionAnswer(); QuestionAnswer falseAnswer = new QuestionAnswer(); trueAnswer.Answer = checkTrueLabel.Text; falseAnswer.Answer = checkFalseLabel.Text; newQuestion.Answers = new List <QuestionAnswer>(); newQuestion.Answers.Add(trueAnswer); newQuestion.Answers.Add(falseAnswer); newQuestion.Modelanswer = new QuestionAnswer(); if (checkTrue.Checked) { newQuestion.Modelanswer.Answer = checkTrueLabel.Text; } else if (checkFalse.Checked) { newQuestion.Modelanswer.Answer = checkFalseLabel.Text; } } break; case 3: if (String.IsNullOrEmpty(questionAnswer.Text)) { MessageBox.Show("Please add the answer"); } else { QuestionAnswer essayAnswer = new QuestionAnswer(); essayAnswer.Answer = questionAnswer.Text; newQuestion.Answers = new List <QuestionAnswer>(); newQuestion.Modelanswer = new QuestionAnswer(); newQuestion.Answers.Add(essayAnswer); newQuestion.Modelanswer.Answer = ""; } break; } newQuestion.Course = new Course(); newQuestion.Course.Id = (int)QuestionCourse.SelectedValue; QuestionDAL.Add(newQuestion); }
public static List <Question> GetTestQuestion(int testId) { return(QuestionDAL.GetTestQuestion(testId)); }
public static void AddQuestion(Question question) { QuestionDAL.AddQuestion(question); }
public ExamPaper GetNextPrevQuestion(int pageIndex, int pageSize, int userId) { QuestionDAL questionDAL = new QuestionDAL(); return(questionDAL.GetNextPrevQuestion(pageIndex, pageSize, userId)); }
public List <QuestionEntity> GetQuestionsByExamID(int ExamID, int numpreguntas) { QuestionDAL questionDAL = new QuestionDAL(); return(questionDAL.GetQuestionsByExamID(ExamID, numpreguntas)); }
public List <QuestionEntity> GetquestionWithResponses(string course, string area, int questionnumber) { QuestionDAL questionDAL = new QuestionDAL(); return(questionDAL.GetquestionWithResponses(course, area, questionnumber)); }
public void updateQuestion(int questionid, String question, String answer) { QuestionDAL.UpdateQuestion(questionid, question, answer); }
public List <Question> getAllQuestions() { return(QuestionDAL.GetQuestions()); }
public QuestionEntity Getstudentquestions(string course, string area, string Description) { QuestionDAL questionDAL = new QuestionDAL(); return(questionDAL.Getstudentquestions(course, area, Description)); }
public ChoiceEntities GetAnswerByID(int ID) { QuestionDAL topicDAL = new QuestionDAL(); return(topicDAL.GetAnswerByID(ID)); }
public static List <Question> GetQuestions(int testid, int userId) { return(QuestionDAL.GetQuestions(testid, userId)); }
public void GetQuestionPaper(int questionCount, int userId) { QuestionDAL questionDAL = new QuestionDAL(); questionDAL.GetQuestionPaper(questionCount, userId); }