<html>
<head>
<title>One or Several Quiz - RJM Programming - July, 2021</title>
<meta charset="utf-8"/>
<script type='text/javascript'>
var qs=["Which countries comprise Indochina?|Which countries border the Gulf of Thailand?",
"Which are primary colours?|Which are secondary colours?",
"In order which are 6th, 7th and 8th longest rivers in the world?|In order which are 1st, 2nd and 3rd longest rivers in the world?",
"How many in a baker's dozen?|What is the base number of hexidecimal numbers?",
"As of 30/7/2021 how many countries use the euro as their primary currency?",
"Which of these capital cities are South American ones?|Which of these capital cities are European ones?",
"In order which are increasing atomic number gaseous element symbols of the periodic table?",
"Which three consecutive numbers form a numerical sequence?",
"That's odd?!|Feel like getting even?!",
"Which cloud types can result in drizzle?|Which cloud types result in no precipitation?",
"Of the main taxonomic ranks below which categorizes Homo?|Of the main taxonomic ranks below which categorizes Cnidaria?",
"Which set of three consecutive rock types are Metamorphic rocks?|Which set of three consecutive rock types are Sedimentary rocks?|Which set of three consecutive rock types are Igneous rocks?",
];
var os=["Cambodia, China, Japan, Laos, Myanmar, North Korea, South Korea, Thailand, Vietnam, India, Bangladesh, Malaysia",
"orange, yellow, purple, blue, red, brown, green",
"Yangtze, Mekong, ParanĂ¡, Irtysh, Lena, Mississippi, Nile, Yellow, Congo, Amazon",
"12, 14, 16, 15, 13, 24, 10",
"27, 25, 19, 21, 23, 22, 12, 17",
"Paris, Montevideo, Caracas, Pretoria, Jakarta, New Delhi, Lima, San Salvador, Georgetown, Tashkent, Copenhagen, Sucre",
"Og, F, B, C, Xe, Ne, N, Be, Li, Ca, K, Ka, Ar, H, O, He, Cl",
"2, 4, 15, 81, 9, 3, 33, 38, 42, 21, 14, 8, 56, 45, 31",
"72, 84, 15, 81, 9, 63, 33, 38, 42, 21, 14, 88, 56, 45, 31",
"Cirrus, Cirrocumulus, Cirrostratus, Altocumulus, Altostratus, Nimbostratus, Stratocumulus, Stratus, Cumulus, Cumulonimbus",
"kingdom, phylum or division, class, order, family, genus, species",
"pumice, gabbro, granite, slate, marble, schist, limestone, sandstone, shale"
];
var as=["Cambodia, Laos, Myanmar, Thailand, Vietnam|Thailand, Vietnam, Cambodia",
"yellow, blue, red|orange, purple, green",
"Yellow,ParanĂ¡,Congo|Nile,Amazon,Yangtze",
"13|16",
"19",
"Montevideo, Caracas, Lima, Georgetown, Sucre|Paris, Copenhagen",
"H,N,O,F,He,Ne,Cl,Ar,Kr,Xe,Og",
"81, 9, 3",
"15, 81, 9, 63, 33, 21, 45, 31|72, 84, 38, 42, 14, 88, 56",
"Stratocumulus, Stratus|Cirrus, Cirrocumulus, Cirrostratus",
"genus|phylum or division",
"slate, marble, schist|limestone, sandstone, shale|pumice, gabbro, granite"
];
var repeated=false;
var ck=false;
var score=0;
var goes=0;
var lastq=-1;
var savedih=''
var gmlist='';
var validcall=true;
var inthegame=false;
var zero=0, zeroes=[0];
var snum=1;
var prevs='';
var overallq="";
var overallm="";
var overalla="";
function scoreit() {
var suffix=' ... Bad luck.';
if (inthegame && validcall) {
goes++;
if (('' + zeroes.length) == '0') {
document.getElementById('score').innerHTML='Score: ' + score + '/' + goes + suffix;
gmlist='';
document.getElementById('answer').size='1';
document.getElementById('answer').innerHTML=savedih;
validcall=false;
inthegame=false;
pickq();
return '';
}
var answs=gmlist.split(',');
var rw=[];
var i=-1;
for (var ijk=0; ijk<without(zeroes.length); ijk++) {
//if (ijk == 0) { alert(gmlist + ' ' + zeroes[0] + ' ' + zeroes.length + ' zero=' + zero + ' ... ' + document.getElementById('answer').getAttribute('data-title')); }
if (gmlist.toLowerCase() == document.getElementById('answer').getAttribute('data-title').split('|')[zeroes[zero]].toLowerCase().replace(/\ /g,'') && eval(1 + ijk) == eval('' + zeroes.length)) {
score+=eval('' + document.getElementById('answer').getAttribute('data-title').split('|')[zeroes[zero]].toLowerCase().replace(/\|/g,',').split(',').length);
suffix=' ... Well done!';
} else if (document.getElementById('answer').getAttribute('data-title').split('|')[zeroes[zero]].toLowerCase().indexOf(' ') != -1 && eval(1 + ijk) == eval('' + zeroes.length)) {
rw=(',' + document.getElementById('answer').getAttribute('data-title').split('|')[zeroes[zero]] + ',').replace(/\,\ /g,',');
for (i=0; i<answs.length; i++) {
//if (rw == rw.replace(',' + answs[i] + ',', '|')) { alert('was=' + rw + ' via ' + ',' + answs[i] + ',' + ' and now=' + rw.replace(',' + answs[i] + ',', '|')); }
rw=rw.replace(',' + answs[i] + ',', ',');
}
//alert(rw.replace(/\,/g, '').replace(/\ /g, ''));
if (rw.replace(/\|/g, '').replace(/\,/g, '').replace(/\ /g, '') == '' && eval(1 + ijk) == eval('' + zeroes.length)) {
score+=eval('' + document.getElementById('answer').getAttribute('data-title').split('|')[zeroes[zero]].toLowerCase().replace(/\|/g,',').split(',').length);
suffix=' ... Well done!';
}
}
if (eval(1 + ijk) == eval('' + zeroes.length)) {
zero=zeroes[eval(1 + ijk)];
}
}
document.getElementById('score').innerHTML='Score: ' + score + '/' + goes + suffix;
gmlist='';
document.getElementById('answer').size='1';
document.getElementById('answer').innerHTML=savedih;
validcall=false;
inthegame=false;
pickq();
} else if (inthegame) {
validcall=true;
document.body.style.cursor='progress';
setTimeout(scoreit, 15000);
}
}
function getask() {
qs=eval("[" + overallq + "]");
os=eval("[" + overallm + "]");
as=eval("[" + overalla + "]");
//alert(qs);
//alert(os);
//alert(as);
pickq();
}
function pickq() {
if (!ck) {
ck=true;
if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
document.getElementById('answer').onchange=function() { twoanswer(); };
}
document.getElementById('resa').href=document.URL.split('#')[0].split('?')[0];
if (window.localStorage) {
if (('' + window.localStorage.getItem("dykquiz")).replace('undefined','').replace('null','') != '') {
var bigqa=decodeURIComponent(window.localStorage.getItem("dykquiz"));
var bqs=bigqa.split('"^"');
if (bqs.length >= 3) {
overallq=bqs[0] + '"';
overallm='"' + bqs[1] + '"';
overalla='"' + bqs[2];
document.getElementById('smode').innerHTML="<select id=sdyk onchange=' if (this.value.length != 0) { eval(this.value); } prevs=this.value; ' style=display:inline-block;><option value=''>" + '"' + "Did You Know" + '"' + "</option><option onclick=getask(); value='getask();'>Recall Saved Quiz Questions and Answers</option><option onclick=ask(); value='ask();'>Reask</option></select>";
}
}
}
}
if (savedih == '') { savedih=document.getElementById('answer').innerHTML; }
var apick=Math.floor(Math.random() * qs.length);
while (apick == lastq) {
apick=Math.floor(Math.random() * qs.length);
}
if (eval('' + qs.length) > 1) { lastq=apick; }
var spick=Math.floor(Math.random() * 2);
var selih=savedih;
var answs=os[apick].split(',');
document.body.style.cursor='pointer';
if (qs[apick].replace('Of the ',' consecutive ').indexOf(' consecutive ') != -1) { spick=1; }
for (var i=0; i<answs.length; i++) {
if (spick == 1 ) {
selih+="<option onclick='oneanswer(this);' value='" + answs[i].trim() + "'>" + answs[i].trim() + "</option>";
} else {
selih=selih.replace(savedih, savedih + "<option onclick='oneanswer(this);' value='" + answs[i].trim() + "'>" + answs[i].trim() + "</option>");
}
spick=Math.floor(Math.random() * 2);
if (qs[apick].replace('Of the ',' consecutive ').indexOf(' consecutive ') != -1) { spick=1; }
}
document.getElementById('answer').innerHTML=selih;
document.getElementById('answer').size='' + eval(1 + answs.length);
//document.getElementById('answer').setAttribute('data-title', wor(as[apick]));
document.getElementById('answer').setAttribute('data-title', as[apick]);
document.getElementById('answer').value='';
document.getElementById('theq').innerHTML=maybesel(qs[apick]);
}
function wor(ap) {
var thingos=ap.replace(/\ /g,'').replace(/\|/g,',').split(',');
var sofara=',' + thingos[0] + ',';
repeated=false;
for (var iij=1; iij<thingos.length; iij++) {
if (sofara.indexOf(',' + thingos[iij] + ',') != -1) { repeated=true; }
sofara+=thingos[iij] + ',';
}
return ap;
}
function maybesel(inq) {
zero=0;
zeroes=[0];
if (inq.indexOf('|') == -1) {
return inq;
} else {
var seltd=' selected';
var selopts=inq.split('|');
var seloh='<select id=selt onchange="zero=oureval(this);" size=' + selopts.length + ' multiple></select>';
for (var isel=0; isel<selopts.length; isel++) {
seloh=seloh.replace('</select>', '<option value=' + isel + seltd + '>' + selopts[isel] + '</option></select>');
seltd='';
}
//alert(seloh);
return seloh;
}
}
function oureval(sin) {
zero=-1;
zeroes=[];
for (var i=0; i<sin.options.length; i++) {
if (sin.options[i].selected) {
if (zero < 0) {
zero=eval('' + sin.options[i].value);
zeroes.push(zero);
zero=0;
} else {
zeroes.push(eval('' + sin.options[i].value));
}
}
}
if (zero < 0) { zero=zero; }
//alert('zeroes.length=' + zeroes.length);
if (eval(''+ zeroes.length) > 1) {
document.getElementById('answer').setAttribute('data-title', wor(document.getElementById('answer').getAttribute('data-title')));
}
return zero;
}
function without(zl) {
if (document.getElementById('selt')) {
if (('' + zeroes.length) == ('' + document.getElementById('selt').size)) {
//alert('before: ' + document.getElementById('answer').getAttribute('data-title'));
if (document.getElementById('answer').getAttribute('data-title').indexOf(',') == -1) {
document.getElementById('answer').setAttribute('data-title',wor(document.getElementById('answer').getAttribute('data-title').replace(/\|/g, ', ')));
} else if (document.getElementById('answer').getAttribute('data-title').indexOf(' ') != -1) {
document.getElementById('answer').setAttribute('data-title',wor(document.getElementById('answer').getAttribute('data-title').replace(/\|/g, ', ')));
} else {
document.getElementById('answer').setAttribute('data-title',wor(document.getElementById('answer').getAttribute('data-title').replace(/\|/g, ',')));
}
//alert('afeter: ' + document.getElementById('answer').getAttribute('data-title'));
zl=1;
zero=0;
zeroes=[zero];
} else if (eval('' + zeroes.length) > 1) {
var dgis='', dgdelim=',';
//alert('Before: ' + document.getElementById('answer').getAttribute('data-title'));
if (document.getElementById('answer').getAttribute('data-title').indexOf(',') == -1) {
dgdelim=', '; //document.getElementById('answer').setAttribute('data-title',document.getElementById('answer').getAttribute('data-title').replace(/\|/g, ', '));
} else if (document.getElementById('answer').getAttribute('data-title').indexOf(' ') != -1) {
dgdelim=', '; //document.getElementById('answer').setAttribute('data-title',document.getElementById('answer').getAttribute('data-title').replace(/\|/g, ', '));
} else {
dgdelim=','; //document.getElementById('answer').setAttribute('data-title',document.getElementById('answer').getAttribute('data-title').replace(/\|/g, ','));
}
for (var jj=0; jj<zeroes.length; jj++) {
if (jj == 0) {
dgis=document.getElementById('answer').getAttribute('data-title').split('|')[zeroes[jj]];
} else {
dgis+=dgdelim + document.getElementById('answer').getAttribute('data-title').split('|')[zeroes[jj]];
}
}
document.getElementById('answer').setAttribute('data-title',wor(dgis));
//alert('After: ' + document.getElementById('answer').getAttribute('data-title'));
zl=1;
zero=0;
zeroes=[zero];
//} else {
//alert('why? ' + zeroes.length + ' vs ' + document.getElementById('selt').size);
}
}
return zl;
}
function twoanswer() {
oneanswer(document.getElementById('answer'));
}
function oneanswer(invlo) {
var invl=invlo.value + '|', adone=false;
if (invl == '') { return ''; }
inthegame=true;
var isvalid=false;
var morethanone=0;
document.body.style.cursor='pointer';
if (('' + invl).indexOf('|') != -1) {
if ((',' + gmlist.replace(/\ /g,'') + ',').indexOf(',' + invl.split('|')[0].replace(/\ /g,'') + ',') == -1) {
isvalid=true;
if (gmlist == '') {
gmlist=invl.split('|')[0];
} else {
gmlist+=',' + invl.split('|')[0];
}
} else if (repeated) {
//alert('gmlist=' + gmlist);
isvalid=true;
gmlist+=',' + invl.split('|')[0];
}
// alert('gmlist=' + gmlist);
}
var sin=document.getElementById('answer');
for (var ii=1; ii<sin.options.length; ii++) {
if (sin.options[ii].selected) {
morethanone++;
}
}
if (morethanone > 1) {
gmlist='';
isvalid=false;
}
for (var i=1; i<sin.options.length; i++) {
if (sin.options[i].selected) {
if (sin.options[i].innerText.indexOf(String.fromCodePoint(10004)) == -1) {
sin.options[i].innerText+=' ' + String.fromCodePoint(10004);
//alert(1);
} else if (morethanone > 1) {
adone=false;
if (sin.options[i].innerText.split(String.fromCodePoint(10004)).length > 1) {
if (sin.options[i].innerText.split(String.fromCodePoint(10004))[1].trim() != '') {
adone=true;
}
}
if (!adone) { sin.options[i].innerText=sin.options[i].innerText.split(String.fromCodePoint(10004))[0] + String.fromCodePoint(10004); }
}
if ((sin.options[i].value + '|').indexOf('|') != -1) {
//if (gmlist.indexOf((sin.options[i].value + '|').split('|')[0]) == -1) {
if ((',' + gmlist.replace(/\ /g,'') + ',').indexOf(',' + (sin.options[i].value + '|').split('|')[0].replace(/\ /g,'') + ',') == -1) {
if (gmlist == '') {
gmlist=(sin.options[i].value + '|').split('|')[0];
} else {
gmlist+=',' + (sin.options[i].value + '|').split('|')[0];
}
if ((sin.options[i].innerText + ' ').indexOf(' ' + gmlist.split(',').length + ' ') == -1) {
sin.options[i].innerText+=' ' + gmlist.split(',').length;
}
//alert(3);
}
} else {
adone=false;
if (sin.options[i].innerText.split(String.fromCodePoint(10004)).length > 1) {
if (sin.options[i].innerText.split(String.fromCodePoint(10004))[1].trim() != '') {
adone=true;
}
}
//alert('adone=' + adone);
}
} else if (morethanone > 1) {
if (sin.options[i].innerText.indexOf(String.fromCodePoint(10004)) != -1) {
sin.options[i].innerText=sin.options[i].innerText.split(String.fromCodePoint(10004))[0];
//alert(2);
sin.options[i].style.backgroundColor='white';
//} else {
//alert(7);
}
} else if (invl.indexOf(sin.options[i].value) == 0) {
adone=false;
if (sin.options[i].innerText.split(String.fromCodePoint(10004)).length > 1) {
if (sin.options[i].innerText.split(String.fromCodePoint(10004))[1].trim() != '') {
adone=true;
}
}
//alert('5:' + morethanone + ':' + invl + ' adone=' + adone + ' gmlist=' + gmlist);
}
}
if (isvalid) {
invlo.style.backgroundColor='rgb(230,230,230)';
if ((invlo.innerText + ' ').indexOf(' ' + gmlist.split(',').length + ' ') == -1) {
invlo.innerText+=' ' + gmlist.split(',').length;
}
validcall=false;
if (morethanone == 1) {
//alert(8);
document.body.style.cursor='progress';
setTimeout(scoreit, 15000);
} else {
//alert(9);
scoreit();
}
} else {
//alert(0);
document.body.style.cursor='progress';
setTimeout(scoreit, 15000);
}
}
function ask() {
var cnt=0;
var theq=" ", cdelimq="";
var them=" ", cdelimm="";
var thea=" ", cdelima="";
overallq="";
overallm="";
overalla="";
while (theq != "" && them != "" && thea != "") {
if (qs.length > cnt) {
theq=prompt("Enter question(s) (delimited by |) for set " + eval(1 + cnt), qs[cnt]);
} else {
theq=prompt("Enter question(s) (delimited by |) for set " + eval(1 + cnt), "");
}
if (!theq) { theq=""; }
if (theq != '') {
if (os.length > cnt) {
them=prompt("Enter full list of choices using comma delimitation " + eval(1 + cnt), os[cnt]);
} else {
them=prompt("Enter full list of choices using comma delimitation " + eval(1 + cnt), "");
}
if (!them) { them=""; }
}
if (theq != '' && them != '') {
if (as.length > cnt) {
thea=prompt("Enter full list of correct answer (using padded comma delimitation where order does not matter) set(s) (delimited by |) " + eval(1 + cnt), as[cnt]);
} else {
thea=prompt("Enter full list of correct answer (using padded comma delimitation where order does not matter) set(s) (delimited by |) " + eval(1 + cnt), "");
}
if (!thea) { thea=""; }
}
if (theq != "" && them != "" && thea != "") {
overallq+=cdelimq + '"' + theq + '"';
overallm+=cdelimq + '"' + them + '"';
overalla+=cdelimq + '"' + thea + '"';
cdelimq=",";
cdelimm=",";
cdelima=",";
cnt++;
}
}
if (overallq != "" && overallm != "" && overalla != "") {
//alert(1);
if (window.localStorage) {
//alert(11);
if (('' + window.localStorage.getItem("dykquiz")).replace('undefined','').replace('null','') != '') {
window.localStorage.removeItem("dykquiz");
window.localStorage.setItem("dykquiz", encodeURIComponent(overallq + '^' + overallm + '^' + overalla));
} else {
window.localStorage.setItem("dykquiz", encodeURIComponent(overallq + '^' + overallm + '^' + overalla));
}
}
location.href=document.URL.split('#')[0].split('?')[0];
}
if (document.getElementById('sdyk')) {
document.getElementById('sdyk').value=prevs;
}
}
</script>
</head>
<body onload="pickq();">
<h1>One or Several <div id=smode style=display:inline-block;><a title='Asks for your question and answer data for quiz' id=dmode style='cursor:pointer;text-decoration:underline;' onclick=ask();>"Did You Know"</a></div> Quiz</h1>
<h3>RJM Programming <a id=resa href=./one_or_several_quiz.html title=Restart>-</a> July, 2021</h3>
<h4 id=score>Score: 0/0</h4>
<table cellpadding=10 cellspacing=10 border=20 style='width:90%'>
<tr><th style='text-align:center;background-color:yellow;'>Question</th></tr>
<tr><td id=theq style='text-align:center;'></td></tr>
<tr><th style='background-color:orange;'>Answer</th></tr>
<tr><td style='text-align:center;'><select style='background-color:pink;text-align:center;' id=answer data-title='' title='' size=1 multiple><option data-onclick='oneanswer(this);' value=''>Please select answer(s) below, as necessary, in order you click them ...</option></select></td></tr>
</table>
</body>
</html>