Skip to content

Commit

Permalink
Use updated lesson data when updating quiz (#2336)
Browse files Browse the repository at this point in the history
* Use live lesson data when updating quiz

Using the `$_POST` data led to inconsistent results after updating to 5.0. This method is tied to `save_post` so the lesson data will be updated by the time it fires.

* Remove dead code in lesson class that was causing another error
  • Loading branch information
jom authored and donnapep committed Nov 22, 2018
1 parent fd46d79 commit 643e949
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions includes/class-sensei-lesson.php
Expand Up @@ -455,11 +455,15 @@ public function quiz_update( $post_id ) {

// Sanitize and setup the post data
$_POST = stripslashes_deep( $_POST );

// Retrieve the update lesson.
$lesson = get_post( $post_id );

if ( isset( $_POST['quiz_id'] ) && ( 0 < absint( $_POST['quiz_id'] ) ) ) {
$quiz_id = absint( $_POST['quiz_id'] );
} // End If Statement
$post_title = esc_html( $_POST['post_title'] );
$post_status = esc_html( $_POST['post_status'] );
$post_title = esc_html( $lesson->post_title );
$post_status = esc_html( $lesson->post_status );
$post_content = '';

// Setup Query Arguments
Expand Down Expand Up @@ -2802,7 +2806,6 @@ public function lesson_save_question( $data = array(), $context = 'quiz' ) {
} // End If Statement

$post_title = $question_text;
$post_author = $data['post_author'];
$post_status = 'publish';
$post_type = 'question';
// Handle the extended question text
Expand Down

0 comments on commit 643e949

Please sign in to comment.