Add studio-defined account-registration questions
CI / Tests (PHP 8.2) (pull_request) Successful in 44s
CI / Tests (PHP 8.1) (pull_request) Successful in 45s
CI / No Debug Code (pull_request) Successful in 2s
CI / Coding Standards (pull_request) Successful in 2m46s
CI / PHPStan (pull_request) Successful in 2m58s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m41s
CI / Build Plugin Zip (pull_request) Skipped

Studio admins can now define registration questions that every new student
answers as a required second step during signup, with each student's answers
shown under a "Registration Information" section in the admin.

Extends the existing Registration domain: us_questions gains a scope column
(offering | account) and a nullable offering_id, and account answers reuse
us_question_answers with registration_type = 'account'. Authoring reuses the
Offerings -> Questions page via an "Account signup" scope (studio-admin only).
The registration form becomes two steps (progressive enhancement via
assets/js/register.js; works without JS); required answers are validated before
the account is created and apply to all signup paths (invite, group link,
self-approval). StudentHistory::registrationInfo() powers the admin section.

Bumps the plugin version to 1.1.0 so dbDelta runs the schema migration.

Closes #90

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
2026-07-23 09:59:59 -03:00
co-authored by Claude Opus 4.8
parent 34e8f660ab
commit 49c59a950c
23 changed files with 702 additions and 98 deletions
+19 -7
View File
@@ -10,6 +10,8 @@ if (! defined('ABSPATH')) {
/**
* @var list<\Unsupervised\Schedular\Offering\Offering> $offeringList
* @var \Unsupervised\Schedular\Offering\Offering|null $selectedOffering
* @var bool $accountScope Whether the studio-wide account-signup questions are selected.
* @var bool $manageAll Whether the current user is a studio admin (may edit account questions).
* @var list<\Unsupervised\Schedular\Registration\Question>|null $questions
*/
?>
@@ -18,21 +20,31 @@ if (! defined('ABSPATH')) {
<form method="get">
<input type="hidden" name="page" value="us-questions">
<label for="offering_id"><?php esc_html_e('Offering', 'unsupervised-schedular'); ?></label>
<label for="offering_id"><?php esc_html_e('Questions for', 'unsupervised-schedular'); ?></label>
<select name="offering_id" id="offering_id" onchange="this.form.submit()">
<option value="0"><?php esc_html_e('— Select an offering —', 'unsupervised-schedular'); ?></option>
<option value="0"><?php esc_html_e('— Select —', 'unsupervised-schedular'); ?></option>
<?php if ($manageAll) : ?>
<option value="<?php echo esc_attr(Question::SCOPE_ACCOUNT); ?>" <?php selected($accountScope); ?>>
<?php esc_html_e('Account signup (all registrations)', 'unsupervised-schedular'); ?>
</option>
<?php endif; ?>
<?php foreach ($offeringList as $offering) : ?>
<option value="<?php echo esc_attr((string) $offering->id); ?>" <?php selected($selectedOffering && $selectedOffering->id === $offering->id); ?>>
<option value="<?php echo esc_attr((string) $offering->id); ?>" <?php selected(! $accountScope && $selectedOffering && $selectedOffering->id === $offering->id); ?>>
<?php echo esc_html($offering->title); ?>
</option>
<?php endforeach; ?>
</select>
</form>
<?php if (null === $selectedOffering) : ?>
<p><?php esc_html_e('Choose an offering to manage its intake questions.', 'unsupervised-schedular'); ?></p>
<?php if (! $accountScope && null === $selectedOffering) : ?>
<p><?php esc_html_e('Choose an offering to manage its intake questions, or "Account signup" for the questions every new student answers when registering.', 'unsupervised-schedular'); ?></p>
<?php else : ?>
<h2><?php echo esc_html(sprintf(/* translators: %s: offering title */ __('Questions for "%s"', 'unsupervised-schedular'), $selectedOffering->title)); ?></h2>
<?php if ($accountScope) : ?>
<h2><?php esc_html_e('Account signup questions', 'unsupervised-schedular'); ?></h2>
<p><?php esc_html_e('Every new student answers these required-if-marked questions as a second step after choosing their name and password.', 'unsupervised-schedular'); ?></p>
<?php else : ?>
<h2><?php echo esc_html(sprintf(/* translators: %s: offering title */ __('Questions for "%s"', 'unsupervised-schedular'), $selectedOffering->title)); ?></h2>
<?php endif; ?>
<h3><?php esc_html_e('Add Question', 'unsupervised-schedular'); ?></h3>
<form method="post">
@@ -74,7 +86,7 @@ if (! defined('ABSPATH')) {
<h3><?php esc_html_e('Current Questions', 'unsupervised-schedular'); ?></h3>
<?php if (empty($questions)) : ?>
<p><?php esc_html_e('No questions configured for this offering.', 'unsupervised-schedular'); ?></p>
<p><?php esc_html_e('No questions configured yet.', 'unsupervised-schedular'); ?></p>
<?php else : ?>
<table class="wp-list-table widefat fixed striped">
<thead>
+28
View File
@@ -11,6 +11,7 @@ if (! defined('ABSPATH')) {
* @var list<array{id: int, start_dt: string, end_dt: string, offering: string, instructor: string, status: string}> $past
* @var list<array{id: int, offering: string, status: string}> $enrolments
* @var list<array{policy: string, version: string, context: string, accepted_at: string}> $acceptances
* @var list<array{question: string, answer: string, required: bool}> $registrationInfo
* @var list<array{question: string, answer: string, context: string}> $intake
* @var list<array{created_at: string, context: string, method: string, status: string, amount: float, tax_amount: float, total: float, currency: string, receipt: string}> $payments
* @var string $backUrl
@@ -101,6 +102,33 @@ $renderLessons = static function (array $rows, bool $withActions = false): void
<?php submit_button(esc_html__('Save account details', 'unsupervised-schedular'), 'secondary', 'submit', false); ?>
</form>
<h2><?php esc_html_e('Registration Information', 'unsupervised-schedular'); ?></h2>
<?php if (empty($registrationInfo)) : ?>
<p><?php esc_html_e('No registration questions are configured.', 'unsupervised-schedular'); ?></p>
<?php else : ?>
<table class="wp-list-table widefat fixed striped">
<thead>
<tr>
<th><?php esc_html_e('Question', 'unsupervised-schedular'); ?></th>
<th><?php esc_html_e('Answer', 'unsupervised-schedular'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($registrationInfo as $row) : ?>
<tr>
<td>
<?php echo esc_html($row['question']); ?>
<?php if ($row['required']) : ?>
<span class="us-required" aria-hidden="true">*</span>
<?php endif; ?>
</td>
<td><?php echo esc_html($row['answer']); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
<?php if ($canBilling) : ?>
<h2><?php esc_html_e('Billing method', 'unsupervised-schedular'); ?></h2>
<form method="post">