RezinaLMS-BackEnd/internal/domain/practice_stimulus_block_validate.go
Yared Yemane 9b504b87a2 feat: add practice-level stimulus blocks for shared IELTS content
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>
2026-07-02 03:16:36 -07:00

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
}