更新json

This commit is contained in:
luying
2020-10-27 19:19:41 +08:00
parent c25f95942c
commit db040b2438
32 changed files with 30130 additions and 32362 deletions
@@ -40,8 +40,7 @@ export class EventBattleHandler {
}
let { status, type, eventId: dataEventId, question } = event;
let flag = checkEventStatus(type, status);
if(!flag) {
if(status != EVENT_RECORD_STATUS.WAITING) {
return resResult(STATUS.EVENT_STATUS_ERROR);
}
if(dataEventId != eventId) {
@@ -51,7 +50,24 @@ export class EventBattleHandler {
if(!curQuestion) return resResult(STATUS.EVENT_QUESTION_NOT_FOUND);
let {isCorrect, answerNo} = checkQuiz(questionId, answer);
await EventRecordModel.saveEventAnswer(eventCode, questionId, isCorrect?EVENT_ANSWER_STATUS.CORRECT:EVENT_ANSWER_STATUS.WRONG);
let result = await EventRecordModel.saveEventAnswer(eventCode, questionId, isCorrect?EVENT_ANSWER_STATUS.CORRECT:EVENT_ANSWER_STATUS.WRONG);
if(!result) {
return resResult(STATUS.EVENT_RECORD_NOT_FOUND);
}
let { question: newQuestion } = result;
let isClear = true, allCorrect = true;
for(let {status} of newQuestion) {
if(status) {
if(status == EVENT_ANSWER_STATUS.WRONG) {
allCorrect = false;
}
}else {
isClear = false; allCorrect = false;
}
}
if(isClear) {
await EventRecordModel.setStatusByCode(roleId, eventCode, allCorrect?EVENT_RECORD_STATUS.BATTLE_SUCCESS:EVENT_RECORD_STATUS.BATTLE_FAIL);
}
return resResult(STATUS.SUCCESS, { eventCode, eventId, questionId, isCorrect, answerNo });
}