I have been trying for a long time to generate a question test where operations with 2 rationals appear printed. Can someone help me with the code? shows the following errors. a) The options appear repeated in some questions b) The generation of random numbers for the operations seems to stick. c) The options should present the final result of the operation and not a series of operations where it is indicated what must be done. d) The correct answers should come out at the end after all the questions come out. e) You lack a title and write the questions in bold.
SetAttributes[shuffle, Orderless];
op = {Plus, Subtract, Times, Divide};
r1 = RandomChoice[Range[-5, 5]]/RandomChoice[Range[1, 5]];
r2 = RandomChoice[Range[-5, 5]]/RandomChoice[Range[1, 5]];
Do[op1 = RandomChoice[op];
ans = Simplify[r1 op1 r2];
choices = {ans,
ans + RandomChoice[Range[-5, 5]]/RandomChoice[Range[1, 5]],
ans + RandomChoice[Range[-5, 5]]/RandomChoice[Range[1, 5]],
ans + RandomChoice[Range[-5, 5]]/RandomChoice[Range[1, 5]],
ans + RandomChoice[Range[-5, 5]]/RandomChoice[Range[1, 5]]};
correct = Position[choices, ans][[1, 1]];
shuffledChoices = RandomSample[choices];
Print["Pregunta ", i, ":"];
Print[r1, " ",
Which[op1 === Plus, "+", op1 === Subtract, "-", op1 === Times, "*",
op1 === Divide, ":"], " ", r2, " = ?"];
Print["a) ", shuffledChoices[[1]]];
Print["b) ", shuffledChoices[[2]]];
Print["c) ", shuffledChoices[[3]]];
Print["d) ", shuffledChoices[[4]]];
Print["e) ", shuffledChoices[[5]]];
Print["Respuesta correcta: ", CharacterRange["a", "e"][[correct]]];
Print[""];
If[i == 10, Print["END test"]], {i, 1, 10}]