(* Require XMLgen_MC.nb ver >=0.04 *)
SetDirectory[NotebookDirectory[]];
<<XMLgenMC.mx;
TTS[mt_]:=ToString[TeXForm[StandardForm[mt]]];
TOT[mt_]:=ToString[OneLineTeXForm[mt]];
TOTT[mt_]:=ToString[OneLineTeXForm[Transpose[mt]]];
TOC[mt_,c_]:=TOTT[{Transpose[mt][[c]]}];
TTD[r_]:=StringReplace[TT[r],"\\frac"->"\\dfrac"];
Rnz[m_]:=(RandomInteger[m]+1)*(2*RandomInteger[1]-1); (* \\pm 1,\pm2,...,\pm(m+1) *)
Rpos[m_]:=RandomInteger[m]+1; (* 1,2,...,m+1 *)
TTC[A_,n_]:=TOTT[{(Transpose[A])[[n]]}];
Col[A_,n_]:=Transpose[{A[[Range[Length[A]],n]]}];
ColCat[CL_]:=Join@@@(Transpose@CL);
TOPt[A_]:="\\(("<>TOT[A[[1]]]<>","<>TOT[A[[2]]]<>","<>TOT[A[[3]]]<>")\\)";
PtString[M_]:=StringReplace[ToString[M],{"{"->"(","}"->")"}];
Title="パラメータ表示と平面上の領域(区間)";
SELNUM=5;NUM=200;

(* Select matrices satisfying some mapping conditions *)
QtList={}; For[ct=1,ct≤1000,ct++,
Tmp={{Rnz[1],Rnz[2],0},{Rnz[2],Rnz[1],Rnz[1]},{Rnz[1],Rnz[2],Rnz[1]}};
While [Det[Tmp]==0,Tmp={{Rnz[3],Rnz[2],Rnz[3]},{Rnz[3],Rnz[3],Rnz[3]},{Rnz[3],Rnz[3],0}}];
Tmp2={Tmp[[1]],Tmp[[1]]+12*(Tmp[[2]]-Tmp[[1]]),Tmp[[1]]+12*(Tmp[[3]]-Tmp[[1]])};
  QtList=Append[QtList,{RandomInteger[1]+1,Tmp2}];
QtList=DeleteDuplicates[QtList]];QtList=RandomSample[QtList,NUM];Length[QtList]

QtextF[mm_]:=Module[{Cn,wx,A,B,C},{Cn,{A,B,C}}=QtList[[mm]];
wx=TOTT[{{x,y,z}}];
Return["空間の3点A"<>TOPt[A]<>",B"<>TOPt[B]<>",C"<>TOPt[C]<>"に対し, 三角形ABCの周および内部にある点をすべて選びなさい."]];

QtextF[3]

CListF[mm_]:=Module[{Cn,A,B,C,s,t,p,u,v,X,fs,ret={}},
{Cn,{A,B,C}}=QtList[[mm]];fs="正解です.";
p=A;u=B-A;v=C-A;
X=p+(1/6)*u+(3/4)*v;ret=Append[ret,{TOPt[X],fs}];
X=p+(1/4)*u+(1/4)v;ret=Append[ret,{TOPt[X],fs}];
X=p+(2/3)*u+(1/4)*v;ret=Append[ret,{TOPt[X],fs}];
X=p*(1/12)*u+(11/12)*v;ret=Append[ret,{TOPt[X],fs}];
X=p*(1/6)*u+(5/6)*v;ret=Append[ret,{TOPt[X],fs}];
X=p*(2/3)*u+(1/6)*v;ret=Append[ret,{TOPt[X],fs}];
X=p*(1/3)*u+(1/4)*v;ret=Append[ret,{TOPt[X],fs}];
X=p*(1/3)*u+(1/2)*v;ret=Append[ret,{TOPt[X],fs}];
Return[RandomSample[ret,Cn]]];
QtextF[3]
CListF[3]

ICListF[mm_]:=Module[{Cn,A,B,C,s,t,p,u,v,X,fs1,fs2,ret={}},
{Cn,{A,B,C}}=QtList[[mm]];fs="正解です.";
fs1="\\(x=\\overvec{OA}+s\\overvec{AB}+t\\overvec{AC}\\)の場合,\\("
<>TOT[s]<>","<>TOT[t]<>"\\)はどのような範囲でなければならないか考えてみよう.";
fs2="そもそも平面上にないようです.";
p=A;u=B-A;v=C-A;
X=p+u+(1/2)*v;ret=Append[ret,{TOPt[X],fs1}];
X=p+(1/4)*u+(5/6)v;ret=Append[ret,{TOPt[X],fs1}];
X=p+(2/3)*u+(3/4)v;ret=Append[ret,{TOPt[X],fs1}];
X=p-(1/3)*u+(1/2)v;ret=Append[ret,{TOPt[X],fs1}];
X=p+(1/4)*u-(2/3)v;ret=Append[ret,{TOPt[X],fs1}];
X=2*p+(2/3)*u+(1/4)*v;ret=Append[ret,{TOPt[X],fs2}];
X=-p+(1/6)*u+(3/4)*v;ret=Append[ret,{TOPt[X],fs2}];
X=-p+(1/12)*u+(2/3)*v;ret=Append[ret,{TOPt[X],fs2}];
Return[RandomSample[ret,SELNUM-Cn]]];

ICListF[5]

GenerateMCxml[DFname[],"LA/06-03."<>Title<>"(MC1)",Title,NUM,"false",QtextF,CListF,ICListF]