zoukankan      html  css  js  c++  java
  • 笔试考试系统-参加考试的验证、历史错题集、考试管理、实时监控

    今日任务:

    1、参加考试的验证

    1.1页面效果:

    如果该校区/机构未开放次考试模式,则给与相应提示,并且不能进入考试页面。

    1.2核心代码:

    前台ajax请求

    <script type="text/javascript">
    function gotoIndex(types) {
    var id = $("#PaperLibrary").val();
    $.ajax({
    type: "post",
    url: "/Exam/CheckPaperDetails",
    dataType: "json",
    data: { "id": id ,"types":types},
    success: function (result) {
    if (result.states != 0) {
    alert(result.t);
    }
    else {
    if (types == 1) {
    window.top.location.href = "/Exam/ExamIndex/" + id;
    }
    else if (types == 2) {
    window.top.location.href = "/Exam/Index/" + id;
    } else {
    window.top.location.href = "/Exam/ExamTest/" + id;
    }
    }
    }
    })

    }

    </script>

    controller核心代码:

    /// <summary>
    /// 进入考试界面验证是否有资格加入考试
    /// </summary>
    /// <param name="id">卷库编号</param>
    /// <param name="types">考试类型</param>
    /// <returns></returns>
    public ActionResult CheckPaperDetails(int id, int types)
    {
    OnLineExamDB db = new OnLineExamDB();
    if (types == 2)
    {
    //1:该校区/机构未设置该模式 2:该校区/机构未到考试开放时间 3:该校区/机构模式未设置任何考试科目
    //获取卷库、专业,查询到要生成的试卷规则,根据规则生成试卷并添加到表中、显示在页面
    StuInfo stu = System.Web.HttpContext.Current.Session["StuInfo"] as StuInfo;
    if (stu == null)
    {
    return RedirectToAction("/Exam/UserCenter");
    }

    List<PaperLibraryDetail> pdlist = db.PaperLibraryDetail.ToList();
    if (pdlist == null)
    {
    return Json(new { t = "该校区/机构未设置该模式", states = 1 });
    }
    PaperLibraryDetail p = pdlist.First(a => a.major_Id == stu.major_Id && a.PaperLibrary_Id == id && a.exam_Type == 2);
    DateTime? typeTime = p.beginTime;
    TimeSpan tbegin = Convert.ToDateTime(typeTime).TimeOfDay;
    TimeSpan tend = Convert.ToDateTime(typeTime).AddHours(1).TimeOfDay;
    TimeSpan tnow = DateTime.Now.TimeOfDay;
    if (tnow < tbegin && tnow > tend)
    {
    return Json(new { t = "该校区/机构未到考试开放时间", states = 2 });
    }
    List<PaperLibraryDetailCourse> pc = db.PaperLibraryDetailCourse.Where(a => a.Detail_Id == p.Detail_Id).ToList();
    if (pc.Count <= 0)
    {
    return Json(new { t = "该校区/机构的随机试题模式未设置任何考试科目", states = 3 });
    }
    }
    else if (types == 1)
    {

    List<PaperLibraryDetail> pdlist = db.PaperLibraryDetail.ToList();
    if (pdlist == null)
    {
    return Json(new { t = "该校区/机构未设置该模式", states = 1 });
    }
    StuInfo stu = System.Web.HttpContext.Current.Session["StuInfo"] as StuInfo;
    List<Paper> list = db.Paper.Where(a => a.status == 1 && a.PaperLibrary_Id == id).ToList();
    if (list.Count <= 0)
    {
    return Json(new { t = "没有任何试题,请联系管理员添加试题!", states = 3 });
    }
    PaperLibraryDetail p = pdlist.First(a => a.major_Id == stu.major_Id && a.PaperLibrary_Id == id && a.exam_Type == 2);
    DateTime? typeTime = p.beginTime;
    TimeSpan tbegin = Convert.ToDateTime(typeTime).TimeOfDay;
    TimeSpan tend = Convert.ToDateTime(typeTime).AddHours(1).TimeOfDay;
    TimeSpan tnow = DateTime.Now.TimeOfDay;
    if (tnow < tbegin && tnow > tend)
    {
    return Json(new { t = "该校区/机构未到考试开放时间", states = 2 });
    }
    }
    return Json(new { t = "正常", states = 0 });

    }

    2、历史错题集

    2.1页面效果

     2.2核心代码

    /// <summary>
    /// 历史错题集
    /// </summary>
    /// <returns></returns>
    public ActionResult ErrorList()
    {
    using (OnLineExamDB db = new OnLineExamDB())
    {
    StuInfo stu = System.Web.HttpContext.Current.Session["StuInfo"] as StuInfo;
    var list = from a in db.ScoreInfo
    from b in db.Paper
    from c in db.QuestionBank
    where a.result == 2 && b.stu_Id == stu.stu_Id && c.question_Id == b.question_Id && a.paper_Id == b.paper_Id
    select new {
    a,
    b,
    c
    };
    List<ErrorQuestionModel> resultlist = new List<ErrorQuestionModel>();
    foreach (var item in list)
    {
    ErrorQuestionModel errorquestion = new ErrorQuestionModel();
    errorquestion.paper_Id =Convert.ToInt32(item.a.paper_Id);
    errorquestion.answer_Owner = item.a.answer_Owner;
    errorquestion.createTime = item.a.createTime;
    errorquestion.question_Title = item.c.question_Title;
    errorquestion.question_Id = item.b.question_Id;
    errorquestion.question_Option1 = item.c.question_Option1;
    errorquestion.question_Option2 = item.c.question_Option2;
    errorquestion.question_Option3 = item.c.question_Option3;
    errorquestion.question_Option4 = item.c.question_Option4;
    errorquestion.result = item.a.result;
    errorquestion.rightAnswer = item.c.rightAnswer;
    resultlist.Add(errorquestion);
    }
    return View(resultlist);
    }
    }

    3、考试管理

    3.1页面效果

     3.2核心代码

    /// <summary>
    /// 考试管理列表页
    /// </summary>
    /// <returns></returns>
    public ActionResult ExamManager()
    {
    using (OnLineExamDB db = new OnLineExamDB())
    {
    List<StudentListModel> list = db.StuInfo.Where(a => a.Status != 2).Select(a => new StudentListModel
    {
    stu_Id = a.stu_Id,
    stu_No = a.stu_No,
    stu_Name = a.stu_Name,
    password = a.password,
    LoginTimes = a.LoginTimes,
    LoginDate = a.LoginDate,
    Status = a.Status,
    ClassName = a.ClassName,
    Institution_Name = a.Institution.i_Name,
    major_Name = a.major.major_Name
    }).ToList();
    return View(list);
    }
    }
    /// <summary>
    /// 修改考生状态-视图
    /// </summary>
    /// <param name="id">主键编号</param>
    /// <returns></returns>
    public ActionResult UpdateExamState(int id)
    {
    using (OnLineExamDB db = new OnLineExamDB())
    {
    UpdateStudentModel model = db.StuInfo.Where(a => a.stu_Id == id).Select(a => new UpdateStudentModel
    {
    institution_Id = a.institution_Id,
    stu_Id = a.stu_Id,
    LoginDate = a.LoginDate,
    LoginTimes = a.LoginTimes,
    password = a.password,
    Status = a.Status,
    stu_Name = a.stu_Name,
    stu_No = a.stu_No,
    major_Id = a.major_Id,
    ClassName=a.ClassName
    }).FirstOrDefault();
    ViewBag.Institution = GetInstitutionForDDL();
    ViewBag.Major = GetMajorForDDL();
    return View(model);
    }
    }
    /// <summary>
    /// 修改考生状态-实现功能
    /// </summary>
    /// <param name="model">学生信息</param>
    /// <returns></returns>
    [HttpPost]
    public ActionResult UpdateExamState(UpdateStudentModel model)
    {
    using (OnLineExamDB db = new OnLineExamDB())
    {
    StuInfo stu = db.StuInfo.First(a => a.stu_Id == model.stu_Id);
    stu.Status = model.Status;
    db.SaveChanges();
    ViewBag.Major = GetMajorForDDL();
    return RedirectToAction("ExamManager");
    }
    }

    4、实施监控

    为防止学生考试期间出现作弊行为,禁止学生操作复制粘贴功能,禁止右键操作

    4.1核心代码:

    //禁用右键、复制粘贴
    document.oncontextmenu = new Function("event.returnValue=false");
    document.onselectstart = new Function("event.returnValue=false");

    5、燃尽图

  • 相关阅读:
    HDU3336 Count the string —— KMP next数组
    CodeForces
    51Nod 1627 瞬间移动 —— 组合数学
    51Nod 1158 全是1的最大子矩阵 —— 预处理 + 暴力枚举 or 单调栈
    51Nod 1225 余数之和 —— 分区枚举
    51Nod 1084 矩阵取数问题 V2 —— 最小费用最大流 or 多线程DP
    51Nod 机器人走方格 V3 —— 卡特兰数、Lucas定理
    51Nod XOR key —— 区间最大异或值 可持久化字典树
    HDU4825 Xor Sum —— Trie树
    51Nod 1515 明辨是非 —— 并查集 + 启发式合并
  • 原文地址:https://www.cnblogs.com/chengyp/p/13492072.html
Copyright © 2011-2022 走看看