Skip to content

Commit

Permalink
update answer checker
Browse files Browse the repository at this point in the history
strips out whitespace at the beginning and end of answers
  • Loading branch information
SethClydesdale committed Apr 30, 2024
1 parent b1901ab commit f466943
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions resources/javascript/genki.js
Original file line number Diff line number Diff line change
Expand Up @@ -1814,12 +1814,12 @@
for (; i < j; i++) {
correct = false;
data = input[i].dataset;
val = Genki.toHalfWidth(input[i].value).toLowerCase().replace(/。|、|\,|\./g, '');
val = Genki.toHalfWidth(input[i].value).toLowerCase().replace(/。|、|\,|\.|^\s+|\s+$|\n/g, '');

// check for the correct answer
for (k in data) {
if (/answer/.test(k)) {
answer = Genki.toHalfWidth(data[k]).toLowerCase().replace(/。|、|\,|\./g, '');
answer = Genki.toHalfWidth(data[k]).toLowerCase().replace(/。|、|\,|\.|^\s+|\s+$|\n/g, '');

// check if there's alternative answers in the answer
// alternative answers are given as %(alt1/alt2/etc.)
Expand Down
2 changes: 1 addition & 1 deletion resources/javascript/genki.min.js

Large diffs are not rendered by default.

0 comments on commit f466943

Please sign in to comment.