// JavaScript Document
/*This loads the buttons' functions*/
$(document).ready(function(){
$('#check1').click(check1);
$('#check2').click(check2);
$('#check3').click(check3);
$('#check3one').click(check3one);
$('#check3two').click(check3two);
$('#check4').click(check4);
$('#printit').click(printit);
});
//print the answers
function printit() {
var name=prompt("Please enter your name");
var exercisename=$('#exercisename').val();
var answer1 = "";
var answer2 = "";
var answer3 = "";
var answer4 = "";
var answer5 = "";
var answer6 = "";
var answer7 = "";
var answer8 = "";
var answer9 = "";
var answer10 = "";
var answer11 = "";
var answer12 = "";
var answer13 = "";
var answer14 = "";
var answer15 = "";
var answer16="";
var bonus = "";
var challenge = "";
switch(exercisename)
{
case "Etymology Exercise I":
answer1 = "1. " + $('#text1').val();
answer2 = "2. " + $('#text2').val();
answer3 = "3. " + $('#text3').val();
answer4 = "4. " + $('#text4').val();
answer5 = "5. " + $('#text5').val();
answer6 = "6. " + $('#text6').val();
break;
case "Etymology Exercise II":
for (i=1; i<=11 ;i++)
{
var ischecked = $('#box'+i).attr('checked');
if (ischecked)
{
answer1 = answer1 + i + ". " + $('#box'+i).val() + "
";
}
else
{
answer1 = answer1 + i + ". not related to -pre" + "
";
}
}
break;
case "Grammar Exercise I":
answer1 = "1. " + $('#text1').val();
answer2 = "2. " + $('#text2').val();
answer3 = "3. " + $('#text3').val();
answer4 = "4. " + $('#text4').val();
break;
case "Grammar Exercise II":
if (document.exercise.radio1[0].checked)
{
answer1 = "1. the curious ministers";
}
else if (document.exercise.radio1[1].checked)
{
answer1 = "1. the heavenly ancient ones";
}
else if (document.exercise.radio1[2].checked)
{
answer1 = "1. that ancient enemy";
}
if (document.exercise.radio2[0].checked)
{
answer1 = "2. blindfolded";
}
else if (document.exercise.radio2[1].checked)
{
answer2 = "2. as a captive";
}
else if (document.exercise.radio2[2].checked)
{
answer2 = "2. as a brave conqueror";
}
if (document.exercise.radio3[0].checked)
{
answer3 = "3. a Beast";
}
else if (document.exercise.radio3[1].checked)
{
answer3 = "3. a whale";
}
else if (document.exercise.radio3[2].checked)
{
answer3 = "3. a warlike creature";
}
if (document.exercise.radio4[0].checked)
{
answer4 = "4. He will be shown mercy";
}
else if (document.exercise.radio4[1].checked)
{
answer4 = "4. He will tremble with his whole body";
}
else if (document.exercise.radio4[2].checked)
{
answer4 = "4. He will be consigned to the eternal flames of Hell";
}
if (document.exercise.radio5[0].checked)
{
answer5 = "5. the chosen ones";
}
else if (document.exercise.radio5[1].checked)
{
answer5 = "5. a huge monster";
}
else if (document.exercise.radio5[2].checked)
{
answer5 = "5. the voters";
}
break;
default:
}
contents= "
'; contents+=name; contents+='
'; contents+=exercisename; contents+=''; contents+=''; contents+=answer1; contents+='
'; contents+=''; contents+=answer2; contents+='
'; contents+=''; contents+=answer3; contents+='
'; contents+=''; contents+=answer4; contents+='
' contents+=''; contents+=answer5; contents+='
' contents+=''; contents+=answer6; contents+='
' contents+=''; contents+=answer7; contents+='
' contents+=''; contents+=answer8; contents+='
' contents+=''; contents+=answer9; contents+='
' contents+=''; contents+=answer10; contents+='
' contents+=''; contents+=answer11; contents+='
' contents+=''; contents+=answer12; contents+='
' contents+=''; contents+=answer13; contents+='
' contents+=''; contents+=answer14; contents+='
' contents+=''; contents+=answer15; contents+='
' contents+=''; contents+=answer16; contents+='
' contents+=''; contents+=bonus; contents+='
'; contents+=''; contents+=challenge; contents+='
'; contents+=''; planner=window.open("","","menubar,height=500,width=600,scrollbars,resizable","false"); planner.document.write(contents); planner.document.close(); planner.focus(); } //checks exercise 4 function check4() { var total = 0; var txt1 = $('#text1').val(); var txt2 = $('#text2').val(); var txt3 = $('#text3').val(); var txt4 = $('#text4').val(); if (txt1.toLowerCase()=="luxuriam") { total = total + 1; } if (txt2.toLowerCase()=="discordiam") { total = total + 1; } if (txt3.toLowerCase()=="desperationem") { total = total + 1; } if (txt4.toLowerCase()=="praesumptionem") { total = total + 1; } if (total == 4) { alert("Congratulations! All of your answers are correct."); } else if (total == 1) { alert("You have " + total + " answer correct.\n\nCare to try again?"); } else { alert("You have " + total + " answers correct.\n\nCare to try again?"); } } //checks exercise 3 function check3() { var total = 0; var txt1 = $('#text1').val(); var txt2 = $('#text2').val(); var txt3 = $('#text3').val(); var txt4 = $('#text4').val(); var txt5 = $('#text5').val(); var txt6 = $('#text6').val(); var txt7 = $('#text7').val(); var txt8 = $('#text8').val(); var txt9 = $('#text9').val(); var txt10 = $('#text10').val(); var txt11 = $('#text11').val(); var txt12 = $('#text12').val(); if (txt1.toLowerCase()=="bon") { total = total + 1; } if (txt2.toLowerCase()=="terr") { total = total + 1; } if (txt3.toLowerCase()=="poen") { total = total + 1; } if (txt4.toLowerCase()=="face") { total = total + 1; } if (txt5.toLowerCase()=="fact") { total = total + 1; } if (txt6.toLowerCase()=="perturba") { total = total + 1; } if (txt7.toLowerCase()=="perturbat") { total = total + 1; } if (txt8.toLowerCase()=="porta") { total = total + 1; } if (txt9.toLowerCase()=="portat") { total = total + 1; } if (txt10.toLowerCase()=="fec") { total = total + 1; } if (txt11.toLowerCase()=="perturbav") { total = total + 1; } if (txt12.toLowerCase()=="portav") { total = total + 1; } if (total == 12) { alert("Congratulations! All of your answers are correct."); } else if (total == 1) { alert("You have " + total + " answer correct.\n\nCare to try again?"); } else { alert("You have " + total + " answers correct.\n\nCare to try again?"); } } //checks exercise 3 function check3one() { var total = 0; var txt1 = $('#text1').val(); var txt2 = $('#text2').val(); var txt3 = $('#text3').val(); if (txt1.toLowerCase()=="bon") { total = total + 1; } if (txt2.toLowerCase()=="terr") { total = total + 1; } if (txt3.toLowerCase()=="poen") { total = total + 1; } if (total == 3) { alert("Congratulations! All of your answers are correct."); } else if (total == 1) { alert("You have " + total + " answer correct.\n\nCare to try again?"); } else { alert("You have " + total + " answers correct.\n\nCare to try again?"); } } //checks exercise 3 function check3two() { var total = 0; var txt4 = $('#text4').val(); var txt5 = $('#text5').val(); var txt6 = $('#text6').val(); var txt7 = $('#text7').val(); var txt8 = $('#text8').val(); var txt9 = $('#text9').val(); var txt10 =$('#text10').val(); var txt11 =$('#text11').val(); var txt12 =$('#text12').val(); if (txt4.toLowerCase()=="face") { total = total + 1; } if (txt10.toLowerCase()=="fec") { total = total + 1; } if (txt5.toLowerCase()=="fact") { total = total + 1; } if (txt6.toLowerCase()=="perturba") { total = total + 1; } if (txt11.toLowerCase()=="perturbav") { total = total + 1; } if (txt7.toLowerCase()=="perturbat") { total = total + 1; } if (txt8.toLowerCase()=="porta") { total = total + 1; } if (txt12.toLowerCase()=="portav") { total = total + 1; } if (txt9.toLowerCase()=="portat") { total = total + 1; } if (total == 9) { alert("Congratulations! All of your answers are correct."); } else if (total == 1) { alert("You have " + total + " answer correct.\n\nCare to try again?"); } else { alert("You have " + total + " answers correct.\n\nCare to try again?"); } } //checks exercise 1 function check2() { var totalright = 0; var box1 = $('#box1').attr('checked'); var box2 = $('#box2').attr('checked'); var box4 = $('#box4').attr('checked'); var box6 = $('#box6').attr('checked'); var box7 = $('#box7').attr('checked'); var box10 = $('#box10').attr('checked'); var totalwrong = 0; var box3 = $('#box3').attr('checked'); var box5 = $('#box5').attr('checked'); var box8 = $('#box8').attr('checked'); var box9 = $('#box9').attr('checked'); if (box1) { totalright = totalright + 1; } if (box3) { totalwrong = totalwrong + 1; } if (box4) { totalright = totalright + 1; } if (box5) { totalwrong = totalwrong + 1; } if (box6) { totalright = totalright + 1; } if (box7) { totalright = totalright + 1; } if (box8) { totalwrong = totalwrong + 1; } if (box9) { totalwrong = totalwrong + 1; } if (box2) { totalright = totalright + 1; } if (box10) { totalright = totalright + 1; } if (totalright == 6) { if (totalwrong==0) { alert("Congratulations! All of your answers are correct."); } else { alert("You have checked " + totalright + " answers correctly and " + totalwrong + " answers incorrectly.\n\nCare to try again?"); } } else { alert("You have checked " + totalright + " answers correctly and " + totalwrong + " answers incorrectly.\n\nCare to try again?"); } } //checks exercise 2 function check1() { var total = 0; var txt1 = $('#text1').val(); var txt2 = $('#text2').val(); var txt3 = $('#text3').val(); var txt4 = $('#text4').val(); var txt5 = $('#text5').val(); var txt6 = $('#text6').val(); if (txt1.toLowerCase()=="capacious") { total = total + 1; } if (txt2.toLowerCase()=="accept") { total = total + 1; } if (txt3.toLowerCase()=="except") { total = total + 1; } if (txt4.toLowerCase()=="participate") { total = total + 1; } if (txt5.toLowerCase()=="captive") { total = total + 1; } if (txt6.toLowerCase()=="incipient") { total = total + 1; } if (total == 6) { alert("Congratulations! All of your answers are correct."); } else if (total == 1) { alert("You have " + total + " answer correct.\n\nCare to try again?"); } else { alert("You have " + total + " answers correct.\n\nCare to try again?"); } } }