我的用例如下:
我有一个带有测验的页面,测验有 N 个部分/问题和 M 个可能的答案。问题和答案都包含多个字段(例如,每个答案的图像、标题和颜色)。我正在使用切片并将问题放在可重复区域中,但您不能在可重复区域内设置组字段。
有什么替代方法吗?Wordpress 高级自定义字段轻松解决了这个问题。
我的用例如下:
我有一个带有测验的页面,测验有 N 个部分/问题和 M 个可能的答案。问题和答案都包含多个字段(例如,每个答案的图像、标题和颜色)。我正在使用切片并将问题放在可重复区域中,但您不能在可重复区域内设置组字段。
有什么替代方法吗?Wordpress 高级自定义字段轻松解决了这个问题。
用切片建模应该没有问题。您将拥有像您在不可重复字段中描述的问题及其图像等的切片以及在可重复字段中带有其图像的答案。
然后在文档编写部分,您将为每个问题调用一个切片,并为每个答案选择“添加新元素到组”。
这是您的内容类型的 json 结构应如下所示的示例:
{
"Main" : {
"home_title" : {
"type" : "StructuredText",
"config" : {
"single" : "heading1, heading2, heading3, heading4, heading5, heading6",
"label" : "home title",
"placeholder" : "Home"
}
},
"body" : {
"type" : "Slices",
"fieldset" : "Slice zone",
"config" : {
"labels" : {
"mcq" : [ {
"name" : "...",
"display" : ""
} ]
},
"choices" : {
"Question" : {
"type" : "Slice",
"fieldset" : "Question",
"description" : "Question and answers",
"icon" : "help",
"display" : "list",
"non-repeat" : {
"question" : {
"type" : "StructuredText",
"config" : {
"single" : "heading4",
"label" : "question"
}
},
"code_snippet" : {
"type" : "StructuredText",
"config" : {
"multi" : "preformatted",
"label" : "code snippet"
}
},
"correct_answer" : {
"type" : "Number",
"config" : {
"label" : "Correct answer"
}
},
"answer_explanatrion" : {
"type" : "StructuredText",
"config" : {
"multi" : "paragraph, preformatted, heading3, heading4, heading5, heading6, strong, em, hyperlink, image, embed, list-item, o-list-item, o-list-item",
"label" : "Answer explanation"
}
}
},
"repeat" : {
"answers" : {
"type" : "StructuredText",
"config" : {
"multi" : "paragraph, preformatted, strong, em, embed",
"label" : "Answers"
}
}
}
}
}
}
}
}
}