Skip to content

Commit

Permalink
update: fib
Browse files Browse the repository at this point in the history
  • Loading branch information
daonham committed Mar 31, 2022
1 parent 6aba156 commit 8c80bd5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class QuestionFillInBlanks extends QuestionBase {
};

convertInputField = ( option ) => {
const { answered, isReviewing, showCorrectReview, isCheckedAnswer, resultQuestions } = this.props;
const { answered, isReviewing, showCorrectReview, isCheckedAnswer } = this.props;

let title = option.title;

Expand All @@ -94,15 +94,8 @@ class QuestionFillInBlanks extends QuestionBase {

const answerID = answers ? answers?.[ id ] : undefined;

let clx = '';
if ( answerID || isReviewing ) { // If is answered,
if ( isCheckedAnswer ) {
clx = answerID?.isCorrect ? 'correct' : 'fail';
}
if ( isReviewing ) {
clx = resultQuestions?.correct ? 'correct' : 'fail';
}
elContent += `<span class="lp-fib-answered ${ clx }">`;
if ( answerID || isReviewing ) {
elContent += `<span class="lp-fib-answered ${ ( showCorrectReview || isCheckedAnswer ) && answerID?.correct ? ( answerID?.isCorrect ? 'correct' : 'fail' ) : '' }">`;

if ( ! answerID?.isCorrect ) {
elContent += `<span class="lp-fib-answered__answer">${ answered?.[ id ] ?? '' }</span>`;
Expand Down
1 change: 0 additions & 1 deletion assets/src/apps/js/frontend/question-types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ export default compose(
keyPressed: getData( 'keyPressed' ),
showCorrectReview: getData( 'showCorrectReview' ),
isReviewing: getData( 'mode' ) === 'reviewing',
resultQuestions: getData( 'results' ).questions?.[ id ],
};
} ),
withDispatch( () => {
Expand Down
4 changes: 3 additions & 1 deletion inc/user-item/class-lp-user-item-quiz.php
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ public function calculate_quiz_result( array $answered = array() ): array {
$result['question_count'] = count( $question_ids );
$result['time_spend'] = $this->get_time_interval( 'display' );
$result['passing_grade'] = $quiz->get_passing_grade();
$checked_questions = $this->get_checked_questions();

foreach ( $question_ids as $question_id ) {
$question = LP_Question::get_question( $question_id );
Expand Down Expand Up @@ -551,11 +552,12 @@ public function calculate_quiz_result( array $answered = array() ): array {

$can_review_quiz = get_post_meta( $quiz->get_id(), '_lp_review', true ) === 'yes';
if ( $can_review_quiz && ! array_key_exists( 'instant_check', $answered ) ) {

$result['questions'][ $question_id ]['explanation'] = $question->get_explanation();
$result['questions'][ $question_id ]['options'] = learn_press_get_question_options_for_js(
$question,
array(
'include_is_true' => get_post_meta( $quiz->get_id(), '_lp_show_correct_review', true ) === 'yes',
'include_is_true' => in_array( $question_id, $checked_questions ) || get_post_meta( $quiz->get_id(), '_lp_show_correct_review', true ) === 'yes',
'answer' => $answered[ $question_id ] ?? '',
)
);
Expand Down

0 comments on commit 8c80bd5

Please sign in to comment.