Initial plugin version

This commit is contained in:
Ruben Ramirez 2025-04-03 13:05:41 -05:00
commit 3a0cdb3ef1
21 changed files with 1922 additions and 0 deletions

20
composer.json Normal file
View file

@ -0,0 +1,20 @@
{
"name": "quiztech/assessment-platform",
"description": "Quiztech Assessment Platform WordPress Plugin",
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "Your Name/Company Name",
"email": "your-email@example.com"
}
],
"require": {
"php": ">=7.4"
},
"autoload": {
"psr-4": {
"Quiztech\\AssessmentPlatform\\": "src/"
}
}
}

20
composer.lock generated Normal file
View file

@ -0,0 +1,20 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "5179ff615eb5c35d6f4a82c9ea72e8ee",
"packages": [],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": ">=7.4"
},
"platform-dev": {},
"plugin-api-version": "2.6.0"
}

View file

@ -0,0 +1,88 @@
<?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() {
// Call the namespaced function
\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
}
?>

View file

@ -0,0 +1,80 @@
<?php
namespace Quiztech\AssessmentPlatform\Gateways;
/**
* Handles Stripe payment gateway interactions.
*/
class StripeGateway {
/**
* Initiate a payment process via Stripe (e.g., create Checkout Session).
*
* @param int $user_id The ID of the user making the purchase.
* @param string $item_id Identifier for the credit pack or item.
* @param int $quantity Quantity being purchased.
* @param array $metadata Additional data to pass to Stripe.
* @return mixed Stripe Session ID, redirect URL, or WP_Error on failure.
*/
public function initiatePayment( $user_id, $item_id, $quantity = 1, $metadata = [] ) {
// Placeholder for Stripe payment initiation logic
// 1. Get item details (price, name) based on $item_id
// 2. Format line items for Stripe Checkout
// 3. Set success/cancel URLs
// 4. Call Stripe API to create a Checkout Session
// 5. Return session ID or redirect URL
\error_log('Stripe Payment Initiation Called - Placeholder');
// Example error return:
// return new \WP_Error('stripe_error', 'Failed to create Stripe session.');
return false; // Placeholder
}
/**
* Handle incoming Stripe webhooks.
*
* @param array $payload The webhook payload (usually from file_get_contents('php://input')).
* @param string $signature The value of the Stripe-Signature header.
* @return bool True if handled successfully, false otherwise.
*/
public function handleWebhook( $payload, $signature ) {
// Placeholder for Stripe webhook handling logic
// 1. Verify the webhook signature using the endpoint secret.
// 2. Parse the event object from the payload.
// 3. Handle specific event types (e.g., 'checkout.session.completed').
// 4. If payment successful:
// - Extract relevant data (user_id from metadata, transaction_id, credits_purchased).
// - Call \Quiztech\AssessmentPlatform\Includes\quiztech_process_successful_payment().
// 5. Return appropriate response to Stripe (e.g., 200 OK).
\error_log('Stripe Webhook Handler Called - Placeholder');
// Example event handling structure:
// $event = null;
// try {
// $event = \Stripe\Webhook::constructEvent(
// $payload, $signature, 'YOUR_STRIPE_WEBHOOK_SECRET'
// );
// } catch(\UnexpectedValueException $e) {
// // Invalid payload
// \error_log('Stripe Webhook Error: Invalid payload.');
// return false;
// } catch(\Stripe\Exception\SignatureVerificationException $e) {
// // Invalid signature
// \error_log('Stripe Webhook Error: Invalid signature.');
// return false;
// }
// // Handle the event
// switch ($event->type) {
// case 'checkout.session.completed':
// $session = $event->data->object;
// // Extract data and call quiztech_process_successful_payment...
// break;
// // ... handle other event types
// default:
// \error_log('Received unknown Stripe event type ' . $event->type);
// }
return true; // Placeholder
}
}

162
src/Includes/credits.php Normal file
View file

@ -0,0 +1,162 @@
<?php
namespace Quiztech\AssessmentPlatform\Includes;
/**
* File for handling the credit system logic.
*
* @package Quiztech
*/
// If this file is called directly, abort.
if ( ! \defined( 'WPINC' ) ) {
\die;
}
/**
* Get the credit balance for a specific user.
* Defaults to 0 if no balance is found.
*
* @param int $user_id The ID of the user.
* @return int The user's credit balance.
*/
function quiztech_get_user_credit_balance( $user_id ) {
if ( ! $user_id ) {
return 0;
}
// Using user meta to store balance as decided initially.
$balance = \get_user_meta( $user_id, '_quiztech_credit_balance', true );
return $balance ? (int) $balance : 0;
}
/**
* Update the credit balance for a specific user.
* Can handle adding or subtracting credits.
*
* @param int $user_id The ID of the user.
* @param int $amount The amount to change the balance by (positive to add, negative to subtract).
* @param string $transaction_type Optional description of the transaction (e.g., 'purchase', 'invite_sent').
* @return bool|int False on failure, new balance on success.
*/
function quiztech_update_user_credit_balance( $user_id, $amount, $transaction_type = '' ) {
if ( ! $user_id || ! is_numeric( $amount ) ) {
return false;
}
$current_balance = quiztech_get_user_credit_balance( $user_id );
$new_balance = $current_balance + (int) $amount;
// Prevent balance from going below zero unless specifically allowed later.
if ( $new_balance < 0 ) {
// For now, just prevent negative balances. Could throw an error or return false later.
$new_balance = 0;
// Maybe return false here to indicate failure if deduction wasn't possible?
// For now, let's just cap at 0 and let the calling function check.
}
$updated = \update_user_meta( $user_id, '_quiztech_credit_balance', $new_balance );
if ( $updated ) {
// Optional: Hook for logging transactions if needed later
// do_action('quiztech_credit_transaction', $user_id, $amount, $new_balance, $transaction_type);
return $new_balance;
}
return false;
}
/**
* Calculate the total credit cost of an assessment.
* Sums the 'credit_cost' meta of all associated questions.
*
* @param int $assessment_id The ID of the assessment post.
* @return int The total credit cost.
*/
function quiztech_calculate_assessment_cost( $assessment_id ) {
if ( ! $assessment_id ) {
return 0;
}
// TODO: Get the array of question IDs associated with the assessment (from post meta).
$question_ids = \get_post_meta( $assessment_id, '_quiztech_question_ids', true ); // Assuming meta key '_quiztech_question_ids'
$question_ids = \is_array( $question_ids ) ? $question_ids : array();
$total_cost = 0;
foreach ( $question_ids as $question_id ) {
// TODO: Get the 'credit_cost' meta for each question.
$cost = \get_post_meta( $question_id, '_quiztech_credit_cost', true ); // Assuming meta key '_quiztech_credit_cost'
$total_cost += $cost ? (int) $cost : 0;
}
return $total_cost;
}
/**
* Hook to update the assessment's total credit cost whenever it's saved.
*
* @param int $post_id The post ID.
* @param WP_Post $post The post object.
* @param bool $update Whether this is an existing post being updated or not.
*/
function quiztech_update_assessment_cost_on_save( $post_id, $post, $update ) {
if ( \defined( 'DOING_AUTOSAVE' ) && \DOING_AUTOSAVE ) {
return;
}
if ( \wp_is_post_revision( $post_id ) ) {
return;
}
if ( 'assessment' !== $post->post_type ) {
return;
}
$total_cost = quiztech_calculate_assessment_cost( $post_id );
\update_post_meta( $post_id, '_quiztech_total_credits', $total_cost ); // Assuming meta key '_quiztech_total_credits'
}
\add_action( 'save_post', __NAMESPACE__ . '\quiztech_update_assessment_cost_on_save', 10, 3 );
/**
* Deduct credits when an invitation is sent for a specific job/assessment.
* Checks if the user has enough credits before deducting.
*
* @param int $user_id The ID of the user sending the invite (Quiz Manager).
* @param int $job_id The ID of the job post.
* @return bool True on successful deduction, false otherwise (e.g., insufficient funds).
*/
function quiztech_deduct_credits_for_invite( $user_id, $job_id ) {
if ( ! $user_id || ! $job_id ) {
return false;
}
// TODO: Get the assessment ID associated with the job.
$assessment_id = \get_post_meta( $job_id, '_quiztech_assessment_id', true ); // Assuming meta key '_quiztech_assessment_id'
if ( ! $assessment_id ) {
// No assessment assigned to the job.
return false; // Or maybe true if invites are free without an assessment? Decide later.
}
// TODO: Get the required credits (should be stored on assessment meta).
$required_credits = \get_post_meta( $assessment_id, '_quiztech_total_credits', true );
$required_credits = $required_credits ? (int) $required_credits : 0;
if ( $required_credits <= 0 ) {
// Assessment costs nothing, allow sending.
return true;
}
$current_balance = quiztech_get_user_credit_balance( $user_id );
if ( $current_balance < $required_credits ) {
// Insufficient funds.
// TODO: Maybe set a transient for an admin notice?
return false;
}
// Deduct credits.
$new_balance = quiztech_update_user_credit_balance( $user_id, -$required_credits, 'invite_sent_job_' . $job_id );
// Check if update was successful (didn't return false)
return ( false !== $new_balance );
}
?>

123
src/Includes/payments.php Normal file
View file

@ -0,0 +1,123 @@
<?php
namespace Quiztech\AssessmentPlatform\Includes;
use Quiztech\AssessmentPlatform\Gateways\StripeGateway;
/**
* File for handling payment integration logic.
*
* @package Quiztech
*/
// If this file is called directly, abort.
if ( ! \defined( 'WPINC' ) ) {
\die;
}
/**
* Initiate the credit purchase process.
* This would typically be called via an AJAX handler or form submission.
* It should interact with the chosen payment gateway handler.
*
* @param int $user_id The ID of the user making the purchase.
* @param string $item_id Identifier for the credit pack or item being purchased.
* @param int $quantity The quantity being purchased.
* @return mixed Gateway-specific response (e.g., redirect URL, session ID) or WP_Error on failure.
*/
function quiztech_initiate_credit_purchase( $user_id, $item_id, $quantity = 1 ) {
// TODO: Validate input ($user_id, $item_id, $quantity)
// TODO: Get details about the item (price, credits amount) based on $item_id
// TODO: Determine active payment gateway (e.g., Stripe from settings). For now, assume Stripe.
$active_gateway = 'stripe'; // Replace with dynamic logic later
if ( 'stripe' === $active_gateway ) {
$gateway = new StripeGateway();
// TODO: Pass necessary metadata (e.g., item details for Stripe session)
$result = $gateway->initiatePayment( $user_id, $item_id, $quantity );
return $result; // Return whatever the gateway method returns (e.g., session ID, URL, WP_Error)
}
// If no active or supported gateway found
return new \WP_Error( 'no_gateway', \__( 'No active or supported payment gateway configured.', 'quiztech' ) );
}
/**
* Handle incoming payment gateway webhooks.
* This needs to be registered as a REST endpoint or admin-ajax handler.
*/
function quiztech_handle_payment_webhook() {
// TODO: Identify the gateway from the request (e.g., URL parameter, request header). Assume Stripe for now.
$gateway_slug = 'stripe'; // Replace with dynamic logic later
if ( 'stripe' === $gateway_slug ) {
$payload = @file_get_contents('php://input');
$signature = isset($_SERVER['HTTP_STRIPE_SIGNATURE']) ? $_SERVER['HTTP_STRIPE_SIGNATURE'] : '';
if ( empty($payload) || empty($signature) ) {
\wp_send_json_error( 'Missing payload or signature for Stripe webhook.', 400 );
return; // Exit
}
$gateway = new StripeGateway();
$handled = $gateway->handleWebhook( $payload, $signature );
if ( $handled ) {
// The handleWebhook method should call quiztech_process_successful_payment internally if needed.
\wp_send_json_success( 'Webhook processed.', 200 );
} else {
\wp_send_json_error( 'Stripe webhook verification or processing failed.', 400 );
}
return; // Exit
}
// Handle other gateways or errors if no matching gateway found
\wp_send_json_error( 'Invalid or unsupported webhook request.', 400 );
}
// TODO: Register quiztech_handle_payment_webhook as a REST endpoint or AJAX action.
// Example REST endpoint registration:
// add_action( 'rest_api_init', function () {
// register_rest_route( 'quiztech/v1', '/webhook/payment', array(
// 'methods' => 'POST',
// 'callback' => 'quiztech_handle_payment_webhook',
// 'permission_callback' => '__return_true' // IMPORTANT: Implement proper permission checks!
// ) );
// } );
/**
* Process a successful payment notification from a gateway webhook.
* This function is typically called *by* the gateway-specific webhook handler.
*
* @param int $user_id The user ID who made the purchase.
* @param int $credits_purchased The number of credits purchased.
* @param string $transaction_id The gateway's transaction ID.
* @param string $gateway_slug Slug of the gateway (e.g., 'stripe').
* @return bool True on success, false on failure.
*/
function quiztech_process_successful_payment( $user_id, $credits_purchased, $transaction_id, $gateway_slug ) {
if ( ! $user_id || ! $credits_purchased > 0 || empty( $transaction_id ) || empty( $gateway_slug ) ) {
// Log error: Invalid data received for payment processing.
return false;
}
// TODO: Add checks to prevent processing the same transaction ID multiple times.
// Update the user's credit balance
$result = quiztech_update_user_credit_balance(
$user_id,
(int) $credits_purchased,
\sprintf( '%s_purchase_%s', $gateway_slug, $transaction_id )
);
if ( false !== $result ) {
// Optional: Log successful transaction details somewhere (custom table?)
// Optional: Send purchase confirmation email to user
// do_action('quiztech_credits_purchased', $user_id, $credits_purchased, $transaction_id, $gateway_slug);
return true;
} else {
// Log error: Failed to update credit balance for user $user_id after successful payment $transaction_id.
return false;
}
}
?>

175
src/Includes/post-types.php Normal file
View file

@ -0,0 +1,175 @@
<?php
namespace Quiztech\AssessmentPlatform\Includes;
/**
* File for registering Custom Post Types.
*
* @package Quiztech
*/
// If this file is called directly, abort.
if ( ! \defined( 'WPINC' ) ) {
\die;
}
/**
* Register Custom Post Types used by the Quiztech plugin.
*/
function quiztech_register_post_types() {
// Question CPT
$question_labels = array(
'name' => \_x( 'Questions', 'Post type general name', 'quiztech' ),
'singular_name' => \_x( 'Question', 'Post type singular name', 'quiztech' ),
'menu_name' => \_x( 'Questions', 'Admin Menu text', 'quiztech' ),
'name_admin_bar' => \_x( 'Question', 'Add New on Toolbar', 'quiztech' ),
'add_new' => \__( 'Add New', 'quiztech' ),
'add_new_item' => \__( 'Add New Question', 'quiztech' ),
'new_item' => \__( 'New Question', 'quiztech' ),
'edit_item' => \__( 'Edit Question', 'quiztech' ),
'view_item' => \__( 'View Question', 'quiztech' ),
'all_items' => \__( 'All Questions', 'quiztech' ),
'search_items' => \__( 'Search Questions', 'quiztech' ),
'parent_item_colon' => \__( 'Parent Questions:', 'quiztech' ),
'not_found' => \__( 'No questions found.', 'quiztech' ),
'not_found_in_trash' => \__( 'No questions found in Trash.', 'quiztech' ),
'featured_image' => \_x( 'Question Cover Image', 'Overrides the “Featured Image” phrase for this post type. Added in 4.3', 'quiztech' ),
'set_featured_image' => \_x( 'Set cover image', 'Overrides the “Set featured image” phrase for this post type. Added in 4.3', 'quiztech' ),
'remove_featured_image' => \_x( 'Remove cover image', 'Overrides the “Remove featured image” phrase for this post type. Added in 4.3', 'quiztech' ),
'use_featured_image' => \_x( 'Use as cover image', 'Overrides the “Use as featured image” phrase for this post type. Added in 4.3', 'quiztech' ),
'archives' => \_x( 'Question archives', 'The post type archive label used in nav menus. Default “Post Archives”. Added in 4.4', 'quiztech' ),
'insert_into_item' => \_x( 'Insert into question', 'Overrides the “Insert into post”/”Insert into page” phrase (used when inserting media into a post). Added in 4.4', 'quiztech' ),
'uploaded_to_this_item' => \_x( 'Uploaded to this question', 'Overrides the “Uploaded to this post”/”Uploaded to this page” phrase (used when viewing media attached to a post). Added in 4.4', 'quiztech' ),
'filter_items_list' => \_x( 'Filter questions list', 'Screen reader text for the filter links heading on the post type listing screen. Default “Filter posts list”/”Filter pages list”. Added in 4.4', 'quiztech' ),
'items_list_navigation' => \_x( 'Questions list navigation', 'Screen reader text for the pagination heading on the post type listing screen. Default “Posts list navigation”/”Pages list navigation”. Added in 4.4', 'quiztech' ),
'items_list' => \_x( 'Questions list', 'Screen reader text for the items list heading on the post type listing screen. Default “Posts list”/”Pages list”. Added in 4.4', 'quiztech' ),
);
$question_args = array(
'labels' => $question_labels,
'public' => true, // Accessible in admin and potentially theme/API
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'question' ),
'capability_type' => 'post', // Consider custom capabilities later
'has_archive' => false, // No archive page for individual questions
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'custom-fields' ), // Title = Question text, Editor = Description/Context
'show_in_rest' => true, // Enable Gutenberg/REST API support
'menu_icon' => 'dashicons-editor-help',
);
\register_post_type( 'question', $question_args );
// Assessment CPT
$assessment_labels = array(
'name' => \_x( 'Assessments', 'Post type general name', 'quiztech' ),
'singular_name' => \_x( 'Assessment', 'Post type singular name', 'quiztech' ),
'menu_name' => \_x( 'Assessments', 'Admin Menu text', 'quiztech' ),
'name_admin_bar' => \_x( 'Assessment', 'Add New on Toolbar', 'quiztech' ),
'add_new' => \__( 'Add New', 'quiztech' ),
'add_new_item' => \__( 'Add New Assessment', 'quiztech' ),
'new_item' => \__( 'New Assessment', 'quiztech' ),
'edit_item' => \__( 'Edit Assessment', 'quiztech' ),
'view_item' => \__( 'View Assessment', 'quiztech' ),
'all_items' => \__( 'All Assessments', 'quiztech' ),
'search_items' => \__( 'Search Assessments', 'quiztech' ),
'parent_item_colon' => \__( 'Parent Assessments:', 'quiztech' ),
'not_found' => \__( 'No assessments found.', 'quiztech' ),
'not_found_in_trash' => \__( 'No assessments found in Trash.', 'quiztech' ),
// ... other labels similar to Question ...
);
$assessment_args = array(
'labels' => $assessment_labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'assessment' ),
'capability_type' => 'post',
'has_archive' => true, // Maybe an archive page listing available assessments?
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'custom-fields' ), // Title = Assessment Name, Editor = Description
'show_in_rest' => true,
'menu_icon' => 'dashicons-forms',
);
\register_post_type( 'assessment', $assessment_args );
// Job CPT
$job_labels = array(
'name' => \_x( 'Jobs', 'Post type general name', 'quiztech' ),
'singular_name' => \_x( 'Job', 'Post type singular name', 'quiztech' ),
'menu_name' => \_x( 'Jobs', 'Admin Menu text', 'quiztech' ),
'name_admin_bar' => \_x( 'Job', 'Add New on Toolbar', 'quiztech' ),
'add_new' => \__( 'Add New', 'quiztech' ),
'add_new_item' => \__( 'Add New Job', 'quiztech' ),
'new_item' => \__( 'New Job', 'quiztech' ),
'edit_item' => \__( 'Edit Job', 'quiztech' ),
'view_item' => \__( 'View Job', 'quiztech' ),
'all_items' => \__( 'All Jobs', 'quiztech' ),
'search_items' => \__( 'Search Jobs', 'quiztech' ),
'parent_item_colon' => \__( 'Parent Jobs:', 'quiztech' ),
'not_found' => \__( 'No jobs found.', 'quiztech' ),
'not_found_in_trash' => \__( 'No jobs found in Trash.', 'quiztech' ),
// ... other labels similar to Question ...
);
$job_args = array(
'labels' => $job_labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'job' ),
'capability_type' => 'post',
'has_archive' => true, // Archive page listing jobs makes sense
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'custom-fields' ), // Title = Job Title, Editor = Job Description
'show_in_rest' => true,
'menu_icon' => 'dashicons-businessman',
);
\register_post_type( 'job', $job_args );
// User Evaluation CPT
$evaluation_labels = array(
'name' => \_x( 'User Evaluations', 'Post type general name', 'quiztech' ),
'singular_name' => \_x( 'User Evaluation', 'Post type singular name', 'quiztech' ),
'menu_name' => \_x( 'User Evaluations', 'Admin Menu text', 'quiztech' ),
'name_admin_bar' => \_x( 'User Evaluation', 'Add New on Toolbar', 'quiztech' ),
'add_new' => \__( 'Add New', 'quiztech' ),
'add_new_item' => \__( 'Add New Evaluation', 'quiztech' ),
'new_item' => \__( 'New Evaluation', 'quiztech' ),
'edit_item' => \__( 'Edit Evaluation', 'quiztech' ),
'view_item' => \__( 'View Evaluation', 'quiztech' ),
'all_items' => \__( 'All Evaluations', 'quiztech' ),
'search_items' => \__( 'Search Evaluations', 'quiztech' ),
'parent_item_colon' => \__( 'Parent Evaluations:', 'quiztech' ),
'not_found' => \__( 'No evaluations found.', 'quiztech' ),
'not_found_in_trash' => \__( 'No evaluations found in Trash.', 'quiztech' ),
// ... other labels similar to Question ...
);
$evaluation_args = array(
'labels' => $evaluation_labels,
'public' => false, // Evaluations should not be public facing
'publicly_queryable' => false, // Not queryable from front-end URLs
'show_ui' => true, // Show in admin UI / custom backend
'show_in_menu' => true, // Show in admin menu (maybe under Jobs or Assessments later?)
'query_var' => false, // No query var needed
'rewrite' => false, // No rewrite rules needed
'capability_type' => 'post', // Use post capabilities for now, refine later
'has_archive' => false, // No archive page
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'custom-fields' ), // Title could be "Applicant Email - Job Title", no editor needed
'show_in_rest' => true, // Allow access via REST API for custom backend/reporting
'menu_icon' => 'dashicons-clipboard',
);
\register_post_type( 'user_evaluation', $evaluation_args );
}
\add_action( 'init', __NAMESPACE__ . '\quiztech_register_post_types' );
?>

66
src/Includes/roles.php Normal file
View file

@ -0,0 +1,66 @@
<?php
namespace Quiztech\AssessmentPlatform\Includes;
/**
* File for defining user roles and capabilities.
*
* @package Quiztech
*/
// If this file is called directly, abort.
if ( ! \defined( 'WPINC' ) ) {
\die;
}
/**
* Add custom roles and capabilities.
* This should ideally run on plugin activation.
*/
function quiztech_add_roles_and_capabilities() {
// Role definition code will go here.
// Example: Add the 'quiz_manager' role
\add_role(
'quiz_manager',
\__( 'Quiz Manager', 'quiztech' ),
array(
'read' => true, // Basic read access
// Add specific capabilities for Quiztech CPTs later
// 'edit_questions' => true,
// 'publish_questions' => true,
// 'delete_questions' => true,
// ... etc for assessments, jobs, evaluations
)
);
// Add capabilities to Administrator role as well
$admin_role = \get_role( 'administrator' );
if ( $admin_role ) {
// Add specific capabilities later
// $admin_role->add_cap( 'manage_quiztech_settings' );
// $admin_role->add_cap( 'edit_questions' );
// ... etc
}
}
/**
* Remove custom roles and capabilities.
* This should ideally run on plugin deactivation.
*/
function quiztech_remove_roles_and_capabilities() {
// Remove the 'quiz_manager' role
\remove_role( 'quiz_manager' );
// Remove capabilities from Administrator role
$admin_role = \get_role( 'administrator' );
if ( $admin_role ) {
// Remove specific capabilities later
// $admin_role->remove_cap( 'manage_quiztech_settings' );
// $admin_role->remove_cap( 'edit_questions' );
// ... etc
}
}
?>

View file

@ -0,0 +1,47 @@
<?php
namespace Quiztech\AssessmentPlatform\Includes;
/**
* File for registering Custom Taxonomies.
*
* @package Quiztech
*/
// If this file is called directly, abort.
if ( ! \defined( 'WPINC' ) ) {
\die;
}
/**
* Register Custom Taxonomies used by the Quiztech plugin.
*/
function quiztech_register_taxonomies() {
// Quiztech Category Taxonomy (for Questions and Assessments)
$category_labels = array(
'name' => \_x( 'Quiztech Categories', 'taxonomy general name', 'quiztech' ),
'singular_name' => \_x( 'Quiztech Category', 'taxonomy singular name', 'quiztech' ),
'search_items' => \__( 'Search Categories', 'quiztech' ),
'all_items' => \__( 'All Categories', 'quiztech' ),
'parent_item' => \__( 'Parent Category', 'quiztech' ),
'parent_item_colon' => \__( 'Parent Category:', 'quiztech' ),
'edit_item' => \__( 'Edit Category', 'quiztech' ),
'update_item' => \__( 'Update Category', 'quiztech' ),
'add_new_item' => \__( 'Add New Category', 'quiztech' ),
'new_item_name' => \__( 'New Category Name', 'quiztech' ),
'menu_name' => \__( 'Categories', 'quiztech' ),
);
$category_args = array(
'hierarchical' => true, // Like post categories
'labels' => $category_labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'quiztech-category' ),
'show_in_rest' => true, // Enable REST API support
);
\register_taxonomy( 'quiztech_category', array( 'question', 'assessment' ), $category_args ); // Apply to Questions and Assessments
}
\add_action( 'init', __NAMESPACE__ . '\quiztech_register_taxonomies' );
?>

25
vendor/autoload.php vendored Normal file
View file

@ -0,0 +1,25 @@
<?php
// autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit5179ff615eb5c35d6f4a82c9ea72e8ee::getLoader();

579
vendor/composer/ClassLoader.php vendored Normal file
View file

@ -0,0 +1,579 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see https://www.php-fig.org/psr/psr-0/
* @see https://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
/** @var \Closure(string):void */
private static $includeFile;
/** @var string|null */
private $vendorDir;
// PSR-4
/**
* @var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array<string, list<string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var list<string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* List of PSR-0 prefixes
*
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
*
* @var array<string, array<string, list<string>>>
*/
private $prefixesPsr0 = array();
/**
* @var list<string>
*/
private $fallbackDirsPsr0 = array();
/** @var bool */
private $useIncludePath = false;
/**
* @var array<string, string>
*/
private $classMap = array();
/** @var bool */
private $classMapAuthoritative = false;
/**
* @var array<string, bool>
*/
private $missingClasses = array();
/** @var string|null */
private $apcuPrefix;
/**
* @var array<string, self>
*/
private static $registeredLoaders = array();
/**
* @param string|null $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
self::initializeIncludeClosure();
}
/**
* @return array<string, list<string>>
*/
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
}
return array();
}
/**
* @return array<string, list<string>>
*/
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
/**
* @return list<string>
*/
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
/**
* @return list<string>
*/
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
/**
* @return array<string, string> Array of classname => path
*/
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array<string, string> $classMap Class to filename map
*
* @return void
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
$paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
$paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
$paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
$paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
$paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
$paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param list<string>|string $paths The PSR-0 base directories
*
* @return void
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param list<string>|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
* @return void
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*
* @return void
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*
* @return void
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*
* @return void
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*
* @return void
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
if (null === $this->vendorDir) {
return;
}
if ($prepend) {
self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
} else {
unset(self::$registeredLoaders[$this->vendorDir]);
self::$registeredLoaders[$this->vendorDir] = $this;
}
}
/**
* Unregisters this instance as an autoloader.
*
* @return void
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
if (null !== $this->vendorDir) {
unset(self::$registeredLoaders[$this->vendorDir]);
}
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return true|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
$includeFile = self::$includeFile;
$includeFile($file);
return true;
}
return null;
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
/**
* Returns the currently registered loaders keyed by their corresponding vendor directories.
*
* @return array<string, self>
*/
public static function getRegisteredLoaders()
{
return self::$registeredLoaders;
}
/**
* @param string $class
* @param string $ext
* @return string|false
*/
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*
* @param string $file
* @return void
*/
self::$includeFile = \Closure::bind(static function($file) {
include $file;
}, null, null);
}
}

359
vendor/composer/InstalledVersions.php vendored Normal file
View file

@ -0,0 +1,359 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer;
use Composer\Autoload\ClassLoader;
use Composer\Semver\VersionParser;
/**
* This class is copied in every Composer installed project and available to all
*
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
*
* To require its presence, you can require `composer-runtime-api ^2.0`
*
* @final
*/
class InstalledVersions
{
/**
* @var mixed[]|null
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
*/
private static $installed;
/**
* @var bool|null
*/
private static $canGetVendors;
/**
* @var array[]
* @psalm-var array<string, array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
private static $installedByVendor = array();
/**
* Returns a list of all package names which are present, either by being installed, replaced or provided
*
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackages()
{
$packages = array();
foreach (self::getInstalled() as $installed) {
$packages[] = array_keys($installed['versions']);
}
if (1 === \count($packages)) {
return $packages[0];
}
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
}
/**
* Returns a list of all package names with a specific type e.g. 'library'
*
* @param string $type
* @return string[]
* @psalm-return list<string>
*/
public static function getInstalledPackagesByType($type)
{
$packagesByType = array();
foreach (self::getInstalled() as $installed) {
foreach ($installed['versions'] as $name => $package) {
if (isset($package['type']) && $package['type'] === $type) {
$packagesByType[] = $name;
}
}
}
return $packagesByType;
}
/**
* Checks whether the given package is installed
*
* This also returns true if the package name is provided or replaced by another package
*
* @param string $packageName
* @param bool $includeDevRequirements
* @return bool
*/
public static function isInstalled($packageName, $includeDevRequirements = true)
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
}
}
return false;
}
/**
* Checks whether the given package satisfies a version constraint
*
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
*
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
*
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
* @param string $packageName
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
* @return bool
*/
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints((string) $constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
}
/**
* Returns a version constraint representing all the range(s) which are installed for a given package
*
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
* whether a given version of a package is installed, and not just whether it exists
*
* @param string $packageName
* @return string Version constraint usable with composer/semver
*/
public static function getVersionRanges($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
$ranges = array();
if (isset($installed['versions'][$packageName]['pretty_version'])) {
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
}
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
}
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
}
if (array_key_exists('provided', $installed['versions'][$packageName])) {
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
}
return implode(' || ', $ranges);
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['version'])) {
return null;
}
return $installed['versions'][$packageName]['version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
*/
public static function getPrettyVersion($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
return null;
}
return $installed['versions'][$packageName]['pretty_version'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
*/
public static function getReference($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
if (!isset($installed['versions'][$packageName]['reference'])) {
return null;
}
return $installed['versions'][$packageName]['reference'];
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @param string $packageName
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
*/
public static function getInstallPath($packageName)
{
foreach (self::getInstalled() as $installed) {
if (!isset($installed['versions'][$packageName])) {
continue;
}
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
}
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
}
/**
* @return array
* @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}
*/
public static function getRootPackage()
{
$installed = self::getInstalled();
return $installed[0]['root'];
}
/**
* Returns the raw installed.php data for custom implementations
*
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
* @return array[]
* @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}
*/
public static function getRawData()
{
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = include __DIR__ . '/installed.php';
} else {
self::$installed = array();
}
}
return self::$installed;
}
/**
* Returns the raw data of all installed.php which are currently loaded for custom implementations
*
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
public static function getAllRawData()
{
return self::getInstalled();
}
/**
* Lets you reload the static array from another file
*
* This is only useful for complex integrations in which a project needs to use
* this class but then also needs to execute another project's autoloader in process,
* and wants to ensure both projects have access to their version of installed.php.
*
* A typical case would be PHPUnit, where it would need to make sure it reads all
* the data it needs from this class, then call reload() with
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
* the project in which it runs can then also use this class safely, without
* interference between PHPUnit's dependencies and the project's dependencies.
*
* @param array[] $data A vendor/composer/installed.php data set
* @return void
*
* @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $data
*/
public static function reload($data)
{
self::$installed = $data;
self::$installedByVendor = array();
}
/**
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
*/
private static function getInstalled()
{
if (null === self::$canGetVendors) {
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
}
$installed = array();
if (self::$canGetVendors) {
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
}
}
}
}
if (null === self::$installed) {
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require __DIR__ . '/installed.php';
self::$installed = $required;
} else {
self::$installed = array();
}
}
if (self::$installed !== array()) {
$installed[] = self::$installed;
}
return $installed;
}
}

21
vendor/composer/LICENSE vendored Normal file
View file

@ -0,0 +1,21 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

10
vendor/composer/autoload_classmap.php vendored Normal file
View file

@ -0,0 +1,10 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
);

View file

@ -0,0 +1,9 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
);

10
vendor/composer/autoload_psr4.php vendored Normal file
View file

@ -0,0 +1,10 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Quiztech\\AssessmentPlatform\\' => array($baseDir . '/src'),
);

38
vendor/composer/autoload_real.php vendored Normal file
View file

@ -0,0 +1,38 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit5179ff615eb5c35d6f4a82c9ea72e8ee
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
/**
* @return \Composer\Autoload\ClassLoader
*/
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
require __DIR__ . '/platform_check.php';
spl_autoload_register(array('ComposerAutoloaderInit5179ff615eb5c35d6f4a82c9ea72e8ee', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit5179ff615eb5c35d6f4a82c9ea72e8ee', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit5179ff615eb5c35d6f4a82c9ea72e8ee::getInitializer($loader));
$loader->register(true);
return $loader;
}
}

36
vendor/composer/autoload_static.php vendored Normal file
View file

@ -0,0 +1,36 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit5179ff615eb5c35d6f4a82c9ea72e8ee
{
public static $prefixLengthsPsr4 = array (
'Q' =>
array (
'Quiztech\\AssessmentPlatform\\' => 28,
),
);
public static $prefixDirsPsr4 = array (
'Quiztech\\AssessmentPlatform\\' =>
array (
0 => __DIR__ . '/../..' . '/src',
),
);
public static $classMap = array (
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit5179ff615eb5c35d6f4a82c9ea72e8ee::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit5179ff615eb5c35d6f4a82c9ea72e8ee::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit5179ff615eb5c35d6f4a82c9ea72e8ee::$classMap;
}, null, ClassLoader::class);
}
}

5
vendor/composer/installed.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"packages": [],
"dev": true,
"dev-package-names": []
}

23
vendor/composer/installed.php vendored Normal file
View file

@ -0,0 +1,23 @@
<?php return array(
'root' => array(
'name' => 'quiztech/assessment-platform',
'pretty_version' => '1.0.0+no-version-set',
'version' => '1.0.0.0',
'reference' => null,
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev' => true,
),
'versions' => array(
'quiztech/assessment-platform' => array(
'pretty_version' => '1.0.0+no-version-set',
'version' => '1.0.0.0',
'reference' => null,
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
),
);

26
vendor/composer/platform_check.php vendored Normal file
View file

@ -0,0 +1,26 @@
<?php
// platform_check.php @generated by Composer
$issues = array();
if (!(PHP_VERSION_ID >= 70400)) {
$issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.';
}
if ($issues) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL);
} elseif (!headers_sent()) {
echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL;
}
}
trigger_error(
'Composer detected issues in your platform: ' . implode(' ', $issues),
E_USER_ERROR
);
}