Widget:WikidocBoardReview: Difference between revisions

Jump to navigation Jump to search
Matt Pijoan (talk | contribs)
No edit summary
Undo revision 1008080 by William J Gibson (talk)
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<includeonly>
<includeonly>
<script src="http://www.wikidoc.org/includes/raty/jquery.timer.js"></script>
<script type="text/javascript" src="http://www.wikidoc.org/includes/raty/jquery.raty.js"></script>
<style type="text/css">
<style type="text/css">
.boxed{
.boxed{
border:5px solid black;
border:0px solid black !important;
}
}
.redBoxed{
border:0px solid #F00 !important;


.unboxed{
.unboxed{
Line 16: Line 21:
.imageDiv{
.imageDiv{
margin:5px 5px 5px 5px;
margin:5px 5px 5px 5px;
}


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


function examHandler(arg,exam){
.WBRImgButton img{
if(arg === 'Random'){
width:auto;  
selectExam(exam);
height:35px;
} else if(arg === 'Queue'){
queueExam();
} else {
alert("Wat.");
}
}


$('#next').on('click', function(event){
#globalWrapper{
var Q = document.getElementById('question');
z-index:-1;
Q.innerHTML = "";
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 {
#navPane{
endExam();
position:relative;  
return;
float:left;
width:5%;
}
}
});
#examSpace{
 
position:relative;
$('#home').on('click', function(event){
float:right;
location.reload();
width:94%;
});
 
$('#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 {
#navBar{
alert("Already at beginning");
position:relative;
float:right;
width:95%;
background-color:#3366CC;
}
}
});
.navPaneButton{
height:20px;
background-color:#D0D0D0;
padding-top:5px;
color:#000000 ;
font-weight:bold;
text-align: center;
}
}
function queueExam(){
div.answerNoBorder{
var api = new mw.Api();
border:0px solid #FFF;
var result;
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(",");
div.answerBorder{
Questions = jQuery.grep(Questions, function(value) {
border:0px solid #000;
        return value != 'Placeholder';
      });
if(Questions.length < 1){
alert("You do not have a Queue!");
return false;
} else {
 
    $("input[name='stash']").val(Questions);
        var Q = document.getElementById('question');
        Q.innerHTML = "";
        $('#next').css('visibility','visible');
} } });  
}
}
function selectExam(exam){
div.explanationHide{
var Q = document.getElementById('question');
height:0px;
if(exam === "MCAT"){
visibility:hidden;
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" );
var tableTemp = "<table style='width:100%;'><th><td><b>Keyword</b></td></th><tr>";
for(var i=0;i<mc.length;i++){
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");
} 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 />";
div.explanationShow{
table += "<table style='width:100%;'><tr><td style='width:49%;'><b>Specialty/Organ System</b></td><td style='width:49%;'><b>Subjects/Keywords</b></td></tr>";
height:auto;
if(categories['sub'].length => categories['main'].length){
visibility:visible;
  for(var i=0;i<categories['sub'].length;i++){
      if(categories['main'][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></td><td><input type='checkbox' name='SubCat' value='"+categories['sub'][i]+"' />"+categories['sub'][i]+"</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>"
var Q = document.getElementById('question');
Q.innerHTML = table;
}
}
</style>
<script type="text/javascript">
function ensureLoggedIn() {
mw.loader.load('mediaWiki.user');
if ($.isEmptyObject(wgUserName)) {
alert("Please Log In To Continue.");
window.location.replace("http://www.wikidoc.org/index.php?title=Special:UserLogin&returnto=Board_Review");
} else {
curriculumType();
}
}
}
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>";
function curriculumType() {
$("#Go").click(function() {
var options = {
  var Mfields = $("[name=MainCat]").serializeArray();
examtype : null,
  var Sfields = $("[name=SubCat]").serializeArray();
timer : null,
  var sMain = new Array();
qbank : null,
  var sSub = new Array();
searchMethod : null,
  if (Mfields.length === 0)
timer : null,
  {
examType : '',
    alert('No Main Category Selected');
timeAmt : 0,
    selectExam();
questionListAll : new Array(),
  } else if(Sfields.length === 0)
numQuestion : null,
  {
currentQuestion : 0,
    alert('No Sub Category Selected');
examQuestions : new Array(),
    selectExam();
isParsed : 0,
  } else if(!parseInt($("#numQues").val())){
answeredRight : 0,
    alert('Invalid Number of Quesitons');
Question : {
    selectExam();
PageName : null,
  } else if(parseInt($("#numQues").val()) > 45){
PageAuthor : null,
    alert('Too Many Questions');
Prompt : null,
    selectExam();
RightAnswer : ' ',
  } else if(parseInt($("#numQues").val()) <= 1){
AnswerA : null,
    alert('Too Few Questions');
AnswerB : null,
    selectExam();
AnswerC : null,
  } else{
AnswerD : null,
    $("[name=MainCat]:checked").each( function() {
AnswerE : null,
              sMain.push($(this).val());
AnswerAExp : null,
             
AnswerBExp : null,
    });
AnswerCExp : null,
        $("[name=SubCat]:checked").each( function() {
AnswerDExp : null,
              sSub.push($(this).val());
AnswerEExp : null,
    });
selectedAnswer : 'F',
    var numQues = $("#numQues").val();
lastParsed : 0,
    var Questions = loadExam(exam, numQues, sSub, sMain).toString();
creditReceived : false
    $("input[name='stash']").val(Questions);
}
        var Q = document.getElementById('question');
}
        Q.innerHTML = "";
var stuffs = "<a href='#' class='Curric' id='USMLE Step 1'><img src='http://static.wikidoc.org/8/87/Step1.png' /></a>";
        $('#home').css('visibility','visible');
stuffs += "<a href='#' class='Curric' id='USMLE Step 2 CK'><img src='http://static.wikidoc.org/0/07/Step2CK.png' /></a>";
        loadQuestion();
stuffs += "<a href='#' class='Curric' id='USMLE Step 3'><img src='http://static.wikidoc.org/0/08/Step3.png' /></a>";
}});
stuffs += "<a href='#' class='Curric' id='Board Review'><img src='http://static.wikidoc.org/7/75/Boardcertification.png' /></a>";
stuffs += "<a href='#' class='Curric' id='MCAT'><img src='http://static.wikidoc.org/4/4b/MCAT.png' /></a><br />";
$("#exam").html(stuffs);
$('.Curric').click(options, chooseQBank);


$("#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 chooseQBank(event) {
event.data.examtype = $(this).attr('id');
var divs = null;
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 />";
$("#exam").html(divs);
$('.stepTwo').click(event.data, tutorOrExam);
}
function tutorOrExam(event) {


event.data.qbank = $(this).attr('id');
var buttons = '';
buttons = "<div id='Tutor' class='noSelect WBRButton ToE'><br />Tutor Mode</div><div id='Exam' class='noSelect WBRButton ToE'><br />Exam Mode</div><br /><br /><br />";
$("#exam").append(buttons);
$('.ToE').click(event.data, categoryOrKeyword);
}
function categoryOrKeyword(event) {
event.data.examType = $(this).attr('id');
var buttons = '';
buttons = "<div id='Category' class='noSelect WBRButton CoK'><br />Category</div><div id='Keyword' class='noSelect WBRButton CoK'><br />Keyword</div><br /><br /><br />";
$("#exam").append(buttons);
$('.CoK').click(event.data, timerToggle);
}
function timerToggle(event) {
event.data.searchMethod = $(this).attr('id');
var form = null;
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 ($("#exam").find('#yes').length == 0) {
$("#exam").append(form);
}
$('#yes').click(event.data, timerDuration);


 
if (event.data.searchMethod === "Category") {
function loadExam(exam, numQues, SubCat, MainCat){
$('#nop').click(event.data, countCats);
$.ajaxSetup({async: false});
} else {
var Questions = new Array();
$('#nop').click(event.data, Keywords);
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);
});
}
}
})
function timerDuration(event) {
.error( function ( error ) {
event.data.timer = true;
        $.each(error, function(key, value) {  
var form = null;
  alert(key + ': ' + value);  
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) {
} );
$("#exam").append(form);
}
}
return Questions;
if (event.data.searchMethod === "Category") {
$('.stepFour').click(event.data, countCats);
} else {
$('.stepFour').click(event.data, Keywords);
}
}
}
function Keywords(event) {
var stuffs = "<div id='formSpace'></div><div class='WBRButton' id='orOp'><br />OR</div><div class='WBRButton' id='andOp'><br />AND</div><div class='WBRButton' id='showQueries'><br />SHOW</div><br /><br /><br />";
$("#exam").append(stuffs);
var orBox = "<div class='query'> <input type='text' class='queryString' /> </div><br />";
var andBox = " <input type='text' class='queryString' /> ";
$("#formSpace").html(orBox);
$(".queryString").focus(function () {
$(".focused").removeClass("focused");
$(this).parent().addClass("focused");
$(".queryString").focusout(function () {
if ($(this).val().length <= 1) {
$(this).remove();
}
});
});


function loadQuestion(){
$("#orOp").click(function () {
var Questions = $("input[name='stash']").val().split(",");
$("#formSpace").append(orBox);
var name = Questions[parseInt($("input[name='pos']").val())-1];
$(".queryString").focus(function () {
$.ajaxSetup({async: false});
$(".focused").removeClass("focused");
var right = " ";
$(this).parent().addClass("focused");
var qs = "[["+name+"]]|?PageAuthor|?Prompt|?RightAnswer|?AnswerA|?AnswerB|?AnswerC|?AnswerD|?AnswerE|?Explanation|?AnswerAExp|?AnswerBExp|?AnswerCExp|?AnswerDExp|?AnswerEExp|?WBRImage|?WBRImageCaption|?WBRImagePlace";
$(".queryString").focusout(function () {
var api = new mw.Api();
if ($(this).val().length <= 1) {
api.get( {
$(this).remove();
action: 'ask',
}
query: qs,
});
format: 'json'
});
}, {
});
ok: function (data) {
hideButtons();
$.each(data.query.results, function(index, value){


var short = value.printouts;
$("#andOp").click(function () {
        var temp = $("input[name='stash']").val().split(",");
var andBox = "<input type='text' class='queryString' />";
var Q = document.getElementById('question');
$(".focused").append(andBox);
        var author = ' ';
$(".queryString").focus(function () {
        if(short.PageAuthor['0']) {author = short.PageAuthor['0'];}
$(".focused").removeClass("focused");
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 />";
$(this).parent().addClass("focused");
        right = short.RightAnswer;
$(".queryString").focusout(function () {
        if(short.AnswerA.length > 0){
if ($(this).val().length <= 1) {
        Q.innerHTML += "<div style='border:5px solid #FFF;' class='answer' id='A'> A. " + short.AnswerA + "<div id='AnsAImage' class='imageDiv'></div></div>";
$(this).remove();
        }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'].fulltext + "</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'].fulltext + "</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'].fulltext + "</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'].fulltext + "</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'].fulltext + "</i></div>";}


          if(short.WBRImage){
$("#showQueries").click(event.data, showQueries);
            for(var i=0;i<short.WBRImage.length;i++){
function showQueries(event) {
                if(short.WBRImagePlace[i] === "Prompt"){
$("#removeNum").remove();
                document.getElementById('promptImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]);
event.data.queries = [];
                             
event.data.questionListAll = [];
event.data.keyword = {};
event.data.keyword.iterator = 0;
$.each($(".query"), function (index, value) {
event.data.queries[index] = "[[ExamType::" + event.data.examtype + "]]";
$.each($(this).children(), function (ind, val) {
event.data.queries[index] += "[[WBRKeyword::" + $(this).val() + "]]";
});
});
runQueries(event.data);
}
function runQueries(obj) {
var api = new mw.Api();
api.get({
action : 'ask',
query : obj.queries[obj.keyword.iterator],
format : 'json'
})
.always(function (data) {
$.each(data.query.results, function (index, value) {
obj.questionListAll.push(value.fulltext);
});
if ((obj.keyword.iterator + 1) < obj.queries.length) {
obj.keyword.iterator++;
runQueries(obj);
} else {
removeDuplicates(obj);
}
});
}
function removeDuplicates(obj) {
                if(res.Count > 45){
                        obj.maxQ = 45;
                } else {
                        obj.maxQ = res.Count;
                 }
                 }
            if(short.WBRImagePlace[i] === "Answer A"){
var output = "<div id='removeNum'><b>Choose the number of questions you would like to answer. The maximum number of questions you can select is <span id='countShow'>" + obj.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></div>";
                document.getElementById('AnsAImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]);
if ($("#exam").find('#numQues').length == 0) {
                             
$("#exam").append(output);
                }
} else {
            if(short.WBRImagePlace[i] === "Answer B"){
 
                document.getElementById('AnsBImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]);
alert('Please ensure you have valid keywords entered');
                             
}
                }
 
            if(short.WBRImagePlace[i] === "Answer C"){
$("#Go").click(obj, TNG);
                document.getElementById('AnsCImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]);
}
                             
}
                }
function TNG(event) {
            if(short.WBRImagePlace[i] === "Answer D"){
event.data.numQuestion = $("#numQues").val();
                document.getElementById('AnsDImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]);
        if(event.data.numQuestion > 0 && event.data.numQuestion <= 45){
                             
loadNextQuestion(event.data);
                }
        } else {
            if(short.WBRImagePlace[i] === "Answer E"){
        alert('Invalid number of questions entered.');
                document.getElementById('AnsEImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]);
                             
                }
            }
         }
         }
       
}
        $("div.answer").mouseover(function() {
function selectCats(exam) {
            $(this).css({'border': '5px solid #000'})
var categories = [];
        }).mouseout(function() {
var table = null;
            $(this).css({'border': '5px solid #FFF'})
table = "<br /><b>Select All That Apply:</b><br /><br /><br />"; ;
        });
if (exam.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 {


    $( "div.answer" ).click(function(){
if (exam.examtype === "USMLE Step 1") {
      var Results = $("input[name='results']").val().split(",");
categories['main'] = new Array("Anatomy", "Behavioral Science/Psychiatry", "Biochemistry", "Biostatistics/Epidemiology", "Embryology", "Ethics", "Genetics", "Histology", "Immunology", "Microbiology", "Pathology", "Pathophysiology", "Pharmacology", "Physiology");
      var Pos = parseInt($("input[name='pos']").val()) - 1;
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");
      $(".answerExp").css("height","auto");
} else if (exam.examtype === "USMLE Step 2 CK") {
      $(".answerExp").css("visibility","visible");
categories['main'] = new Array("Internal medicine", "Surgery", "OB/GYN", "Pediatrics", "Psychiatry");
      $("div#" + $(this).attr("id")).css({'border': '5px solid #000'});
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");
      $("div#" +short.RightAnswer.valueOf()).css({'color':'#F00'});
} else if (exam.examtype === "USMLE Step 3") {
      if(short.RightAnswer.valueOf() == $( this ).attr("id").valueOf()){
categories['main'] = new Array("Community Medical Health Center", "Primary Care Office", "Inpatient Facilities", "Emergency Room");
        Results[Pos] = true;
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");
        removeFromQueue(value.fulltext);
} else if (exam.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");
      else
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");
      {
}
      Results[Pos] = false;
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>";
      addToQueue(value.fulltext);
if (categories['sub'].length >= categories['main'].length) {}
      }
var table = "<br /><br /><b>Select All That Apply:</b><br /><br /><br />";
      Q.innerHTML += "<br /><br />The correct answer is: " + short.RightAnswer.valueOf() + "<br /><br /><i>" + short.Explanation + "</i><div id='ExpImage'></div><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(short.WBRImage){
if (categories['sub'].length >= categories['main'].length) {
            for(var i=0;i<=short.WBRImage.length;i++){


                if(short.WBRImagePlace[i] === "Prompt"){
for (var i = 0; i < categories['sub'].length; i++) {
                document.getElementById('ExpImage') }
if (categories['main'][i]) {
                  }}
table += "<tr><td><input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + " ( " + exam.arrCounts['category']['main'][categories['main'][i]] + " ) </td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( " + exam.arrCounts['category']['sub'][categories['sub'][i]] + " )</td></tr>";
} else {
table += "<tr><td></td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( " + exam.arrCounts['category']['sub'][categories['sub'][i]] + " ) </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");
});
}
});


      $("input[name='results']").val(Results.toString());
$("#UnselectAll").click(function () {
      showButtons();
if ($("#UnselectAll").html() === "Select All Sub Categories") {
      $("input[name='stash']").val(Questions.toString());
$("[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");
});
}
});


$("#CountQ").click(exam, selectExamLength);
}
}
function selectExamLength(event) {
var Main = new Array();
var Sub = new Array();
if ($("[name=MainCat]:checked").length > 0 && $("[name=SubCat]:checked").length > 0) {
$("[name=MainCat]:checked").each(function () {
Main.push($(this).val());
});
$("[name=SubCat]:checked").each(function () {
Sub.push($(this).val());
});
event.data.mainCat = Main;
event.data.subCat = Sub;
var api = new mw.Api(event, Main, Sub);
api.get({
action : 'catcount',
main : JSON.stringify(Main),
sub : JSON.stringify(Sub),
exam : event.data.examtype,
format : 'json'
}, {
ok : function (res) {
                if( res.Count > 45){
                        event.data.maxQ = 45;
                } else {
                        event.data.maxQ = res.Count;
                }
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'>" + event.data.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>";
if ($("#exam").find('#numQues').length == 0) {
$("#exam").append(output);


function getImage(filename, caption){
}
  var api = new mw.Api();
$("#Go").click(event.data, inputValidation);
  var result;
}
    api.get( {
});
action: 'parse',
} else {
text: '[[File:' + filename + ']]',
alert('Please ensure you have both a main and a sub category selected');
format: 'json',
}
        async: false
        } , {
ok: function(data) {
        result = data.parse.text['*'];
}});
  if(caption === "no-display"){
  return result;
  } else {
  result += caption;
  return result;
  }
}
}
function inputValidation(event) {
if ($("#numQues").val().length > 0 && parseInt($("#numQues").val(), 10) <= parseInt($("#countShow").html(), 10) && parseInt($("#numQues").val(), 10) > 0) {
event.data.numQuestion = $("#numQues").val();
$("#exam").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />");
if (event.data.timer) {
event.data.examTimer = $.timer(function () {
var rem = parseInt($("#timeRem").html());
$('#timerBox').css("visibility", "visible");
$('#timerBox').html(formatTime(rem));
if (rem == 0) {
event.data.examTimer.stop();
$("#content").click(event.data, endExam);
} else {
var temp = rem - 7;
$("#timeRem").html(temp.toString());
if (rem < 0) {
$("#timeRem").html("0");
}
}
}, 70, false);


function showButtons(){
event.data.examTimer.toggle();
$('#next').css('visibility','visible');
}
$('#back').css('visibility','visible');
loadNextQuestion(event.data);
} else {
alert('Invalid entry in number of questions input');
}
}
// Common functions
function pad(number, length) {
var str = '' + number;
while (str.length < length) {
str = '0' + str;
}
return str;
}
function formatTime(time) {
var min = parseInt(time / 6000),
sec = parseInt(time / 100) - (min * 60),
hundredths = pad(time - (sec * 100) - (min * 6000), 2);
return (min > 0 ? pad(min, 2) : "00") + ":" + pad(sec, 2);
}
function loadNextQuestion(event) {
if(event.searchMethod === "Category"){
var api = new mw.Api(event);
api.get({
action : 'load',
main : JSON.stringify(event.mainCat),
sub : JSON.stringify(event.subCat),
exam : event.examtype,
num : event.numQuestion,
format : 'json'
}, {
ok : function (res) {
var i = 0;
event.currentQuestion = 0;
$.each(res.questions.list, function (key, element) {
element.PageName = key;
event.examQuestions[i] = element;
i++;
});
addToNavBar(event);
}
});
} else if(event.searchMethod === "Keyword"){
var api = new mw.Api(event);
api.get({
action : 'load',
keywords : JSON.stringify(event.questionListAll),
num : event.numQuestion,
format : 'json'
}, {
ok : function (res) {
var i = 0;
event.currentQuestion = 0;
$.each(res.questions.list, function (key, element) {
element.PageName = key;
event.examQuestions[i] = element;
i++;
});
addToNavBar(event);
}
});
}
}
}
function hideButtons(){
function addToNavBar(exam) {
$('#next').css('visibility','hidden');
$("#exam").html("<div id='navBar'><div id='flag' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/8/89/Flag_3_16_14.png' /></div><div id='back' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/c/c1/WBRLeftArrowlightblue.png' /></div><div id='next' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/e/eb/WBRRightArrowlightblue.png' /></div><div id='finish' class='noSelect WBRButton'><br />Finish</div></div><div id='navPane'></div><div id='examSpace'></div><span id='timeRem' style='height: 0px; visibility: hidden'>" + exam.timeAmt.toString() + "</span>");
$('#back').css('visibility','hidden');
$("#flag").click(function(){alert("Coming Soon!")});
        $("#back").click(exam, questionNavigation);
$("#next").click(exam, questionNavigation);
$("#finish").click(exam, endExam);
if (exam.timer) {
$("#bodyContent").append("<div style='position:absolute; z-index:1000; width:300px; height:50px; top:0px; right:0px; border: 1px solid #000; background-color:#EEE; float:right; visibility:hidden;' id='timerBox'>Testing.</div>");
$("#timerBox").click(function () {
exam.examTimer.toggle();
});
}
$.each(exam.examQuestions, function (index, value) {
$("#navPane").append("<div id='" + index + "' class='navPaneButton'> " + (index - -1) + "</div>");
});
        $(".navPaneButton").click(exam, questionNavigation);
$("#" + exam.currentQuestion).addClass("boxed");
       
$(".navPaneButton:odd").css("background-color", "#3338CC");
        $(".navPaneButton:odd").css("background-color", "#B0B0B0");
questionDisplay(exam);
}
}
function endExam(){
function questionDisplay(exam) {
hideButtons();
var obj = new Object();
var correct = 0;
obj = exam.examQuestions[exam.currentQuestion];
var Results = $("input[name='results']").val().split(",");
if (obj.isParsed === 0) {
for (var i=0;i<Results.length;i++){
$("#examSpace").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />");
if(Results[i].valueOf() == new String("true").valueOf()){
parseQuestions(exam);
correct++;
} else {
var htmlStuff = "<b>Question " + (exam.currentQuestion - -1) + " / " + (exam.examQuestions.length) + "</b><br /><br />" + obj.Prompt + "<br />";
if (obj.AnswerA && obj.AnswerA.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='A'><input type='radio' value='A' id='Ar'>" + trimP(obj.AnswerA) + "</div>";
}
if (obj.AnswerAExp && obj.AnswerAExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Ae'>" + trimP(obj.AnswerAExp) + "</div>";
}
if (obj.AnswerB && obj.AnswerB.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='B'><input type='radio' value='B' id='Ar' />" + trimP(obj.AnswerB) + "</div>";
}
if (obj.AnswerBExp && obj.AnswerBExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Be'>" + trimP(obj.AnswerBExp) + "</div>";
}
if (obj.AnswerC && obj.AnswerC.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='C'><input type='radio' value='C' id='Ar' />" + trimP(obj.AnswerC) + "</div>";
}
if (obj.AnswerCExp && obj.AnswerCExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Ce'>" + trimP(obj.AnswerCExp) + "</div>";
}
if (obj.AnswerD && obj.AnswerD.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='D'><input type='radio' value='D' id='Ar'>" + trimP(obj.AnswerD) + "</div>";
}
if (obj.AnswerDExp && obj.AnswerDExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='De'>" + trimP(obj.AnswerDExp) + "</div>";
}
if (obj.AnswerEExp && obj.AnswerE.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='E'><input type='radio' value='E' id='Ar'>" + trimP(obj.AnswerE) + "</div>";
}
if (obj.AnswerEExp && obj.AnswerEExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Ee'>" + trimP(obj.AnswerEExp) + "</div>";
}
$("#examSpace").html(htmlStuff);
if (exam.examQuestions[exam.currentQuestion].selectedAnswer !== 'F') {
$("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).addClass("boxed");
}
$("div.answer").mouseover(function () {
$(this).css({
'border' : '0px solid #000'
})
}).mouseout(function () {
$(this).css({
'border' : '0px solid #FFF'
})
});
$("div.answer").click(exam, answerClicked);
}
}
}
function trimP(data) {
return data.substring(3, data.length - 4).trim(); ;
}
}
var n = (100 / Results.length ) * correct;
function questionReview(exam) {
var Q = document.getElementById('question');
var obj = new Object();
Q.innerHTML = "<h2>Exam Results:</h2>";
obj = exam.examQuestions[exam.currentQuestion];
Q.innerHTML += "<br /><br /><b>Questions Asked:</b> " + Results.length.toString();
if (obj.isParsed === 0) {
Q.innerHTML += "<br /><br /><b>Questions Answered Correctly:</b> " + correct.toString();
$("#examSpace").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />");
Q.innerHTML += "<br /><br /><b>Score:</b> " + Math.floor(n).toString() + "%";
parseQuestions(exam);
Q.innerHTML += "<form><input type='button' onclick='location.reload()' value='Back to start' /><input type='button' onclick='selectExam()' value='Start a new exam' /></form>";
} else {
return;
$("#examSpace").append("<br /><a href='http://www.wikidoc.org/index.php/Talk:" + obj.PageName + "' target='_blank'>Click here to discuss this question!</a><br />");
 
var htmlStuff = "<b>Author:</b> " + obj.PageAuthor + "<br /><br /><b>Question " + (exam.currentQuestion - -1) + " / " + (exam.examQuestions.length) + "</b><br /><br />" + obj.Prompt + "<br />";
if (obj.AnswerA && obj.AnswerA.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='A'><input type='radio' id='Ar'>  " + obj.AnswerA + "</div></input>";
}
if (obj.AnswerAExp && obj.AnswerAExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Ae'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerAExp + "</i></div>";
}
if (obj.AnswerB && obj.AnswerB.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='B'><input type='radio' id='Br'> " + obj.AnswerB + "</input></div>";
}
if (obj.AnswerBExp && obj.AnswerBExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Be'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerBExp + "</div></i>";
}
if (obj.AnswerC && obj.AnswerC.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='C'><input type='radio' id='Cr'> " + obj.AnswerC + "</input></div>";
}
if (obj.AnswerCExp && obj.AnswerCExp.length > 0 && exam.examType === "Tutor") {
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'><input type='radio' id='Dr'> " + obj.AnswerD + "</input></div>";
}
if (obj.AnswerDExp && obj.AnswerDExp.length > 0 && exam.examType === "Tutor") {
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'><input type='radio' id='Er'> " + obj.AnswerE + "</input></div>";
}
if (obj.AnswerEExp && obj.AnswerEExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Ee'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerEExp + "</i></div>";
}
$("#examSpace").html(htmlStuff);
addRatyRating(exam);
if (exam.examQuestions[exam.currentQuestion].selectedAnswer && exam.examQuestions[exam.currentQuestion].RightAnswer == exam.examQuestions[exam.currentQuestion].selectedAnswer) {
$("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).addClass("boxed");
} else {
 
$("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).addClass("redBoxed");
$("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).removeClass("answerNoBorder");
$("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).addClass("boxed");
$("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).removeClass("answerNoBorder");
}
$("#examSpace").append("<br /><br />The correct answer is: " + exam.examQuestions[exam.currentQuestion].RightAnswer + "<br /><br /><b>" + exam.examQuestions[exam.currentQuestion].Explanation + "</b><br /><br />");
}
}
}
function addRatyRating(exam) {
var ratyLayers = "<center>Rate this question!</center><br /><span style='position:relative; float:left;'>Difficulty: <div id='star1'></div></span><span style='position:relative; float:left;left:33%;'>High Yield: <div id='star2'></div></span><span style='position:relative; float:left;left:66%'>Quality: <div id='star3'></div></span><br /><br /><br />"
$("#examSpace").prepend(ratyLayers);


function removeFromQueue(question){
getRating(exam.examQuestions[exam.currentQuestion].PageName, exam);
var api = new mw.Api();
var result;
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(question) != -1){
var pageContent = $title.text().split(',');
pageContent = jQuery.grep(pageContent, function(value) {
        return value != question;
      });


var token = mw.user.tokens.get( 'editToken' )
 
addNewSection( "User:" + mw.user.name() + "/WBRQueue2",question, token );
}
function answerClicked(event){
$(".answer").removeClass("boxed");
$('input[type=radio]').prop('checked', function () {
    return this.getAttribute('checked') == 'checked';
});
$(this).addClass("boxed");
$(this).find("#Ar").prop("checked",true);
if($("#exam").find('#submit').length == 0){
$("#examSpace").append("<div class='noSelect WBRButton' id='submit'><br />Submit</div>");
                $("#submit").click(event.data, answerSubmitted);
}
}
}});
return result;
}
}
function getRating(page, exam) {
var api = new mw.Api();
api.get({
action : 'wbrgetrating',
question : page,
format : 'json'
}, {
ok : function (res) {
$("#star1").raty({
path : 'http://www.wikidoc.org/includes/raty/img/',
click : function (score, event) {
submitRating("difficulty", score, exam.examQuestions[exam.currentQuestion].PageName)
},
                score: res.wbrgetrating.difficulty,
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
});
        $("#star1").append("(Avg: " + res.wbrgetrating.difficulty + ", n=" + res.wbrgetrating.diffCount + ")" );
$("#star2").raty({
path : 'http://www.wikidoc.org/includes/raty/img/',
click : function (score, event) {
submitRating("yield", score, exam.examQuestions[exam.currentQuestion].PageName)
},
score: res.wbrgetrating.yield,
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
});
        $("#star2").append("(Avg: " + res.wbrgetrating.yield + ", n=" + res.wbrgetrating.qualCount + ")" );
$("#star3").raty({
path : 'http://www.wikidoc.org/includes/raty/img/',
click : function (score, event) {
submitRating("quality", score, exam.examQuestions[exam.currentQuestion].PageName)
},
score: res.wbrgetrating.quality,
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
});
        $("#star3").append("(Avg: " + res.wbrgetrating.quality + ", n=" + res.wbrgetrating.yieldSum + ")" );
}
});}
function answerSubmitted(event) {
        $("#submit").remove();
event.data.examQuestions[event.data.currentQuestion].selectedAnswer = $("div .boxed").attr("id");
if (!event.data.examQuestions[event.data.currentQuestion].creditReceived && event.data.examQuestions[event.data.currentQuestion].selectedAnswer === event.data.examQuestions[event.data.currentQuestion].RightAnswer) {
event.data.answeredRight += 1;
event.data.examQuestions[event.data.currentQuestion].creditReceived = true;
}
if (event.data.examType === "Tutor") {
$(".answerExp").css("height", "auto");
$(".answerExp").css("visibility", "visible");
                $(".answerExp").each(function(){
                              if($(this).attr('id') === event.data.examQuestions[event.data.currentQuestion].RightAnswer+"e"){
                                      $(this).prepend("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Correct:</b> ");
                              } else {
                                      $(this).prepend("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Incorrect:</b> ");
                              }
                });


function addToQueue(question){
}
var api = new mw.Api();
$("div.answer").unbind('click');
var result;
var api = new mw.Api();
var pageString =  "User:" + mw.user.name() + "/WBRQueue";
api.get({
api.get( {
action : 'wbrinsertmetric',
action: 'query',
username : mw.user.getName(),
format: 'json',
question : event.data.examQuestions[event.data.currentQuestion].PageName,
        titles: pageString,
selectedAnswer : event.data.examQuestions[event.data.currentQuestion].selectedAnswer,
export: 'export',
format : 'json'
        } , {
})
ok:function (data) {
.done(function (data) {
        var xml = data.query.export["*"];
console.log('API result:', data);
    xmlDoc = $.parseXML( xml ),
});
    $xml = $( xmlDoc ),
if (event.data.examType === "Exam") {
    $title = $xml.find( "text" );
$("#" + event.data.examQuestions[event.data.currentQuestion].selectedAnswer).addClass("boxed");
 
} else if (event.data.examType === "Tutor") {
var pageContent = $title.text().split(',');
$("#examSpace").append("<br /><br />The correct answer is: " + event.data.examQuestions[event.data.currentQuestion].RightAnswer + "<br /><br />" + event.data.examQuestions[event.data.currentQuestion].Explanation + "<br />");
pageContent.push(question);
                $("#examSpace").append("<b>Author:</b> " +  event.data.examQuestions[event.data.currentQuestion].PageAuthor + "<br /><br /><b>Wiki Page:</b>" + event.data.examQuestions[event.data.currentQuestion].PageName + "<br /><br />Discuss this question <a href='http://www.wikidoc.org/index.php/Talk:" + event.data.examQuestions[event.data.currentQuestion].PageName + "'>Here</a>");
var token = mw.user.tokens.get( 'editToken' );
$("#" + event.data.examQuestions[event.data.currentQuestion].selectedAnswer).addClass("boxed");
addNewSection( "User:" + mw.user.name() + "/WBRQueue",question, token );
$("#" + event.data.examQuestions[event.data.currentQuestion].RightAnswer).addClass("redBoxed");
}});
addRatyRating(event.data);
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 questionReviewNavigation(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");
questionReview(event.data);
}
}
function endExam(event) {
if (event.data.timer) {
$('#timerBox').html("");
$('#timerBox').css("visibility", "hidden");
event.data.examTimer.stop();
}
$("#examSpace").html("");
var datas;
datas = "";
datas += "<br />You answered " + event.data.answeredRight + " out of " + event.data.examQuestions.length + " correctly.<br /> Your percentage score is: ";
var percent = (event.data.answeredRight / event.data.examQuestions.length) * 100;
datas += percent + "%<br /><br />Click the Navigation Buttons on the left to review the questions you answered.";
var api = new mw.Api();


api.get({
action : 'wbrinsertexam',
username : mw.user.getName(),
size : event.data.examQuestions.length,
score : percent,
format : 'json'
})
.done(function (data) {
console.log('API result:', data);
});


function addNewSection( title, content, editToken ) {
$("#examSpace").append(datas);
$.ajaxSetup({async: false});
$(".navPaneButton").unbind('click');
    $.ajax({
$(".navPaneButton").click(event.data, questionReviewNavigation);
        url: mw.util.wikiScript( 'api' ),
}
        data: {
function submitRating(ratingType, score, page) {
            format: 'json',
      if(ratingType === "difficulty"){
            action: 'edit',
var api = new mw.Api();
            title: title,
api.get({
            text: content,
action : 'wbrinsertrating',
            token: editToken,
username : mw.user.getName(),
            recreate: 'r',
question : page,
        },
difficulty : score,
        dataType: 'json',
format : 'json'
        type: 'POST',
}, {
        success: function( data ) {
ok : function (res) {}
            if ( data && data.edit && data.edit.result == 'Success' ) {
});
                // reload page if edit was successful
} else if (ratingType === "yield"){
            } else if ( data && data.error ) {
var api = new mw.Api();
                alert( 'Error: Not Logged In' );
api.get({
            } else {
action : 'wbrinsertrating',
                alert( 'Error: Not Logged In' );
username : mw.user.getName(),
            }
question : page,
        },
yield : score,
        error: function( xhr ) {
format : 'json'
            alert( 'Error: Not Logged In. Please log in to create a Question.' );
}, {
        }
ok : function (res) {}
    });
});
}
else if (ratingType === "quality"){
var api = new mw.Api();
api.get({
action : 'wbrinsertrating',
username : mw.user.getName(),
question : page,
quality : score,
format : 'json'
}, {
ok : function (res) {}
});
}
}
}
$('#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 parseQuestions(examObj) {
<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 tobeParsed = null;
</div>
var parsed = null;
<div id="question" style="visibility:hidden;">
var q = examObj.currentQuestion;
<b>Click here to start the exam:</b><br />
switch (examObj.examQuestions[q].lastParsed) {
<a href="#" onclick="loginCheck('Random','USMLE Step 1')"><img src="http://static.wikidoc.org/8/87/Step1.png" /></a>
case 0:
<a href="#" onclick="loginCheck('Random','USMLE Step 2 CK')"><img src="http://static.wikidoc.org/0/07/Step2CK.png" /></a>
tobeParsed = examObj.examQuestions[q].Prompt;
<a href="#" onclick="loginCheck('Random','USMLE Step 3')"><img src="http://static.wikidoc.org/0/08/Step3.png" /></a>
break;
<a href="#" onclick="loginCheck('Random','Board Review')"><img src="http://static.wikidoc.org/7/75/Boardcertification.png" /></a>
case 1:
<a href="#" onclick="loginCheck('Random','MCAT')"><img src="http://static.wikidoc.org/4/4b/MCAT.png" /></a><br />
tobeParsed = "A. " + examObj.examQuestions[q].AnswerA;
<!-- bold + larger font size-->
break;
<b>Click here to repeat questions you've gotten wrong previously</b>
case 2:
<input type="button" onclick="loginCheck('Queue','Nuffin')" value="Review Exam" /><br />
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;
case 12:
tobeParsed = examObj.examQuestions[q].Author
}
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['*'];


</div>
switch (examObj.examQuestions[q].lastParsed) {
case 0:
examObj.examQuestions[q].Prompt = parsed;
break;
case 1:
examObj.examQuestions[q].AnswerA = parsed;
break;
case 2:
examObj.examQuestions[q].AnswerB = parsed;
break;
case 3:
examObj.examQuestions[q].AnswerC = parsed;
break;
case 4:
examObj.examQuestions[q].AnswerD = parsed;
break;
case 5:
examObj.examQuestions[q].AnswerE = parsed;
break;
case 6:
examObj.examQuestions[q].Explanation = parsed;
break;
case 7:
examObj.examQuestions[q].AnswerAExp = parsed;
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;
case 12:
examObj.examQuestions[q].Author = parsed;
break
}
if (examObj.examQuestions[q].lastParsed < 13) {
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);
}
}
}
function countCats(event) {
event.data.timeAmt = parseInt($(this).attr("id"), 10) * 6000;
var temp = event.data.examtype.replace(/ /g, "_");
var api = new mw.Api();
api.get({
action : 'singlecat',
exam : temp,
format : 'json',
async : false
}, {
ok : function (data) {
event.data.arrCounts = data;
selectCats(event.data);
}
});
}


<input type='hidden' id='stash' name='stash' value='' />
function urlSwapSpace(swap) {
<input type='hidden' name='pos' value='1' />
return swap.split(' ').join('+');
<input type='hidden' name='results' value='' />
}
<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>
$(document).ready(ensureLoggedIn);
</form>
</script>
<div id="exam"></div>
</includeonly>
</includeonly>

Latest revision as of 14:57, 10 August 2014