Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion classes/QuizBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public function prepare_answer_data( $question_id, $question_type, $input, $data
$answer_title = Input::sanitize( wp_slash( $input['answer_title'] ) ?? '', '' );
$is_correct = Input::sanitize( $input['is_correct'] ?? 0, 0, Input::TYPE_INT );
$image_id = Input::sanitize( $input['image_id'] ?? null );
$image_id = empty( $image_id ) ? null : (int) $image_id;
// Let the hook handle special cases (e.g. draw_image, pin_image) and return a normalized value (URL).
$answer_two_gap_match_raw = isset( $input['answer_two_gap_match'] ) ? wp_unslash( $input['answer_two_gap_match'] ) : '';
$answer_two_gap_match_raw = apply_filters(
Expand Down Expand Up @@ -170,7 +171,14 @@ public function save_question_answers( $question_id, $question_type, $question_a

// New answer.
if ( self::FLAG_NEW === $data_status ) {
$wpdb->insert( $answers_table, $answer_data );
// Filter out null values to use database column defaults.
$insert_data = array_filter(
$answer_data,
function ( $value ) {
return null !== $value;
}
);
$wpdb->insert( $answers_table, $insert_data );
$answer_id = $wpdb->insert_id;
}

Expand Down