Introduce practice_stimulus_blocks, authoring_profile, and stimulus_block_key on question set items. Full practice GET/PUT returns merged effective_dynamic_payload for admin authoring. Co-authored-by: Cursor <cursoragent@cursor.com>
24 lines
621 B
Go
24 lines
621 B
Go
package domain
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// ValidateStimulusBlockKeyReferences ensures each membership references a known block key.
|
|
func ValidateStimulusBlockKeyReferences(memberships []QuestionSetMembership, blockKeys map[string]struct{}) error {
|
|
for _, m := range memberships {
|
|
if m.StimulusBlockKey == nil {
|
|
continue
|
|
}
|
|
key := strings.TrimSpace(*m.StimulusBlockKey)
|
|
if key == "" {
|
|
return fmt.Errorf("stimulus_block_key cannot be empty")
|
|
}
|
|
if _, ok := blockKeys[key]; !ok {
|
|
return fmt.Errorf("stimulus_block_key %q does not match a stimulus block on this practice", key)
|
|
}
|
|
}
|
|
return nil
|
|
}
|