fix(demo): advance seeded candidates past onboarding and show the express summary in Russian

This commit is contained in:
shira committed 2026-10-10 01:39:58 +03:00
1 parent 41206abbcf
commit 945ab6d6a9
9 files changed
+296 -10

No files matched your search

@@ -311,9 +311,18 @@ func (service *AttemptService) persistFinalizedAttempt(
return nil
}
// expressResultSummary is the user-facing text of a finished express run. The
// product UI is in Russian, and the text is stored in the immutable result, so
// a run finished before this text changed keeps the text it was stored with.
const expressResultSummary = "Это тренировочный запуск: он не оценивает и не подтверждает уровень."
// expressEndedSummary is the text of an express run that expired or was left
// unfinished. Like expressResultSummary, it is stored in the immutable result.
const expressEndedSummary = "Тренировочный запуск завершился до окончания: он не оценивает и не подтверждает уровень."
func assessmentFinalizedResultPresentation(kind domain.AssessmentAttemptKind) (string, []string) {
if kind == domain.AssessmentAttemptKindDemoExpress {
return "This training run is educational only. It does not assess or confirm a grade.", []string{"demonstration_only"}
return expressResultSummary, []string{"demonstration_only"}
}
return "", []string{"uncalibrated_thresholds", "demo_bank", "practice_not_included", "unproctored"}
}
@@ -411,7 +420,7 @@ func terminalAttemptResult(attempt domain.AssessmentAttempt) (AssessmentAttemptR
switch snapshot.Kind {
case domain.AssessmentAttemptKindDemoExpress:
result.Outcome = domain.AssessmentAttemptOutcomeDemonstration
result.Summary = "This training run ended before completion. It does not assess or confirm a grade."
result.Summary = expressEndedSummary
case domain.AssessmentAttemptKindRoot, domain.AssessmentAttemptKindCorrective:
result.Limitations = []string{"uncalibrated_thresholds", "demo_bank", "practice_not_included", "unproctored"}
result.Outcome = domain.AssessmentAttemptOutcomeNotDetermined
+31 -4
View File
@@ -84,11 +84,13 @@ type Input struct {
Password domain.Password
}
// Report lists what one run created and what it found. It holds addresses
// of synthetic accounts and identifiers only.
// Report lists what one run created, what it changed in an existing record,
// and what it found. It holds addresses of synthetic accounts and identifiers
// only.
type Report struct {
PolicyVersion int32
Created []string
Updated []string
Present []string
Logins []Login
PreparedAttempts []PreparedAttempt
@@ -114,6 +116,13 @@ func (report *Report) record(created bool, item string) {
report.Present = append(report.Present, item)
}
// update notes a change to a record that already existed. It is kept apart
// from the created records, so a repeated run that repairs a stand reports no
// new record.
func (report *Report) update(item string) {
report.Updated = append(report.Updated, item)
}
// Seed builds the demo world or finds it complete.
func (seeder *Seeder) Seed(ctx context.Context, input Input) (Report, error) {
const location = "Seeder.Seed"
@@ -565,8 +574,9 @@ func (seeder *Seeder) ensureMembership(ctx context.Context, organizationID, user
}
// ensureCandidate gives a candidate its consents, manual profile, and
// questionnaire; a prepared candidate also gets the prepared full attempt and
// a published card. It returns the prepared attempt, or a zero ID.
// questionnaire, then sets the onboarding step that the questionnaire leaves;
// a prepared candidate also gets the prepared full attempt and a published
// card. It returns the prepared attempt, or a zero ID.
func (seeder *Seeder) ensureCandidate(
ctx context.Context,
spec accountSpec,
@@ -593,6 +603,9 @@ func (seeder *Seeder) ensureCandidate(
return domain.AssessmentAttemptID{}, fmt.Errorf("%s - %w", location, err)
}
report.record(created, "questionnaire of "+spec.email())
if err := seeder.ensureOnboarding(ctx, user.ID, spec.email(), report); err != nil {
return domain.AssessmentAttemptID{}, fmt.Errorf("%s - %w", location, err)
}
if spec.role != rolePrepared {
return domain.AssessmentAttemptID{}, nil
}
@@ -609,6 +622,20 @@ func (seeder *Seeder) ensureCandidate(
return attemptID, nil
}
// ensureOnboarding leaves the candidate at candidate_assessment, the step that
// a saved questionnaire leaves in the ordinary flow. A stand that already has
// the step, or a later one, is unchanged, so a repeat reports no update.
func (seeder *Seeder) ensureOnboarding(ctx context.Context, userID uuid.UUID, email string, report *Report) error {
changed, err := seeder.deps.Store.AdvanceCandidateOnboarding(ctx, userID, seeder.now())
if err != nil {
return fmt.Errorf("advance onboarding of %s: %w", email, err)
}
if changed {
report.update("onboarding of " + email + " at candidate_assessment")
}
return nil
}
// grantConsent grants the current text of the purpose; a repeat of the same
// version is idempotent in the ledger.
func (seeder *Seeder) grantConsent(ctx context.Context, subjectID uuid.UUID, purpose domain.ConsentPurpose) error {