diff --git a/src/main/java/com/dsideal/FengHuang/Exam/Controller/ExamController.java b/src/main/java/com/dsideal/FengHuang/Exam/Controller/ExamController.java index 9d47f22..c683d5d 100644 --- a/src/main/java/com/dsideal/FengHuang/Exam/Controller/ExamController.java +++ b/src/main/java/com/dsideal/FengHuang/Exam/Controller/ExamController.java @@ -75,9 +75,15 @@ public class ExamController extends Controller { * @param order_id */ @Before({GET.class}) - public void getQuestion(int order_id) { + public void getQuestion(int order_id, int finish) { String person_id = getCookie("person_id"); - Record record = em.getQuestion(person_id, order_id); + if (finish == 1 && em.HaveJiaoJuan(person_id) <= 0) { + Kv kv = Kv.by("success", false); + kv.set("message", "你还没有交卷,不能使用此接口!"); + renderJson(kv); + return; + } + Record record = em.getQuestion(person_id, order_id, finish); renderJson(record); } @@ -133,24 +139,6 @@ public class ExamController extends Controller { renderJson(kv); } - /** - * 功能:获取指定题目的信息(交卷后可见) - * - * @param order_id - */ - @Before({GET.class}) - public void getQuestionAfterJiaoJuan(int order_id) { - String person_id = getCookie("person_id"); - if (em.HaveJiaoJuan(person_id) <= 0) { - Kv kv = Kv.by("success", false); - kv.set("message", "你还没有交卷,不能使用此接口!"); - renderJson(kv); - return; - } - Record record = em.getQuestionAfterJiaoJuan(person_id, order_id); - renderJson(record); - } - /** * 功能:查看自己答卷的整体情况,哪个题目答了,哪个题目没有答(交卷后可见) */ diff --git a/src/main/java/com/dsideal/FengHuang/Exam/Model/ExamModel.java b/src/main/java/com/dsideal/FengHuang/Exam/Model/ExamModel.java index 80992f5..646b73d 100644 --- a/src/main/java/com/dsideal/FengHuang/Exam/Model/ExamModel.java +++ b/src/main/java/com/dsideal/FengHuang/Exam/Model/ExamModel.java @@ -141,13 +141,13 @@ public class ExamModel { * * @param order_id */ - public Record getQuestion(String person_id, int order_id) { + public Record getQuestion(String person_id, int order_id, int finish) { String sql = "select question_id,reply from t_exam_record where person_id=? and order_id=?"; Record r = Db.findFirst(sql, person_id, order_id); int question_id = r.getInt("question_id"); String reply = r.getStr("reply"); - sql = "select t1.question_id,t1.type_id,t1.content,t1.A,t1.B,t1.C,t1.D,t1.E,t1.F,t1.G,t1.score,t2.type_name from t_exam_question as t1 inner join t_exam_question_type as t2 on t1.type_id=t2.type_id where t1.question_id=?"; + sql = "select t1.question_id,t1.type_id,t1.content,t1.answer,t1.memo,t1.A,t1.B,t1.C,t1.D,t1.E,t1.F,t1.G,t1.score,t2.type_name from t_exam_question as t1 inner join t_exam_question_type as t2 on t1.type_id=t2.type_id where t1.question_id=?"; Record record = Db.findFirst(sql, question_id); JSONArray array = new JSONArray(); @@ -172,7 +172,21 @@ public class ExamModel { record.remove("F"); record.remove("G"); + //是否正确的标识 + String answer = record.getStr("answer"); + if (StrKit.isBlank(reply)) record.set("flag", 0); + else if (answer.equals(reply)) { + record.set("flag", 1); + } else record.set("flag", 2); + + //是不是交卷前查阅 + if (finish == 0) { + record.remove("answer"); + record.remove("memo"); + } + //选项 record.set("xuanxiang", array); + //题号 record.set("order_id", order_id); return record; } @@ -205,16 +219,6 @@ public class ExamModel { return Db.findFirst(sql, person_id).getInt("count"); } - /** - * 功能:获取指定题目的信息(交卷后可见)+答案 - * - * @param order_id - */ - public Record getQuestionAfterJiaoJuan(String person_id, int order_id) { - String sql = "select question_id from t_exam_record where person_id=? and order_id=?"; - int question_id = Db.findFirst(sql, person_id, order_id).getInt("question_id"); - return Db.findById("t_exam_question", "question_id", question_id); - } /** * 功能:查看自己答卷的整体情况,哪个题目答对,哪个题目没有答,哪些答错(交卷后可见)