(*© 2012-Present Computational ClassNotes, lossofgenerality.org, Creative Commons License *)
(*https://creativecommons.org/licenses/by-nc-sa/3.0/us/  :  Attribution-NonCommercial-ShareAlike *)

SetOptions[EvaluationNotebook[],Background->LightGray]

Cloud Libraries

CloudGet["https://www.wolframcloud.com/objects/ccn/module/v5.1"];
init[];
Clear[init];

logic1[ctr_,mywords_,abcd_]:=Module[{correct,vv,words,wrong,vars,aa,a,b,c,example,choices,molecule={},wrongmolecule={},name,chars,n,removed,chars0},


vv=Release@Map[Hold[RandomChoice@{ToUpperCase,ToLowerCase}],RandomSample[Complement[CharacterRange["a","z"],{"l","o", "i","e"}],2]];


correct={};
wrong={{},{},{}};
choices=Join[{correct},wrong];
While[Or@@(#[[1]]===#[[2]]&/@Permutations[choices, {2}]),

name=names[[1]];
chars=chars0=Characters@name;
n=RandomInteger[{1,Length@chars}];
chars[[n]]="_";
removed=StringJoin@chars;

correct=chars0[[n]];
wrong=Complement[chars0,{chars0[[n]]}];

wrong=RandomSample[wrong,If[Length@wrong>3, 3,Length@wrong]];

choices=Join[{correct},wrong];];


If [mywords=!={}, words=mywords[vars,ctr], words[s_]:=Nothing];


<|

"question labeled"->(
myFRAME1@Column@{
Row@{ctr,"Choose the missing letter"},
Spacer@100,
Style[removed,Bold, 25],
Spacer@100,
RandomChoice[CCNENGLISH`nounsveggies[ToLowerCase@name]]["image"]
}
),

"question"->(
myFRAME1@Column@{
Row@{ctr,"Choose the missing letter"},
Spacer@100,
Style[removed,Bold, 25],
Spacer@100,
RandomChoice[CCNENGLISH`nounsveggies[ToLowerCase@name]]["image"]
}
),


"anime"->(

{(*
ImageResize[myRASTER[#],{450,540}]&/@list*)}

),

"tutorial_anime"->(
{}
),

"example"->(

example=Column@{
Row@{Style["Example Stuff",Orange,FontSize->18,FontWeight->Bold]}
}

),

(*This was added in 4.0 to allow for pdf that is different than exampl*)
"example PDF"->(

(*example*)
{}

(*Column@{
Row@{Style["PDF Stuff",Orange,FontSize->18,FontWeight->Bold]}

}*)

),

"example_anime"->(

{}
),

"solution"->(
{
Row@{Style["Solution",FontSize->18,FontWeight->Bold]},
words["solution"],
correct
}
),

"correct"->(
myFRAME2@correct
),

"wrong"->(
myFRAME2/@wrong
),

"video"->({}),
"molecule"->(molecule), (*used for the question or example*)
"molecule"->(molecule), 
"wrong_molecule"->(wrongmolecule),
"abcd"->({})


|>

];



logic2[ctr_,mywords_,abcd_]:=Module[{correct,vv,words,wrong,vars,aa,a,b,c,example,choices,molecule={},wrongmolecule={},name,chars,n,removed,chars0},


vv=Release@Map[Hold[RandomChoice@{ToUpperCase,ToLowerCase}],RandomSample[Complement[CharacterRange["a","z"],{"l","o", "i","e"}],2]];


correct={};
wrong={{},{},{}};
choices=Join[{correct},wrong];
While[Or@@(#[[1]]===#[[2]]&/@Permutations[choices, {2}]),

name=names[[2]];
chars=chars0=Characters@name;
n=RandomInteger[{1,Length@chars}];
chars[[n]]="_";
removed=StringJoin@chars;

correct=chars0[[n]];
wrong=Complement[chars0,{chars0[[n]]}];

wrong=RandomSample[wrong,If[Length@wrong>3, 3,Length@wrong]];

choices=Join[{correct},wrong];];


If [mywords=!={}, words=mywords[vars,ctr], words[s_]:=Nothing];


<|

"question labeled"->(
myFRAME1@Column@{
Row@{ctr,"Choose the missing letter"},
Spacer@100,
Style[removed,Bold, 25],
Spacer@100,
RandomChoice[CCNENGLISH`nounsveggies[ToLowerCase@name]]["image"]
}
),

"question"->(
myFRAME1@Column@{
Row@{ctr,"Choose the missing letter"},
Spacer@100,
Style[removed,Bold, 25],
Spacer@100,
RandomChoice[CCNENGLISH`nounsveggies[ToLowerCase@name]]["image"]
}
),


"anime"->(

{(*
ImageResize[myRASTER[#],{450,540}]&/@list*)}

),

"tutorial_anime"->(
{}
),

"example"->(

example=Column@{
Row@{Style["Example Stuff",Orange,FontSize->18,FontWeight->Bold]}
}

),

(*This was added in 4.0 to allow for pdf that is different than exampl*)
"example PDF"->(

(*example*)
{}

(*Column@{
Row@{Style["PDF Stuff",Orange,FontSize->18,FontWeight->Bold]}

}*)

),

"example_anime"->(

{}
),

"solution"->(
{
Row@{Style["Solution",FontSize->18,FontWeight->Bold]},
words["solution"],
correct
}
),

"correct"->(
myFRAME2@correct
),

"wrong"->(
myFRAME2/@wrong
),

"video"->({}),
"molecule"->(molecule), (*used for the question or example*)
"molecule"->(molecule), 
"wrong_molecule"->(wrongmolecule),
"abcd"->({})


|>

];



logic3[ctr_,mywords_,abcd_]:=Module[{correct,vv,words,wrong,vars,aa,a,b,c,example,choices,molecule={},wrongmolecule={},name,chars,n,removed,chars0},


vv=Release@Map[Hold[RandomChoice@{ToUpperCase,ToLowerCase}],RandomSample[Complement[CharacterRange["a","z"],{"l","o", "i","e"}],2]];


correct={};
wrong={{},{},{}};
choices=Join[{correct},wrong];
While[Or@@(#[[1]]===#[[2]]&/@Permutations[choices, {2}]),

name=names[[3]];
chars=chars0=Characters@name;
n=RandomInteger[{1,Length@chars}];
chars[[n]]="_";
removed=StringJoin@chars;

correct=chars0[[n]];
wrong=Complement[chars0,{chars0[[n]]}];

wrong=RandomSample[wrong,If[Length@wrong>3, 3,Length@wrong]];

choices=Join[{correct},wrong];];


If [mywords=!={}, words=mywords[vars,ctr], words[s_]:=Nothing];


<|

"question labeled"->(
myFRAME1@Column@{
Row@{ctr,"Choose the missing letter"},
Spacer@100,
Style[removed,Bold, 25],
Spacer@100,
RandomChoice[CCNENGLISH`nounsveggies[ToLowerCase@name]]["image"]
}
),

"question"->(
myFRAME1@Column@{
Row@{ctr,"Choose the missing letter"},
Spacer@100,
Style[removed,Bold, 25],
Spacer@100,
RandomChoice[CCNENGLISH`nounsveggies[ToLowerCase@name]]["image"]
}
),


"anime"->(

{(*
ImageResize[myRASTER[#],{450,540}]&/@list*)}

),

"tutorial_anime"->(
{}
),

"example"->(

example=Column@{
Row@{Style["Example Stuff",Orange,FontSize->18,FontWeight->Bold]}
}

),

(*This was added in 4.0 to allow for pdf that is different than exampl*)
"example PDF"->(

(*example*)
{}

(*Column@{
Row@{Style["PDF Stuff",Orange,FontSize->18,FontWeight->Bold]}

}*)

),

"example_anime"->(

{}
),

"solution"->(
{
Row@{Style["Solution",FontSize->18,FontWeight->Bold]},
words["solution"],
correct
}
),

"correct"->(
myFRAME2@correct
),

"wrong"->(
myFRAME2/@wrong
),

"video"->({}),
"molecule"->(molecule), (*used for the question or example*)
"molecule"->(molecule), 
"wrong_molecule"->(wrongmolecule),
"abcd"->({})


|>

];


logic4[ctr_,mywords_,abcd_]:=Module[{correct,vv,words,wrong,vars,aa,a,b,c,example,choices,molecule={},wrongmolecule={},name,chars,n,removed,chars0},


vv=Release@Map[Hold[RandomChoice@{ToUpperCase,ToLowerCase}],RandomSample[Complement[CharacterRange["a","z"],{"l","o", "i","e"}],2]];


correct={};
wrong={{},{},{}};
choices=Join[{correct},wrong];
While[Or@@(#[[1]]===#[[2]]&/@Permutations[choices, {2}]),

name=names[[4]];
chars=chars0=Characters@name;
n=RandomInteger[{1,Length@chars}];
chars[[n]]="_";
removed=StringJoin@chars;

correct=chars0[[n]];
wrong=Complement[chars0,{chars0[[n]]}];

wrong=RandomSample[wrong,If[Length@wrong>3, 3,Length@wrong]];

choices=Join[{correct},wrong];];


If [mywords=!={}, words=mywords[vars,ctr], words[s_]:=Nothing];


<|

"question labeled"->(
myFRAME1@Column@{
Row@{ctr,"Choose the missing letter"},
Spacer@100,
Style[removed,Bold, 25],
Spacer@100,
RandomChoice[CCNENGLISH`nounsveggies[ToLowerCase@name]]["image"]
}
),

"question"->(
myFRAME1@Column@{
Row@{ctr,"Choose the missing letter"},
Spacer@100,
Style[removed,Bold, 25],
Spacer@100,
RandomChoice[CCNENGLISH`nounsveggies[ToLowerCase@name]]["image"]
}
),


"anime"->(

{(*
ImageResize[myRASTER[#],{450,540}]&/@list*)}

),

"tutorial_anime"->(
{}
),

"example"->(

example=Column@{
Row@{Style["Example Stuff",Orange,FontSize->18,FontWeight->Bold]}
}

),

(*This was added in 4.0 to allow for pdf that is different than exampl*)
"example PDF"->(

(*example*)
{}

(*Column@{
Row@{Style["PDF Stuff",Orange,FontSize->18,FontWeight->Bold]}

}*)

),

"example_anime"->(

{}
),

"solution"->(
{
Row@{Style["Solution",FontSize->18,FontWeight->Bold]},
words["solution"],
correct
}
),

"correct"->(
myFRAME2@correct
),

"wrong"->(
myFRAME2/@wrong
),

"video"->({}),
"molecule"->(molecule), (*used for the question or example*)
"molecule"->(molecule), 
"wrong_molecule"->(wrongmolecule),
"abcd"->({})


|>

];

logic5[ctr_,mywords_,abcd_]:=Module[{correct,vv,words,wrong,vars,aa,a,b,c,example,choices,molecule={},wrongmolecule={},name,chars,n,removed,chars0},


vv=Release@Map[Hold[RandomChoice@{ToUpperCase,ToLowerCase}],RandomSample[Complement[CharacterRange["a","z"],{"l","o", "i","e"}],2]];


correct={};
wrong={{},{},{}};
choices=Join[{correct},wrong];
While[Or@@(#[[1]]===#[[2]]&/@Permutations[choices, {2}]),

name=names[[5]];
chars=chars0=Characters@name;
n=RandomInteger[{1,Length@chars}];
chars[[n]]="_";
removed=StringJoin@chars;

correct=chars0[[n]];
wrong=Complement[chars0,{chars0[[n]]}];

wrong=RandomSample[wrong,If[Length@wrong>3, 3,Length@wrong]];

choices=Join[{correct},wrong];];


If [mywords=!={}, words=mywords[vars,ctr], words[s_]:=Nothing];


<|

"question labeled"->(
myFRAME1@Column@{
Row@{ctr,"Choose the missing letter"},
Spacer@100,
Style[removed,Bold, 25],
Spacer@100,
RandomChoice[CCNENGLISH`nounsveggies[ToLowerCase@name]]["image"]
}
),

"question"->(
myFRAME1@Column@{
Row@{ctr,"Choose the missing letter"},
Spacer@100,
Style[removed,Bold, 25],
Spacer@100,
RandomChoice[CCNENGLISH`nounsveggies[ToLowerCase@name]]["image"]
}
),


"anime"->(

{(*
ImageResize[myRASTER[#],{450,540}]&/@list*)}

),

"tutorial_anime"->(
{}
),

"example"->(

example=Column@{
Row@{Style["Example Stuff",Orange,FontSize->18,FontWeight->Bold]}
}

),

(*This was added in 4.0 to allow for pdf that is different than exampl*)
"example PDF"->(

(*example*)
{}

(*Column@{
Row@{Style["PDF Stuff",Orange,FontSize->18,FontWeight->Bold]}

}*)

),

"example_anime"->(

{}
),

"solution"->(
{
Row@{Style["Solution",FontSize->18,FontWeight->Bold]},
words["solution"],
correct
}
),

"correct"->(
myFRAME2@correct
),

"wrong"->(
myFRAME2/@wrong
),

"video"->({}),
"molecule"->(molecule), (*used for the question or example*) 
"wrong_molecule"->(wrongmolecule),
"abcd"->({})


|>

];

DATA

CloudConnect["wayne@compclassnotes.com","Wolf!123"]
CloudSymbol["CCNENGLISH`ctrveggies"]=0;
CCNENGLISH`nounsveggies=<|


"pea"->{
<|"name"->Style["Pea",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Pea",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Pea",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Pea",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Pea",40],"image"->ImageResize[,200]|>} ,

"potato"->{
<|"name"->Style["Potato",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Potato",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Potato",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Potato",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Potato",40],"image"->ImageResize[,200]|>} ,


"onion"->{
<|"name"->Style["Onion",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Onion",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Onion",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Onion",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Onion",40],"image"->ImageResize[,200]|>} ,

"chilli"->{
<|"name"->Style["Chilli",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Chilli",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Chilli",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Chilli",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Chilli",40],"image"->ImageResize[,200]|>} ,


"tomato"->{
<|"name"->Style["Tomato",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Tomato",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Tomato",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Tomato",40],"image"->ImageResize[,200]|>,
<|"name"->Style["Tomato",40],"image"->ImageResize[,200]|>} 







|>;

names=Keys@CCNENGLISH`nounsveggies

CloseKernels[];

LaunchKernels[4]

SetSharedVariable[CCNENGLISH`nounsveggies];

JSON

PNG=False;
debugCORRECT=False;
isSERVER="JSON";
myDIRECTORY={NotebookDirectory[],"veggiesnames_","SVG"};
myGIFDIRECTORY={NotebookDirectory[],"veggiesnames_","GIF"};
myCDFDIRECTORY={NotebookDirectory[],"veggiesnames_","cdf"};
myPDFDIRECTORY={NotebookDirectory[],"veggiesnames_","pdf"};


myTITLE={" "," "," "};


vars=Table[
ParallelTable[


varilist={

{logic1,{},<|"type"->"1","question"->myDIRECTORY,"tutorial"->myDIRECTORY,"anime"->myGIFDIRECTORY|>},
{logic2,{},<|"type"->"1","question"->myDIRECTORY,"tutorial"->myDIRECTORY,"anime"->myGIFDIRECTORY|>},
{logic3,{},<|"type"->"1","question"->myDIRECTORY,"tutorial"->myDIRECTORY,"anime"->myGIFDIRECTORY|>},
{logic4,{},<|"type"->"1","question"->myDIRECTORY,"tutorial"->myDIRECTORY,"anime"->myGIFDIRECTORY|>},
{logic5,{},<|"type"->"1","question"->myDIRECTORY,"tutorial"->myDIRECTORY,"anime"->myGIFDIRECTORY|>}
};


nn=Length@varilist;
varilist=RandomSample[varilist,nn];

(*uncomment these two lines if chained questions*)
(*varilist=Flatten[varilist,1];
nn=Length@varilist;*)
tmp=ConstantArray["",nn];
logics=varilist[[All,1]];
words=varilist[[All,2]];
etc=varilist[[All,3]];

title=<|
1->"1. ",
2->"2. ",
3->"3. ",
4->"4. ",
5->"5. ",
6->"6. "

|>;



Table[tmp[[ii]]=makeVAR[title[ii],logics[[ii]],words[[ii]],If[ii==1,{},( tmp[[ii-1]])[[1]][[2]]],etc[[ii]]]["json"],{ii,1,nn}],

{32}],
{1}];

vars=Flatten[vars,1];

CloseKernels[];

Export[FileNameJoin@{NotebookDirectory[],"cache","cache.json"},vars];

CloseKernels[];