← All changes
|
assets/src/apps/js/frontend/quiz/components/buttons/button-check.js
+17
-3
4.1.7
→
4.4.10
View file →
| @@ -16,8 +16,23 @@ | ||
| 16 | 16 | |
| 17 | 17 | checkAnswer = () => { |
| 18 | 18 | const { checkAnswer, question, answered } = this.props; |
| 19 | 19 | |
| 20 | + // Fix temporary for FIB. | |
| 21 | + if ( question.type === 'fill_in_blanks' ) { | |
| 22 | + const elFIB = document.querySelector( `.question-fill_in_blanks[data-id="${ question.id }"]` ); | |
| 23 | + const elInputs = elFIB.querySelectorAll( '.lp-fib-input > input' ); | |
| 24 | + elInputs.forEach( ( elInput ) => { | |
| 25 | + if ( elInput.value.length > 0 ) { | |
| 26 | + this.setState( { | |
| 27 | + loading: true, | |
| 28 | + } ); | |
| 29 | + checkAnswer( question.id ); | |
| 30 | + return false; | |
| 31 | + } | |
| 32 | + } ); | |
| 33 | + } | |
| 34 | + | |
| 20 | 35 | if ( answered ) { |
| 21 | 36 | checkAnswer( question.id ); |
| 22 | 37 | |
| 23 | 38 | this.setState( { |
| @@ -32,16 +47,15 @@ | ||
| 32 | 47 | return ( |
| 33 | 48 | <> |
| 34 | 49 | <button className={ classNames( 'lp-button', 'instant-check', { |
| 35 | 50 | loading: this.state.loading, |
| 36 | - disable: ! answered, | |
| 37 | 51 | } ) } onClick={ this.checkAnswer } |
| 38 | 52 | > |
| 39 | 53 | <span className="instant-check__icon" /> |
| 40 | - { __( 'Check answer', 'learnpress' ) } | |
| 54 | + { __( 'Check answers', 'learnpress' ) } | |
| 41 | 55 | |
| 42 | 56 | { ! answered && ( |
| 43 | - <div className="instant-check__info" dangerouslySetInnerHTML={ { __html: __( 'You need to answer the question before check answer.', 'learnpress' ) } } /> | |
| 57 | + <div className="instant-check__info" dangerouslySetInnerHTML={ { __html: __( 'You need to answer the question before checking the answer key.', 'learnpress' ) } } /> | |
| 44 | 58 | ) } |
| 45 | 59 | </button> |
| 46 | 60 | </> |
| 47 | 61 | ); |