From 6942e7de77a56c1f91733fc658588ca5d5f7a25b Mon Sep 17 00:00:00 2001 From: Ruben Ramirez Date: Thu, 3 Apr 2025 22:26:54 -0500 Subject: [PATCH] feat: Implement basic Assessment and Question Management UI templates --- template-manage-assessments.php | 60 ++++++++++- template-manage-questions.php | 186 +++++++++++++++++++++++++++++++- 2 files changed, 236 insertions(+), 10 deletions(-) diff --git a/template-manage-assessments.php b/template-manage-assessments.php index 8cd144c..2dcf46a 100644 --- a/template-manage-assessments.php +++ b/template-manage-assessments.php @@ -8,9 +8,10 @@ */ // Ensure the user is logged in and has the appropriate capability. -// Using 'manage_options' as a placeholder capability for Quiz Managers. -// Replace with a more specific capability like 'manage_quiztech_assessments' if defined. -if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) { +// Capability required to manage assessments. +$required_capability = 'edit_assessments'; // Corresponds to 'assessment' CPT capability_type + +if ( ! is_user_logged_in() || ! current_user_can( $required_capability ) ) { // Redirect to login page or show an error message. wp_safe_redirect( wp_login_url( get_permalink() ) ); exit; @@ -18,6 +19,10 @@ if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) { // wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'quiztech' ), 403 ); } +// Get the URL for the Assessment Builder page +$builder_page = get_page_by_path( 'assessment-builder' ); // Assuming 'assessment-builder' is the slug +$builder_url = $builder_page ? get_permalink( $builder_page->ID ) : ''; + get_header(); ?>
@@ -29,8 +34,53 @@ get_header(); ?>
-

- + + +

+ +

+ + +

+ + 'assessment', + 'post_status' => 'publish', // Or 'any' if you want drafts etc. + 'posts_per_page' => -1, // Show all + 'orderby' => 'title', + 'order' => 'ASC', + ); + $assessments_query = new WP_Query( $args ); + ?> + + have_posts() ) : ?> + + + + + + + + + have_posts() ) : $assessments_query->the_post(); ?> + + + + + + +
+ + + + +
+ + +

+ +
diff --git a/template-manage-questions.php b/template-manage-questions.php index e3f8fe4..009bdfc 100644 --- a/template-manage-questions.php +++ b/template-manage-questions.php @@ -8,9 +8,10 @@ */ // Ensure the user is logged in and has the appropriate capability. -// Using 'manage_options' as a placeholder capability for Quiz Managers. -// Replace with a more specific capability like 'manage_quiztech_questions' if defined. -if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) { +// Capability required to manage questions. +$required_capability = 'edit_questions'; // Corresponds to 'question' CPT capability_type + +if ( ! is_user_logged_in() || ! current_user_can( $required_capability ) ) { // Redirect to login page or show an error message. wp_safe_redirect( wp_login_url( get_permalink() ) ); exit; @@ -18,6 +19,14 @@ if ( ! is_user_logged_in() || ! current_user_can( 'manage_options' ) ) { // wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'quiztech' ), 403 ); } +// Define available question types (should ideally come from a central config or helper) +$question_types = array( + 'multiple-choice' => __( 'Multiple Choice', 'quiztech' ), + 'true-false' => __( 'True/False', 'quiztech' ), + 'short-answer' => __( 'Short Answer', 'quiztech' ), + // Add other types as needed +); + get_header(); ?>
@@ -29,8 +38,175 @@ get_header(); ?>
-

- + +

+ + + +

+ + 'question', + 'post_status' => 'publish', // Or 'any' + 'posts_per_page' => 20, // Add pagination later + 'orderby' => 'title', + 'order' => 'ASC', + ); + $questions_query = new WP_Query( $args ); + ?> + + have_posts() ) : ?> + + + + + + + + + + + have_posts() ) : $questions_query->the_post(); ?> + name ) : __( 'N/A', 'quiztech' ); + ?> + + + + + + + + +
+ + + +
+ + + +

+ + + +