Skip to content

Commit

Permalink
fix: crash on judge when correct answer is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
zrll12 committed Dec 9, 2024
1 parent d090afc commit 6eaba98
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/service/score.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ impl score::Model {
continue;
};
let user_answer = user_answer.as_str().unwrap();

if user_answer.is_empty() || correct_answer.answer.is_empty() {
continue;
}

let score = match question.r#type {
QuestionType::Text | QuestionType::SingleChoice => {
Expand All @@ -64,16 +68,11 @@ impl score::Model {
}
}

info!("{}", user_answer.len() == correct_answer.len());

if flag_wrong {
info!("flag_wrong");
0
} else if user_answer.len() == correct_answer.len() {
info!("all");
all
} else {
info!("{} {}", sub, all);
sub
}
}
Expand Down

0 comments on commit 6eaba98

Please sign in to comment.