如何在 ResearchKit 上创建个人同意页面?
Posted
技术标签:
【中文标题】如何在 ResearchKit 上创建个人同意页面?【英文标题】:How to create individual consent pages on ResearchKit? 【发布时间】:2016-03-02 04:02:35 【问题描述】:我在 iPhone ios 9.1 的 Swift 上使用 Xcode 7.1.1 编码和 ResearchKit。我正在尝试创建同意页面,并且一直在网上寻找没有成功的示例。
从http://www.raywenderlich.com/104575/researchkit-tutorial-with-swift,我得到了代码:
import Foundation
import ResearchKit
public var ConsentDocument:ORKConsentDocument
let consentDocument=ORKConsentDocument()
consentDocument.title = "Consent"
//Consent Sections
let consentSectionTypes: [ORKConsentSectionType] = [
.Overview,
.DataGathering,
.Privacy,
.DataUse,
.TimeCommitment,
.StudySurvey,
.StudyTasks,
.Withdrawing
]
let consentSections: [ORKConsentSection] = consentSectionTypes.map contentSectionType in
let consentSection = ORKConsentSection(type: contentSectionType)
consentSection.summary = "If you wish to complete this study..."
consentSection.content = "In this study you will only be asked 10 easy question!!!"
return consentSection
consentDocument.sections = consentSections
// Getting Signature
consentDocument.addSignature(ORKConsentSignature(forPersonWithTitle: nil, dateFormatString: nil, identifier: "ConsentDocumentParticipantSignature"))
return consentDocument
问题是,这段代码创建了具有相同摘要和内容的每个页面。如何为每个单独的部分制作单独的页面??
【问题讨论】:
您可以在地图内使用一个开关块,并为不同的contentSectionType
分配不同的字符串。
@Yuan 能举个例子吗?我正在尝试 ''switch consentSectionTypes case consentSectionTypes.Overview: Overview.summary = "如果你想完成这项研究......" Overview.content = "在这项研究中,你只会被问到 10 个简单的问题!!!"' '
【参考方案1】:
正如袁建议将您的地图功能替换如下:
let consentSections: [ORKConsentSection] = consentSectionTypes.map contentSectionType in
let consentSection = ORKConsentSection(type: contentSectionType)
switch contentSectionType
case .Overview:
consentSection.summary = "Overview"
consentSection.content = "Overview - Content"
case .DataGathering:
consentSection.summary = "DataGathering"
consentSection.content = "DataGathering - Content"
case .Privacy:
consentSection.summary = "Privacy"
consentSection.content = "Privacy - Content"
case .DataUse:
consentSection.summary = "DataUse"
consentSection.content = "DataUse - Content"
case .TimeCommitment:
consentSection.summary = "TimeCommitment"
consentSection.content = "TimeCommitment - Content"
case .StudySurvey:
consentSection.summary = "StudySurvey"
consentSection.content = "StudySurvey - Content"
case .StudyTasks:
consentSection.summary = "StudyTasks"
consentSection.content = "StudyTasks - Content"
case .Withdrawing:
consentSection.summary = "Withdrawing"
consentSection.content = "Withdrawing - Content"
default:
break
return consentSection
【讨论】:
感谢您的有用回答!以上是关于如何在 ResearchKit 上创建个人同意页面?的主要内容,如果未能解决你的问题,请参考以下文章
如何使用 Swift 2.2 中的 ResearchKit 在自定义活动步骤中禁用下一个按钮?
如何在 ResearchKit 中配置具有多个 ORKAudioSteps 的 ORKOrderedTask?