Help with a Calculated MultiChoice Question

Help with a Calculated MultiChoice Question

by Philip Norton -
Number of replies: 1

I have a two part question that I'd like to ask.

There are {x} green blocks and {y} red blocks in a bag.

1) What is the probability of selecting a green block?

A) {x} / {y}

B) {y} / {x}

C) {x} / {={x} + {y}}

D) {y} / {={x} + {y}}


2) If 2 green blocks are removed, is there a greater probability of drawing a red or a green block?

A) Green blocks

B) Red blocks

C) Equal chance of each


I have no problem with question 1, but question 2 has flummoxed me because I need to use a formula to determine whether the answer is correct or not:

A) {=if({={x} - 2}>{y}, 100%, 0%)}
B) {=if({={x} - 2}<{y}, 100%, 0%)}
C) {=if({={x} - 2}=={y}, 100%, 0%)}

I have a feeling the answer is "No"... Can it be done?
Average of ratings: -
In reply to Philip Norton

Re: Help with a Calculated MultiChoice Question

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello Philip,

I'm not saying you can't do it with the Calculated multi-choice question, but you can do it with the Formulas question:

Random variables
  x = {10:20};
  y = {10:20};
Global variables
  a = join("",str(x)," / ",str(y));
  b = join("",str(y)," / ",str(x));
  c = join("",str(x)," / ",str(x+y));
  d = join("",str(y)," / ",str(x+y));
  q1 = [a,b,c,d];
  a1 = 2;
  q2 = ["Green blocks","Red blocks","Equal chance of each"];
  a2 = (x-2>y) ? 0 : ((x-2<y) ? 1 : ((x-2==y) ? 2 : -1));
Part 1
Answer
  a1
Part's text
  {_0:q1}
Part 2
Answer
  a2
Part's text
  {_0:q2}

Here's what you'll get:

ForumQuiz_20200408_1422.png

The above question is not completely finished. You will probably want x and y to always be different and the order of choices for the first question to be shuffled, but it can be done.

XML attached:

Average of ratings: Useful (1)