First, let me say that this will improve in two ways in 13.1: support of Setting
and a dedicated form notebook for QuestionObject
content.
That said, if you want to use the QuestionObject
interface in 13.0 but have programmatic access to the answer or the assessment you can use one of these tricks:
Store the student answer in a symbol using a comparator function
QuestionObject["How many career home runs did Hank Aaron hit?",
AssessmentFunction[{714 -> False, 755 -> True,
868 -> False}, (MatchQ[$studentanswer = #1, #2] &)]]
Store the student answer and assessment in symbols using a wrapper around the assessment function. Note the need to specify the interface since it is not automatically inferred from the custom assessment.
QuestionObject[
QuestionInterface["MultipleChoice", <|"Choices" -> {714, 755, 868},
"Prompt" ->
"How many career home runs did Hank Aaron hit?"|>], ($result =
AssessmentFunction[{714 -> False, 755 -> True,
868 -> False}][$answer = #])["AnswerCorrect"] &]