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]>
58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Unsupervised\Schedular\Registration;
|
|
|
|
use Unsupervised\Schedular\Val;
|
|
|
|
class Answer {
|
|
|
|
public const REG_LESSON = 'lesson';
|
|
public const REG_ENROLLMENT = 'enrollment';
|
|
public const REG_ACCOUNT = 'account';
|
|
|
|
/**
|
|
* Polymorphic registration targets an answer can attach to. `account` is used
|
|
* by studio-wide questions answered at signup (registration_id = the user ID).
|
|
*
|
|
* @var list<string>
|
|
*/
|
|
public const VALID_REGISTRATION_TYPES = [ self::REG_LESSON, self::REG_ENROLLMENT, self::REG_ACCOUNT ];
|
|
|
|
public function __construct(
|
|
public readonly int $questionId,
|
|
public readonly string $registrationType,
|
|
public readonly int $registrationId,
|
|
public readonly int $studentId,
|
|
public readonly ?string $answerValue = null,
|
|
public readonly ?int $id = null,
|
|
) {}
|
|
|
|
public static function fromRow( \stdClass $row ): self {
|
|
return new self(
|
|
questionId: Val::int( $row->question_id ),
|
|
registrationType: Val::string( $row->registration_type ),
|
|
registrationId: Val::int( $row->registration_id ),
|
|
studentId: Val::int( $row->student_id ),
|
|
answerValue: Val::stringOrNull( $row->answer_value ),
|
|
id: Val::int( $row->id ),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Returns a plain array representation of the answer.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(): array {
|
|
return [
|
|
'id' => $this->id,
|
|
'question_id' => $this->questionId,
|
|
'registration_type' => $this->registrationType,
|
|
'registration_id' => $this->registrationId,
|
|
'student_id' => $this->studentId,
|
|
'answer_value' => $this->answerValue,
|
|
];
|
|
}
|
|
}
|