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]>
68 lines
2.3 KiB
PHP
68 lines
2.3 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Unsupervised\Schedular\Tests\Unit\Registration;
|
|
|
|
use Unsupervised\Schedular\Registration\Answer;
|
|
use Unsupervised\Schedular\Tests\Unit\TestCase;
|
|
|
|
class AnswerTest extends TestCase
|
|
{
|
|
public function testConstructorAndProperties(): void
|
|
{
|
|
$answer = new Answer(3, Answer::REG_LESSON, 12, 5, 'Beginner', 99);
|
|
|
|
self::assertSame(3, $answer->questionId);
|
|
self::assertSame(Answer::REG_LESSON, $answer->registrationType);
|
|
self::assertSame(12, $answer->registrationId);
|
|
self::assertSame(5, $answer->studentId);
|
|
self::assertSame('Beginner', $answer->answerValue);
|
|
self::assertSame(99, $answer->id);
|
|
}
|
|
|
|
public function testFromRowMapsCorrectly(): void
|
|
{
|
|
$row = (object) [
|
|
'id' => '99',
|
|
'question_id' => '3',
|
|
'registration_type' => Answer::REG_ENROLLMENT,
|
|
'registration_id' => '12',
|
|
'student_id' => '5',
|
|
'answer_value' => '1',
|
|
];
|
|
|
|
$answer = Answer::fromRow($row);
|
|
|
|
self::assertSame(99, $answer->id);
|
|
self::assertSame(3, $answer->questionId);
|
|
self::assertSame(Answer::REG_ENROLLMENT, $answer->registrationType);
|
|
self::assertSame(12, $answer->registrationId);
|
|
}
|
|
|
|
public function testToArrayContainsExpectedKeys(): void
|
|
{
|
|
$answer = new Answer(3, Answer::REG_LESSON, 12, 5);
|
|
$arr = $answer->toArray();
|
|
|
|
foreach (['id', 'question_id', 'registration_type', 'registration_id', 'student_id', 'answer_value'] as $key) {
|
|
self::assertArrayHasKey($key, $arr);
|
|
}
|
|
}
|
|
|
|
public function testValidRegistrationTypeConstants(): void
|
|
{
|
|
self::assertContains(Answer::REG_LESSON, Answer::VALID_REGISTRATION_TYPES);
|
|
self::assertContains(Answer::REG_ENROLLMENT, Answer::VALID_REGISTRATION_TYPES);
|
|
self::assertContains(Answer::REG_ACCOUNT, Answer::VALID_REGISTRATION_TYPES);
|
|
}
|
|
|
|
public function testAccountAnswerTargetsTheUser(): void
|
|
{
|
|
$answer = new Answer(3, Answer::REG_ACCOUNT, 42, 42, 'By a friend');
|
|
|
|
self::assertSame(Answer::REG_ACCOUNT, $answer->registrationType);
|
|
self::assertSame(42, $answer->registrationId);
|
|
self::assertSame(42, $answer->studentId);
|
|
}
|
|
}
|