main
黄海 2 years ago
parent bce7b7efe1
commit f96aee6f0a

@ -105,21 +105,15 @@ public class OpenGaussReplicationToKafka {
Init();
// 删除槽
// DeleteSlot(slotName);
// 创建槽
// CreateSlot(slotName);
// 查看槽
//ListSlot();
// TruncateTable();
//插入测试数据
// InsertTestData();
//获取最后的读取偏移位置
String lsn = GetRestartLsn(slotName);

@ -58,6 +58,7 @@ public class ExamModel {
//3、创建当前人员的试题
// 目前的思路是单选题,判断题,多选题的顺序来进行题目的随机化处理
//单选25, 多选15,判断10
sql = "select type_id from t_exam_question group by type_id order by type_id";
List<Record> listTypeCnt = Db.find(sql);
@ -70,9 +71,15 @@ public class ExamModel {
// 调用shuffle方法进行随机化打乱
Collections.shuffle(tmpList);
//此题型需要抽取的数量
sql = "select count from t_exam_question_type where type_id=?";
int count = Db.findFirst(sql, type_id).getInt("count");
//批量存
List<Record> writeList = new ArrayList<>();
int c = 0;
for (Record r1 : tmpList) {
c++;
Record rExam = new Record();
rExam.set("person_id", person_id);
rExam.set("order_id", ++order_id);
@ -81,6 +88,7 @@ public class ExamModel {
rExam.set("answer", r1.getStr("answer"));
rExam.set("score", r1.getInt("score"));
writeList.add(rExam);
if (c == count) break;
}
Db.batchSave("t_exam_record", writeList, 100);
}
@ -162,30 +170,30 @@ public class ExamModel {
int question_id = r.getInt("question_id");
String reply = r.getStr("reply");
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=?";
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();
for (char x = 'A'; x <= 'F'; x++) {
for (char x = 'a'; x <= 'f'; x++) {
if (!StrKit.isBlank(record.getStr(String.valueOf(x)))) {
JSONObject jo = new JSONObject();
jo.put("key", String.valueOf(x));
jo.put("key", String.valueOf(x).toUpperCase());
jo.put("value", record.getStr(String.valueOf(x)));
boolean flag = true;
if (StrKit.isBlank(reply)) flag = false;
else if (reply.indexOf(x) < 0) flag = false;
else if (reply.toLowerCase().indexOf(x) < 0) flag = false;
jo.put("checked", flag);
array.add(jo);
}
}
record.remove("A");
record.remove("B");
record.remove("C");
record.remove("D");
record.remove("E");
record.remove("F");
record.remove("G");
record.remove("a");
record.remove("b");
record.remove("c");
record.remove("d");
record.remove("e");
record.remove("f");
record.remove("g");
//是否正确的标识
String answer = record.getStr("answer");

Loading…
Cancel
Save