Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added error message to graphs #107

Closed
Closed
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
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;
}


Loading