Skip to content

Commit 5e082af

Browse files
committed
don't set score to 0 if question already shows the answer
1 parent 35bcf86 commit 5e082af

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

client/src/App.tsx

+6-3
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ const App: React.FC = () => {
118118
};
119119

120120
const handleViewSolution = (e: React.MouseEvent<HTMLAnchorElement>) => {
121-
// set the score to 0 - you aren't allowed any help
122-
setUseScore(0);
123121

124122
// Get question ID
125123
const questionId = Number(e.currentTarget.id);
@@ -129,10 +127,15 @@ const App: React.FC = () => {
129127
let solution = problemList.problems[questionId].solution;
130128
let solutionsToShow = [...showSolution];
131129

130+
// if the solution has not been shown before, set the score to 0
131+
if (solutionsToShow[questionId] === "") {
132+
// set the score to 0 - you aren't allowed any help
133+
setUseScore(0);
134+
}
135+
132136
// if the solution is an error, show that we can take "Error" or "ValueError"
133137
console.log('solution', solution);
134138
if (solution === '"ValueError slice step cannot be zero"') {
135-
console.log('hit');
136139
solution += ' - Error or ValueError are the accepted answers';
137140
}
138141
solutionsToShow[questionId] = solution;

0 commit comments

Comments
 (0)