Message Boards Message Boards

2
|
1468 Views
|
1 Reply
|
4 Total Likes
View groups...
Share
Share this post:

How to make a true false question?

I am wondering how to make a true or false question. Here is a working question: What day of the week is today?

QuestionObject[
 QuestionInterface[
  "MultipleChoice", <|
   "Prompt" -> "What is the day of the week today?", 
   "Choices" -> {"Monday", "Tuesday", "Wednesday", "Thursday", 
     "Friday", "Saturday", "Sunday"}|>], 
 AssessmentFunction[DateValue[Today, "DayName", String]]]

I can't get this true-or-false question to work:

QuestionObject[
 QuestionInterface[
  "TrueFalse", <|
   "Prompt" -> 
    "Is the current year a leap year in the Gregorian calendar?"|>], 
 AssessmentFunction[{"True" -> TrueQ[LeapYearQ[Today]], 
   "False" -> ! LeapYearQ[Today]}]]

If a year is not a leap year, then its a common year. How can I tell that a leap year is not a common year, and vice versa to create a question.

POSTED BY: Peter Burbery
Posted 1 year ago

I'm not very familiar with QuestionObjects and so forth, but reading the documentation leads me to believe that you need to assign integer values. To do that, you can use Boole.

QuestionObject[
 QuestionInterface[
  "TrueFalse", <|
   "Prompt" -> "Is the current year a leap year in the Gregorian calendar?"|>], 
 AssessmentFunction[{True -> Boole[LeapYearQ[Today]], False -> Boole[Not[LeapYearQ[Today]]]}]]

Also, I would think you could use "MultipleChoice":

QuestionObject[
 QuestionInterface[
  "MultipleChoice", <|
   "Prompt" -> "Is the current year a leap year in the Gregorian calendar?",
   "Choices" -> {"Yes", "No"}|>], 
 AssessmentFunction[{"Yes" -> Boole[LeapYearQ[Today]], "No" -> Boole[Not[LeapYearQ[Today]]]}]]
POSTED BY: Eric Rimbey
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