Skip to content

Commit

Permalink
added error message to graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAmaia committed May 25, 2024
1 parent 6d9b166 commit ed69f7f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/components/shared/Exercises/GraphInput.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//import { useState } from 'react';
//import { useState } from 'react';
import { useState } from 'react';
import '../../../styles/Exercises/GraphInput.scss';

interface GraphQuestionData {
Expand Down Expand Up @@ -105,14 +105,25 @@ function GraphInput({
//console.log(i);
if (!i) {
//console.log(`${i} is incorrect`);
//setWrong(true);
setWrong(true);
return;
}
}
//console.log('all right!');
nextExercise();

};

function wrongMessage(isWrong: boolean) {
if (isWrong) {
return "That's not quite right. Try again!";
} else {
return;
}
}

const [wrong, setWrong] = useState(false);

const makeLine = (
data: GraphLineData,
setCorrect: (id: number, value: boolean) => void
Expand All @@ -128,6 +139,9 @@ function GraphInput({
<div id="graphinput-question-box">
{questionArray.map((x) => makeLine(x, setValueCorrect))}
</div>
<div className="graphinput-wrong-box">
<h3 id="graphinput-check-wrong">&nbsp;{wrongMessage(wrong)}&nbsp;</h3>
</div>
<div id="graphinput-check-button-container">
<button id="graphinput-check-button" onClick={checkCorrect}>
Check
Expand Down
20 changes: 18 additions & 2 deletions src/styles/Exercises/GraphInput.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#graphinput-check-question {
@include font-styles();
margin-bottom: 2vh;
//margin-top: -20px;
}

#graphinput-question {
Expand All @@ -24,7 +25,7 @@
margin-bottom: 2vh;
margin-left: 0;
margin-right: auto;
margin-top: 150px;
margin-top: 210px;
padding-left: 8%;
}

Expand Down Expand Up @@ -78,7 +79,9 @@

#graphinput-check-button-container {
align-self: center;
padding-top: 4vh;
//position: relative;
padding-bottom: 5vh
//padding-top: 4vh;
}

#graphinput-check-button {
Expand All @@ -89,3 +92,16 @@
color: colors.$text-white;
padding: 1.25vw 2.5vw;
}


#graphinput-check-wrong {
@include font-styles();
color: red;

}

.graphinput-wrong-box {
align-self: center;
}


0 comments on commit ed69f7f

Please sign in to comment.