private double?NormalizeToCelius(ExamQuestion question) { var answer = question.ExamQuestionAnswer.FirstOrDefault(); double?results = null; switch (question.SourceConversion.ConversionName) { case "Celsius": results = question.InputValue; break; case "Kelvin": results = question.InputValue - 273.15; break; case "Fahrenheit": double fahrenheitMultiplier = 5.0 / 9.0; results = ((question.InputValue.Value - 32) * fahrenheitMultiplier); break; case "Rankine": double rankineMultiplier = 5.0 / 9.0; results = (question.InputValue - 491.67) * rankineMultiplier; break; } return(results); }
/// <summary> /// 强化练习 /// </summary> /// <param name="totalCount">共多少道题</param> /// <param name="exerciseType">1:顺序 2:随机</param> /// <returns></returns> public static IList <ExamQuestion> GetExamQuestionListForQhlx(int totalCount, int exerciseType) { IList <ExamQuestion> examQuestionList = new List <ExamQuestion>(); ExamQuestion examQuestion = null; StringBuilder sbSQL = new StringBuilder(); sbSQL.Append(" SELECT QuestionID FROM ( "); sbSQL.AppendFormat(" SELECT TOP {0} QuestionID FROM ExamQuestion ORDER BY WrongCount DESC ", totalCount); sbSQL.Append(" ) AS QuestionInfo "); if (exerciseType == 2) { sbSQL.Append(" ORDER BY NEWID() "); } using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sbSQL.ToString())) { while (dr.Read()) { examQuestion = GetExamQuestionByQuestionId(Convert.ToInt32(dr["QuestionID"])); examQuestionList.Add(examQuestion); } } return(examQuestionList); }
/// <summary> /// 获得问题实体 /// </summary> /// <param name="questionId"></param> /// <returns></returns> public static ExamQuestion GetExamQuestionByQuestionId(int questionId) { ExamQuestion examQuestion = null; string strSql = string.Format("SELECT {0} FROM ExamQuestion WHERE QuestionId = @QuestionID ", EXAMQUESTIONFILEDLIST); SqlParameter parm = new SqlParameter("@QuestionId", questionId); using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, strSql, parm)) { if (dr.Read()) { examQuestion = new ExamQuestion(); examQuestion.CategoryID = Convert.ToInt32(dr["CategoryID"]); examQuestion.ClickCount = Convert.ToInt32(dr["ClickCount"]); examQuestion.QuestionID = questionId; examQuestion.QuestionLibrary = Convert.ToInt32(dr["QuestionLibrary"]); examQuestion.QuestionName = dr["QuestionName"].ToString(); examQuestion.QuestionPhoto = string.IsNullOrEmpty(dr["QuestionPhoto"].ToString()) == true ? "" : "/upload/questionphoto/" + dr["QuestionPhoto"].ToString(); examQuestion.QuestionRemark = dr["QuestionRemark"].ToString(); examQuestion.QuestionType = Convert.ToInt32(dr["QuestionType"]) == 1 ? QuestionType.Choice : QuestionType.Judgmeng; examQuestion.RightAnswer = Convert.ToInt32(dr["RightAnswer"]); examQuestion.RightAnswerString = Utils.ReturnRightAnswerToString(examQuestion.RightAnswer, examQuestion.QuestionType); examQuestion.WrongCount = Convert.ToInt32(dr["WrongCount"]); if (examQuestion.QuestionType == QuestionType.Choice) { //该题为选择题 examQuestion.AnswerList = ExamAnswerRepository.GetExamAnswerListByQuestonId(questionId); } } } return(examQuestion); }
public async Task <Unit> Handle(Command request, CancellationToken cancellationToken) { var chapterRepository = _unitOfWork.Repository <Chapter>(); var chapter = await chapterRepository.GetByIdAsync(request.ChapterId); if (chapter == null) { throw new RestException(HttpStatusCode.NotFound, "Chapter not found"); } var examQuestionRepository = _unitOfWork.Repository <ExamQuestion>(); var examQuestion = new ExamQuestion { ChapterId = request.ChapterId, Content = request.Content, Option1 = request.Option1, Option2 = request.Option2, Option3 = request.Option3, Option4 = request.Option4, CorrectAnswer = request.CorrectAnswer }; examQuestionRepository.Add(examQuestion); var success = await _unitOfWork.CompleteAsync() > 0; if (success) { return(Unit.Value); } throw new Exception(ExceptionMessages.ProblemSavingChanges); }
public async Task <IHttpActionResult> PutExamQuestion(int id, ExamQuestion examQuestion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != examQuestion.examId) { return(BadRequest()); } db.Entry(examQuestion).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ExamQuestionExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private async Task GradeTemperatureConversion(ExamQuestion question) { var answer = question.ExamQuestionAnswer.FirstOrDefault().Answer; double?results = NormalizeToCelius(question); switch (question.DestinationConversion.ConversionName) { case "Kelvin": results = results + 273.15; break; case "Fahrenheit": double FahrenheitMultiplier = 9.0 / 5.0; results = (results * FahrenheitMultiplier) + 32; break; case "Rankine": double rankineMultiplier = 9.0 / 5.0; results = (results * rankineMultiplier) + 491.67; break; } var studentResponse = Math.Round(answer.Value, 1); results = Math.Round(results.Value, 1); if (results == studentResponse) { question.ExamQuestionAnswer.FirstOrDefault().IsCorrect = true; } else { question.ExamQuestionAnswer.FirstOrDefault().IsCorrect = false; } await _testRepository.GradeResponse(question.ExamQuestionAnswer.FirstOrDefault()); }
public async Task <bool> AddQuestion(QuestionViewModel question, Guid examId) { try { var oQuestion = new Question { Title = question.Title, RatePolicy = question.RatePolicy, Options = (ICollection <Option>)question.Options, Type = question.Type }; await dbContext.Questions.AddAsync(oQuestion); await dbContext.SaveChangesAsync(); var examQuestion = new ExamQuestion { ExamId = examId, QuestionId = oQuestion.Id }; await dbContext.ExamQuestions.AddAsync(examQuestion); await dbContext.SaveChangesAsync(); return(await Task.FromResult(true)); } catch (Exception) { return(await Task.FromResult(false)); } }
public async Task <IHttpActionResult> PostExamQuestion(ExamQuestion examQuestion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.ExamQuestions.Add(examQuestion); try { await db.SaveChangesAsync(); } catch (DbUpdateException) { if (ExamQuestionExists(examQuestion.examId)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = examQuestion.examId }, examQuestion)); }
public async Task <IHttpActionResult> AddQuestion(Models.ExamQuestion mdlQuestion) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } List <ExamQuestion> tmpQuestions = await db.ExamQuestions.ToListAsync(); bool questFound = false; foreach (ExamQuestion quest in tmpQuestions) { if (quest.SettingID == mdlQuestion.SettingID && quest.QuestionID == mdlQuestion.QuestionID) { questFound = true; break; } } if (questFound == true) { return(BadRequest("This question is already in this exam setting")); } ExamQuestion dbQuestion = AutoMapper.Mapper.Map <ExamQuestion>(mdlQuestion); dbQuestion = db.ExamQuestions.Add(dbQuestion); db.Entry(dbQuestion).State = EntityState.Modified; await db.SaveChangesAsync(); return(Ok()); }
public static IList <ExamQuestion> GetErrorLibraryQuestionList(int userId) { StringBuilder sbSQL = new StringBuilder(); sbSQL.AppendFormat(" SELECT QuestionId FROM ExamQuestion "); sbSQL.Append(" WHERE EXISTS( "); sbSQL.Append(" SELECT * FROM ExamErrorLibrary "); sbSQL.Append(" WHERE ExamErrorLibrary.UserId = @UserID "); sbSQL.Append(" AND ExamQuestion.QuestionID = ExamErrorLibrary.QuestionID "); sbSQL.Append(" ) "); SqlParameter parm = new SqlParameter("@UserID", userId); IList <ExamQuestion> examQuestionList = new List <ExamQuestion>(); ExamQuestion examQuestion = null; using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, sbSQL.ToString(), parm)){ while (dr.Read()) { examQuestion = GetExamQuestionByQuestionId(Convert.ToInt32(dr["QuestionId"])); examQuestionList.Add(examQuestion); } } return(examQuestionList); }
public ExamQuestion SaveQuestion(ExamQuestion eq, HttpPostedFileBase upload) { if (eq.Id == 0) { if (upload != null && upload.ContentLength > 0) { eq.ImageData = new byte[upload.ContentLength]; eq.ImageMimeType = upload.ContentType; upload.InputStream.Read(eq.ImageData, 0, upload.ContentLength); } _db.ExamQuestions.Add(eq); _db.SaveChanges(); return(eq); } var entity = _db.ExamQuestions.Find(eq.Id); if (entity != null) { entity.Examination = eq.Examination; entity.ExamAnswer = eq.ExamAnswer; entity.QuestionContent = eq.QuestionContent; if (upload != null && upload.ContentLength > 0) { entity.ImageData = new byte[upload.ContentLength]; entity.ImageMimeType = upload.ContentType; upload.InputStream.Read(entity.ImageData, 0, upload.ContentLength); } } _db.Entry(entity).State = EntityState.Modified; _db.SaveChanges(); return(entity); }
public async Task <IActionResult> Edit(int id, [Bind("qId,eId")] ExamQuestion examQuestion) { if (id != examQuestion.eId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(examQuestion); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ExamQuestionExists(examQuestion.eId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["eId"] = new SelectList(_context.Exam, "eId", "eId", examQuestion.eId); ViewData["qId"] = new SelectList(_context.Question, "qId", "qId", examQuestion.qId); return(View(examQuestion)); }
public async Task <Exam> Initialize() { _testRepository.Initialize(); Exam exam = new Exam(); exam.ExamId = 1; exam.DateCompleted = null; exam.DateCreated = DateTime.Now; exam.Description = "Exam 1"; exam.IsComplete = false; exam.IsCreated = true; exam.IsGraded = false; exam.TeacherId = 1; exam.StudentId = 1; ExamQuestion question = new ExamQuestion(); question.ExamId = 1; question.ExamQuestionId = 1; question.InputValue = 23; question.SourceConversionId = 1; question.DestinationConversionId = 3; question.SourceConversion = new Conversion() { ConversionId = 1, ConversionTypeId = 2, ConversionName = "Kelvin", ConversionType = new ConversionType() { ConversionTypeId = 2, ConversionName = "Temperature" } }; question.DestinationConversion = new Conversion() { ConversionId = 3, ConversionTypeId = 2, ConversionName = "Celsius", ConversionType = new ConversionType() { ConversionTypeId = 2, ConversionName = "Temperature" } }; question.Exam = exam; exam.ExamQuestion = new List <ExamQuestion>(); exam.ExamQuestion.Add(question); return(exam); }
public ActionResult DeleteConfirmed(int id) { ExamQuestion examQuestion = db.ExamQuestions.Find(id); db.ExamQuestions.Remove(examQuestion); db.SaveChanges(); return(RedirectToAction("Index")); }
private string GetQuestionEntityForJson(int questionId) { StringBuilder sbText = new StringBuilder("{"); ExamQuestion examQuestion = ExamQuestionRepository.GetExamQuestionByQuestionId(questionId); if (examQuestion != null) { sbText.AppendFormat("\"questionid\":{0},", examQuestion.QuestionID); sbText.AppendFormat("\"clickcount\":{0},", examQuestion.ClickCount); sbText.AppendFormat("\"questiontype\":{0},", (int)examQuestion.QuestionType); sbText.Append("\"questionphoto\":\""); Utils.SerializeString(examQuestion.QuestionPhoto, sbText); sbText.Append("\","); sbText.Append("\"questionremark\":\""); if (string.IsNullOrEmpty(examQuestion.QuestionRemark)) { Utils.SerializeString("Sorry!该题暂时没有说明!<br />我们会尽快对该题说明补充完整。", sbText); } else { Utils.SerializeString(examQuestion.QuestionRemark, sbText); } sbText.Append("\","); sbText.Append("\"rightanswerstring\":\""); Utils.SerializeString(examQuestion.RightAnswerString, sbText); sbText.Append("\","); sbText.AppendFormat("\"wrongcount\":{0},", examQuestion.WrongCount); if (examQuestion.QuestionType == QuestionType.Judgmeng) { sbText.Append("\"questionname\":\""); Utils.SerializeString(examQuestion.QuestionName, sbText); sbText.Append("\""); } if (examQuestion.QuestionType == QuestionType.Choice) { sbText.Append("\"questionname\":\""); Utils.SerializeString(examQuestion.QuestionName, sbText); sbText.Append("\u003C\u0062\u0072\u0020\u002F\u003E"); IList <ExamAnswer> examAnswerList = examQuestion.AnswerList; foreach (ExamAnswer item in examAnswerList) { Utils.SerializeString(item.AnswerName, sbText); sbText.Append("\u003C\u0062\u0072\u0020\u002F\u003E"); } sbText.Append("\""); } } else { sbText.Append(ErrorJson); //没有问题,返回错误,代码为-1 } sbText.Append("}"); return(sbText.ToString()); }
public ActionResult Edit([Bind(Include = "Id,ExamId,Question,Answer")] ExamQuestion examQuestion) { if (ModelState.IsValid) { db.Entry(examQuestion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id = new SelectList(db.Exams, "ID", "Name", examQuestion.Id); return(View(examQuestion)); }
public async Task <IHttpActionResult> GetExamQuestion(int id) { ExamQuestion examQuestion = await db.ExamQuestions.FindAsync(id); if (examQuestion == null) { return(NotFound()); } return(Ok(examQuestion)); }
public async Task <IActionResult> Add(ExamViewModel examViewModel) { if (ModelState.IsValid) { Exam exam = new Exam() { CreatedDate = DateTime.Now, Content = examViewModel.Question.Content, ExamQuestions = examViewModel.Question.ExamQuestions, textId = examViewModel.Question.textId, Title = examViewModel.Question.Title }; List <ExamQuestion> examQuestions = new List <ExamQuestion>(); foreach (var question in examViewModel.Question.ExamQuestions) { ExamQuestion examQuestion = new ExamQuestion() { AnswerA = question.AnswerA, AnswerB = question.AnswerB, AnswerC = question.AnswerC, AnswerD = question.AnswerD, Question = question.Question, CorrectAnswer = question.CorrectAnswer, ExamId = exam.ExamId, QuestionNumber = question.QuestionNumber }; examQuestions.Add(examQuestion); } exam.ExamQuestions = examQuestions; using (var dbContext = new ApplicationDbContext()) { dbContext.Database.EnsureCreated(); dbContext.Add(exam); int insertResult = dbContext.SaveChanges(); if (insertResult > 0) { return(RedirectToAction("List", "Exam")); } } } else { ViewBag.ErrorMessage = "Lütfen boş alanları doldurunuz!"; return(View()); } return(RedirectToAction("Add", "Exam")); }
public ActionResult Edit([Bind(Include = "E_id,E_name,S_id,duration")] ExamQuestion examQuestion) { if (ModelState.IsValid) { db.Entry(examQuestion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.S_id = new SelectList(db.Subjects, "S_id", "name", examQuestion.S_id); return(View(examQuestion)); }
public ActionResult Edit([Bind(Include = "Id,ExamId,QuestionId,QuestionNumber,IsActive")] ExamQuestion examQuestion) { if (ModelState.IsValid) { db.Entry(examQuestion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ExamId = new SelectList(db.Exams, "Id", Thread.CurrentThread.CurrentCulture.Name.Equals("en-US") ? "Name_En" : "Name_En", examQuestion.ExamId); ViewBag.QuestionId = new SelectList(db.Questions, "Id", Thread.CurrentThread.CurrentCulture.Name.Equals("en-US") ? "Question_En" : "Question_Ar", examQuestion.QuestionId); return(View(examQuestion)); }
public ActionResult Create([Bind(Include = "Id,ExamId,Question,Answer, Point")] ExamQuestion examQuestion) { if (ModelState.IsValid) { db.ExamQuestions.Add(examQuestion); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Id = new SelectList(db.Exams, "ID", "Name", examQuestion.Id); return(View(examQuestion)); }
public async Task <bool> AddQuestion(ExamQuestion question) { var questionData = new Infrastructure.DataModel.ExamQuestion() { SourceConversionId = question.SourceConversionId, DestinationConversionId = question.DestinationConversionId, ExamId = question.ExamId, InputValue = question.InputValue }; return(await _testRepository.AddQuestion(questionData)); }
public async Task <bool> AddQuestion(ExamQuestion question) { try { _examMockDbContext.ExamQuestion.Add(question); return(true); } catch { return(false); } }
public int Delete(ExamQuestion model) { var examQuestion = context.ExamQuestions.Where(eq => eq.ExamId == model.ExamId && eq.QuestionId == model.QuestionId).SingleOrDefault(); if (examQuestion != null) { context.ExamQuestions.Remove(examQuestion); return(context.SaveChanges()); } return(0); }
public void Save(ExamQuestion eq) { string query = @"update OTExamQuestion set ans = @ans where examid= @examid and questionid= @questionid"; SqlParameter[] param = { new SqlParameter("@examid", eq.ExamId), new SqlParameter("@questionid", eq.QuestionId), new SqlParameter("@ans", eq.Answer) }; DAO.IUD(param, query, System.Data.CommandType.Text); }
private async Task <ExamQuestion> GenerateExamQuestion(Exam exam) { var question = new ExamQuestion() { TypeId = _random.Next(1, 2), Description = "Test description, try to get random answer", Points = 5, ExamId = exam.ExamId }; return(await _service.InsertQuestion(question)); }
public ActionResult Edit([Bind(Include = "Id,ExamId,QuestionId,OrderId")] ExamQuestion examQuestion) { if (ModelState.IsValid) { db.Entry(examQuestion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.QuestionId = new SelectList(db.Question, "Id", "QuestionText", examQuestion.QuestionId); ViewBag.ExamId = new SelectList(db.Exam, "Id", "Title", examQuestion.ExamId); return(View(examQuestion)); }
public List <ExamQuestion> GetQuestionsBySubjectWithDifficulty(string subject, int difficulty) { //Brings Questions Then converts it to ExamScript which is a list of questions without answer List <Question> questions = new ExamScripRepository().GetQuestionsBySubjectWithDifficulty(subject, difficulty); List <ExamQuestion> examScript = new List <ExamQuestion>(); foreach (var question in questions) { var examQuestion = new ExamQuestion(question); examScript.Add(examQuestion); } return(examScript); }
public async Task <IActionResult> Create([Bind("qId,eId")] ExamQuestion examQuestion) { if (ModelState.IsValid) { _context.Add(examQuestion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["eId"] = new SelectList(_context.Exam, "eId", "eId", examQuestion.eId); ViewData["qId"] = new SelectList(_context.Question, "qId", "qId", examQuestion.qId); return(View(examQuestion)); }
public async Task <ExamQuestion> InsertQuestion(ExamQuestion question) { var responseMessage = await _http.PostAsJsonAsync("api/exam/question", question); if (responseMessage.Content != null) { var jsonString = await responseMessage.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <ExamQuestion>(jsonString)); } return(null); }
protected void btnGenerateQuiz_Click(object sender, EventArgs e) { try { string studentID = Profile.card_id; int courseID = Convert.ToInt32(ddlCourseID.SelectedValue); int subjectID = Convert.ToInt32(ddlSubjectID.SelectedValue); List<Quiz_TrueFalse> trueFalseQuestions = new List<Quiz_TrueFalse>(); List<Quiz_TrueFalse> drCrQuestions = new List<Quiz_TrueFalse>(); List<Quiz_FillInTheBlanks> fillInTheBlanks = new List<Quiz_FillInTheBlanks>(); List<Quiz_MultipleQuestion> multipleQuestion = new List<Quiz_MultipleQuestion>(); //List<Quiz_Comprehension> comprehensions = new List<Quiz_Comprehension>(); #region Load Questions from Distribution foreach (GridViewRow row in gvQuestionDistribution.Rows) { DropDownList ddlChapters = (DropDownList)row.FindControl("ddlChapters"); TextBox txtTrueFalse = (TextBox)row.FindControl("txtTrueFalse"); TextBox txtDrCr = (TextBox)row.FindControl("txtDrCr"); TextBox txtFillInTheBlank = (TextBox)row.FindControl("txtFillInTheBlank"); TextBox txtMCQ = (TextBox)row.FindControl("txtMCQ"); TextBox txtComprehension = (TextBox)row.FindControl("txtComprehension"); int chapterID = Convert.ToInt32(ddlChapters.SelectedValue); if (txtTrueFalse.Text.Length > 0) { trueFalseQuestions.AddRange(STD_MockTestManager.GetMockTest_TrueFalses(studentID, courseID, subjectID, chapterID, false, Convert.ToInt32(txtTrueFalse.Text))); } if (txtDrCr.Text.Length > 0) { drCrQuestions.AddRange(STD_MockTestManager.GetMockTest_TrueFalses(studentID, courseID, subjectID, chapterID, true, Convert.ToInt32(txtDrCr.Text))); } if (txtFillInTheBlank.Text.Length > 0) { fillInTheBlanks.AddRange(STD_MockTestManager.GetMockTest_FillInTheBlanks(studentID, courseID, subjectID, chapterID, Convert.ToInt32(txtFillInTheBlank.Text))); } if (txtMCQ.Text.Length > 0) { multipleQuestion.AddRange(STD_MockTestManager.GetMockTest_MCQ(studentID, courseID, subjectID, chapterID, Convert.ToInt32(txtMCQ.Text))); } //if (txtComprehension.Text.Length > 0) //{ // comprehensions.AddRange(STD_MockTestManager.GetMockTest_Comprehension(studentID, courseID, subjectID, chapterID, Convert.ToInt32(txtComprehension.Text))); //} } #endregion List<ExamQuestion> questions = new List<ExamQuestion>(); if (trueFalseQuestions.Count > 0 || drCrQuestions.Count > 0 || fillInTheBlanks.Count > 0 || multipleQuestion.Count > 0) { //phExamHeader.Visible = true; phActions.Visible = true; #region True False Questions foreach (Quiz_TrueFalse tfQ in trueFalseQuestions) { ExamQuestion eq = new ExamQuestion(); eq.QuestionType = (int)Enums.QuestionTypes.TrueFalse; eq.QuestionNo = tfQ.TrueFalseID; eq.ComprehensionID = tfQ.ComprehensionID; questions.Add(eq); StudentExamQuestion seq = new StudentExamQuestion(0, eq.QuestionNo, eq.QuestionType, studentID, 1, "", DateTime.Now, "", DateTime.Now); StudentExamQuestionManager.InsertStudentExamQuestion(seq); } #endregion #region Dr/ Cr Questions foreach (Quiz_TrueFalse drcrQ in drCrQuestions) { ExamQuestion eq = new ExamQuestion(); eq.QuestionType = (int)Enums.QuestionTypes.DrCr; eq.QuestionNo = drcrQ.TrueFalseID; eq.ComprehensionID = drcrQ.ComprehensionID; questions.Add(eq); StudentExamQuestion seq = new StudentExamQuestion(0, eq.QuestionNo, eq.QuestionType, studentID, 1, "", DateTime.Now, "", DateTime.Now); StudentExamQuestionManager.InsertStudentExamQuestion(seq); } #endregion #region Multiple Choice Questions foreach (Quiz_MultipleQuestion mcq in multipleQuestion) { ExamQuestion eq = new ExamQuestion(); eq.QuestionType = (int)Enums.QuestionTypes.MCQ; eq.QuestionNo = mcq.MultipleQustionID; eq.ComprehensionID = mcq.ComprehensionID; questions.Add(eq); StudentExamQuestion seq = new StudentExamQuestion(0, eq.QuestionNo, eq.QuestionType, studentID, 1, "", DateTime.Now, "", DateTime.Now); StudentExamQuestionManager.InsertStudentExamQuestion(seq); } #endregion #region Fill In The Blanks foreach (Quiz_FillInTheBlanks fitb in fillInTheBlanks) { ExamQuestion eq = new ExamQuestion(); eq.QuestionType = (int)Enums.QuestionTypes.FillInTheBlanks; eq.QuestionNo = fitb.FillInTheBlanksID; eq.ComprehensionID = fitb.ComprehensionID; questions.Add(eq); StudentExamQuestion seq = new StudentExamQuestion(0, eq.QuestionNo, eq.QuestionType, studentID, 1, "", DateTime.Now, "", DateTime.Now); StudentExamQuestionManager.InsertStudentExamQuestion(seq); } #endregion Session["questions"] = questions; Session["totalQuestion"] = questions.Count; _loadQuestionList(); Session["questionNo"] = 1; _loadQuestion(0); btnSubmit.Visible = true; //clkExamTime.Enabled = true; Session["startTime"] = DateTime.Now; } } catch (Exception ex) { } }
private void _loadQuestion(int index) { try { _hideAll(); List<ExamQuestion> questions = (List<ExamQuestion>)Session["questions"]; ExamQuestion sQuestion = new ExamQuestion(); sQuestion = (questions[index]); if (sQuestion.ComprehensionID > 0) { Quiz_Comprehension com = Quiz_ComprehensionManager.GetQuiz_ComprehensionByComprehensionID(sQuestion.ComprehensionID); lblComprehensionPara.Text = com.Comprehension; phComprehension.Visible = true; } if (sQuestion.QuestionType == (int)Enums.QuestionTypes.TrueFalse) { Quiz_TrueFalse tfQuestion = Quiz_TrueFalseManager.GetQuiz_TrueFalseByTrueFalseID(sQuestion.QuestionNo); lblTrueFalseQuestionTitle.Text = tfQuestion.QuestionTitle; hfTrueFalse.Value = tfQuestion.IsTrue.ToString(); lblQuestionNo1.Text = (index + 1).ToString(); phTrueFalse.Visible = true; //rblTrueFalse.Enabled = !sQuestion.IsAnswered; rblTrueFalse.SelectedValue = sQuestion.Answer; } else if (sQuestion.QuestionType == (int)Enums.QuestionTypes.DrCr) { Quiz_TrueFalse tfQuestion = Quiz_TrueFalseManager.GetQuiz_TrueFalseByTrueFalseID(sQuestion.QuestionNo); lblDrCrQuestionTitle.Text = tfQuestion.QuestionTitle; hfDrCr.Value = tfQuestion.IsTrue.ToString(); lblQuestionNo2.Text = (index + 1).ToString(); phDrCr.Visible = true; //rblDrCr.Enabled = !sQuestion.IsAnswered; rblDrCr.SelectedValue = sQuestion.Answer; } else if (sQuestion.QuestionType == (int)Enums.QuestionTypes.MCQ) { lblMCQNo.Text = (index + 1).ToString(); Quiz_MultipleQuestion mcq = Quiz_MultipleQuestionManager.GetQuiz_MultipleQuestionByMultipleQustionID(sQuestion.QuestionNo); lblMcqTitle.Text = mcq.MultipleQuestionName; gvMultipleQUestionsAnswer.DataSource = Quiz_MultipleQuestionDetailsManager.GetAllQuiz_MultipleQuestionDetailsByMultipleQustionID(sQuestion.QuestionNo); gvMultipleQUestionsAnswer.DataBind(); phMCQ.Visible = true; if (sQuestion.IsAnswered) { string[] answers = sQuestion.Answer.Split(','); for (int i = 0; i < gvMultipleQUestionsAnswer.Rows.Count; i++) { GridViewRow row = gvMultipleQUestionsAnswer.Rows[i]; CheckBox cbTrueFalse = (CheckBox)row.FindControl("cbTrueFalse"); //cbTrueFalse.Enabled = false; cbTrueFalse.Checked = bool.Parse(answers[i]); } } } else if (sQuestion.QuestionType == (int)Enums.QuestionTypes.FillInTheBlanks) { phFillInTheBlanks.Visible = true; lblFillInTheBlankNo.Text = (index + 1).ToString(); Quiz_FillInTheBlanks fitb = Quiz_FillInTheBlanksManager.GetQuiz_FillInTheBlanksByFillInTheBlanksID(sQuestion.QuestionNo); lblfillInTheBlankTitle.Text = fitb.Question; gvFillIntheBlanksDetails.DataSource = Quiz_FillInTheBlanksDetailsManager.GetQuiz_FillInTheBlanksByFillInTheBlanksID(sQuestion.QuestionNo); gvFillIntheBlanksDetails.DataBind(); if (sQuestion.IsAnswered) { string[] answers = sQuestion.Answer.Split(new string[] { "[#&#]" }, StringSplitOptions.None); for (int i = 0; i < gvFillIntheBlanksDetails.Rows.Count; i++) { TextBox txtAnswer = (TextBox)gvFillIntheBlanksDetails.Rows[i].FindControl("txtAnswer"); txtAnswer.Text = answers[i]; //txtAnswer.Enabled = false; } } } } catch (Exception ex) { } }