add questions

This commit is contained in:
2026-09-01 01:01:37 +07:00
parent 4431a4d491
commit 69666ee264
23 changed files with 4151 additions and 368 deletions
+31
View File
@@ -49,6 +49,7 @@ func mapStory(o *storytelling.Story) *proto.Story {
return &proto.Story{
Introduction: mapIntroduction(o.Introduction),
Places: mapPlaces(o.Places),
Questions: mapQuestions(o.Questions),
}
}
@@ -197,3 +198,33 @@ func convertIntroduction(o *proto.Introduction) *storytelling.Introduction {
Audio: o.Audio,
}
}
func mapQuestions(o []*storytelling.Question) []*proto.Question {
res := make([]*proto.Question, 0, len(o))
for _, item := range o {
res = append(res, mapQuestion(item))
}
return res
}
func mapQuestion(o *storytelling.Question) *proto.Question {
if o == nil {
return nil
}
return &proto.Question{
Code: o.Code,
Text: o.Text,
Answer: o.Answer,
}
}
func convertQuestion(o *proto.Question) *storytelling.Question {
if o == nil {
return nil
}
return &storytelling.Question{
Code: o.Code,
Text: textFormatter.FormatText(o.Text),
Answer: textFormatter.FormatText(o.Answer),
}
}