quiztech-assessment-platform/quiztech-assessment-platform.php
Ruben Ramirez 130b9eefb9 feat: Implement front-end assessment interaction AJAX flow
- Add AssessmentAjaxHandler class for AJAX requests.
- Add assessment.js for front-end logic.
- Implement pre-screening form submission via AJAX.
- Implement answer auto-save via AJAX.
- Implement final assessment submission via AJAX.
- Update assessment-shell.php template for dynamic rendering and JS hooks.
- Enqueue and localize assessment.js conditionally.

Refs: assessment_interaction_plan.md
Note: Includes TODOs for evaluation CPT handling, status updates, and sanitization.
2025-04-03 16:02:16 -05:00

129 lines
No EOL
4.1 KiB
PHP

<?php
/**
* Plugin Name: Quiztech Assessment Platform
* Plugin URI: https://quiztech.com/
* Description: A platform for creating assessments, inviting applicants, and managing results.
* Version: 0.1.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Your Name / Company Name
* Author URI: https://yourwebsite.com/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: quiztech
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! \defined( 'WPINC' ) ) {
die;
}
/**
* Define constants
*/
\define( 'QUIZTECH_VERSION', '0.1.0' );
\define( 'QUIZTECH_PLUGIN_DIR', \plugin_dir_path( __FILE__ ) );
\define( 'QUIZTECH_PLUGIN_URL', \plugin_dir_url( __FILE__ ) );
\define( 'QUIZTECH_PLUGIN_FILE', __FILE__ );
/**
* Load Composer autoloader.
*/
require_once __DIR__ . '/vendor/autoload.php';
/**
* Load plugin dependencies. (Now handled by autoloading)
*/
// require_once QUIZTECH_PLUGIN_DIR . 'includes/post-types.php'; // Autoloaded
// require_once QUIZTECH_PLUGIN_DIR . 'includes/taxonomies.php'; // Autoloaded
// require_once QUIZTECH_PLUGIN_DIR . 'includes/roles.php'; // Autoloaded
/**
* The core plugin class that is used to define internationalization,
* admin-specific hooks, and public-facing site hooks.
*/
// require plugin_dir_path( __FILE__ ) . 'includes/class-quiztech.php';
/**
* Begins execution of the plugin.
*
* Since everything within the plugin is registered via hooks,
* then kicking off the plugin from this point in the file does
* not affect the page life cycle.
*
* @since 0.1.0
*/
function run_quiztech() {
// $plugin = new Quiztech();
// $plugin->run();
}
// run_quiztech();
// Placeholder for activation/deactivation hooks
\register_activation_hook( __FILE__, __NAMESPACE__ . '\activate_quiztech' );
\register_deactivation_hook( __FILE__, __NAMESPACE__ . '\deactivate_quiztech' );
/**
* The code that runs during plugin activation.
* This action is documented in includes/class-quiztech-activator.php
*/
function activate_quiztech() {
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
$table_name = $wpdb->prefix . 'quiztech_invitations';
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
token varchar(32) NOT NULL,
job_id bigint(20) unsigned NOT NULL,
assessment_id bigint(20) unsigned NOT NULL,
applicant_email varchar(255) NOT NULL,
status varchar(20) NOT NULL DEFAULT 'pending', -- e.g., pending, viewed, completed, expired
created_timestamp datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
expiry_timestamp datetime DEFAULT NULL, -- Optional expiry
PRIMARY KEY (id),
UNIQUE KEY token (token),
KEY job_id (job_id),
KEY assessment_id (assessment_id),
KEY applicant_email (applicant_email(191)), -- Index prefix for potential long emails
KEY status (status)
) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
\dbDelta( $sql );
// Call the namespaced function for roles
\Quiztech\AssessmentPlatform\Includes\quiztech_add_roles_and_capabilities();
\flush_rewrite_rules(); // Ensure rewrite rules are updated for CPTs/taxonomies
}
/**
* The code that runs during plugin deactivation.
* This action is documented in includes/class-quiztech-deactivator.php
*/
function deactivate_quiztech() {
// Call the namespaced function
\Quiztech\AssessmentPlatform\Includes\quiztech_remove_roles_and_capabilities();
\flush_rewrite_rules(); // Clean up rewrite rules
}
/**
* Initialize the plugin's features.
*/
function quiztech_init() {
// Initialize frontend handler for invitation links
$frontend_handler = new \Quiztech\AssessmentPlatform\Includes\FrontendHandler();
$frontend_handler->init_hooks();
// Initialize AJAX handler for assessment interactions
\Quiztech\AssessmentPlatform\Includes\Ajax\AssessmentAjaxHandler::init();
// TODO: Instantiate other core classes and call their init methods here
// e.g., Admin menu handler, AJAX handlers, Shortcode handlers etc.
}
add_action( 'plugins_loaded', 'quiztech_init' );
?>
?>