|
|
@@ -86,7 +86,12 @@ export class RedisService {
|
|
|
answer: Answer
|
|
|
) {
|
|
|
const key = `exam:${roomId}:answers:${userId}:${questionId}`;
|
|
|
- await this.client.hset(key, 'data', JSON.stringify(answer));
|
|
|
+ // 确保username字段被正确存储
|
|
|
+ const answerWithUsername = {
|
|
|
+ ...answer,
|
|
|
+ username: answer.username || ''
|
|
|
+ };
|
|
|
+ await this.client.hset(key, 'data', JSON.stringify(answerWithUsername));
|
|
|
// 设置过期时间,30天
|
|
|
await this.client.expire(key, 30 * 24 * 60 * 60);
|
|
|
}
|