Widget:SandboxNew: Difference between revisions
Jump to navigation
Jump to search
Matt Pijoan (talk | contribs) No edit summary |
Matt Pijoan (talk | contribs) No edit summary |
||
(512 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<includeonly> | <includeonly> | ||
< | <style type="text/css"> | ||
.boxed{ | |||
border:5px solid black; | |||
} | |||
.unboxed{ | |||
border:0px; | |||
} | } | ||
#go{ | |||
width:150px; | |||
height:50px; | |||
background-color:#0f0; | |||
} | } | ||
.imageDiv{ | |||
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: default; | |||
color:#FFFFFF; | |||
text-align: center; | |||
vertical-align: middle; | |||
margin-right:10px; | |||
} | } | ||
</style> | |||
<script type="text/javascript"> | |||
var countdownTimer, countdownCurrent; | |||
$.getScript("http://wikidoc.org/includes/jquery.timer.js", function () { | |||
$(document).ready(function () { | |||
countdownTimer = $.timer(function () { | |||
var min = parseInt(countdownCurrent / 6000); | |||
var sec = parseInt(countdownCurrent / 100) - (min * 60); | |||
var micro = pad(countdownCurrent - (sec * 100) - (min * 6000), 2); | |||
var output = "00"; | |||
if (min > 0) { | |||
output = pad(min, 2); | |||
} | |||
$('.countdowntime').html(output + ":" + pad(sec, 2)); | |||
if (countdownCurrent == 0) { | |||
countdownTimer.stop(); | |||
endExam(); | |||
} else { | |||
countdownCurrent -= 7; | |||
if (countdownCurrent < 0) { | |||
countdownCurrent = 0; | |||
} | |||
} | |||
}, 70, false); | |||
}); | |||
}); | |||
$(document).ready(function () { | |||
$.getScript("http://wikidoc.org/resources/mediawiki.api/mediawiki.api.js", function () { | |||
if (!mw.user.name()) { | |||
alert("Please Log In To Continue."); | |||
window.location.replace("http://wikidoc.org/index.php?title=Special:UserLogin&returnto=User%3AMatt+Pijoan"); | |||
} | |||
}); | |||
}); | }); | ||
function endExam() { | |||
hideButtons(); | |||
var correct = 0; | |||
var Results = $("input[name='results']").val().split(","); | |||
for (var i = 0; i < Results.length; i++) { | |||
if (Results[i].valueOf() == new String("true").valueOf()) { | |||
correct++; | |||
} | |||
} | |||
var n = (100 / Results.length) * correct; | |||
var Q = document.getElementById('question'); | |||
Q.innerHTML = "<h2>Exam Results:</h2>"; | |||
Q.innerHTML += "<br /><br /><b>Questions Asked:</b> " + Results.length.toString(); | |||
Q.innerHTML += "<br /><br /><b>Questions Answered Correctly:</b> " + correct.toString(); | |||
Q.innerHTML += "<br /><br /><b>Score:</b> " + Math.floor(n).toString() + "%"; | |||
Q.innerHTML += "<form><input type='button' onclick='location.reload()' value='Back to start' /><input type='button' onclick='selectExam()' value='Start a new exam' /></form>"; | |||
return; | |||
} | } | ||
function | |||
var | function loginCheck(exam) { | ||
var form = "<div id='Pat' class='noSelect WBRButton'><br />USMLE Format</div><div id='Flash' class='noSelect WBRButton'><br />Flash Cards</div>"; | |||
$("#question").html(form); | |||
$(".WBRButton").click(function () { | |||
alert($(this).attr('id')); | |||
var form = "<div id='y' class='noSelect WBRButton'><br />Enable Timer</div><div id='n' class='noSelect WBRButton'><br />Disable Timer</div>"; | |||
$("#question").html(form); | |||
$(".WBRButton").click(function () { | |||
alert($(this).attr('id')); | |||
if ($(this).attr('id') === 'y') { | |||
var form = "<div id='1' class='noSelect WBRButton'><br />1 Minute</div><div id='10' class='noSelect WBRButton'><br />10 Minute</div><div id='20' class='noSelect WBRButton'><br />20 Minutes</div><div id='40' class='noSelect WBRButton'><br />40 Minutes</div>" | |||
$("#question").html(form); | |||
$(".WBRButton").click(function () { | |||
alert($(this).parent.attr('id')); | |||
countdownCurrent = parseInt($(this).attr('id')) * 6000; | |||
examHandler(exam); | |||
}); | |||
} else { | |||
examHandler(exam); | |||
} | |||
}); | |||
}); | |||
} | } | ||
function pad(number, length) { | |||
var str = '' + number; | |||
while (str.length < length) { | |||
str = '0' + str; | |||
} | |||
return str; | |||
} | } | ||
function examHandler(exam) { | |||
Q.innerHTML | if (exam === 'Queue') { | ||
$(" | queueExam(); | ||
} else { | |||
selectExam(exam); | |||
} | |||
$('#next').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 < Questions.length) { | |||
$("input[name='pos']").val(Pos + 1); | |||
loadQuestion(); | |||
} | } else { | ||
endExam(); | |||
return; | |||
} | |||
}); | |||
$('#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 { | |||
alert("Already at beginning"); | |||
} | |||
}); | |||
} | |||
function catQuestionCount(exam, type, cat){ | |||
var queryString = "[[ExamType::"+exam+"]] "; | |||
if(type === "m") { | |||
queryString += "[[MainCategory::"+cat+"]]"; | |||
} else { | |||
queryString += "[[SubCategory::"+cat+"]]"; | |||
} | } | ||
var api = new mw.Api(); | var api = new mw.Api(); | ||
api.get( { | api.get( { | ||
action: 'ask', | action: 'ask', | ||
query: | query: queryString, | ||
format: 'json', | format: 'json', | ||
async: false | async: false | ||
}, { | }, { | ||
ok: function (data) { | ok: function (data) { | ||
$.each(data.query.results, function(index, value){ | $.each(data.query.results,function(index, value) { | ||
var count = parseInt(document.getElementById(cat).innerHTML); | |||
count = count+1; | |||
document.getElementById(cat).innerHTML = count.toString(); | |||
}); | }); | ||
} | }});} | ||
}) | |||
. | function completeQuestionCount(exam, main, sub) { | ||
var queryString = "http://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"; | |||
$.get(queryString, function (data) { | |||
var obj = jQuery.parseJSON(data); | |||
$("#countShow").html(obj.rows.toString()); | |||
$.each(obj.results, function(index, value){ | |||
alert(value.fulltext); | |||
}); | |||
$("#numQues").removeAttr('disabled'); | |||
}); | }); | ||
} | } | ||
return | |||
function urlSwapSpace(swap){ | |||
return swap.split(' ').join('+'); | |||
} | } | ||
function | function queueExam() { | ||
var | var api = new mw.Api(); | ||
var | var result; | ||
$ | var pageString = "User:" + mw.user.name() + "/WBRQueue"; | ||
api.get({ | |||
action : 'query', | |||
var | 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,') ==r-1) { | |||
addNewSection("User:" + mw.user.name() + "/WBRQueue", 'Placeholder,', mw.user.tokens.get('editToken')); | |||
alert('First Timah!'); | |||
return false; | |||
} | |||
var Questions = $title.text().split(","); | |||
Questions = jQuery.grep(Questions, function (value) { | |||
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) { | |||
var Q = document.getElementById('question'); | var Q = document.getElementById('question'); | ||
if (exam === "MCAT") { | |||
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", "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 and 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 and 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 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"); | |||
} 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 />"; | |||
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(exam,"s",categories['sub'][i]); | |||
if (categories['main'][i]) { | |||
catQuestionCount(exam,"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>" | |||
var Q = document.getElementById('question'); | |||
Q.innerHTML = table; | |||
} | |||
Q.innerHTML += "<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 /><b>Second: choose the number of questions you would like to answer. The maximum number of questions you can select is <span id='countShow'></span>.</b><br /><br /><br />Number of questions:<input type='text' id='numQues' disabled /><br /><br /><div id='Go' class='noSelect WBRButton'>Click here to begin the exam</div>"; | |||
$("#Go").click(function () { | |||
if (countdownCurrent) { | |||
countdownTimer.toggle(); | |||
} | |||
var Mfields = $("[name=MainCat]").serializeArray(); | |||
var Sfields = $("[name=SubCat]").serializeArray(); | |||
var sMain = new Array(); | |||
var sSub = new Array(); | |||
if (Mfields.length === 0) { | |||
alert('No Main Category Selected'); | |||
selectExam(); | |||
} else if (Sfields.length === 0) { | |||
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 Q = document.getElementById('question'); | |||
Q.innerHTML = "Loading..."; | |||
var Questions = loadExam(exam, numQues, sSub, sMain).toString(); | |||
$("input[name='stash']").val(Questions); | |||
Q.innerHTML = ""; | |||
$('#home').css('visibility', 'visible'); | |||
loadQuestion(); | |||
} | |||
}); | |||
}); | $("#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"); | |||
}); | |||
} | |||
}); | |||
$("#CountQ").click(function () { | |||
var sMain = new Array(); | |||
var sSub = new Array(); | |||
$("[name=MainCat]:checked").each(function () { | |||
sMain.push($(this).val()); | |||
}); | |||
$("[name=SubCat]:checked").each(function () { | |||
sSub.push($(this).val()); | |||
}); | |||
completeQuestionCount(exam, sMain, sSub); | |||
}); | |||
} | |||
function loadExam(exam, numQues, SubCat, MainCat) { | |||
$.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() { | |||
var Questions = $("input[name='stash']").val().split(","); | |||
var name = Questions[parseInt($("input[name='pos']").val()) - 1]; | |||
$.ajaxSetup({ | |||
async : false | |||
}); | |||
var right = " "; | |||
var qs = "[[" + name + "]]|?PageAuthor|?Prompt|?RightAnswer|?AnswerA|?AnswerB|?AnswerC|?AnswerD|?AnswerE|?Explanation|?AnswerAExp|?AnswerBExp|?AnswerCExp|?AnswerDExp|?AnswerEExp|?WBRImage|?WBRImageCaption|?WBRImagePlace"; | |||
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(","); | |||
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> " + 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> " + 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> " + 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> " + 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> " + short.AnswerEExp['0'].fulltext + "</i></div>"; | |||
} | |||
if (short.WBRImage) { | |||
for (var i = 0; i < short.WBRImage.length; i++) { | |||
if (short.WBRImagePlace[i] === "Prompt") { | |||
document.getElementById('promptImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]); | |||
} | |||
if (short.WBRImagePlace[i] === "Answer A") { | |||
document.getElementById('AnsAImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]); | |||
} | |||
if (short.WBRImagePlace[i] === "Answer B") { | |||
document.getElementById('AnsBImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]); | |||
} | |||
if (short.WBRImagePlace[i] === "Answer C") { | |||
document.getElementById('AnsCImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]); | |||
} | |||
if (short.WBRImagePlace[i] === "Answer D") { | |||
document.getElementById('AnsDImage').innerHTML += getImage(short.WBRImage[i], short.WBRImageCaption[i]); | |||
} | |||
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 | |||
function getImage(filename, caption) { | |||
var api = new mw.Api(); | |||
var result; | |||
api.get({ | |||
action : 'parse', | |||
text : '[[File:' + filename + ']]', | |||
format : 'json', | |||
async : false | |||
}, { | |||
ok : function (data) { | |||
result = data.parse.text['*']; | |||
} | |||
}); | |||
if (caption === "no-display") { | |||
return result; | |||
} else { | |||
result += caption; | |||
return result; | |||
} | |||
} | } | ||
function | |||
$('#next').css('visibility',' | function showButtons() { | ||
$('#back').css('visibility',' | $('#next').css('visibility', 'visible'); | ||
$('#back').css('visibility', 'visible'); | |||
} | } | ||
function | function hideButtons() { | ||
$('#next').css('visibility', 'hidden'); | |||
$('#back').css('visibility', 'hidden'); | |||
} | } | ||
function removeFromQueue(question) { | |||
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); | |||
} | |||
} | |||
}); | |||
return result; | |||
} | } | ||
var | |||
function addToQueue(question) { | |||
return; | 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"); | |||
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 addNewSection(title, content, editToken) { | |||
$.ajaxSetup({ | |||
async : false | |||
}); | |||
$.ajax({ | |||
url : mw.util.wikiScript('api'), | |||
data : { | |||
format : 'json', | |||
action : 'edit', | |||
title : title, | |||
text : content, | |||
token : editToken, | |||
recreate : 'r', | |||
}, | |||
dataType : 'json', | |||
type : 'POST', | |||
success : function (data) { | |||
if (data && data.edit && data.edit.result == 'Success') { | |||
// reload page if edit was successful | |||
} else if (data && data.error) { | |||
alert('Error: Not Logged In'); | |||
} else { | |||
alert('Error: Not Logged In'); | |||
} | |||
}, | |||
error : function (xhr) { | |||
alert('Error: Not Logged In. Please log in to create a Question.'); | |||
} | |||
}); | |||
} | } | ||
$('#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> | </script> | ||
<form> | <span class='countdowntime'></span> | ||
<div id="question"> | <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> | |||
<input type="button" onclick=" | <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> | ||
</div> | |||
<div id="question" style="visibility:hidden;"> | |||
<b>Click here to start the exam:</b><br /> | |||
<a href="#" onclick="loginCheck('USMLE Step 1')"><img src="http://static.wikidoc.org/8/87/Step1.png" /></a> | |||
<a href="#" onclick="loginCheck('USMLE Step 2 CK')"><img src="http://static.wikidoc.org/0/07/Step2CK.png" /></a> | |||
<a href="#" onclick="loginCheck('USMLE Step 3')"><img src="http://static.wikidoc.org/0/08/Step3.png" /></a> | |||
<a href="#" onclick="loginCheck('Board Review')"><img src="http://static.wikidoc.org/7/75/Boardcertification.png" /></a> | |||
<a href="#" onclick="loginCheck('MCAT')"><img src="http://static.wikidoc.org/4/4b/MCAT.png" /></a><br /> | |||
<!-- bold + larger font size--> | |||
<b>Click here to repeat questions you've gotten wrong previously</b> | |||
<input type="button" onclick="loginCheck('Queue')" value="Review Exam" /><br /> | |||
</div> | </div> | ||
<input type='hidden' id='stash' name='stash' value='' /> | <input type='hidden' id='stash' name='stash' value='' /> | ||
<input type='hidden' name='pos' value=' | <input type='hidden' name='pos' value='1' /> | ||
<input type='hidden' name='results' value='' /> | <input type='hidden' name='results' value='' /> | ||
<div style="width:100%"><div id=" | <input type='hidden' name='FC' value='' /> | ||
<input type='hidden' name='time' value='' /> | |||
<div style="width:100%"><div id="home" class="noSelect WBRButton" style="visibility:hidden;"><br />Home</div><div id="back" class="noSelect WBRButton" style="visibility:hidden;"><br />Back</div><div id="next" class="noSelect WBRButton" style="visibility:hidden;"><br />Next</div> </div> | |||
</form> | </form> | ||
</includeonly> | </includeonly> |