@@ -29,6 +29,8 @@ import Modal from 'react-modal';
2929import 'ace-builds/src-noconflict/mode-java' ;
3030import 'ace-builds/src-noconflict/theme-github' ;
3131
32+ import leftArrow from '../../assets/left-arrow.png' ;
33+
3234const MainWrapper = styled . div `
3335 background-color: #f6f4fc;
3436 position: relative;
@@ -60,11 +62,17 @@ const BoxResult = styled.div`
6062
6163const SubWrapper = styled . div `
6264 display: flex;
65+ align-items: center;
6366
6467 .link {
6568 color: #303030;
6669 text-decoration: none;
6770 }
71+
72+ img {
73+ /* margin-top: -3px; */
74+ margin-right: 10px;
75+ }
6876` ;
6977
7078const Back = styled . p `
@@ -145,6 +153,18 @@ const Padding = styled.div`
145153 padding: 0 20px;
146154` ;
147155
156+ const ScoreResult = styled . p `
157+ font-size: 120%;
158+ font-weight: bold;
159+ margin-top: 20px;
160+ ` ;
161+
162+ const CodeResult = styled . p `
163+ font-family: 'Fira Code', monospace;
164+ font-size: 90%;
165+ color: ${ ( { color } ) => ( color ? color : '#3d3d3d' ) } ;
166+ ` ;
167+
148168// MODAL
149169const ModalClose = styled . div `
150170 width: 20px;
@@ -185,22 +205,6 @@ const Learn = () => {
185205 setIsOpen ( false ) ;
186206 } ;
187207
188- const [ colorAnswer , setColorAnswer ] = useState ( '#3D3D3D' ) ;
189-
190- const runClick = ( ) => {
191- setResult ( `
192- // running tests, tests completed
193- ` ) ;
194- setColorAnswer ( '#39A14A' ) ;
195- } ;
196-
197- const falseClick = ( ) => {
198- setResult ( `
199- // output: jawaban Anda masih belum benar
200- ` ) ;
201- setColorAnswer ( '#F44336' ) ;
202- } ;
203-
204208 const [ code , setCode ] = useState ( `// setup
205209let myArr = [];
206210
@@ -212,15 +216,35 @@ let myArr = [];
212216 setCode ( newValue ) ;
213217 } ;
214218
219+ const [ run , setRun ] = useState ( 0 ) ;
220+ const [ answerDefault , setAnswerDefault ] = useState ( 'block' ) ;
221+ const [ answerFalse , setAnswerFalse ] = useState ( 'none' ) ;
222+ const [ answerTrue , setAnswerTrue ] = useState ( 'none' ) ;
223+
224+ const runClick = ( ) => {
225+ setRun ( run + 1 ) ;
226+ setAnswerDefault ( 'none' ) ;
227+ console . log ( run ) ;
228+ if ( run >= 2 ) {
229+ // setModalForm(true);
230+ setAnswerTrue ( 'block' ) ;
231+ setAnswerFalse ( 'none' ) ;
232+ } else {
233+ // setModalForm(false);
234+ setAnswerFalse ( 'block' ) ;
235+ setAnswerTrue ( 'none' ) ;
236+ }
237+ } ;
238+
215239 return (
216240 < MainWrapper >
217241 < MenuBar />
218242 < ConceptSection >
219243 < SubWrapper >
220- < Topic > Array</ Topic >
221- < Link to = "/learn-topics" className = "link" >
222- < Back > (back to List Topics)</ Back >
244+ < Link to = "/quiz-list" className = "link" >
245+ < img src = { leftArrow } alt = "back" />
223246 </ Link >
247+ < Topic > Array</ Topic >
224248 </ SubWrapper >
225249 < SubTopic > Perkenalan</ SubTopic >
226250 < Text >
@@ -302,13 +326,29 @@ let myArr = [];
302326 />
303327 < ButtonWrapper >
304328 < Button onClick = { runClick } > RUN</ Button >
305- < p onClick = { falseClick } > run</ p >
306329 </ ButtonWrapper >
307330 </ CodeSection >
308331 < ConsoleSection >
309332 < SubTopic > Live Console</ SubTopic >
310- < BoxResult >
333+ { /* <BoxResult>
311334 <CodeText color={colorAnswer}>{result}</CodeText>
335+ </BoxResult> */ }
336+ < BoxResult style = { { display : `${ answerDefault } ` } } >
337+ < CodeResult style = { { color : '#39A14A' } } >
338+ /= Your test output will go here =/
339+ </ CodeResult >
340+ </ BoxResult >
341+ < BoxResult style = { { display : `${ answerTrue } ` } } >
342+ < CodeResult > /== result ==/</ CodeResult >
343+ < CodeResult style = { { color : '#39A14A' } } >
344+ tests completed, your answer is correct
345+ </ CodeResult >
346+ </ BoxResult >
347+ < BoxResult style = { { display : `${ answerFalse } ` , color : '#F44336' } } >
348+ < CodeResult > /== result ==/</ CodeResult >
349+ < CodeResult style = { { color : '#F44336' } } >
350+ sorry, your answer is wrong
351+ </ CodeResult >
312352 </ BoxResult >
313353 < ButtonWrapper >
314354 < Button onClick = { openModal } > SUBMIT</ Button >
0 commit comments