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
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:
@@ -12,6 +12,12 @@ class Question {
|
||||
public const FIELD_SELECT = 'select';
|
||||
public const FIELD_CHECKBOX = 'checkbox';
|
||||
|
||||
/** Question is scoped to a single offering, asked at booking/enrolment time. */
|
||||
public const SCOPE_OFFERING = 'offering';
|
||||
|
||||
/** Question is studio-wide, asked once at account signup (no offering). */
|
||||
public const SCOPE_ACCOUNT = 'account';
|
||||
|
||||
/**
|
||||
* All valid field types.
|
||||
*
|
||||
@@ -24,19 +30,31 @@ class Question {
|
||||
self::FIELD_CHECKBOX,
|
||||
];
|
||||
|
||||
/**
|
||||
* All valid scopes.
|
||||
*
|
||||
* @var list<string>
|
||||
*/
|
||||
public const VALID_SCOPES = [
|
||||
self::SCOPE_OFFERING,
|
||||
self::SCOPE_ACCOUNT,
|
||||
];
|
||||
|
||||
/**
|
||||
* Build an intake question value object.
|
||||
*
|
||||
* @param list<string>|null $options Choices for a `select` field.
|
||||
* @param int|null $offeringId The owning offering, or null for account-scoped questions.
|
||||
* @param list<string>|null $options Choices for a `select` field.
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly int $offeringId,
|
||||
public readonly ?int $offeringId,
|
||||
public readonly string $label,
|
||||
public readonly string $fieldType = self::FIELD_TEXT,
|
||||
public readonly ?array $options = null,
|
||||
public readonly bool $isRequired = false,
|
||||
public readonly int $sortOrder = 0,
|
||||
public readonly bool $isActive = true,
|
||||
public readonly string $scope = self::SCOPE_OFFERING,
|
||||
public readonly ?int $id = null,
|
||||
) {}
|
||||
|
||||
@@ -50,13 +68,14 @@ class Question {
|
||||
}
|
||||
|
||||
return new self(
|
||||
offeringId: Val::int( $row->offering_id ),
|
||||
offeringId: Val::intOrNull( $row->offering_id ),
|
||||
label: Val::string( $row->label ),
|
||||
fieldType: Val::string( $row->field_type ),
|
||||
options: $options,
|
||||
isRequired: Val::bool( $row->is_required ),
|
||||
sortOrder: Val::int( $row->sort_order ),
|
||||
isActive: Val::bool( $row->is_active ),
|
||||
scope: Val::string( $row->scope ),
|
||||
id: Val::int( $row->id ),
|
||||
);
|
||||
}
|
||||
@@ -70,6 +89,7 @@ class Question {
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'offering_id' => $this->offeringId,
|
||||
'scope' => $this->scope,
|
||||
'label' => $this->label,
|
||||
'field_type' => $this->fieldType,
|
||||
'options' => $this->options,
|
||||
|
||||
Reference in New Issue
Block a user