private void loadAnswers() { con = SqlHelper.getInstance(); con.Open(); cmd = new SqlCommand("select answer_id,answer_desc,user_name from Answers, Users where Answers.user_id = Users.user_id and post_id=" + post_id, con); ListAnswers.DataSource = cmd.ExecuteReader(); ListAnswers.DataBind(); }
/// <summary> /// Get GradeAnswer function /// </summary> public void GetPoint() { foreach (var candidate in ListCandidates) { MaxPoint += candidate.Point; } if (MaxPoint > 10) { MaxPoint = Math.Floor(MaxPoint); } else { MaxPoint = Math.Ceiling(MaxPoint); } // Count number of candidate var numberOfQuestion = ListCandidates.Count; // Wrong PaperNo if (numberOfQuestion == 0) { Logs[0] = "Wrong Paper No\n"; for (var i = 0; i < Constant.PaperSet.QuestionSet.QuestionList.Count; i++) { Points[i] = 0; } return; } // Get mark one by one for (var questionOrder = 0; questionOrder < ListCandidates.Count; questionOrder++) { try { if (numberOfQuestion > questionOrder) { var res = GradeAnswer(ListCandidates.ElementAt(questionOrder), ListAnswers.ElementAt(questionOrder), questionOrder); //Exactly -> Log true and return 0 point if (res != null) { Points[questionOrder] = Math.Round(double.Parse(res["Point"]), 4); Logs[questionOrder] = res["Comment"]; } else { Points[questionOrder] = 0; Logs[questionOrder] = "False\n"; } } else { // Not enough candidate // It rarely happens, it's this project's demos and faults. throw new Exception("No questions found at question " + questionOrder + " paperNo = " + PaperNo + "\n"); } } catch (Exception e) { // When something's wrong: // Log error and return 0 point for student. Points[questionOrder] = 0; Logs[questionOrder] = e.Message + "\n"; } } }