Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/routes/geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ const generators = {
},
check(body) {
const userNum = parseFloat((body.userAnswer || '').replace(/\s+/g, ''));
const correct = !isNaN(userNum) && Math.abs(userNum - body.answer) < 0.5;
const correct = !isNaN(userNum) && Math.round(userNum * 100) === Math.round(body.answer * 100);
return { correct, display: body.display, message: correct ? 'Correct!' : 'Incorrect' };
},
},
Expand Down
4 changes: 2 additions & 2 deletions server/routes/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ const generators = {
const rn = ansNum / g; const rd = ansDen / g;
answer = rd === 1 ? rn : Math.round((rn / rd) * 100) / 100;
display = answer + ' km/h';
prompt = `A cyclist rides ${d1} km at ${s1} km/h then ${d2} km at ${s2} km/h. Find the average speed (to 2 d.p. if needed).`;
prompt = `A cyclist rides ${d1} km at ${s1} km/h then ${d2} km at ${s2} km/h. Find the average speed. Give your answer correct to 2 decimal places.`;
} else {
const ms = randInt(5, 30);
answer = Math.round(ms * 3.6 * 100) / 100; display = answer + ' km/h';
Expand All @@ -1191,7 +1191,7 @@ const generators = {
},
check(body) {
const ua = parseFloat((body.userAnswer || '').replace(/[^\d.\-\/]/g, ''));
const correct = !isNaN(ua) && Math.abs(ua - body.answer) < 0.05;
const correct = !isNaN(ua) && Math.round(ua * 100) === Math.round(body.answer * 100);
return { correct, display: body.display, message: correct ? 'Correct!' : 'Incorrect' };
},
},
Expand Down
Loading