quiztech_theme/template-assessment-builder.php

92 lines
No EOL
4.7 KiB
PHP

<?php
/**
* Template Name: Assessment Builder
*
* This template is used for the page where Quiz Managers can build and edit Assessments.
*
* @package Quiztech
*/
// 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' ) ) {
// Redirect to login page or show an error message.
wp_safe_redirect( wp_login_url( get_permalink() ) );
exit;
// Alternatively, display an error message:
// wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'quiztech' ), 403 );
}
get_header(); ?>
<div id="primary" class="content-area quiztech-assessment-builder-area">
<main id="main" class="site-main">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="entry-content">
<div id="assessment-builder-container" style="display: flex; gap: 20px;">
<!-- Left Pane: Question Library -->
<div id="assessment-builder-library" style="flex: 1; border: 1px solid #ccc; padding: 15px;">
<h2><?php esc_html_e( 'Question Library', 'quiztech' ); ?></h2>
<p><?php esc_html_e( 'Search/filter controls will go here.', 'quiztech' ); ?></p>
<div id="library-questions-list">
<?php esc_html_e( 'Questions will be loaded here via AJAX.', 'quiztech' ); ?>
<!-- Example Question Item Structure (for planning)
<div class="library-question-item" data-question-id="123">
<strong>Question Title</strong> (Type: Multiple Choice) [Cost: 1 credit]
<button class="add-question-to-assessment">Add</button>
</div>
-->
</div>
<hr>
<h3><?php esc_html_e( 'Create New Question', 'quiztech' ); ?></h3>
<p><?php esc_html_e( 'Form for creating a new question will go here.', 'quiztech' ); ?></p>
</div>
<!-- Right Pane: Current Assessment -->
<div id="assessment-builder-current" style="flex: 2; border: 1px solid #ccc; padding: 15px;">
<h2><?php esc_html_e( 'Current Assessment', 'quiztech' ); ?></h2>
<p>
<label for="assessment-title"><?php esc_html_e( 'Assessment Title:', 'quiztech' ); ?></label><br>
<input type="text" id="assessment-title" name="assessment_title" style="width: 100%;">
</p>
<div id="current-assessment-questions">
<h3><?php esc_html_e( 'Selected Questions', 'quiztech' ); ?></h3>
<?php esc_html_e( 'Questions added from the library will appear here.', 'quiztech' ); ?>
<!-- Example Selected Question Item Structure (for planning)
<div class="selected-question-item" data-question-id="123">
<strong>Question Title</strong> (Type: Multiple Choice) [Cost: 1 credit]
<button class="remove-question-from-assessment">Remove</button>
</div>
-->
</div>
<hr>
<div id="assessment-summary">
<strong><?php esc_html_e( 'Total Estimated Cost:', 'quiztech' ); ?></strong>
<span id="assessment-total-cost">0</span> <?php esc_html_e( 'credits', 'quiztech' ); ?>
</div>
<p>
<button id="save-assessment-button" class="button button-primary"><?php esc_html_e( 'Save Assessment', 'quiztech' ); ?></button>
<span class="spinner" style="float: none; vertical-align: middle;"></span>
<span id="save-status" style="margin-left: 10px;"></span>
</p>
</div>
</div><!-- #assessment-builder-container -->
</div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_footer();