public IHttpActionResult PutAnswerDetail(int id, AnswerDetail AnswerDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != AnswerDetail.AnswerDetailID) { return(BadRequest()); } db.Entry(AnswerDetail).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!AnswerDetailExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public JsonResult Edit(int Id, AnswerDetail data) { if (data != null) { data.AnswerDetailID = Id; db.Entry(data).State = EntityState.Modified; db.SaveChanges(); return(Json(new { Message = "Đã sửa thành công!" }, JsonRequestBehavior.AllowGet)); } return(null); }
public ActionResult Delete(int id) { AnswerDetail entity = db.AnswerDetail.FirstOrDefault(a => a.AnswerID == id); if (entity != null) { db.AnswerDetail.Remove(entity); db.SaveChanges(); } return(Json(new { Message = "Đã xóa thành công!" }, JsonRequestBehavior.AllowGet)); }
public IHttpActionResult GetAnswerDetail(int id) { AnswerDetail AnswerDetail = db.AnswerDetail.Find(id); if (AnswerDetail == null) { return(NotFound()); } return(Ok(AnswerDetail)); }
public IHttpActionResult PostAnswerDetail(AnswerDetail AnswerDetail) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.AnswerDetail.Add(AnswerDetail); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = AnswerDetail.AnswerDetailID }, AnswerDetail)); }
public IHttpActionResult DeleteAnswerDetail(int id) { AnswerDetail AnswerDetail = db.AnswerDetail.Find(id); if (AnswerDetail == null) { return(NotFound()); } db.AnswerDetail.Remove(AnswerDetail); db.SaveChanges(); return(Ok(AnswerDetail)); }
protected void btnDeleteSection_Click(object sender, EventArgs e) { Sections sec = new Sections(); Question ques=new Question (); Assessment ass = new Assessment(); AnswerDetail ansDetail = new AnswerDetail(); CVTCMenu menu=new CVTCMenu (); QuestionResponse qr=new QuestionResponse (); int sectOID = Convert.ToInt32(Request.QueryString["soid"].ToString()); int AssOID = sec.GetAssessmentOIDBySectionOID(sectOID); if (ass.GetAssessmentStatusByOID(Convert.ToInt32(AssOID)) == 1) { LabelMessage.Text = "This group can not be deleted.It has been Locked"; return; } else { string menuURL = "pg/assessment/section.aspx?soid=" + sectOID + ""; //Delete from AnswerDetails and Question Table by SectionOID bool DeleteFromAnswerDetail=ansDetail.DeleteAnswerDetailBySectionOID(sectOID); Collection<Question> qList = new Collection<Question>(); qList = ques.GetQuestionOIDBySectionOID(sectOID); foreach (Question q in qList ) { qr.DeleteQuestionBySectionOID(q.QuestionOID); } bool DeleteFromQuestion = ques.DeleteQuestionBySectionOID(sectOID); bool DeleteFromMenu = menu.DeleteMenuByMenuURL(menuURL); bool DeleteFromSection = sec.DeleteSectionBySectionOID(sectOID); if (DeleteFromSection && DeleteFromMenu) { InitializeQuestion(sectOID); LabelMessage.Text = "This question group has been deleted successfully"; } else { LabelMessage.Text = "This question group can not be deleted.Please try again.."; } ButtonRefresh_Click(null, null); } }
private void CreateAnswerDetail(Answer answer, MyTaskQuestionsViewModel question) { var answerDetail = new AnswerDetail() { DateCreation = DateTime.Now, IdAnswer = answer.Id, CopyNumber = question.CopyNumber, StatusRegister = CStatusRegister.Active }; if (question.IdQuestionDetail != Guid.Empty) { answerDetail.IdQuestionDetail = question.IdQuestionDetail; } if (question.CodeTypePoll == CTypePoll.Open) { answerDetail.AnswerValue = question.Answer; } _answerDetailDao.InsertOrUpdate(answerDetail); }
//Save Value For Score Section private void GetValueForScore( int answerOID) { bool res = false; try { string fieldName1 = null; string fieldName2 = null; string fieldName3 = null; string fieldName4 = null; string fieldName5 = null; string fieldName6 = null; string fieldName11 = null; string fieldName22 = null; string fieldName33 = null; string fieldName44 = null; string fieldName55 = null; string fieldName66 = null; Student student = (Student)(Session["currentStd"]); int aoid = Convert.ToInt32(Session["aoid"].ToString()); //Get Assessment By OID ass = ass.GetAssessmentByOID(aoid); //Assign Value to Answer ans = ans.GetAnswerByStudentOIDAndAOID(student.StudentOID, aoid); // if (ans == null) if (ans != null) { ans = new Answer(); ans.AssessmentOID = ass.AssessmentOID; ans.CreatedBy = 1; ans.NumberOfPrinted = 0; ans.BannerID = student.StudentID; ans.StudentOID = student.StudentOID;//Get Currently Login Student OID foreach (Section s in ass.SectionList) { if (s.SectionName != "NoScore") { //to do for section //Each Question foreach (Question q in s.QuestionList) { ansDetail = new AnswerDetail(); ansDetail.CreatedBy = 1; ansDetail.SectionOID = s.SectionOID; ansDetail.QuestionOID = q.QuestionOID; fieldName11 = Convert.ToString("A1" + q.QuestionOID); fieldName1 = Request.Form[fieldName11]; fieldName22 = Convert.ToString("A2" + q.QuestionOID); fieldName2 = Request.Form[fieldName22]; fieldName33 = Convert.ToString("A3" + q.QuestionOID); fieldName3 = Request.Form[fieldName33]; fieldName44 = Convert.ToString("A4" + q.QuestionOID); fieldName4 = Request.Form[fieldName44]; fieldName55 = Convert.ToString("A5" + q.QuestionOID); fieldName5 = Request.Form[fieldName55]; fieldName66 = Convert.ToString("A6" + q.QuestionOID); fieldName6 = Request.Form[fieldName66]; if (fieldName1 == "on") { response = "Not true at all"; answerPoint = q.Reverse==0? 1:6; //res = true; } else if (fieldName2 == "on") { response = "Somewhat Untrue"; answerPoint = q.Reverse == 0 ? 2 : 5; //res = true; } else if (fieldName3 == "on") { response = "Slightly Untrue "; answerPoint = q.Reverse == 0 ? 3 : 4; //res = true; } else if (fieldName4 == "on") { response = "Slightly True "; answerPoint = q.Reverse == 0 ? 4 : 3; //res = true; } else if (fieldName5 == "on") { response = "Somewhat True "; answerPoint = q.Reverse == 0 ? 5 : 2; //res = true; } else if (fieldName6 == "on") { response = "Completely True"; answerPoint = q.Reverse == 0 ? 6 : 1; //res = true ; } //else //{ // response = "No Answer"; // answerPoint = 0; // //res = true ; //} QuestionResponse Qres=new QuestionResponse (); //int answerPoint=Qres.GetQuestionFlagPointByQOIDAndResponse(q..QuestionOID ,response); ansDetail.AnswerPoint = answerPoint; ansDetail.Response = response; ansDetailList.Add(ansDetail); } } } //Assign Answer Details List to ans.AnswerDetailList = ansDetailList; //Save if (answerOID > 0) { ans.addAnswerDetails(answerOID); } //else //{ // ans.AddAnswer(); //} } } catch { } //return res; }
//private void CheckValueNonScore() //Check Value For NonScore private bool CheckValueNonScore() { try { bool ResultNonScore = true; Student student = (Student)(Session["currentStd"]); int aoid = Convert.ToInt32(Session["aoid"].ToString()); Assessment asst = new Assessment(); int ansOID = asst.GetAnswerOIDByAssessmentOID(aoid); //Get Assessment By OID ass = ass.GetAssessmentByOID(aoid); //Assign Value to Answer ans = ans.GetAnswerBySOIDAndAOID(student.StudentOID, aoid); if (ans == null) { ans = new Answer(); ans.AssessmentOID = ass.AssessmentOID; //ans.CreatedBy = 1; //ans.NumberOfPrinted = 0; //ans.BannerID = student.StudentID; //ans.StudentOID = student.StudentOID;//Get Currently Login Student OID foreach (Section s in ass.SectionList) { if (s.SectionName == "NoScore") { //to do for section //Each Question foreach (Question q in s.QuestionList) { QResponselistPerOID.Clear(); QResponselistPerOID = qresponse.GetQuestionRespByQOID(q.QuestionOID); ansDetail = new AnswerDetail(); //ansDetail.CreatedBy = 1; //ansDetail.SectionOID = s.SectionOID; //ansDetail.QuestionOID = q.QuestionOID; response = null; foreach (QuestionResponse qr in QResponselistPerOID) { fieldName1 = Convert.ToString("A" + q.QuestionOID + qr.QuestionResponseOID); fieldName1 = Request.Form[fieldName1]; if (fieldName1 != null) { response = qr.Response; } } if (response == null) { ResultNonScore = false; return ResultNonScore; //Alert.Show("Please Answer All NonScore Questions"); //break ; } //ansDetail.Response = response; //ansDetailList.Add(ansDetail); } } } } return ResultNonScore; } catch(Exception ax) { return false; } }
//Check Value For Score private bool CheckValueForScore() { bool res = true; try { #region Variable string fieldName1 = null; string fieldName2 = null; string fieldName3 = null; string fieldName4 = null; string fieldName5 = null; string fieldName6 = null; string fieldName11 = null; string fieldName22 = null; string fieldName33 = null; string fieldName44 = null; string fieldName55 = null; string fieldName66 = null; #endregion Student student = (Student)(Session["currentStd"]); int aoid = Convert.ToInt32(Session["aoid"].ToString()); ass = ass.GetAssessmentByOID(aoid); ans = ans.GetAnswerBySOIDAndAOID(student.StudentOID, aoid); if (ans == null) { ans = new Answer(); foreach (Section s in ass.SectionList) { if (s.SectionName != "NoScore") { foreach (Question q in s.QuestionList) { #region Initialization ansDetail = new AnswerDetail(); fieldName11 = Convert.ToString("A1" + q.QuestionOID); fieldName1 = Request.Form[fieldName11]; fieldName22 = Convert.ToString("A2" + q.QuestionOID); fieldName2 = Request.Form[fieldName22]; fieldName33 = Convert.ToString("A3" + q.QuestionOID); fieldName3 = Request.Form[fieldName33]; fieldName44 = Convert.ToString("A4" + q.QuestionOID); fieldName4 = Request.Form[fieldName44]; fieldName55 = Convert.ToString("A5" + q.QuestionOID); fieldName5 = Request.Form[fieldName55]; fieldName66 = Convert.ToString("A6" + q.QuestionOID); fieldName6 = Request.Form[fieldName66]; #endregion #region Check if (fieldName1 == "on") { res = true; } else if (fieldName2 == "on") { res = true; } else if (fieldName3 == "on") { res = true; } else if (fieldName4 == "on") { res = true; } else if (fieldName5 == "on") { res = true; } else if (fieldName6 == "on") { res = true; } else { res = false; return res; } #endregion } } } } } catch { } return res; }
public IHttpActionResult PostQuestionnaireQuestions([FromBody] QuestionnaireQuestionsRequest request) { QuestionaireQuestionResponse response = new QuestionaireQuestionResponse(); try { if (CommonHelpers.ValidateRequest(request.UserToken)) { List <QuestionDetail> QuestionAnswerList = new List <QuestionDetail>(); DBAgent = new DataAccessProvider(DataAccessProvider.ParamType.ServerCredentials, ConfigurationManager.AppSettings["DBServerName"], ConfigurationManager.AppSettings["DBUserName"], ConfigurationManager.AppSettings["DBPassword"]); DBAgent.ClearParams(); DBAgent.AddParameter("@ParamQuestionnaireID", request.QuestionnaireID); DBAgent.AddParameter("@ParamPQID", request.PQID); string data = DBAgent.ExecuteStoredProcedure("dbo.spGetAllQuestionAnswersForQuestionnaire"); if (data.Length > 0) { DataSet ds = CommonHelpers.GetDataSetFromXml(data); if (ds.Tables.Count > 0) { int CurrentQuestionID = 0; QuestionDetail qd = null; foreach (DataRow dr in ds.Tables[0].Rows) { if (CurrentQuestionID != int.Parse(dr["QuestionID"].ToString())) { if (qd != null) { //Save Previous Question QuestionAnswerList.Add(qd); } //New Question qd = new QuestionDetail(); qd.QuestionText = dr["QuestionText"].ToString(); qd.QuestionID = dr["QuestionID"].ToString(); CurrentQuestionID = int.Parse(dr["QuestionID"].ToString()); } AnswerDetail ans = new AnswerDetail(); ans.AnswerID = dr["AnswerID"].ToString(); ans.AnswerText = dr["AnswerText"].ToString(); ans.SelectedAnswer = bool.Parse(dr["SelectedAnswer"].ToString()); ans.AnswerPoints = int.Parse(dr["AnswerPoints"].ToString()); qd.QuestionAnswers.Add(ans); } QuestionAnswerList.Add(qd); //Adding last Question response.QuestionAnswerList = QuestionAnswerList; } } else { response.ErrorMessage = "No Data"; } } else { response.ErrorMessage = "Invalid Request"; DBAgent = new DataAccessProvider(DataAccessProvider.ParamType.ServerCredentials, ConfigurationManager.AppSettings["DBServerName"], ConfigurationManager.AppSettings["DBUserName"], ConfigurationManager.AppSettings["DBPassword"]); DBAgent.ClearParams(); DBAgent.AddParameter("@ParamRefID", request.PQID); DBAgent.AddParameter("@ParamRefType", "PQID"); DBAgent.AddParameter("@ParamAction", "IR"); DBAgent.AddParameter("@ParamComment", "Invalid Request from Mobile App - QuestionnaireQuestionsController - " + request.UserToken); DBAgent.ExecuteNonQuery("dbo.spAddUserAction"); } } catch (Exception ex) { response.ErrorMessage = ex.Message; CommonHelpers.writeLogToFile("API: PostQuestionnaireQuestions - QuestionnaireQuestionsController.cs", ex.Message + Environment.NewLine + ex.StackTrace); } return(Ok(response)); }
public JsonResult Create(AnswerDetail data) { db.AnswerDetail.Add(data); db.SaveChanges(); return(Json(new { Message = "Đã thêm thành công!" }, JsonRequestBehavior.AllowGet)); }
public AnswerDetailResult(AnswerDetail result) { Result = result; }
//Save Value For NonScore Section private int GetValueNonScore() { try { int answerOID = 0; Student student = (Student)(Session["currentStd"]); int aoid = Convert.ToInt32(Session["aoid"].ToString()); //Get Assessment By OID ass = ass.GetAssessmentByOID_QuestionSheet(aoid); //Assign Value to Answer ans = ans.GetAnswerBySOIDAndAOID(student.StudentOID, aoid); if (ans == null) { ans = new Answer(); ans.CreatedDate = DateTime.Now; ans.AssessmentOID = ass.AssessmentOID; ans.CreatedBy = 1; ans.NumberOfPrinted = 0; ans.BannerID = student.StudentID; ans.StudentOID = student.StudentOID;//Get Currently Login Student OID ansDetailList.Clear(); foreach (Section s in ass.SectionList) { if (s.SectionName == "NoScore") { //to do for section //Each Question foreach (Question q in s.QuestionList) { QResponselistPerOID.Clear(); QResponselistPerOID = qresponse.GetQuestionRespByQOID(q.QuestionOID); ansDetail = new AnswerDetail(); ansDetail.CreatedBy = 1; ansDetail.SectionOID = s.SectionOID; ansDetail.QuestionOID = q.QuestionOID; response = null; foreach (QuestionResponse qr in QResponselistPerOID) { fieldName1 = Convert.ToString("A" + q.QuestionOID + qr.QuestionResponseOID); fieldName1 = Request.Form[fieldName1]; if (fieldName1 != null) { response = qr.Response; } //else //{ // response = "No Answer"; //} } ansDetail.Response = response; ansDetailList.Add(ansDetail); } } } //Assign Answer Details List to ans.AnswerDetailList = ansDetailList; //Save if (ans.AnswerOID > 0) { ans.addAnswerDetails(ans.AnswerOID); ansDetailList.Clear(); } else { answerOID = ans.AddAnswer(); ansDetailList.Clear(); } } return answerOID; } catch { return 0; } }
public async Task <IActionResult> GetAssignmentResult([FromBody] GetAssignmentResultPostViewModel model) { if (!ModelState.IsValid) { return(BadRequest(new { message = "request forbidden" })); } var userID = User.Claims.Where(c => c.Type == ClaimTypes.NameIdentifier).FirstOrDefault().Value; var user = await _userManager.FindByIdAsync(userID); if (user == null) { return(NotFound(new { message = "user's token is invalid" })); } var specificAssignmentRecord = _arDbContext.AssignmentRecords.Where(ar => ar.UserID == user.Id && ar.ExerciseID == model.ExerciseID).ToList().FirstOrDefault(); if (specificAssignmentRecord == null) { return(NotFound(new { message = "there is no assignment record for this exercise" })); } if (specificAssignmentRecord.IsFinished == false) { return(NotFound(new { message = "you haven't finished this assignment yet" })); } var answerRecords = _arDbContext.AnswserRecords.Where(q => q.AssignmentRecordID == specificAssignmentRecord.ID).ToList(); var answerDetails = new List <AnswerDetail>(); foreach (var answerRecord in answerRecords) { var answerDetail = new AnswerDetail { SentenceJP = answerRecord.SentenceJP, SentenceEN = answerRecord.SentenceEN, AnswerSentence = QuestionHandler.ConvertDivisionToSentence(answerRecord.AnswerDivision), IsCorrect = answerRecord.IsCorrect }; answerDetails.Add(answerDetail); } var vm = new GetAssignmentResultGetViewModel { AccuracyRate = specificAssignmentRecord.AccuracyRate, AnswerDetails = answerDetails }; return(Ok(vm)); }
public Win_ZHIHU_Response(AnswerDetail detail) { this.SuspendLayout(); Label userName = new Label { AutoSize = true, Dock = System.Windows.Forms.DockStyle.Top, Font = new System.Drawing.Font("宋体", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), Location = new System.Drawing.Point(0, 0), Size = new System.Drawing.Size(85, 19), TabIndex = 0, Text = "作者:" + detail.Responder }; Label upNumber = new Label { AutoSize = true, Dock = System.Windows.Forms.DockStyle.Bottom, Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))), Location = new System.Drawing.Point(0, 19), Margin = new System.Windows.Forms.Padding(3, 10, 3, 0), Padding = new System.Windows.Forms.Padding(0, 10, 0, 0), Size = new System.Drawing.Size(76, 25), TabIndex = 2, Text = "赞数:" + detail.UpNumber }; this.basicInfo = new Panel { AutoSize = true, BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle }; this.basicInfo.Controls.Add(userName); this.basicInfo.Controls.Add(upNumber); this.basicInfo.Dock = System.Windows.Forms.DockStyle.Top; this.basicInfo.Location = new System.Drawing.Point(0, 0); this.basicInfo.Name = "panel11"; this.basicInfo.Padding = new System.Windows.Forms.Padding(0, 0, 0, 10); this.basicInfo.Size = new System.Drawing.Size(754, 56); this.basicInfo.TabIndex = 0; Label contentText = new Label { AutoSize = true, Dock = System.Windows.Forms.DockStyle.Top, Location = new System.Drawing.Point(3, 0), Name = "label9", Padding = new System.Windows.Forms.Padding(5, 10, 0, 15), Size = new System.Drawing.Size(742, 85), MaximumSize = new System.Drawing.Size(742, 0), TabIndex = 0, Text = detail.Content }; this.content = new Panel { AutoSize = true, Dock = System.Windows.Forms.DockStyle.Top, Location = new System.Drawing.Point(0, 56), Size = new System.Drawing.Size(760, 100), TabIndex = 1, }; this.content.Controls.Add(contentText); this.AutoSize = true; this.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.Controls.Add(this.content); this.Controls.Add(this.basicInfo); this.Dock = System.Windows.Forms.DockStyle.Top; this.Location = new System.Drawing.Point(0, 72); this.TabIndex = 1; this.ResumeLayout(true); }