public ActionResult PrevQuestion(ExamPaper exam) { QuestionBL topicBL = new QuestionBL(); //int questionCount = int.Parse(ConfigurationManager.AppSettings["QuestionCount"].ToString()); ExamPaper examPaper = new ExamPaper(); examPaper = (ExamPaper)Session["QuestionPaper"]; //topicBL.GetQuestionPaper(questionCount); examPaper.QuestionEntities = examPaper.QuestionEntities.OrderBy(o => o.Id).ToList(); int index = examPaper.QuestionEntities.FindIndex(item => item.IsShown); examPaper.QuestionEntities[index].IsShown = false; if (index <= examPaper.QuestionEntities.Count - 1 && index > 0) { examPaper.QuestionEntities[index - 1].IsShown = true; examPaper.QuestionEntities[index - 1].HasAlreadyShown = true; } if (index == 0) { examPaper.QuestionEntities[index].IsShown = true; examPaper.QuestionEntities[index].HasAlreadyShown = true; } // Session.Abandon(); Session["QuestionPaper"] = examPaper; return(RedirectToAction("QuestionPaper", "Question")); }
public int Insert(ExamPaper examPaper) { icasEntities.ExamPapers.Add(examPaper); icasEntities.SaveChanges(); return(examPaper.Id); }
public async Task <IActionResult> Edit(int id, [Bind("Id,ExamTitle,SubjectName,SubjectCode,TotalMarks,Instruction,Date")] ExamPaper examPaper) { if (id != examPaper.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(examPaper); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ExamPaperExists(examPaper.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(examPaper)); }
/// <summary> /// 查看全部 /// </summary> /// <returns>list集合</returns> public List <ExamPaper> SelectAll() { List <ExamPaper> list = new List <ExamPaper>(); ExamPaper model = null; using (SqlDataReader dr = DBHelper.RunProcedure("ExamPaper_SelectAll", null)) { while (dr.Read()) { model = new ExamPaper(); model.ExamPaperId = Convert.ToInt32(dr["ExamPaperId"]); if (DBNull.Value != dr["ExamId"]) { model.ExamId = Convert.ToInt32(dr["ExamId"]); } if (DBNull.Value != dr["PaperId"]) { model.PaperId = Convert.ToInt32(dr["PaperId"]); } if (DBNull.Value != dr["OrderIndex"]) { model.OrderIndex = Convert.ToInt32(dr["OrderIndex"]); } model.IsDelete = Convert.ToBoolean(dr["IsDelete"]); list.Add(model); } } return(list); }
public async Task <SharedLookUpResponse> AddExamPaperAsync(AddExam addExamPaper, int instituteId) { if (!await iMSDbContext.ExamPapers.AnyAsync(x => x.InstituteId == instituteId && x.MappingId == addExamPaper.MappingId && x.PublisherName.ToLowerInvariant() == addExamPaper.PublisherName.ToLowerInvariant())) { var examPaper = new ExamPaper() { InstituteId = instituteId, PublisherName = addExamPaper.PublisherName, Pages = addExamPaper.Pages, Description = addExamPaper.Description, MappingId = addExamPaper.MappingId, AcademicYearId = addExamPaper.AcademicYearId }; iMSDbContext.ExamPapers.Add(examPaper); await iMSDbContext.SaveChangesAsync(); return(new SharedLookUpResponse() { HasError = false, Message = "Examination Paper added successfully" }); } else { return(new SharedLookUpResponse() { HasError = true, ErrorType = SharedLookUpResponseType.Code, Message = "Examination Paper with same info is already existed" }); } }
/// <summary> /// 通过条件查询 /// </summary> /// <param name="WhereString">查询条件</param> /// <returns>ExamPaper实体类对象</returns> public List <ExamPaper> SelectByWhere(string WhereString) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@where", WhereString) }; List <ExamPaper> list = new List <ExamPaper>(); ExamPaper model = null; using (SqlDataReader dr = DBHelper.RunProcedure("ExamPaper_SelectByWhere", param)) { while (dr.Read()) { model = new ExamPaper(); model.ExamPaperId = Convert.ToInt32(dr["ExamPaperId"]); if (DBNull.Value != dr["ExamId"]) { model.ExamId = Convert.ToInt32(dr["ExamId"]); } if (DBNull.Value != dr["PaperId"]) { model.PaperId = Convert.ToInt32(dr["PaperId"]); } if (DBNull.Value != dr["OrderIndex"]) { model.OrderIndex = Convert.ToInt32(dr["OrderIndex"]); } model.IsDelete = Convert.ToBoolean(dr["IsDelete"]); list.Add(model); } } return(list); }
private void backgroundWorkerForAddCourse_DoWork(object sender, DoWorkEventArgs e) { ExamPaper paper = new ExamPaper(); int marks; IsMarksConvertible = int.TryParse(marksPerQuestionField.Text.Trim(), out marks); int timeDuration; IsTimeDurationForConvertible = int.TryParse(timeDurationField.Text.Trim(), out timeDuration); int totalQuestions; IsTotalQuestionsConvertible = int.TryParse(totalQuestionField.Text.Trim(), out totalQuestions); IsCourseIdValid = checkCourseId(courseCodeField.Text.Trim()); MessageBox.Show(IsCourseIdValid.ToString()); if ((!IsTotalQuestionsConvertible) || (!IsMarksConvertible) || (!IsTimeDurationForConvertible) || (!IsCourseIdValid)) { return; } paper.Id = courseCodeField.Text.Trim(); paper.Name = courseNameField.Text.Trim(); paper.TimeDuration = timeDuration; paper.MarksPerQuestion = marks; paper.TotalQuestions = totalQuestions; IsExamCourseAdded = api.AddExamPaper(paper); }
private void backgroundWorkerForUpdate_DoWork(object sender, DoWorkEventArgs e) { ExamPaper ePaper = new ExamPaper(); ePaper.Id = courseCodeField.Text.Trim(); ePaper.Name = courseNameField.Text.Trim(); int totalMarksPerQuestion; IsTotalMarks = int.TryParse(marksPerQuestionField.Text.Trim(), out totalMarksPerQuestion); ePaper.MarksPerQuestion = totalMarksPerQuestion; int totalTimeDuration; IsTimeDuraton = int.TryParse(timeDurationField.Text.Trim(), out totalTimeDuration); ePaper.TimeDuration = totalTimeDuration; int totalQuestions; IsTotalQuestion = int.TryParse(totalQuestionField.Text.Trim(), out totalQuestions); ePaper.TotalQuestions = totalQuestions; if ((!IsTimeDuraton) || (!IsTotalQuestion) || (!IsTotalMarks)) { return; } IsExamCourseUpdated = api.UpdateExamPaper(ePaper); }
static void Main(string[] args) { var formatter = new ReverseFormatter(); var faq = new FAQ(formatter) { Title = "FAQ" }; faq.Add("Whats up doc?", "Nothing much"); var book = new Book(formatter) { Title = "To kill a mockingbird", Author = "Harper Lee" }; var exampaper = new ExamPaper(formatter) { Exam = "English", Student = "John" }; var documents = new List <Transcript>(); documents.Add(faq); documents.Add(book); documents.Add(exampaper); foreach (var doc in documents) { Console.WriteLine("-------------------------------"); doc.Print(); Console.WriteLine("-------------------------------"); } }
public ExamPaper GetNextPrevQuestion(int pageIndex, int pageSize, int userId) { QuestionViewEntities questionViewEntities = new QuestionViewEntities(); SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SchoolDBConnectionString"].ConnectionString); con.Open(); SqlCommand cmd = new SqlCommand("stpGetNextQuestion", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PageIndex", pageIndex); cmd.Parameters.AddWithValue("@PageSize", pageSize); cmd.Parameters.Add(new SqlParameter("@QuestionCount", SqlDbType.Int)); cmd.Parameters[2].Direction = ParameterDirection.Output; cmd.Parameters.AddWithValue("@UserId", userId); SqlDataAdapter da = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); da.Fill(ds); int questCount = (int)(cmd.Parameters[2].Value); con.Close(); ExamPaper examPaper = new ExamPaper(); examPaper = CreateDataSet(ds); examPaper.PageSize = pageSize; examPaper.PageIndex = pageIndex; return(examPaper); }
public ActionResult QuestionPaper() { ExamPaper examPaper = new ExamPaper(); if (Session["QuestionPaper"] == null) { QuestionBL topicBL = new QuestionBL(); // i = i + 1; int questionCount = int.Parse(ConfigurationManager.AppSettings["QuestionCount"].ToString()); examPaper = topicBL.GetNextPrevQuestion(1, 1, int.Parse(Session["UserId"].ToString())); examPaper.QuestionEntities = examPaper.QuestionEntities.OrderBy(o => o.Id).ToList(); examPaper.QuestionEntities[0].IsShown = true; examPaper.QuestionEntities[0].HasAlreadyShown = true; examPaper.PageIndex = 1; examPaper.PageSize = 1; Session["QuestionPaper"] = examPaper; } else { examPaper = (ExamPaper)Session["QuestionPaper"]; } return(View(examPaper)); // return View(examPaper); }
public void LoadExamPaper(BaobaoBook book) { ExamPaper paper = null; AnswerList.Clear(); QuestionList.Clear(); if (book != null) { if (!_books.ContainsKey(book) || _books[book] == null) { string examPaper = book.Name; paper = FileSettingsHelper <ExamPaper> .LoadSetting(Path.Combine(ZibaobaoLibContext.Instance.PersistentStorage.DataPath, examPaper)); _books[book] = paper; } else { paper = _books[book]; } } if (paper != null) { foreach (var question in paper.Questions) { QuestionList.Add(question); } if (QuestionList.Count > 0) { _currentQuestionIndex = -1; CurrentQuestionIndex = 0; } } }
public ActionResult Previous(ExamPaper mm) { ExamPaper exam = new ExamPaper(); if (TempData["exampaper"] != null) { exam = (ExamPaper)TempData["exampaper"]; } exam.PageSize = 1; if (mm.UserAnswer != null) { exam.UserAnswer = mm.UserAnswer; } else { exam.UserAnswer = String.Empty; } if (exam.PageIndex > 0) { exam.PageIndex = exam.PageIndex - 1; } ExamPaper examPaper = GetQuestion(exam.PageIndex.ToString(), exam.PageSize.ToString(), exam.UserAnswer.ToString(), exam.QuestionEntities[0].Id.ToString(), mm.CurrentTime); TempData["exampaper"] = examPaper; return(RedirectToAction("OnlineTest", "Question", new { id = "RealTest" })); }
//private int GetQuestionCount(int QuestionCount) //{ // QuestionBL topicBL = new QuestionBL(); // return topicBL.GetAllQuestion(QuestionCount); //} //public JsonResult GetNextQuestion(string pageindex,string pagesize, string radioValue,string quesId) //{ // ExamPaper examPaper = new ExamPaper(); // QuestionBL topicBL = new QuestionBL(); // if (radioValue != null) // { // if(! String.IsNullOrEmpty(quesId)) // if(int.Parse(quesId) > 0 && !String.IsNullOrEmpty(radioValue)) // topicBL.SaveUserAnswer(int.Parse(radioValue), int.Parse(quesId), int.Parse(Session["UserId"].ToString())); // } // int questionCount = int.Parse(ConfigurationManager.AppSettings["QuestionCount"].ToString()); // examPaper = topicBL.GetNextPrevQuestion(int.Parse(pageindex), int.Parse(pagesize), int.Parse(Session["UserId"].ToString())); // examPaper.QuestionEntities = examPaper.QuestionEntities.OrderBy(o => o.Id).ToList(); // return Json(examPaper, JsonRequestBehavior.AllowGet); //} public ExamPaper GetQuestion(string pageindex, string pagesize, string radioValue, string quesId, string currentTime) { ExamPaper examPaper = new ExamPaper(); QuestionBL topicBL = new QuestionBL(); if (radioValue != null && radioValue != String.Empty) { if (!String.IsNullOrEmpty(quesId)) { if (int.Parse(quesId) > 0 && !String.IsNullOrEmpty(radioValue)) { topicBL.SaveUserAnswer(int.Parse(radioValue), int.Parse(quesId), int.Parse(Session["UserId"].ToString()), currentTime); } } } else { ExamBL examBL = new ExamBL(); examBL.UpdateExamTime(int.Parse(Session["UserId"].ToString()), currentTime); } int questionCount = int.Parse(ConfigurationManager.AppSettings["QuestionCount"].ToString()); examPaper = topicBL.GetNextPrevQuestion(int.Parse(pageindex), int.Parse(pagesize), int.Parse(Session["UserId"].ToString())); examPaper.QuestionEntities = examPaper.QuestionEntities.OrderBy(o => o.Id).ToList(); return(examPaper); }
/// <summary> /// 通过Id查询 /// </summary> /// <param name="Id">主键Id</param> /// <returns>ExamPaper实体类对象</returns> public ExamPaper SelectById(int Id) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@ExamPaperId", Id) }; ExamPaper model = new ExamPaper(); using (SqlDataReader dr = DBHelper.RunProcedure("ExamPaper_SelectById", param)) { if (dr.Read()) { model.ExamPaperId = Convert.ToInt32(dr["ExamPaperId"]); if (DBNull.Value != dr["ExamId"]) { model.ExamId = Convert.ToInt32(dr["ExamId"]); } if (DBNull.Value != dr["PaperId"]) { model.PaperId = Convert.ToInt32(dr["PaperId"]); } if (DBNull.Value != dr["OrderIndex"]) { model.OrderIndex = Convert.ToInt32(dr["OrderIndex"]); } model.IsDelete = Convert.ToBoolean(dr["IsDelete"]); } } return(model); }
public ActionResult Exam(string id) { ExamPaper exam = new ExamPaper(); exam.ExamType = id; Session["ExamType"] = id; return(View(exam)); }
/// <summary> /// 增加 /// </summary> /// <param name="ExamPaper">ExamPaper实体对象</param> /// <returns>bool值,判断是否操作成功</returns> public bool Add(ExamPaper model) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@ExamId", model.ExamId), new SqlParameter("@PaperId", model.PaperId), new SqlParameter("@OrderIndex", model.OrderIndex), new SqlParameter("@IsDelete", model.IsDelete) }; return(DBHelper.ExecuteNonQuery("ExamPaper_Add", param)); }
/// <summary> /// 增加 /// </summary> /// <param name="ExamPaper">ExamPaper实体对象</param> /// <returns>int值,返回自增ID</returns> public int AddReturnId(ExamPaper model) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@ExamId", model.ExamId), new SqlParameter("@PaperId", model.PaperId), new SqlParameter("@OrderIndex", model.OrderIndex), new SqlParameter("@IsDelete", model.IsDelete) }; return(Convert.ToInt32(DBHelper.ExecuteScalar("ExamPaper_AddReturnId", param))); }
public async Task <IActionResult> Create([Bind("Id,ExamTitle,SubjectName,SubjectCode,TotalMarks,Instruction,Date")] ExamPaper examPaper) { if (ModelState.IsValid) { _context.Add(examPaper); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(examPaper)); }
public ActionResult QuestionPaper(FormCollection collection, string command) { QuestionBL topicBL = new QuestionBL(); //int questionCount = int.Parse(ConfigurationManager.AppSettings["QuestionCount"].ToString()); ExamPaper examPaper = new ExamPaper(); examPaper = (ExamPaper)Session["QuestionPaper"]; //topicBL.GetQuestionPaper(questionCount); examPaper.QuestionEntities = examPaper.QuestionEntities.OrderBy(o => o.Id).ToList(); // int index = examPaper.QuestionEntities.FindIndex(item => item.IsShown); int rightAnswerIndex = 0; // examPaper.QuestionEntities[0].AnswerEntities.FindIndex(o => o.ID == int.Parse(collection.AllKeys[0])); foreach (AnswerEntities item in examPaper.QuestionEntities[0].AnswerEntities) { if (collection.AllKeys.Length == 2) { if (item.ID == int.Parse(collection.AllKeys[0])) { item.IsUserAnswer = 1; //topicBL.SaveUserAnswer(item.ID, item.IsUserAnswer, int.Parse(Session["UserId"].ToString())); //save userdata break; } } } examPaper.QuestionEntities[0].IsShown = false; if (command == "Next") { if (examPaper.PageIndex < int.Parse(ConfigurationManager.AppSettings["QuestionCount"].ToString())) { examPaper.PageIndex += 1; } } else if (command == "Previous") { if (examPaper.PageIndex <= int.Parse(ConfigurationManager.AppSettings["QuestionCount"].ToString()) && examPaper.PageIndex > 1) { examPaper.PageIndex -= 1; } } examPaper = topicBL.GetNextPrevQuestion(examPaper.PageIndex, examPaper.PageSize, int.Parse(Session["UserId"].ToString())); //Session.Abandon(); Session["QuestionPaper"] = examPaper; return(RedirectToAction("QuestionPaper", "Question")); }
//在TextBox中插入问题和选项文本 public void FillTextBox() { ExamPaper = GeneratePaper(); try { tempQA = ExamPaper.Dequeue(); } catch { MessageBox.Show("试卷生成错误!"); } Score = 0; FillText(); }
public ExamPaper AddExamPaper(ExamPaper examPaper) { var dbExamPaper = new ExamPaper() { Name = examPaper.Name, Url = examPaper.Url, GradeId = examPaper.GradeId == 0 ? 1 : examPaper.GradeId }; _focusDbContext.Add(dbExamPaper); _focusDbContext.SaveChanges(); return(dbExamPaper); }
public JsonResult GetFirstQuestion() { ExamPaper examPaper = new ExamPaper(); QuestionBL topicBL = new QuestionBL(); // i = i + 1; int questionCount = int.Parse(ConfigurationManager.AppSettings["QuestionCount"].ToString()); //examPaper = topicBL.GetQuestionPaper(questionCount); examPaper.QuestionEntities = examPaper.QuestionEntities.OrderBy(o => o.Id).ToList(); examPaper.QuestionEntities[0].IsShown = true; examPaper.QuestionEntities[0].HasAlreadyShown = true; Session["QuestionPaper"] = examPaper; return(Json(examPaper, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 数据访问通过条件查询并分页排序 /// </summary> /// <param name="WhereString">查询条件</param> /// <param name="PageIndex">当前页码</param> /// <param name="PageSize">页大小(每页显示多少条数据)</param> /// <param name="OrderString">排序条件(排序条件为必须参数)</param> /// <returns>ExamPaper实体类对象</returns> public List <ExamPaper> SelectByWhereAndPage(string WhereString, int PageIndex, int PageSize, string OrderString, out int TotalCount) { SqlParameter[] param = new SqlParameter[] { new SqlParameter("@where", WhereString), new SqlParameter("@pageIndex", PageIndex), new SqlParameter("@pageSize", PageSize), new SqlParameter("@orderString", OrderString), new SqlParameter("@TotalCount", ParameterDirection.Output) }; List <ExamPaper> list = new List <ExamPaper>(); ExamPaper model = null; using (SqlDataReader dr = DBHelper.RunProcedure("ExamPaper_SelectByWhereAndPage", param)) { while (dr.Read()) { model = new ExamPaper(); model.ExamPaperId = Convert.ToInt32(dr["ExamPaperId"]); if (DBNull.Value != dr["ExamId"]) { model.ExamId = Convert.ToInt32(dr["ExamId"]); } if (DBNull.Value != dr["PaperId"]) { model.PaperId = Convert.ToInt32(dr["PaperId"]); } if (DBNull.Value != dr["OrderIndex"]) { model.OrderIndex = Convert.ToInt32(dr["OrderIndex"]); } model.IsDelete = Convert.ToBoolean(dr["IsDelete"]); list.Add(model); } if (dr.NextResult() && dr.Read()) { TotalCount = Convert.ToInt32(dr["TotalCount"]); } else { TotalCount = 0; } } return(list); }
public ActionResult OnlineTest(string id) { ExamPaper exam = new ExamPaper(); exam.ExamType = id; Session["ExamType"] = id; if (TempData["exampaper"] != null) { exam = (ExamPaper)TempData["exampaper"]; TempData["exampaper"] = exam; } else { exam = GetQuestion("1", "1", null, null, "60"); TempData["exampaper"] = exam; } return(View(exam)); }
private void buttonNext_Click(object sender, EventArgs e) { if (ExamPaper.Count != 0) { Score += CalScore(); tempQA = ExamPaper.Dequeue(); FillText(); } else { //buttonNext.Text = "交 卷"; Score += CalScore(); MessageBox.Show("您的成绩是" + Convert.ToString(Score) + "分!"); if (SimTest != true) { string str = StudentName + "\t" + StudentID + "\t" + StudentUnitName + "\t" + Score.ToString() + "\t" + DateTime.Now.Date.ToShortDateString() + "\t" + DateTime.Now.ToLongTimeString(); string filePath = Environment.CurrentDirectory + "\\Score.sco"; CSVUtil.WriteCSV(filePath, true, str); } InitParam(); HideControl(); } }
/// <summary> /// 修改 /// </summary> /// <param name="ExamPaper">ExamPaper实体对象</param> /// <returns>bool值,判断是否操作成功</returns> public bool Change(ExamPaper model) { return(dal.Change(model)); }
public int Edit(ExamPaper examPaper) { return examPaperRepository.Edit(examPaper); }
public int Create(ExamPaper examPaper) { return examPaperRepository.Create(examPaper); }
public static void SaveQuestion(ExamPaper examPaper, string name) { FileSettingsHelper <ExamPaper> .SaveSetting(examPaper, Path.Combine(ZibaobaoLibContext.Instance.PersistentStorage.DataPath, name)); }