|
|
@@ -0,0 +1,72 @@
|
|
|
+package com.njuzr.eaibackend.vo;
|
|
|
+
|
|
|
+import com.njuzr.eaibackend.po.BehaviorRecord;
|
|
|
+import lombok.Data;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 单次行为记录 VO,在原始记录基础上附加统计字段
|
|
|
+ */
|
|
|
+@Data
|
|
|
+public class BehaviorRecordItemVO {
|
|
|
+
|
|
|
+ private String id;
|
|
|
+ private Long studentId;
|
|
|
+ private Long assignmentId;
|
|
|
+ private Date createdAt;
|
|
|
+ private List<BehaviorRecord.BehaviorEvent> events;
|
|
|
+
|
|
|
+ // 统计字段
|
|
|
+ private Integer insertCount; // 插入操作次数
|
|
|
+ private Integer deleteCount; // 删除操作次数
|
|
|
+ private Integer copyCount; // 复制操作次数
|
|
|
+ private Integer copyCharacterCount; // 复制字符总数
|
|
|
+ private Integer longPauseCount; // 长暂停次数(>2000ms)
|
|
|
+
|
|
|
+ public static BehaviorRecordItemVO from(BehaviorRecord record) {
|
|
|
+ BehaviorRecordItemVO vo = new BehaviorRecordItemVO();
|
|
|
+ vo.setId(record.getId());
|
|
|
+ vo.setStudentId(record.getStudentId());
|
|
|
+ vo.setAssignmentId(record.getAssignmentId());
|
|
|
+ vo.setCreatedAt(record.getCreatedAt());
|
|
|
+ vo.setEvents(record.getEvents());
|
|
|
+
|
|
|
+ List<BehaviorRecord.BehaviorEvent> events = record.getEvents();
|
|
|
+ if (events == null || events.isEmpty()) {
|
|
|
+ vo.setInsertCount(0);
|
|
|
+ vo.setDeleteCount(0);
|
|
|
+ vo.setCopyCount(0);
|
|
|
+ vo.setCopyCharacterCount(0);
|
|
|
+ vo.setLongPauseCount(0);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ int insertCount = 0, deleteCount = 0, copyCount = 0,
|
|
|
+ copyCharacterCount = 0, longPauseCount = 0;
|
|
|
+
|
|
|
+ for (BehaviorRecord.BehaviorEvent e : events) {
|
|
|
+ String type = e.getType();
|
|
|
+ if (type == null) continue;
|
|
|
+ switch (type) {
|
|
|
+ case "insert" -> insertCount++;
|
|
|
+ case "delete" -> deleteCount++;
|
|
|
+ case "copy" -> {
|
|
|
+ copyCount++;
|
|
|
+ if (e.getInsert() != null) copyCharacterCount += e.getInsert().length();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (e.getPauseTime() != null && e.getPauseTime() > 2000) {
|
|
|
+ longPauseCount++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vo.setInsertCount(insertCount);
|
|
|
+ vo.setDeleteCount(deleteCount);
|
|
|
+ vo.setCopyCount(copyCount);
|
|
|
+ vo.setCopyCharacterCount(copyCharacterCount);
|
|
|
+ vo.setLongPauseCount(longPauseCount);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+}
|