Message Boards Message Boards

How to Use QuestionObject with AssessmentResultObject?

I asked this question on StackExchange, but got no useful replies.

The documentation is very unclear as to how QuestionObject should be combined with AssessmentResultObject to generate a result for further processing.

For example, we have (from the documentation):

QuestionObject["How many career home runs did Hank Aaron hit?", 
x = AssessmentFunction[{714 -> False, 755 -> True, 868 -> False}]]

which produces a nice graphic, but no output one can capture for further processing:

enter image description here

So how do we get the result (True or False in this case)?

x is the AssessmentFunction:

AssessmentFunction[{714 -> False, 755 -> True, 868 -> False}]

The documentation appears to imply that an AssessmentResultObject is automatically created and should be accessible using:

x["property"], where "property is, for instance, "AnswerCorrect".

But this doesn't work, nor do any of the other possibilities, giving an error:

AssessmentFunction::invans: The provided answer is not supported by the comparison method of the assessment function.

The documentation is very unclear as to how these should be combined to generate a result for further processing.

For example, we have:

QuestionObject["How many career home runs did Hank Aaron hit?", 
x = AssessmentFunction[{714 -> False, 755 -> True, 868 -> False}]]

which produces the following:

enter image description here

But how to get the result (True or False in this case)?

x is the AssessmentFunction:

AssessmentFunction[{714 -> False, 755 -> True, 868 -> False}]

The documentation appears to imply that an AssessmentResultObject is automatically created and should be accessible using:

x["property"], where "property is, for instance, "AnswerCorrect".

But this doesn't work, nor do any of the other possibilities, giving an error:

AssessmentFunction::invans: The provided answer is not supported by the comparison method of the assessment function.

So how should QuestionObject be used to generate a result for further processing?

POSTED BY: Jonathan Kinlay
4 Replies

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"] &]

POSTED BY: Bob Sandheinrich

Thanks Bob.

Two excellent solutions here.

Much appreciated.

POSTED BY: Jonathan Kinlay
Posted 2 years ago

It also sounds like you want to you QuestionObject and AssessmentFunction together, but get access to the result programmatically. The documentation examples of nesting QuestionObject["label", AssessmentFunction[...]] seem to be created a self-contained Q&A interface, where the student simply gets visual feedback (green checkmark or red x). I also don't know how to hook into this correctly for sure.

But I think if you use QuestionObject['label", f] and tell QuestionObject your input UI type, you might be able to write a function f that uses AssessmentFunction to do the job.

POSTED BY: Joel Klein
Posted 2 years ago

First problem, I think AssessmentFunction, x in your case, needs to be applied to the "student" input to get the AssessmentResultObject. Second problem, which becomes more obvious when you realize the first, is that x["property"] is supplying a string to an AssessmentFunction expecting a number.

I think what you want is this: (* student supplies answer: *) result = x[715] (* retrieve properties from AssessmentResultObject: *) {result["GivenAnswer"], result["AnswerCorrect"]}

POSTED BY: Joel Klein
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract