An enumeration used for getting and setting the current assessment state of a playground page and providing optional feedback to the user.
Indicates that the user failed the task for the playground page and provides updated hints.
case fail(hints: [String], solution: String?)
hints: A new array of hints for the Hint button. Any existing hints are replaced.
solution: An optional solution string. The content is added as a hint that is hidden by a Show Solution button.
To provide just a solution, leave the
hints array empty. If no solution is provided, there must be at least one string in the
The following example sets one hint for the page. The markup in the hint string displays the word “for” in code voice.
The strings for the solution and for hints can contain markup. For more information on markup, see Markup Formatting Reference.
PlaygroundPage.current.assessmentStatus = .fail(hints: ["Try using a `for` loop"], solution: nil)
Indicates that the user succeeded at the task for the playground page and provides a success message.
case pass(message: String?)
message: A message displayed in the Hints area. The area is expanded to display the message. The Hint button is replaced by a completion button.
The following example shows a popover with the message “Great job!” The message string uses markup to display the word “Great” using bold font.
The message argument can contain markup. For more information on markup, see Markup Formatting Reference.
PlaygroundPage.current.assessmentStatus = .pass(message: "**Great** job!")