Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5344252

Browse files
committed
User should click OK after 2 wrong answers
1 parent1fa8eee commit5344252

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

‎frontend/src/OutputPrediction.js‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export class OutputPrediction extends Component {
8787
message="Sorry, wrong answer. Try again next time!";
8888
}
8989

90+
constuserFailed=wrongAnswers.length===2;
9091
return<div
9192
className="output-prediction"
9293
style={{
@@ -110,33 +111,40 @@ export class OutputPrediction extends Component {
110111
<CorrectConfettiactive={confettiActive}/>
111112
<div><strong>{message}</strong></div>
112113
<button
113-
style={{opacity:state==="waiting" ?1 :0}}
114+
style={{
115+
opacity:
116+
state==="waiting"||
117+
(state==="showingResult"&&userFailed)
118+
?1 :0
119+
}}
114120
className="btn btn-primary"
115-
disabled={!userChoice}
121+
disabled={!userChoice&&!userFailed}
116122
onClick={()=>{
117-
if(userChoice!==answer){
123+
if(userChoice!==answer&&!userFailed){
118124
bookStatePush("prediction.wrongAnswers",userChoice);
119-
if(wrongAnswers.length===0){
120-
bookSetState("prediction.userChoice",null);
121-
return;
125+
bookSetState("prediction.userChoice",null);
126+
if(wrongAnswers.length===1){
127+
bookSetState("prediction.state","showingResult");
122128
}
129+
return;
123130
}
124131
bookSetState("server",codeResult.state);
125132
scrollToNextStep();
126133
bookSetState("prediction.state","showingResult");
127134
setTimeout(()=>animateScroll.scrollToBottom({
128135
duration:30,
129136
container:terminalRef.current.terminalRoot.current
130-
}))
137+
}));
138+
consttimeToFade=userFailed ?0 :3000;
131139
setTimeout(()=>{
132140
bookSetState("prediction.state","fading");
133141
bookSetState("prediction.height",0);
134142
showCodeResult(codeResult);
135-
},3000);
136-
setTimeout(()=>bookSetState("prediction.state","hidden"),4000);
143+
},timeToFade);
144+
setTimeout(()=>bookSetState("prediction.state","hidden"),timeToFade+1000);
137145
}}
138146
>
139-
Submit
147+
{userFailed ?"OK" :"Submit"}
140148
</button>
141149
</div>
142150
</div>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp