public frmReport() { InitializeComponent(); db = new Examv2Context(); procs = new Examv2ContextProcedures(db); FormClosing += (sender, e) => db.Dispose(); }
public frmInsertQuestions() { InitializeComponent(); FormClosing += (sender, e) => db.Dispose(); db = new Examv2Context(); procs = new Examv2ContextProcedures(db); qtype.SelectedIndexChanged += Qtype_SelectedIndexChanged; }
private async void StudentHome_Load(object sender, EventArgs e) { var procs = new Examv2ContextProcedures(db); BindingSource CourseBS = new BindingSource(); var flag = new OutputParameter <bool?>(); var result = await procs.selectStudentCourseAsync(LoginStudent.StudentId, flag); CourseBS.DataSource = result.ToList(); foreach (var item in result) { Trace.WriteLine(item.name); } comboxCourses.DataSource = CourseBS; comboxCourses.DisplayMember = "name"; comboxCourses.ValueMember = "courseID"; }
private async void button2_Click(object sender, EventArgs e) { var procs = new Examv2ContextProcedures(db); var flag = new OutputParameter <bool?>(); int cid = (int)crname.SelectedValue; int mcq = int.Parse(txtNumOFMcq.Text); int tf = int.Parse(txtNumOfTF.Text); if ((mcq + tf) == 10) { var result = await procs.SetNQuestionsAsync(LoginInstructor.InsId, cid, int.Parse(txtNumOFMcq.Text), int.Parse(txtNumOfTF.Text), flag); } else { MessageBox.Show("total num of Questions must be 10"); }//int numOfMcq = txtNumOFMcq.Text; //int numOfTF = txtNumOfTF.Text; //then go to db to generate }
private async void timer1_Tick(object sender, EventArgs e) { this.Text = "your timer " + _ticks.ToString(); if (_ticks < 1000) { _ticks++; } else { timer1.Stop(); var procs = new Examv2ContextProcedures(db); var ExamAnswers = await procs.ExamAnswersAsync(userAnswers, ExamIdP, student.StudentId, qsId); var ExamCorrection = await procs.ExamCorrectionAsync(ExamIdP); studentHome = new StudentHome(student); studentHome.Show(); this.Hide(); } }
private async void frmStartExam_Load(object sender, EventArgs e) { var procs = new Examv2ContextProcedures(db); var flag = new OutputParameter <bool?>(); var ExamId = new OutputParameter <int?>(); var result = await procs.GenerateExamAsync(CourseID, student.StudentId, flag, ExamId); ExamIdP = (int)ExamId.Value; var QuestionsInExam = db.StudentAnswers.Where(e => e.ExamId == ExamId.Value).ToList(); var Questions = db.Question.ToList(); var QNames = Questions.Join(QuestionsInExam, q => q.QuestionId, qn => qn.QuestionId, (q, qn) => new { qn.QuestionId, q.Body, q.Type } ).ToList(); questionsList = new List <QuestionsAnswersMapping>(); for (int i = 0; i < QuestionsInExam?.Count(); i++) { var QuestionAnswers = await procs.ChoiceSelectAsync(QuestionsInExam[i].QuestionId, flag); var c = QuestionAnswers.ToList(); QuestionsAnswersMapping qq = new QuestionsAnswersMapping() { Body = QNames[i].Body, Choice = c, Type = QNames[i].Type, QuestionId = QNames[i].QuestionId, CourseId = CourseID }; questionsList.Add(qq); } ExamQuestion = new BindingSource(questionsList, ""); // ExamQuestionAnswers = new BindingSource(questionsList[0].Choice.ToList(),""); lblQuestionBody.DataBindings.Add("Text", ExamQuestion, "Body"); // for(int x = 0; x < questionsList?.Count; x++) { if (questionsList[ExamQuestion.Position].Type == 1) { rdioanswer1.Text = questionsList[ExamQuestion.Position].Choice[0].choiceBody; rdioanswer1.Checked = true; rdioanswer2.Text = questionsList[ExamQuestion.Position].Choice[1].choiceBody; rdioanswer3.Show(); rdioanswer4.Show(); rdioanswer3.Text = questionsList[ExamQuestion.Position].Choice[2].choiceBody; rdioanswer4.Text = questionsList[ExamQuestion.Position].Choice[3].choiceBody; //rdioanswer1.DataBindings.Add("Text", questionsList[ExamQuestion.Position].Choice[0], "choiceBody"); //rdioanswer2.DataBindings.Add("Text", questionsList[ExamQuestion.Position].Choice[1], "choiceBody"); //rdioanswer3.DataBindings.Add("Text", questionsList[ExamQuestion.Position].Choice[2], "choiceBody"); //rdioanswer4.DataBindings.Add("Text", questionsList[ExamQuestion.Position].Choice[3], "choiceBody"); this.Controls.Add(Navigator); } else if (questionsList[ExamQuestion.Position].Type == 0) { rdioanswer1.Text = "True"; rdioanswer2.Text = "False"; rdioanswer3.Hide(); rdioanswer4.Hide(); this.Controls.Add(Navigator); } }