Skip to content

Commit

Permalink
fix bug where all multiple choice options did not show up in admin an…
Browse files Browse the repository at this point in the history
…d frontend
  • Loading branch information
dwainm committed Sep 29, 2015
1 parent 9d5ae35 commit 98a32a3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
29 changes: 18 additions & 11 deletions classes/class-woothemes-sensei-lesson.php
Original file line number Diff line number Diff line change
Expand Up @@ -1411,17 +1411,24 @@ public function quiz_panel_question_field( $question_type = '', $question_id = 0
$total_wrong = 1;
}

// Setup Wrong Answer HTML
for ( $i = 0; $i < $total_wrong; $i++ ) {
if ( !isset( $wrong_answers[ $i ] ) ) { $wrong_answers[ $i ] = ''; }
$answer_id = $this->get_answer_id( $wrong_answers[ $i ] );
$wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) . '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i . '" name="question_wrong_answers[]" value="' . esc_attr( $wrong_answers[ $i ] ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
if( $question_id ) {
$answers[ $answer_id ] = $wrong_answer;
} else {
$answers[] = $wrong_answer;
}
}
// Setup Wrong Answer HTML
foreach ( $wrong_answers as $i => $answer ){

$answer_id = $this->get_answer_id( $answer );
$wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ;
$wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ;
$wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
if( $question_id ) {

$answers[ $answer_id ] = $wrong_answer;

} else {

$answers[] = $wrong_answer;

}

} // end for each

$answers_sorted = $answers;
if( $question_id && count( $answer_order ) > 0 ) {
Expand Down
6 changes: 4 additions & 2 deletions templates/single-quiz/question_type-multiple-choice.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@

}

} // end if $answer_order_string
}else{
$answers_sorted = $question_answers;
} // end if $answer_order_string

}
} // end if random order

$question_grade = get_post_meta( $question_id, '_question_grade', true );
if( ! $question_grade || $question_grade == '' ) {
Expand Down

0 comments on commit 98a32a3

Please sign in to comment.