Widget:WikidocBoardReview: Difference between revisions

Jump to navigation Jump to search
Matt Pijoan (talk | contribs)
No edit summary
Matt Pijoan (talk | contribs)
No edit summary
Line 16: Line 16:
.imageDiv{
.imageDiv{
margin:5px 5px 5px 5px;
margin:5px 5px 5px 5px;
}


}
.WBRButton{
</style>
font-family:Arial;
<script type="text/javascript">
float:left;
function loginCheck(arg, exam){
background-color:#3366CC;
try{
height:40px;
var api = new mw.Api();
font-weight:bold;
examHandler(arg, exam);
width:150px;
}
display: table-cell;
catch(e){
cursor: pointer;
alert('You are not logged in. Please log in to continue<br />' + e.toString())
color:#FFFFFF;
}
text-align: center;
vertical-align: middle;
margin-right:10px;
}
}


function examHandler(arg,exam){
#navPane{
if(arg === 'Random'){
position:relative;  
selectExam(exam);
float:left;
} else if(arg === 'Queue'){
width:15%;
queueExam();
} else {
alert("Wat.");
}
}
 
#examSpace{
$('#next').on('click', function(event){
position:relative;
var Q = document.getElementById('question');
float:right;
Q.innerHTML = "";
width:84%;
var Questions = $("input[name='stash']").val().split(",");
var Pos = parseInt($("input[name='pos']").val());
if(Pos < Questions.length){
$("input[name='pos']").val(Pos + 1);
loadQuestion();
}
}
else {
.navPaneButton{
endExam();
height:30px;
return;
background-color:#3366CC;
padding-top:5px;
margin-bottom:10px;
color:#FFFFFF;
font-weight:bold;
text-align: center;
}
}
});
div.answerNoBorder{
 
border:5px solid #FFF;
$('#home').on('click', function(event){
location.reload();
});
 
$('#back').on('click', function(event){
var Q = document.getElementById('question');
Q.innerHTML = "";
var Questions = $("input[name='stash']").val().split(",");
var Pos = parseInt($("input[name='pos']").val());
if(Pos > 0){
$("input[name='pos']").val(Pos - 1);
loadQuestion();
}
}
else {
div.answerBorder{
alert("Already at beginning");
border:5px solid #000;
}
}
});
div.explanationHide{
height:0px;
visibility:hidden;
}
}
function queueExam(){
div.explanationShow{
var api = new mw.Api();
height:auto;
var result;
visibility:visible;
var pageString =  "User:" + mw.user.name() + "/WBRQueue";
api.get( {
action: 'query',
format: 'json',
        titles: pageString,
export: 'export',
        } , {
ok:function (data) {
        var xml = data.query.export["*"];
    xmlDoc = $.parseXML( xml ),
    $xml = $( xmlDoc ),
    $title = $xml.find( "text" );
if($title.text().indexOf('Placeholder,') == -1){
addNewSection( "User:" + mw.user.name() + "/WBRQueue",'Placeholder,', mw.user.tokens.get( 'editToken' ) );
alert('First Timah!');
return false;
}
}
    var Questions = $title.text().split(",");
</style>
Questions = jQuery.grep(Questions, function(value) {
<script type="text/javascript">
        return value != 'Placeholder';
function stepOne() {
      });
var options = {
if(Questions.length < 1){
examtype : null,
alert("You do not have a Queue!");
timer : null,
return false;
qbank : null,
} else {
timer : null,
timeAmt : null,
questionListAll : new Array(),
numQuestion : null,
currentQuestion : 0,
examQuestions : new Array(),
isParsed : 0,
answeredRight : 0,
Question : {
PageName : null,
PageAuthor : null,
Prompt : null,
RightAnswer : ' ',
AnswerA : null,
AnswerB : null,
AnswerC : null,
AnswerD : null,
AnswerE : null,
AnswerAExp : null,
AnswerBExp : null,
AnswerCExp : null,
AnswerDExp : null,
AnswerEExp : null,
selectedAnswer : 'F',
lastParsed : 0
}
}
var stuffs = "<a href='#' class='examType' id='USMLE Step 1'><img src='http://static.wikidoc.org/8/87/Step1.png' /></a>";
stuffs += "<a href='#' class='examType' id='USMLE Step 2 CK'><img src='http://static.wikidoc.org/0/07/Step2CK.png' /></a>";
stuffs += "<a href='#' class='examType' id='USMLE Step 3'><img src='http://static.wikidoc.org/0/08/Step3.png' /></a>";
stuffs += "<a href='#' class='examType' id='Board Review'><img src='http://static.wikidoc.org/7/75/Boardcertification.png' /></a>";
stuffs += "<a href='#' class='examType' id='MCAT'><img src='http://static.wikidoc.org/4/4b/MCAT.png' /></a><br />";
$("#exam").html(stuffs);
$('.examType').click(options, stepTwo);


    $("input[name='stash']").val(Questions);
        var Q = document.getElementById('question');
        Q.innerHTML = "";
        $('#next').css('visibility','visible');
} } });
}
}
function selectExam(exam){
function stepTwo(event) {
var Q = document.getElementById('question');
event.data.examtype = $(this).attr('id');
if(exam === "MCAT"){
var divs = null;
var mc = new Array("Biology", "Cell", "Enzymes", "Microbiology", "Cellular Metabolism", "Reproduction", "Embryology", "Musculoskeletal System", "Digestive System ", "Excretory System", "Respiratory System", "Skin", "Circulatory System", "Immune System", "Homeostasis", "Endocrine System", "Nervous System ", "Genetics", "Evolution", "Organic Chemistry", "Nomenclature", "Bonding/Structure", "Isomers", "Alkanes", "AlkenesAlkynes", "Haloalkanes", "Aromatic Compounds", "Alcohols", "Ethers", "Aldehydes ", "Ketones", "Carboxylic Acid", "Carboxylic Acid Derivatives", "Amines", "Nitrogen Containing Compounds", "Purification", "Spectroscopy", "Separations", "Carbohydrates", "Amino Acids", "Peptides", "Proteins", "Nucleic", "Acids", "Chemistry", "Atomic Structure", "Periodic Table", "Phases", "Gases", "Bonding", "Stoichiometry", "Kinetics", "Thermochemistry", "Phases", "Solutions", "Acids and Bases", "Redox Reactions", "Electrochemistry", "Physics", "Kinematics", "Fluids", "Solids", "Newtonian Mechanics", "Momentum", "Energy", "Thermodynamics", "Electrostatics", "Magnetism", "DC Circuits", "AC Circuits", "Periodic Motion", "Waves", "Sound", "Optics", "Light", "Atomic Phenomena", "Nuclear Phenomena" );
divs = "<center><h1>Build your own exam!</h1></center><div id='Pat' class='noSelect WBRButton stepTwo'><br />USMLE Format</div><div id='Flash' class='noSelect WBRButton stepTwo'><br />Flash Cards</div><br /><br /><br />";
var tableTemp = "<table style='width:100%;'><th><td><b>Keyword</b></td></th><tr>";
$("#exam").html(divs);
for(var i=0;i<mc.length;i++){
$('.stepTwo').click(event.data, stepThree);
tableTemp += "<td><input type='checkbox' name='MainCat' value='"+mc[i]+"' />"+mc[i]+"</td>";
if((i+1)%4 == 0){tableTemp += "</tr><tr>";}}
Q.innerHTML += tableTemp + "</tr></table><input type='checkbox' name='SubCat' style='visibility:hidden' value='MCAT' checked />";
} else {
var categories = new Array();
if(exam === "USMLE Step 1"){
categories['main'] = new Array("Anatomy", "Behavioral Science/Psychiatry", "Biochemistry", "Biostatistics/ Epidemiology", "Embryology", "Ethics", "Genetics", "Histology", "Immunology", "Microbiology", "Pathology", "Pathophysiology", "Pharmacology", "Physiology");
categories['sub'] = new Array("Cardiology", "Dermatology", "Endocrine", "Gastrointestinal", "Genitourinary", "Head and Neck", "Hematology", "Musculoskeletal/Rheumatology", "Neurology", "Oncology", "Pulmonology", "Reproductive", "Renal", "Vascular", "General Principles","Infectious Disease");
} else if(exam === "USMLE Step 2 CK"){
categories['main'] = new Array("Internal medicine", "Surgery", "OB/GYN", "Pediatrics", "Psychiatry");
categories['sub'] = new Array("Allergy/Immunology", "Cardiovascular", "Dermatology", "Endocrine", "Gastrointestinal", "Hepatology", "Genitourinary", "Head and Neck", "Hematology", "Infectious Disease", "Musculoskeletal/Rheumatology", "Neurology", "Obstetrics & Gynecology", "Oncology", "Ophthalmology", "Pediatrics", "Poisoning", "Preventive Medicine", "Psychiatry", "Respiratory", "Surgery", "Biostatistics/ Epidemiology", "Ethics", "Electrolytes", "Genetics", "Miscellaneous");
} else if(exam === "USMLE Step 3"){
categories['main'] = new Array("Community Medical Health Center", "Primary Care Office", "Inpatient Facilities", "Emergency Room");
categories['sub'] = new Array("Allergy/Immunology", "Cardiovascular", "Dermatology", "Endocrine", "Gastrointestinal", "Hepatology", "Genitourinary", "Head and Neck", "Hematology", "Infectious Disease", "Musculoskeletal/Rheumatology", "Neurology", "Obstetrics & Gynecology", "Oncology", "Ophthalmology", "Pediatrics", "Poisoning", "Preventive Medicine", "Psychiatry", "Respiratory", "Surgery", "Biostatistics/ Epidemiology", "Ethics", "Electrolytes", "Genetics", "Miscellaneous");
}else if(exam === "Board Review"){
categories['main'] = new Array("Adolescent Medicine", "Advanced Heart Failure and Transplant Cardiology", "Allergy & Immunology", "Cardiovascular Disease", "Clinical Cardiac Electrophysiology", "Critical Care Medicine", "Endocrinology", "Diabetes & Metabolism", "Gastroenterology", "Geriatric Medicine", "Hematology", "Hospice & Palliative Medicine", "Hospital Medicine", "Focused Practice", "Infectious Disease", "Internal Medicine", "Interventional Cardiology", "Medical Oncology", "Nephrology", "Pulmonary Disease", "Rheumatology", "Sleep Medicine", "Sports Medicine", "Transplant Hepatology");
categories['sub'] = new Array("Anesthesiology", "Dermatology", "Emergency Medicine", "Emergency Medicine/Critical Care Medicine", "Family Medicine", "Medical Genetics", "Neurology", "Nuclear Medicine", "Pediatrics", "Physical Medicine & Rehab", "Preventative Medicine", "Psychiatry");
} else {
alert('Coming Soon!');
location.reload();
return false;
}
}
var table = "<center><h1>Build your own exam!</h1></center><br /><br /><b>First: Select All That Apply:</b><br /><br /><br />";
function stepThree(event) {
table += "<table style='width:100%;'><tr><td style='width:49%;'><b>Main Category</b></td><td style='width:49%;'><b>Sub Category</b></td></tr>";
event.data.qbank = $(this).attr('id');
if(categories['sub'].length >= categories['main'].length){
var form = null;
  for(var i=0;i<categories['sub'].length;i++){
form = "<div id='yes' class='noSelect WBRButton stepThree'><br />Enable Timer</div><div id='nop' class='noSelect WBRButton stepThree'><br />Disable Timer</div><br /><br /><br />";
      if(categories['main'][i]){
if ($("#exam").find('#yes').length == 0) {
        table+="<tr><td><input type='checkbox' name='MainCat' value='"+categories['main'][i]+"' />"+categories['main'][i]+"</td><td><input type='checkbox' name='SubCat' value='"+categories['sub'][i]+"' />"+categories['sub'][i]+"</td></tr>";
$("#exam").append(form);
        } else {
}
        table+="<tr><td></td><td><input type='checkbox' name='SubCat' value='"+categories['sub'][i]+"' />"+categories['sub'][i]+"</td></tr>";
$('.stepThree').click(event.data, stepFour);
      }   
  }
} else {
  for(var i=0;i<categories['main'].length;i++){
      if(categories['sub'][i]){
        table+="<tr><td><input type='checkbox' name='MainCat' value='"+categories['main'][i]+"' />"+categories['main'][i]+"</td><td><input type='checkbox' name='SubCat' value='"+categories['sub'][i]+"' />"+categories['sub'][i]+"</td></tr>";
      } else {
        table+="<tr><td><input type='checkbox' name='MainCat' value='"+categories['main'][i]+"' />"+categories['main'][i]+"</td><td></td></tr>";
      }
  }
}    
table += "</table>"
var Q = document.getElementById('question');
Q.innerHTML = table;
}
}
function stepFour(event) {


Q.innerHTML += "<div id='SelectAll' class='noSelect' style='font-family:Arial;float:left;background-color:#3366CC;height:40px;font-weight:bold; width:150px; display: table-cell; cursor: default; color:#FFFFFF; text-align: center; vertical-align: middle;margin-right:10px;'>Click here to select all</div><div id='UnselectAll' class='noSelect' style='font-family:Arial;float:left;background-color:#3366CC;height:40px;font-weight:bold; width:150px; display: table-cell; cursor: default; color:#FFFFFF; text-align: center; vertical-align: middle;'>Click here to clear all</div><br /><br /><br /><br /><b>Second: choose the number of questions you would like to answer. The maximum number of questions you can select is 45.</b><br /><br /><br />Number of questions:<input type='text' id='numQues' /><br /><br /><div id='Go' class='noSelect' style='font-family:Arial;float:left;background-color:#3366CC;height:40px;font-weight:bold; width:150px; display: table-cell; cursor: default; color:#FFFFFF; text-align: center; vertical-align: middle;'>Click here to begin the exam</div>";
if ($(this).attr('id') === 'nop') {
$("#Go").click(function() {
event.data.timer = false;
  var Mfields = $("[name=MainCat]").serializeArray();
$('.stepFour').trigger('click', event.data);
  var Sfields = $("[name=SubCat]").serializeArray();
} else {
  var sMain = new Array();
event.data.timer = true;
  var sSub = new Array();
var form = null;
  if (Mfields.length === 0)
form = "<div id='1' class='noSelect WBRButton stepFour'><br />1 Minute</div><div id='10' class='noSelect WBRButton stepFour'><br />10 Minute</div><div id='20' class='noSelect WBRButton stepFour'><br />20 Minutes</div><div id='40' class='noSelect WBRButton stepFour'><br />40 Minutes</div><br /><br /><br />"
  {
if ($("#exam").find('#1').length == 0) {
    alert('No Main Category Selected');
$("#exam").append(form);
    selectExam();
}
  } else if(Sfields.length === 0)
$('.stepFour').click(event.data, stepFive);
  {
}
    alert('No Sub Category Selected');
    selectExam();
  } else if(!parseInt($("#numQues").val())){
    alert('Invalid Number of Quesitons');
    selectExam();
  } else if(parseInt($("#numQues").val()) > 45){
    alert('Too Many Questions');
    selectExam();
  } else if(parseInt($("#numQues").val()) <= 1){
    alert('Too Few Questions');
    selectExam();
  } else{
    $("[name=MainCat]:checked").each( function() {
              sMain.push($(this).val());
             
    });
        $("[name=SubCat]:checked").each( function() {
              sSub.push($(this).val());
    });
    var numQues = $("#numQues").val();
    var Questions = loadExam(exam, numQues, sSub, sMain).toString();
    $("input[name='stash']").val(Questions);
        var Q = document.getElementById('question');
        Q.innerHTML = "";
        $('#home').css('visibility','visible');
        loadQuestion();
}});
 
$("#SelectAll").click(function() {
$("[name=MainCat]").each( function() {
$(this).attr('checked', true);
});
$("[name=SubCat]").each( function() {
$(this).attr('checked', true);
});
});
$("#UnselectAll").click(function() {
$("[name=MainCat]").each( function() {
$(this).attr('checked', false);
});
$("[name=SubCat]").each( function() {
$(this).attr('checked', false);
});
});
}
}
function stepFive(event) {
var categories = [];
var table = null;
table = "<br /><b>Select All That Apply:</b><br /><br /><br />"; ;
if (event.data.examtype === "MCAT") {
categories['main'] = new Array("Biology", "Cell", "Enzymes", "Microbiology", "Cellular Metabolism", "Reproduction", "Embryology", "Musculoskeletal System", "Digestive System ", "Excretory System", "Respiratory System", "Skin", "Circulatory System", "Immune System", "Homeostasis", "Endocrine System", "Nervous System ", "Genetics", "Evolution", "Organic Chemistry", "Nomenclature", "Bonding/Structure", "Isomers", "Alkanes", "AlkenesAlkynes", "Haloalkanes", "Aromatic Compounds", "Alcohols", "Ethers", "Aldehydes ", "Ketones", "Carboxylic Acid", "Carboxylic Acid Derivatives", "Amines", "Nitrogen Containing Compounds", "Purification", "Spectroscopy", "Separations", "Carbohydrates", "Amino Acids", "Peptides", "Proteins", "Nucleic", "Acids", "Chemistry", "Atomic Structure", "Periodic Table", "Phases", "Gases", "Bonding", "Stoichiometry", "Kinetics", "Thermochemistry", "Phases", "Solutions", "Acids and Bases", "Redox Reactions", "Electrochemistry", "Physics", "Kinematics", "Fluids", "Solids", "Newtonian Mechanics", "Momentum", "Energy", "Thermodynamics", "Electrostatics", "Magnetism", "DC Circuits", "AC Circuits", "Periodic Motion", "Waves", "Sound", "Optics", "Light", "Atomic Phenomena", "Nuclear Phenomena");
for (var i = 0; i < categories['main'].length; i++) {
table += "<td><input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + "</td>";
if ((i + 1) % 4 == 0) {
table += "</tr><tr>";
}
}
} else {


if (event.data.examtype === "USMLE Step 1") {
categories['main'] = new Array("Anatomy", "Behavioral Science/Psychiatry", "Biochemistry", "Biostatistics/Epidemiology", "Embryology", "Ethics", "Genetics", "Histology", "Immunology", "Microbiology", "Pathology", "Pathophysiology", "Pharmacology", "Physiology");
categories['sub'] = new Array("Cardiology", "Dermatology", "Endocrine", "Gastrointestinal", "Genitourinary", "Head and Neck", "Hematology", "Musculoskeletal/Rheumatology", "Neurology", "Oncology", "Pulmonology", "Reproductive", "Renal", "Vascular", "General Principles", "Infectious Disease");
} else if (event.data.examtype === "USMLE Step 2 CK") {
categories['main'] = new Array("Internal medicine", "Surgery", "OB/GYN", "Pediatrics", "Psychiatry");
categories['sub'] = new Array("Allergy/Immunology", "Cardiovascular", "Dermatology", "Endocrine", "Gastrointestinal", "Hepatology", "Genitourinary", "Head and Neck", "Hematology", "Infectious Disease", "Musculoskeletal/Rheumatology", "Neurology", "Obstetrics and Gynecology", "Oncology", "Ophthalmology", "Pediatrics", "Poisoning", "Preventive Medicine", "Psychiatry", "Respiratory", "Surgery", "Biostatistics/ Epidemiology", "Ethics", "Electrolytes", "Genetics", "Miscellaneous");
} else if (event.data.examtype === "USMLE Step 3") {
categories['main'] = new Array("Community Medical Health Center", "Primary Care Office", "Inpatient Facilities", "Emergency Room");
categories['sub'] = new Array("Allergy/Immunology", "Cardiovascular", "Dermatology", "Endocrine", "Gastrointestinal", "Hepatology", "Genitourinary", "Head and Neck", "Hematology", "Infectious Disease", "Musculoskeletal/Rheumatology", "Neurology", "Obstetrics and Gynecology", "Oncology", "Ophthalmology", "Pediatrics", "Poisoning", "Preventive Medicine", "Psychiatry", "Respiratory", "Surgery", "Biostatistics/Epidemiology", "Ethics", "Electrolytes", "Genetics", "Miscellaneous");
} else if (event.data.examtype === "Board Review") {
categories['main'] = new Array("Adolescent Medicine", "Advanced Heart Failure and Transplant Cardiology", "Allergy & Immunology", "Cardiovascular Disease", "Clinical Cardiac Electrophysiology", "Critical Care Medicine", "Endocrinology", "Diabetes and Metabolism", "Gastroenterology", "Geriatric Medicine", "Hematology", "Hospice & Palliative Medicine", "Hospital Medicine", "Focused Practice", "Infectious Disease", "Internal Medicine", "Interventional Cardiology", "Medical Oncology", "Nephrology", "Pulmonary Disease", "Rheumatology", "Sleep Medicine", "Sports Medicine", "Transplant Hepatology");
categories['sub'] = new Array("Anesthesiology", "Dermatology", "Emergency Medicine", "Emergency Medicine/Critical Care Medicine", "Family Medicine", "Medical Genetics", "Neurology", "Nuclear Medicine", "Pediatrics", "Physical Medicine & Rehab", "Preventative Medicine", "Psychiatry");
}
table += "<table style='width:100%;'><tr><td style='width:49%;'><b>Main Category</b></td><td style='width:49%;'><b>Sub Category</b></td></tr>";
if (categories['sub'].length >= categories['main'].length) {}
var table = "<br /><br /><b>Select All That Apply:</b><br /><br /><br />";
table += "<table style='width:100%;'><tr><td style='width:49%;'><b>Main Category</b></td><td style='width:49%;'><b>Sub Category</b></td></tr>";
if (categories['sub'].length >= categories['main'].length) {
for (var i = 0; i < categories['sub'].length; i++) {
catQuestionCount(event.data.examtype, "s", categories['sub'][i]);
if (categories['main'][i]) {
catQuestionCount(event.data.examtype, "m", categories['main'][i]);
table += "<tr><td><input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + " ( <span id='" + categories['main'][i] + "'>0 </span> ) </td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( <span id='" + categories['sub'][i] + "'> 0 </span> )</td></tr>";
} else {
table += "<tr><td></td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( <span id='" + categories['sub'][i] + "'> 0 </span> ) </td></tr>";
}
}
} else {
for (var i = 0; i < categories['main'].length; i++) {
if (categories['sub'][i]) {
table += "<tr><td><input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + "</td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + "</td></tr>";
} else {
table += "<tr><td><input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + "</td><td></td></tr>";
}
}
}
table += "</table><div id='SelectAll' class='noSelect WBRButton'>Select All Main Categories</div><div id='UnselectAll' class='noSelect WBRButton'>Select All Sub Categories</div><br /><br /><br />Second: Click the Count Question Button below to calculate number of questions available:<br /><br /><br /><div id='CountQ' class='noSelect WBRButton'>Count Questions</div><br /><br /><br /><br />"
if ($("#exam").find('#SelectAll').length == 0) {
$("#exam").append(table);
}
}
$("#SelectAll").click(function () {
if ($("#SelectAll").html() === "Select All Main Categories") {
$("[name=MainCat]").each(function () {
$(this).attr('checked', true);
$("#SelectAll").html("Clear All Main Categories");
});
} else {
$("[name=MainCat]").each(function () {
$(this).attr('checked', false);
$("#SelectAll").html("Select All Main Categories");
});
}
});


$("#UnselectAll").click(function () {
if ($("#UnselectAll").html() === "Select All Sub Categories") {
$("[name=SubCat]").each(function () {
$(this).attr('checked', true);
$("#UnselectAll").html("Clear All Sub Categories");
});
} else {
$("[name=SubCat]").each(function () {
$(this).attr('checked', false);
$("#UnselectAll").html("Select All Sub Categories");
});
}
});


function loadExam(exam, numQues, SubCat, MainCat){
$("#CountQ").click(event.data, stepSix);
$.ajaxSetup({async: false});
var Questions = new Array();
while(numQues > Questions.length){
var api = new mw.Api();
var QueryString = '[[ExamType::'+exam+']] [[MainCategory::'+MainCat[Math.floor(Math.random()*MainCat.length)]+']] [[SubCategory::'+SubCat[Math.floor(Math.random()*SubCat.length)]+']]';
api.get( {
action: 'ask',
query: QueryString,
format: 'json',
        async: false
}, {
ok: function (data) {
$.each(data.query.results, function(index, value){
  Questions.push(index);
});
}
})
.error( function ( error ) {
        $.each(error, function(key, value) {
  alert(key + ': ' + value);
});
} );
}
return Questions;
}
}


function loadQuestion(){
function stepSix(event) {
var Questions = $("input[name='stash']").val().split(",");
var Main = new Array();
var name = Questions[parseInt($("input[name='pos']").val())-1];
var Sub = new Array();
$.ajaxSetup({async: false});
if ($("[name=MainCat]:checked").length > 0 && $("[name=SubCat]:checked").length > 0) {
var right = " ";
$("[name=MainCat]:checked").each(function () {
var qs = "[["+name+"]]|?PageAuthor|?Prompt|?RightAnswer|?AnswerA|?AnswerB|?AnswerC|?AnswerD|?AnswerE|?Explanation|?AnswerAExp|?AnswerBExp|?AnswerCExp|?AnswerDExp|?AnswerEExp|?WBRImage|?WBRImageCaption|?WBRImagePlace";
Main.push($(this).val());
var api = new mw.Api();
api.get( {
action: 'ask',
query: qs,
format: 'json'
}, {
ok: function (data) {  
hideButtons();
$.each(data.query.results, function(index, value){


var short = value.printouts;
});
        var temp = $("input[name='stash']").val().split(",");
$("[name=SubCat]:checked").each(function () {
var Q = document.getElementById('question');
        var author = ' ';
        if(short.PageAuthor['0']) {author = short.PageAuthor['0'];}
Q.innerHTML = "<b>Author:</b> " + author + "<br /><br /><b>Question " + $("input[name='pos']").val() + " / " + temp.length + "</b><br /><br />" + short.Prompt + "<br /><div id='promptImage' class='imageDiv'></div><br />";
        right = short.RightAnswer;
        if(short.AnswerA.length > 0){
        Q.innerHTML += "<div style='border:5px solid #FFF;' class='answer' id='A'> A. " + short.AnswerA + "<div id='AnsAImage' class='imageDiv'></div></div>";
        }if(short.AnswerAExp.length > 0){
        Q.innerHTML += "<div style='height:0px; visibility:hidden;border:3px solid #FFF;' class='answerExp' id='Ae'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + short.AnswerAExp['0'] + "</i></div>";
        }if(short.AnswerB.length > 0){
        Q.innerHTML += "<div style='border:5px solid #FFF;border:3px solid #FFF;' class='answer' id='B'> B. " + short.AnswerB + "<div id='AnsBImage' class='imageDiv'></div></div>";
        }if(short.AnswerBExp.length > 0){
        Q.innerHTML += "<div style='height:0px; visibility:hidden;' class='answerExp' id='Be'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + short.AnswerBExp['0'] + "</i></div>";
        }if(short.AnswerC.length > 0){
        Q.innerHTML += "<div style='border:5px solid #FFF;border:3px solid #FFF;' class='answer' id='C'> C. " + short.AnswerC + "<div id='AnsCImage' class='imageDiv'></div></div>";
        }if(short.AnswerCExp.length > 0){
        Q.innerHTML += "<div style='height:0px; visibility:hidden;' class='answerExp' id='Ce'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + short.AnswerCExp['0'] + "</i></div>";
        }if(short.AnswerD.length > 0){
        Q.innerHTML += "<div style='border:5px solid #FFF;border:3px solid #FFF;' class='answer' id='D'> D. " + short.AnswerD + "<div id='AnsDImage' class='imageDiv'></div></div>";
        }if(short.AnswerDExp.length > 0){
        Q.innerHTML += "<div style='height:0px; visibility:hidden;' class='answerExp' id='De'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + short.AnswerDExp['0'] + "</i></div>";
        }if(short.AnswerE.length > 0){
        Q.innerHTML += "<div style='border:5px solid #FFF;border:3px solid #FFF;' class='answer' id='E'> E. " + short.AnswerE + "<div id='AnsEImage' class='imageDiv'></div></div>";
        }if(short.AnswerEExp.length > 0){
        Q.innerHTML += "<div style='height:0px; visibility:hidden;' class='answerExp' id='Ee'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + short.AnswerEExp['0'] + "</i></div>";}


          if(short.WBRImage){
Sub.push($(this).val());
            for(var i=0;i<short.WBRImage.length;i++){
});
                if(short.WBRImagePlace[i] === "Prompt"){
var obj = completeQuestionCount(event.data.examtype, Main, Sub);
                document.getElementById('promptImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]);
$.each(obj.results, function (index, value) {
                             
event.data.questionListAll.push(value.fulltext);
                }
});
            if(short.WBRImagePlace[i] === "Answer A"){
var maxQ;
                document.getElementById('AnsAImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]);
if (obj.rows == 0) {
                             
alert('Insufficient questions in currently selected categories. Please select more Categories.');
                }
} else if (obj.rows >= 45) {
            if(short.WBRImagePlace[i] === "Answer B"){
maxQ = 45;
                document.getElementById('AnsBImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]);
} else {
                             
maxQ = obj.rows;
                }
}
            if(short.WBRImagePlace[i] === "Answer C"){
var output = "<b>Choose the number of questions you would like to answer. The maximum number of questions you can select is <span id='countShow'>" + maxQ + "</span>.</b><br /><br /><br />Number of questions:<input type='text' id='numQues' /><br /><br /><div id='Go' class='noSelect WBRButton'>Click here to begin the exam</div>";
                document.getElementById('AnsCImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]);
if ($("#exam").find('#numQues').length == 0) {
                             
$("#exam").append(output);
                }
}
            if(short.WBRImagePlace[i] === "Answer D"){
$("#Go").click(event.data, stepSeven);
                document.getElementById('AnsDImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]);
} else {
                             
alert('Please ensure you have both a main and a sub category selected');
                }
            if(short.WBRImagePlace[i] === "Answer E"){
                document.getElementById('AnsEImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]);
                             
                }
            }
        }
       
        $("div.answer").mouseover(function() {
            $(this).css({'border': '5px solid #000'})
        }).mouseout(function() {
            $(this).css({'border': '5px solid #FFF'})
        });
 
    $( "div.answer" ).click(function(){
      var Results = $("input[name='results']").val().split(",");
      var Pos = parseInt($("input[name='pos']").val()) - 1;
      $(".answerExp").css("height","auto");
      $(".answerExp").css("visibility","visible");
      $("div#" + $(this).attr("id")).css({'border': '5px solid #000'});
      $("div#" +short.RightAnswer.valueOf()).css({'color':'#F00'});
      if(short.RightAnswer.valueOf() == $( this ).attr("id").valueOf()){
        Results[Pos] = true;
        removeFromQueue(value.fulltext);
      }
      else
      {
      Results[Pos] = false;
      addToQueue(value.fulltext);
      }
      Q.innerHTML += "<br /><br />The correct answer is: "  + short.RightAnswer.valueOf() + "<br /><br /><i>" + short.Explanation + "</i><div id='ExpImage'></div><br />";
      if(short.WBRImage){
            for(var i=0;i<=short.WBRImage.length;i++){
 
                if(short.WBRImagePlace[i] === "Prompt"){
                document.getElementById('ExpImage') }
                  }}
 
      $("input[name='results']").val(Results.toString());
      showButtons();
      $("input[name='stash']").val(Questions.toString());
    });
});
}
}
    }
  );
}
}


function getImage(filename, caption){
function stepSeven(event) {
  var api = new mw.Api();
if ($("#numQues").val().length > 0 && parseInt($("#numQues").val(), 10) <= parseInt($("#countShow").html(), 10) && parseInt($("#numQues").val(), 10) > 0) {
  var result;
event.data.numQuestion = $("#numQues").val();
    api.get( {
$("#exam").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />");
action: 'parse',
loadNextQuestion(event.data);
text: '[[File:' + filename + ']]',
} else {
format: 'json',
alert('Invalid entry in number of questions input');
        async: false
}
        } , {  
ok: function(data) {
        result = data.parse.text['*'];
}});
  if(caption === "no-display"){
  return result;
  } else {
  result += caption;
  return result;
  }
}
}


function showButtons(){
function loadNextQuestion(event) {
$('#next').css('visibility','visible');
var rand = null;
$('#back').css('visibility','visible');
rand = Math.floor(Math.random() * event.questionListAll.length);
}
var name = null;
function hideButtons(){
name = event.questionListAll[rand];
$('#next').css('visibility','hidden');
event.questionListAll.splice(rand, 1);
$('#back').css('visibility','hidden');
var qs = "[[" + name + "]]|?PageAuthor|?Prompt|?RightAnswer|?AnswerA|?AnswerB|?AnswerC|?AnswerD|?AnswerE|?Explanation|?AnswerAExp|?AnswerBExp|?AnswerCExp|?AnswerDExp|?AnswerEExp";
}
var api = new mw.Api(event);
function endExam(){
api.get({
hideButtons();
action : 'ask',
var correct = 0;
query : qs,
var Results = $("input[name='results']").val().split(",");
async : false,
for (var i=0;i<Results.length;i++){
format : 'json'
if(Results[i].valueOf() == new String("true").valueOf()){
}, {
correct++;
ok : function (res) {
}
$.each(res.query.results, function (index, value) {
var temp = value.printouts;
var obj = new Object();
obj.PageName = value.fulltext;
obj.PageAuthor = temp.PageAuthor[0];
obj.RightAnswer = temp.RightAnswer[0];
obj.Prompt = temp.Prompt[0];
obj.AnswerA = temp.AnswerA[0];
obj.AnswerB = temp.AnswerB[0];
obj.AnswerC = temp.AnswerC[0];
obj.AnswerD = temp.AnswerD[0];
obj.AnswerE = temp.AnswerE[0];
obj.Explanation = temp.Explanation[0];
obj.AnswerAExp = temp.AnswerAExp[0];
obj.AnswerBExp = temp.AnswerBExp[0];
obj.AnswerCExp = temp.AnswerCExp[0];
obj.AnswerDExp = temp.AnswerDExp[0];
obj.AnswerEExp = temp.AnswerEExp[0];
obj.selectedAnswer = null;
obj.isParsed = 0;
obj.lastParsed = 0;
event.examQuestions[event.examQuestions.length] = obj;
if (event.examQuestions.length < event.numQuestion) {
loadNextQuestion(event);
} else {
addToNavBar(event);
}
});
}
});
}
}
var n = (100 / Results.length ) * correct;
function addToNavBar(exam) {
var Q = document.getElementById('question');
$("#exam").html("<div id='navPane'></div><div id='examSpace'></div>");
Q.innerHTML = "<h2>Exam Results:</h2>";
$.each(exam.examQuestions, function (index, value) {
Q.innerHTML += "<br /><br /><b>Questions Asked:</b> " + Results.length.toString();
$("#navPane").append("<div id='" + index + "' class='navPaneButton'>" + value.PageName + " : " + (index - -1) + "</div>");
Q.innerHTML += "<br /><br /><b>Questions Answered Correctly:</b> " + correct.toString();
});
Q.innerHTML += "<br /><br /><b>Score:</b> " + Math.floor(n).toString() + "%";
$(".navPaneButton").click(exam, questionNavigation);
Q.innerHTML += "<form><input type='button' onclick='location.reload()' value='Back to start' /><input type='button' onclick='selectExam()' value='Start a new exam' /></form>";
questionDisplay(exam);
return;
}
}


function removeFromQueue(question){
function questionDisplay(exam) {
var api = new mw.Api();
var obj = new Object();
var result;
obj = exam.examQuestions[exam.currentQuestion];
var pageString = "User:" + mw.user.name() + "/WBRQueue";
if (obj.isParsed === 0) {
api.get( {
$("#examSpace").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />");
action: 'query',
parseQuestions(exam);
format: 'json',
} else {
        titles: pageString,
var htmlStuff = "<b>Author:</b> " + obj.PageAuthor + "<br /><br /><b>Question " + (exam.currentQuestion - -1) + " / " + (exam.examQuestions.length - -1) + "</b><br /><br />" + obj.Prompt + "<br />";
export: 'export',
if (obj.AnswerA && obj.AnswerA.length > 0) {
        } , {
htmlStuff += "<div class='answer answerNoBorder' id='A'>  " + obj.AnswerA + "</div>";
ok:function (data) {
}
        var xml = data.query.export["*"];
if (obj.AnswerAExp && obj.AnswerAExp.length > 0) {
    xmlDoc = $.parseXML( xml ),
htmlStuff += "<div class='answerExp explanationHide' id='Ae'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerAExp + "</i></div>";
    $xml = $( xmlDoc ),
}
    $title = $xml.find( "text" );
if (obj.AnswerB && obj.AnswerB.length > 0) {
if($title.text().indexOf(question) != -1){
htmlStuff += "<div class='answer answerNoBorder' id='B'> " + obj.AnswerB + "</div>";
var pageContent = $title.text().split(',');
}
pageContent = jQuery.grep(pageContent, function(value) {
if (obj.AnswerBExp && obj.AnswerBExp.length > 0) {
        return value != question;
htmlStuff += "<div class='answerExp explanationHide' id='Be'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerBExp + "</i></div>";
      });
}
if (obj.AnswerC && obj.AnswerC.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='C'> " + obj.AnswerC + "</div>";
}
if (obj.AnswerCExp && obj.AnswerCExp.length > 0) {
htmlStuff += "<div class='answerExp explanationHide' id='Ce'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerCExp + "</i></div>";
}
if (obj.AnswerD && obj.AnswerD.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='D'> " + obj.AnswerD + "</div>";
}
if (obj.AnswerDExp && obj.AnswerDExp.length > 0) {
htmlStuff += "<div class='answerExp explanationHide' id='De'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerDExp + "</i></div>";
}
if (obj.AnswerEExp && obj.AnswerE.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='E'> " + obj.AnswerE + "</div>";
}
if (obj.AnswerEExp && obj.AnswerEExp.length > 0) {
htmlStuff += "<div class='answerExp explanationHide' id='Ee'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerEExp + "</i></div>";
}
$("#examSpace").html(htmlStuff);


var token = mw.user.tokens.get( 'editToken' )
$("div.answer").mouseover(function () {
addNewSection( "User:" + mw.user.name() + "/WBRQueue2",question, token );
$(this).css({
}
'border' : '5px solid #000'
}});
})
return result;
}).mouseout(function () {
$(this).css({
'border' : '5px solid #FFF'
})
});
$("div.answer").click(exam, answerClicked);
}
}
}


function addToQueue(question){
function answerClicked(event) {
var api = new mw.Api();
event.data.examQuestions[event.data.currentQuestion].selectedAnswer = event.target.id;
var result;
if (event.data.examQuestions[event.data.currentQuestion].RightAnswer === $(this).attr("id")) {
var pageString =  "User:" + mw.user.name() + "/WBRQueue";
event.data.answeredRight += 1;
api.get( {
}
action: 'query',
$(".answerExp").css("height", "auto");
format: 'json',
$(".answerExp").css("visibility", "visible");
        titles: pageString,
$(event.target).css({
export: 'export',
'border' : '5px solid #000'
        } , {
});
ok:function (data) {
$("#examSpace").append("<br /><br />The correct answer is: " + event.data.examQuestions[event.data.currentQuestion].RightAnswer + "<br /><br /><i>" + event.data.examQuestions[event.data.currentQuestion].Explanation + "</i><br />");
        var xml = data.query.export["*"];
if (event.data.currentQuestion > 0) {
    xmlDoc = $.parseXML( xml ),
$("#examSpace").append("<div id='back' class='noSelect WBRButton'><br />Back</div>");
    $xml = $( xmlDoc ),
$("#back").click(event.data, questionNavigation);
    $title = $xml.find( "text" );
}
if (event.data.currentQuestion < event.data.examQuestions.length - 1) {
$("#examSpace").append("<div id='next' class='noSelect WBRButton'><br />Next</div>");
$("#next").click(event.data, questionNavigation);
}
if (event.data.currentQuestion == (event.data.examQuestions.length - 1)) {
$("#examSpace").append("<div id='finish' class='noSelect WBRButton'><br />Finish</div>");
$("#finish").click(event.data, endExam);
}


var pageContent = $title.text().split(',');
pageContent.push(question);
var token = mw.user.tokens.get( 'editToken' );
addNewSection( "User:" + mw.user.name() + "/WBRQueue",question, token );
}});
return result;
}
}


function questionNavigation(event) {
$("#" + event.data.currentQuestion).removeClass("boxed");
if ($(this).attr("id") === "back") {
event.data.currentQuestion--;
} else if ($(this).attr("id") === "next") {
event.data.currentQuestion++;
} else if ($(this).attr("class") === "navPaneButton") {
event.data.currentQuestion = $(this).attr("id");
}
$("#" + event.data.currentQuestion).addClass("boxed");
questionDisplay(event.data);
}
function endExam(event) {
$("#examSpace").html("");
var datas;
datas = "You answered " + event.data.answeredRight + " out of " + event.data.examQuestions.length + " correctly.<br /> Your percentage score is: ";
var percent = (event.data.answeredRight / event.data.numQuestion) * 100;
datas += percent + "%";
$("#examSpace").append(datas);
}
function parseQuestions(examObj) {
var tobeParsed = null;
var parsed = null;
var q = examObj.currentQuestion;
switch (examObj.examQuestions[q].lastParsed) {
case 0:
tobeParsed = examObj.examQuestions[q].Prompt;
break;
case 1:
tobeParsed = "A. " + examObj.examQuestions[q].AnswerA;
break;
case 2:
tobeParsed = "B. " + examObj.examQuestions[q].AnswerB;
break;
case 3:
tobeParsed = "C. " + examObj.examQuestions[q].AnswerC;
break;
case 4:
tobeParsed = "D. " + examObj.examQuestions[q].AnswerD;
break;
case 5:
tobeParsed = "E. " + examObj.examQuestions[q].AnswerE;
break;
case 6:
tobeParsed = examObj.examQuestions[q].Explanation;
break;
case 7:
tobeParsed = examObj.examQuestions[q].AnswerAExp;
break;
case 8:
tobeParsed = examObj.examQuestions[q].AnswerBExp;
break;
case 9:
tobeParsed = examObj.examQuestions[q].AnswerCExp;
break;
case 10:
tobeParsed = examObj.examQuestions[q].AnswerDExp;
break;
case 11:
tobeParsed = examObj.examQuestions[q].AnswerEExp;
break;
}
if (tobeParsed && tobeParsed.length > 0) {
var api = new mw.Api();
api.get({
action : 'parse',
text : tobeParsed,
disablepp : 'disablepp',
format : 'json'
}, {
ok :
function (html) {
parsed = html.parse.text['*'];


function addNewSection( title, content, editToken ) {
switch (examObj.examQuestions[q].lastParsed) {
$.ajaxSetup({async: false});
case 0:
    $.ajax({
examObj.examQuestions[q].Prompt = parsed;
        url: mw.util.wikiScript( 'api' ),
break;
        data: {
case 1:
            format: 'json',
examObj.examQuestions[q].AnswerA = parsed;
            action: 'edit',
break;
            title: title,
case 2:
            text: content,
examObj.examQuestions[q].AnswerB = parsed;
            token: editToken,
break;
            recreate: 'r',
case 3:
        },
examObj.examQuestions[q].AnswerC = parsed;
        dataType: 'json',
break;
        type: 'POST',
case 4:
        success: function( data ) {
examObj.examQuestions[q].AnswerD = parsed;
            if ( data && data.edit && data.edit.result == 'Success' ) {
break;
                // reload page if edit was successful
case 5:
            } else if ( data && data.error ) {
examObj.examQuestions[q].AnswerE = parsed;
                alert( 'Error: Not Logged In' );
break;
            } else {
case 6:
                alert( 'Error: Not Logged In' );
examObj.examQuestions[q].Explanation = parsed;
            }
break;
        },
case 7:
        error: function( xhr ) {
examObj.examQuestions[q].AnswerAExp = parsed;
            alert( 'Error: Not Logged In. Please log in to create a Question.' );
break;
        }
case 8:
    });
examObj.examQuestions[q].AnswerBExp = parsed;
break;
case 9:
examObj.examQuestions[q].AnswerCExp = parsed;
break;
case 10:
examObj.examQuestions[q].AnswerDExp = parsed;
break;
case 11:
examObj.examQuestions[q].AnswerEExp = parsed;
break;
}
if (examObj.examQuestions[q].lastParsed < 12) {
examObj.examQuestions[q].lastParsed += 1;
parseQuestions(examObj);
} else {
examObj.examQuestions[q].isParsed = 1;
questionDisplay(examObj);
}
}
});
} else {
if (examObj.examQuestions[q].lastParsed < 12) {
examObj.examQuestions[q].lastParsed += 1;
parseQuestions(examObj);
} else {
examObj.examQuestions[q].isParsed = 1;
questionDisplay(examObj);
}
}
}
}
$('#changeslist').ready(function() {
$.getScript("http://wikidoc.org/resources/mediawiki.api/mediawiki.api.js", function(){
var api = new mw.Api();
var pageString =  "WBRCurrentQuestion";
api.get( {
action: 'query',
format: 'json',
        titles: pageString,
export: 'export',
        } , {
ok:function (data) {
        var xml = data.query.export["*"];
    xmlDoc = $.parseXML( xml ),
    $xml = $( xmlDoc ),
    $title = $xml.find( "text" );
    var curr = parseInt($title.text());
    document.getElementById('queslink').innerHTML = "<a id='add' href='http://wikidoc.org/index.php/Special:FormEdit/WBRQuestion/WBR" + curr + "'><img src='http://static.wikidoc.org/5/54/Click_here_to_add_a_question.png' /></a>";
$('#add').click(function(){
    addNewSection( "WBRCurrentQuestion",parseInt(curr+1).toString(),mw.user.tokens.get( 'editToken' ));
              });
            }
      });
  });
});
</script>
<form>
<div id="welcome">
<a href="#" onclick="document.getElementById('question').style.visibility='visible';document.getElementById('welcome').style.visibility='hidden';document.getElementById('welcome').style.height='0';"><img src="http://www.wikidoc.org/images/d/da/Click_here_to_answer_questions.png" /></a><br />
<div id="queslink">


</div>
function catQuestionCount(exam, type, cat) {
<a href="http://www.wikidoc.org/index.php/Board_Review_Help"><img src="http://static.wikidoc.org/4/48/Click_here_for_help.png" /></a>
var queryString = "[[ExamType::" + exam + "]] ";
</div>
if (type === "m") {
<div id="question" style="visibility:hidden;">
queryString += "[[MainCategory::" + cat + "]]";
<b>Click here to start the exam:</b><br />
} else {
<a href="#" onclick="loginCheck('Random','USMLE Step 1')"><img src="http://static.wikidoc.org/8/87/Step1.png" /></a>
queryString += "[[SubCategory::" + cat + "]]";
<a href="#" onclick="loginCheck('Random','USMLE Step 2 CK')"><img src="http://static.wikidoc.org/0/07/Step2CK.png" /></a>
}
<a href="#" onclick="loginCheck('Random','USMLE Step 3')"><img src="http://static.wikidoc.org/0/08/Step3.png" /></a>
var api = new mw.Api();
<a href="#" onclick="loginCheck('Random','Board Review')"><img src="http://static.wikidoc.org/7/75/Boardcertification.png" /></a>
api.get({
<a href="#" onclick="loginCheck('Random','MCAT')"><img src="http://static.wikidoc.org/4/4b/MCAT.png" /></a><br />
action : 'ask',
<!-- bold + larger font size-->
query : queryString,
<b>Click here to repeat questions you've gotten wrong previously</b>
format : 'json'
<input type="button" onclick="loginCheck('Queue','Nuffin')" value="Review Exam" /><br />
}, {
ok : function (data) {
$.each(data.query.results, function (index, value) {
var count = parseInt(document.getElementById(cat).innerHTML);
count = count + 1;
document.getElementById(cat).innerHTML = count.toString();
});
}
});
}


</div>
function completeQuestionCount(exam, main, sub) {
var queryString = "http://www.wikidoc.org/index.php?title=Special:Ask&q=[[ExamType::" + urlSwapSpace(exam) + "]][[MainCategory::";
for (var j = 0; j < main.length; j++) {
queryString += urlSwapSpace(main[j]);
if (j != main.length - 1) {
queryString += "||";
}
}
queryString += "]][[SubCategory::";
for (var i = 0; i < sub.length; i++) {
queryString += urlSwapSpace(sub[i]);
if (i != sub.length - 1) {
queryString += "||";
}
}
queryString += "]]&eq=yes&p[format]=json";
var obj;
$.ajax({
url : queryString,
async : false
}).done(function (data) {
obj = jQuery.parseJSON(data);
});
return obj;
}
function urlSwapSpace(swap) {
return swap.split(' ').join('+');
}


<input type='hidden' id='stash' name='stash' value='' />
$(document).ready(stepOne);
<input type='hidden' name='pos' value='1' />
</script>
<input type='hidden' name='results' value='' />
<div id="exam"></div>
<div style="width:100%"><div id="home" class="noSelect" style="margin-right:10px;font-weight:bold;color:#FFFFFF;font-family:Arial;float:left;background-color:#3366CC;height:40px; width:100px; display: table-cell; cursor: default; text-align: center; vertical-align: middle; visibility:hidden;"><br />Home</div><div id="back" class="noSelect" style="margin-right:10px;font-weight:bold;color:#FFFFFF;font-family:Arial;visibility:hidden;float:left;background-color:#3366CC;height:40px; width:100px; display: table-cell; cursor: default; text-align: center; vertical-align: middle;"><br />Back</div><div id="next" class="noSelect" style="font-weight:bold;font-family:Arial;visibility:hidden;float:left;background-color:#3366CC;color:#FFFFFF;height:40px; width:100px; display: table-cell; cursor: default; text-align: center; vertical-align: middle;"><br />Next</div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
</form>
</includeonly>
</includeonly>

Revision as of 18:47, 25 July 2013