From 278b820b00652189e34fa4bf471a120fe78b43ee Mon Sep 17 00:00:00 2001 From: Ruben Ramirez Date: Thu, 3 Apr 2025 23:18:13 -0500 Subject: [PATCH] feat: Add points field and credit cost to Question Management UI --- functions.php | 8 ++++++++ template-manage-questions.php | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/functions.php b/functions.php index 6d15aa2..a1445e9 100644 --- a/functions.php +++ b/functions.php @@ -312,6 +312,7 @@ function quiztech_ajax_get_question() { 'type' => $question_type, 'options' => $options_string, 'category' => $category_id, + 'points' => get_post_meta( $question_id, '_quiztech_question_points', true ), // Add points ] ); } add_action( 'wp_ajax_quiztech_get_question', 'quiztech_ajax_get_question' ); @@ -400,6 +401,13 @@ function quiztech_ajax_save_question() { wp_set_post_terms( $new_or_updated_post_id, [], 'quiztech_category', false ); // Remove terms if none selected } + // Update Question Points meta + $points = isset( $_POST['question_points'] ) ? absint( $_POST['question_points'] ) : 1; // Default to 1 if not set or invalid + update_post_meta( $new_or_updated_post_id, '_quiztech_question_points', $points ); + + // Set Credit Cost meta (always 3 for user-generated questions as per requirement) + update_post_meta( $new_or_updated_post_id, '_quiztech_credit_cost', 3 ); + // --- Prepare Success Response --- // Optionally, generate HTML for the updated/new table row to send back // For simplicity now, just send success and let JS reload or handle update diff --git a/template-manage-questions.php b/template-manage-questions.php index 04c199c..7d96728 100644 --- a/template-manage-questions.php +++ b/template-manage-questions.php @@ -43,6 +43,8 @@ get_header(); ?>