Today we share how to add GK MCQ question in Blogger Post. Flowing the steps.
Change Your Question and answer
You May Like Also
Also Like This
- Login your Blog
- Select HTML mode
- Then Paste the below code
View Demo -Click Here
MCQ Code
Inproratnt:<SCRIPT LANGUAGE="JavaScript">
QUIZTITLE="Play Quiz On 'First in World' | ID:130819b";
lt='<';
gt='>';
//First line: Type 1 = Multiple choice
// 2 = All that apply
// 3 = Fill in the blank
//2nd line: Number of answers if Type is #1 or #2, not included for FITB
//3rd (2nd) line: Question
//nth lines: Answers with first position BLANK for correct answer(s), or
correct FITB answer.
QUIZQUESTIONS=new Array(
1,
3,
"Who was the First American President to Visit India ?",
"George Washington",
" Dwight Eisenhower",
"Abraham Lincoln",
1,
3,
"Where were First Asian Games held ?",
"Lahore, Pakistan",
" New Delhi, India",
"Colombo, Srilanka",
1,
3,
"Who was the First cricketer to achieve hat-trick in both
innings of a Test Match ?",
"Anil Kumble, India",
" Thomas Mathews, Australia",
"Sanath Jayasuriya, Srilanka",
1,
3,
"First President of Pakistan ?",
" Iskandar Mirza",
"Ayub Khan",
"Mohd Ali Jinnah",
1,
3,
"First Woman Pilot to Make Solo Flight ?",
"Velentina Tereshkova",
"Jerrie Mock",
" Elise Deroche",
1,
3,
"First European to Visit China ?",
" Marco Polo",
"Alexander",
"Columbus",
1,
3,
"First Speaker in Hindi at United Nations ?",
"JL Nehru",
"Manmohan Singh",
" Atal Bihari Vajpayee",
1,
3,
"First Woman to climb Mount Everest ?",
"Aarti Saha",
" Junko Tabei",
"Ann Bancroft",
1,
3,
"First Man to Fly Over the English Channel ?",
"Richard E Byrd",
"Wiley Post",
" Louis",
1,
3,
"First Man Cosmonaut in Space ?",
" Yuri Gagrin",
"Alexie Leonov",
"Neil Armstrong");
function showradio(X)
{
if(X==1) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD1">')}
if(X==2) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD2">')}
if(X==3) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD3">')}
if(X==4) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD4">')}
if(X==5) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD5">')}
if(X==6) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD6">')}
if(X==7) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD7">')}
if(X==8) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD8">')}
if(X==9) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD9">')}
if(X==10) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD10">')}
if(X==11) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD11">')}
if(X==12) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD12">')}
if(X==13) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD13">')}
if(X==14) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD14">')}
if(X==15) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD15">')}
if(X==16) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD16">')}
if(X==17) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD17">')}
if(X==18) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD18">')}
if(X==19) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD19">')}
if(X==20) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD20">')}
if(X==21) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD21">')}
if(X==22) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD22">')}
if(X==23) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD23">')}
if(X==24) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD24">')}
if(X==25) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD25">')}
if(X==26) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD26">')}
if(X==27) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD27">')}
if(X==28) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD28">')}
if(X==29) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD29">')}
if(X==30) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD30">')}
if(X==31) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD31">')}
if(X==32) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD32">')}
if(X==33) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD33">')}
if(X==34) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD34">')}
if(X==35) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD35">')}
if(X==36) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD36">')}
if(X==37) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD37">')}
if(X==38) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD38">')}
if(X==39) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD39">')}
if(X==40) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD40">')}
if(X==41) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD41">')}
if(X==42) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD42">')}
if(X==43) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD43">')}
if(X==44) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD44">')}
if(X==45) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD45">')}
if(X==46) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD46">')}
if(X==47) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD47">')}
if(X==48) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD48">')}
if(X==49) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD49">')}
if(X==50) {document.writeln(lt,'INPUT TYPE="radio" NAME="RAD50">')}
FORM_ELEMENT_COUNT=FORM_ELEMENT_COUNT+1;
}
function showcheckbox()
{
document.writeln(lt,'INPUT TYPE="checkbox" NAME="CHK1">');
FORM_ELEMENT_COUNT=FORM_ELEMENT_COUNT+1;
}
function showtext()
{
document.writeln(lt,'INPUT TYPE="text" NAME="TXT1">');
FORM_ELEMENT_COUNT=FORM_ELEMENT_COUNT+1;
}
function scoreit()
{
TEXT_MESSAGES="";
TOTAL_SCORE=0;
CURRENT_ELEMENT=0;
QUESTION_NUMBER=0;
J=0;
while(J<=QUIZQUESTIONS.length-1)
{
QUESTION_NUMBER=QUESTION_NUMBER+1;
QUESTION_TYPE=QUIZQUESTIONS[J];
if(QUESTION_TYPE == 1 || QUESTION_TYPE == 2)
{
/* Move on to number of answers if it's type #1 or #2 */
J=J+1;
QUESTION_ANSWERS=QUIZQUESTIONS[J];
}
/* Move on to question */
J=J+1;
/* IGNORE IT */
TEXT_MESSAGES=TEXT_MESSAGES+QUIZQUESTIONS
[J].toUpperCase()+":";
/* Move onto first answer */
J=J+1;
ANSWER_NUMBER=1
if(QUESTION_TYPE == 3)
{
/* It's a FITB */
TEXT_MESSAGES=TEXT_MESSAGES+QUIZQUESTIONS[J];
if(QUIZQUESTIONS[J] == " "+document.forms[0].elements
[CURRENT_ELEMENT].value.toUpperCase())
{
TOTAL_SCORE=TOTAL_SCORE+100/TOTAL_QUESTIONS;
TEXT_MESSAGES=TEXT_MESSAGES+"(Ok) ";
}
else
{
TEXT_MESSAGES=TEXT_MESSAGES+"(Wrong) ";
}
J=J+1;
CURRENT_ELEMENT=CURRENT_ELEMENT+1;
}
else
{
/* It's a "multiple choice" or "all that apply" */
CHECKBOX_COUNT=0;
CHECKBOX_CORRECT=0;
for(K=1; K<=QUESTION_ANSWERS; K=K+1)
{
if(QUIZQUESTIONS[J].substring(0,1) == " ")
{
/* A correct answer */
TEXT_MESSAGES=TEXT_MESSAGES+QUIZQUESTIONS[J];
if(QUESTION_TYPE == 1)
{
if(document.forms[0].elements[CURRENT_ELEMENT].checked)
{
TOTAL_SCORE=TOTAL_SCORE+100/TOTAL_QUESTIONS;
TEXT_MESSAGES=TEXT_MESSAGES+"(Ok) ";
}
else
{
TEXT_MESSAGES=TEXT_MESSAGES+"(Wrong) ";
}
}
if(QUESTION_TYPE == 2)
{
CHECKBOX_COUNT=CHECKBOX_COUNT+1
if(document.forms[0].elements[CURRENT_ELEMENT].checked)
{
CHECKBOX_CORRECT=CHECKBOX_CORRECT+1;
TEXT_MESSAGES=TEXT_MESSAGES+"(Ok) ";
}
else
{
TEXT_MESSAGES=TEXT_MESSAGES+"(Wrong) ";
}
}
}
else
{
/* An incorrect answer */
if(QUESTION_TYPE == 1)
{
/* Do nothing - only credit score when single correct answer is
checked */
}
if(QUESTION_TYPE == 2)
{
CHECKBOX_COUNT=CHECKBOX_COUNT+1
if(!document.forms[0].elements[CURRENT_ELEMENT].checked)
{
CHECKBOX_CORRECT=CHECKBOX_CORRECT+1;
}
}
}
ANSWER_NUMBER=ANSWER_NUMBER+1;
J=J+1;
CURRENT_ELEMENT=CURRENT_ELEMENT+1;
}
if(QUESTION_TYPE == 2)
{
TOTAL_SCORE=TOTAL_SCORE+((100/TOTAL_QUESTIONS)*
(CHECKBOX_CORRECT/CHECKBOX_COUNT));
}
TEXT_MESSAGES=TEXT_MESSAGES+" | ";
}
}
document.forms[0].Scorebox.value=TOTAL_SCORE;
if(TOTAL_SCORE>99.8)
{
TEXT_MESSAGES="Perfect score!";
}
document.forms[0].Resultstext.value=TEXT_MESSAGES;
}
/********** BEGINNING OF FORM CODE ************/
document.writeln("<BODY BGCOLOR='seashell' TEXT=#000000>");
document.writeln("<H2><CENTER>"+QUIZTITLE+"</CENTER></H2>");
document.writeln(lt,'FORM>');
document.writeln("<TABLE BORDER=0>");
FORM_ELEMENT_COUNT=0;
QUESTION_NUMBER=0;
J=0;
while(J<=QUIZQUESTIONS.length-1)
{
QUESTION_NUMBER=QUESTION_NUMBER+1;
QUESTION_TYPE=QUIZQUESTIONS[J];
/***document.writeln("Type: "+QUIZQUESTIONS[J]+"<BR>");***/
if(QUESTION_TYPE == 1 || QUESTION_TYPE == 2)
{
/* Move on to number of answers if it's type #1 or #2 */
J=J+1;
QUESTION_ANSWERS=QUIZQUESTIONS[J];
/***document.writeln("Answers: ",QUIZQUESTIONS[J]+"<BR>");***/
}
/* Move on to question */
J=J+1;
document.writeln("<TR><TD COLSPAN=2>"+QUIZQUESTIONS[J]
+"</TD></TR>");
/* Move onto first answer */
J=J+1;
ANSWER_NUMBER=1
if(QUESTION_TYPE == 3)
{
/* It's a FITB - display blank text box */
/***document.writeln("FITB answer: "+QUIZQUESTIONS[J]+"<BR>");***/
document.writeln("<TR><TD WIDTH=20 COLSPAN=2>");
showtext();
document.writeln("</TD><TD></TD></TR>");
J=J+1;
}
else
{
/* It's a "multiple choice" or "all that apply" - display and record corrects */
for(K=1; K<=QUESTION_ANSWERS; K=K+1)
{
if(QUIZQUESTIONS[J].substring(0,1) == " ")
{
/* A correct answer - write it WITHOUT leading space */
document.writeln("<TR><TD WIDTH=20>");
if(QUESTION_TYPE == 1)
{
showradio(QUESTION_NUMBER);
}
if(QUESTION_TYPE == 2)
{
showcheckbox();
}
document.writeln("</TD><TD>"+QUIZQUESTIONS[J].substring
(1,QUIZQUESTIONS[J].length)+"</TD></TR>");
}
else
{
/* An incorrect answer - no need to worry about stripping leading
space */
document.writeln("<TR><TD WIDTH=20>");
if(QUESTION_TYPE == 1)
{
showradio(QUESTION_NUMBER);
}
if(QUESTION_TYPE == 2)
{
showcheckbox();
}
document.writeln("</TD><TD>"+QUIZQUESTIONS[J]+"</TD></TR>");
}
ANSWER_NUMBER=ANSWER_NUMBER+1;
J=J+1;
}
}
document.writeln("<TR><TD COLSPAN=2><HR></TD></TR>");
}
TOTAL_QUESTIONS=QUESTION_NUMBER;
document.writeln("</TABLE>");
document.writeln(lt,'INPUT TYPE="button" NAME="ScoreButton" VALUE="
Score the quiz " onClick="scoreit()"><P>');
document.writeln("Score:<BR>");
document.writeln(lt,'INPUT TYPE="text" NAME="Scorebox" VALUE="Click
above to score"><P>');
document.writeln("Correct answers:<BR>");
document.writeln(lt,'TEXTAREA NAME="Resultstext" COLS=70
ROWS=5></TEXTAREA>');
document.writeln("</FORM><HR>");
document.writeln("<FONT SIZE=1>");
document.writeln("</FONT SIZE>");
</SCRIPT>
Change Your Question and answer
0 Comments