Widget:Sandbox: Difference between revisions
Jump to navigation
Jump to search
Matt Pijoan (talk | contribs) No edit summary |
Matt Pijoan (talk | contribs) No edit summary |
||
(107 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<includeonly> | <includeonly> | ||
<script src="http://wikidoc.org/includes/jquery.timer.js"></script> | <script src="http://www.wikidoc.org/includes/raty/jquery.timer.js"></script> | ||
<script type="text/javascript" src="http://wikidoc.org/includes/raty/jquery.raty.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: | border:0px solid black !important; | ||
} | } | ||
.redBoxed{ | .redBoxed{ | ||
border: | border:0px solid #F00 !important; | ||
} | } | ||
.unboxed{ | .unboxed{ | ||
Line 37: | Line 37: | ||
margin-right:10px; | margin-right:10px; | ||
} | } | ||
.WBRImgButton{ | |||
font-family:Arial; | |||
float:left; | |||
height:40px; | |||
font-weight:bold; | |||
width:100px; | |||
display: table-cell; | |||
cursor: pointer; | |||
color:#FFFFFF; | |||
text-align: center; | |||
vertical-align: middle; | |||
margin-right:10px; | |||
} | |||
.WBRImgButton img{ | |||
width:auto; | |||
height:35px; | |||
} | |||
#globalWrapper{ | #globalWrapper{ | ||
z-index:-1; | z-index:-1; | ||
Line 53: | Line 73: | ||
position:relative; | position:relative; | ||
float:right; | float:right; | ||
width: | width:95%; | ||
background-color:#3366CC; | |||
} | } | ||
.navPaneButton{ | .navPaneButton{ | ||
Line 64: | Line 85: | ||
} | } | ||
div.answerNoBorder{ | div.answerNoBorder{ | ||
border: | border:0px solid #FFF; | ||
} | } | ||
div.answerBorder{ | div.answerBorder{ | ||
border: | border:0px solid #000; | ||
} | } | ||
div.explanationHide{ | div.explanationHide{ | ||
Line 78: | Line 99: | ||
} | } | ||
</style> | </style> | ||
<script type="text/javascript"> | <script type="text/javascript">function ensureLoggedIn() { | ||
function ensureLoggedIn() { | mw.loader.load('mediaWiki.user'); | ||
if ($.isEmptyObject(wgUserName)) { | |||
alert("Please Log In To Continue."); | |||
window.location.replace("http://wikidoc.org/index.php?title=Special:UserLogin&returnto=User%3AMatt+Pijoan"); | |||
} else { | |||
curriculumType(); | |||
} | |||
} | } | ||
function curriculumType() { | function curriculumType() { | ||
Line 133: | Line 153: | ||
} | } | ||
function chooseQBank(event) { | function chooseQBank(event) { | ||
window.exam.examtype = $(this).attr('id'); | |||
var divs = null; | 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 />"; | 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); | $("#exam").html(divs); | ||
$('.stepTwo').click( | $('.stepTwo').click(window.exam, tutorOrExam); | ||
} | } | ||
function tutorOrExam(event) { | function tutorOrExam(event) { | ||
window.exam.qbank = $(this).attr('id'); | |||
var buttons = ''; | 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 />"; | 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); | $("#exam").append(buttons); | ||
$('.ToE').click( | $('.ToE').click(window.exam, categoryOrKeyword); | ||
} | } | ||
function categoryOrKeyword(event) { | function categoryOrKeyword(event) { | ||
window.exam.examType = $(this).attr('id'); | |||
var buttons = ''; | 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 />"; | 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); | $("#exam").append(buttons); | ||
$('.CoK').click( | $('.CoK').click(window.exam, timerToggle); | ||
} | } | ||
function timerToggle(event) { | function timerToggle(event) { | ||
window.exam.searchMethod = $(this).attr('id'); | |||
var form = null; | 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 />"; | 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 />"; | ||
Line 161: | Line 181: | ||
$("#exam").append(form); | $("#exam").append(form); | ||
} | } | ||
$('#yes').click( | $('#yes').click(window.exam, timerDuration); | ||
if ( | if (window.exam.searchMethod === "Category") { | ||
$('#nop').click( | $('#nop').click(window.exam, countCats); | ||
} else { | } else { | ||
$('#nop').click( | $('#nop').click(window.exam, Keywords); | ||
} | } | ||
} | } | ||
function timerDuration(event) { | function timerDuration(event) { | ||
window.exam.timer = true; | |||
var form = null; | var form = null; | ||
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 />" | 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 />" | ||
Line 176: | Line 196: | ||
$("#exam").append(form); | $("#exam").append(form); | ||
} | } | ||
if ( | if (window.exam.searchMethod === "Category") { | ||
$('.stepFour').click( | $('.stepFour').click(window.exam, countCats); | ||
} else { | } else { | ||
$('.stepFour').click( | $('.stepFour').click(window.exam, Keywords); | ||
} | } | ||
} | } | ||
Line 225: | Line 245: | ||
}); | }); | ||
$("#showQueries").click( | $("#showQueries").click(window.exam, showQueries); | ||
function showQueries(event) { | function showQueries(event) { | ||
$("#removeNum").remove(); | $("#removeNum").remove(); | ||
window.exam.queries = []; | |||
window.exam.questionListAll = []; | |||
window.exam.keyword = {}; | |||
window.exam.keyword.iterator = 0; | |||
$.each($(".query"), function (index, value) { | $.each($(".query"), function (index, value) { | ||
window.exam.queries[index] = "[[ExamType::" + window.exam.examtype + "]]"; | |||
$.each($(this).children(), function (ind, val) { | $.each($(this).children(), function (ind, val) { | ||
window.exam.queries[index] += "[[WBRKeyword::" + $(this).val() + "]]"; | |||
}); | }); | ||
}); | }); | ||
runQueries( | runQueries(window.exam); | ||
} | } | ||
function runQueries(obj) { | function runQueries(obj) { | ||
Line 260: | Line 280: | ||
} | } | ||
function removeDuplicates(obj) { | function removeDuplicates(obj) { | ||
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'>" + | if (res.Count > 45) { | ||
obj.maxQ = 45; | |||
} else { | |||
obj.maxQ = res.Count; | |||
} | |||
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>"; | |||
if ($("#exam").find('#numQues').length == 0) { | if ($("#exam").find('#numQues').length == 0) { | ||
$("#exam").append(output); | $("#exam").append(output); | ||
Line 272: | Line 297: | ||
} | } | ||
function TNG(event) { | function TNG(event) { | ||
window.exam.numQuestion = $("#numQues").val(); | |||
loadNextQuestion( | if (window.exam.numQuestion > 0 && window.exam.numQuestion <= 45) { | ||
loadNextQuestion(window.exam); | |||
} else { | |||
alert('Invalid number of questions entered.'); | |||
} | |||
} | } | ||
function selectCats( | function selectCats() { | ||
var categories = []; | var categories = []; | ||
var table = null; | var table = null; | ||
table = "<br /><b>Select All That Apply:</b><br /><br /><br />"; ; | table = "<br /><b>Select All That Apply:</b><br /><br /><br />"; ; | ||
if (exam.examtype === "MCAT") { | if (window.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"); | 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++) { | for (var i = 0; i < categories['main'].length; i++) { | ||
Line 289: | Line 318: | ||
} else { | } else { | ||
if (exam.examtype === "USMLE Step 1") { | if (window.exam.examtype === "USMLE Step 1") { | ||
categories['main'] = new Array("Anatomy", "Behavioral Science/Psychiatry", "Biochemistry", "Biostatistics/Epidemiology", "Embryology", "Ethics", "Genetics", "Histology", "Immunology", "Microbiology", "Pathology", "Pathophysiology", "Pharmacology", "Physiology"); | categories['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"); | 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.examtype === "USMLE Step 2 CK") { | } else if (window.exam.examtype === "USMLE Step 2 CK") { | ||
categories['main'] = new Array("Internal medicine", "Surgery", "OB/GYN", "Pediatrics", "Psychiatry"); | 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"); | 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.examtype === "USMLE Step 3") { | } else if (window.exam.examtype === "USMLE Step 3") { | ||
categories['main'] = new Array("Community Medical Health Center", "Primary Care Office", "Inpatient Facilities", "Emergency Room"); | 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"); | 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.examtype === "Board Review") { | } else if (window.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"); | 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"); | 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"); | ||
Line 357: | Line 386: | ||
}); | }); | ||
$("#CountQ").click(exam, selectExamLength); | $("#CountQ").click(window.exam, selectExamLength); | ||
} | } | ||
function selectExamLength(event) { | function selectExamLength(event) { | ||
Line 371: | Line 400: | ||
Sub.push($(this).val()); | Sub.push($(this).val()); | ||
}); | }); | ||
window.exam.mainCat = Main; | |||
window.exam.subCat = Sub; | |||
var api = new mw.Api(event, Main, Sub); | var api = new mw.Api(event, Main, Sub); | ||
api.get({ | api.get({ | ||
Line 378: | Line 407: | ||
main : JSON.stringify(Main), | main : JSON.stringify(Main), | ||
sub : JSON.stringify(Sub), | sub : JSON.stringify(Sub), | ||
exam : | exam : window.exam.examtype, | ||
format : 'json' | format : 'json' | ||
}, { | }, { | ||
ok : function (res) { | ok : function (res) { | ||
if (res.Count > 45) { | |||
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'>" + | window.exam.maxQ = 45; | ||
} else { | |||
window.exam.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'>" + window.exam.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) { | if ($("#exam").find('#numQues').length == 0) { | ||
$("#exam").append(output); | $("#exam").append(output); | ||
} | } | ||
$("#Go").click( | $("#Go").click(window.exam, inputValidation); | ||
} | } | ||
}); | }); | ||
Line 397: | Line 430: | ||
function inputValidation(event) { | function inputValidation(event) { | ||
if ($("#numQues").val().length > 0 && parseInt($("#numQues").val(), 10) <= parseInt($("#countShow").html(), 10) && parseInt($("#numQues").val(), 10) > 0) { | if ($("#numQues").val().length > 0 && parseInt($("#numQues").val(), 10) <= parseInt($("#countShow").html(), 10) && parseInt($("#numQues").val(), 10) > 0) { | ||
window.exam.numQuestion = $("#numQues").val(); | |||
var api = new mw.Api(); | |||
api.get({ | |||
action : 'newExam', | |||
username : mw.user.getName(), | |||
type : window.exam.examtype, | |||
format : 'json' | |||
}) | |||
.done(function (data) { | |||
window.exam.examid = data.newExam.exam_id; | |||
}); | |||
$("#exam").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />"); | $("#exam").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />"); | ||
if ( | if (window.exam.timer) { | ||
window.exam.examTimer = $.timer(function () { | |||
var rem = parseInt($("#timeRem").html()); | var rem = parseInt($("#timeRem").html()); | ||
$('#timerBox').css("visibility", "visible"); | $('#timerBox').css("visibility", "visible"); | ||
$('#timerBox').html(formatTime(rem)); | $('#timerBox').html(formatTime(rem)); | ||
if (rem == 0) { | if (rem == 0) { | ||
window.exam.examTimer.stop(); | |||
$("#content").click( | $("#content").click(window.exam, endExam); | ||
} else { | } else { | ||
var temp = rem - 7; | var temp = rem - 7; | ||
Line 416: | Line 459: | ||
}, 70, false); | }, 70, false); | ||
window.exam.examTimer.toggle(); | |||
} | } | ||
loadNextQuestion( | loadNextQuestion(); | ||
} else { | } else { | ||
alert('Invalid entry in number of questions input'); | alert('Invalid entry in number of questions input'); | ||
} | } | ||
} | } | ||
function loadNextQuestion() { | |||
function | window.exam.examQuestions = []; | ||
var | if (window.exam.searchMethod === "Category") { | ||
var api = new mw.Api(window.exam); | |||
api.get({ | |||
action : 'load', | |||
main : JSON.stringify(window.exam.mainCat), | |||
sub : JSON.stringify(window.exam.subCat), | |||
exam : window.exam.examtype, | |||
num : window.exam.numQuestion, | |||
format : 'json' | |||
}, { | |||
ok : function (res) { | |||
var i = 0; | |||
window.exam.currentQuestion = 0; | |||
$.each(res.questions.list, function (key, element) { | |||
element.PageName = key; | |||
window.exam.examQuestions[i] = element; | |||
i++; | |||
}); | |||
addToNavBar(window.exam); | |||
} | |||
}); | |||
} else if (window.exam.searchMethod === "Keyword") { | |||
var api = new mw.Api(window.exam); | |||
api.get({ | |||
action : 'load', | |||
keywords : JSON.stringify(window.exam.questionListAll), | |||
num : window.exam.numQuestion, | |||
format : 'json' | |||
}, { | |||
ok : function (res) { | |||
var i = 0; | |||
window.exam.currentQuestion = 0; | |||
$.each(res.questions.list, function (key, element) { | |||
element.PageName = key; | |||
window.exam.examQuestions[i] = element; | |||
i++; | |||
}); | |||
addToNavBar(); | |||
} | |||
}); | |||
} | } | ||
} | } | ||
function | function addToNavBar() { | ||
$("#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>"); | |||
$("#flag").click(function () { | |||
alert("Coming Soon!") | |||
}); | }); | ||
$("#back").click(questionNavigation); | |||
$("#next").click(questionNavigation); | |||
$("#finish").click(endExam); | |||
$("#back").click( | if (window.exam.timer) { | ||
$("#next").click( | |||
$("#finish").click( | |||
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>"); | $("#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 () { | $("#timerBox").click(function () { | ||
exam.examTimer.toggle(); | window.exam.examTimer.toggle(); | ||
}); | }); | ||
} | } | ||
$.each(exam.examQuestions, function (index, value) { | $.each(window.exam.examQuestions, function (index, value) { | ||
$("#navPane").append("<div id='" + index + "' class='navPaneButton'> " + (index - -1) + "</div>"); | $("#navPane").append("<div id='" + index + "' class='navPaneButton'> " + (index - -1) + "</div>"); | ||
}); | }); | ||
$(" | $(".navPaneButton").click(questionNavigation); | ||
$(".navPaneButton:odd").css("background-color", "#3338CC"); | $(".navPaneButton:odd").css("background-color", "#3338CC"); | ||
$(".navPaneButton:odd").css("background-color", "#B0B0B0"); | |||
questionDisplay( | questionDisplay(); | ||
} | } | ||
function questionDisplay( | function questionDisplay() { | ||
var obj = new Object(); | var obj = new Object(); | ||
obj = exam.examQuestions[exam.currentQuestion]; | obj = window.exam.examQuestions[window.exam.currentQuestion]; | ||
if (obj.isParsed === 0) { | if (obj.isParsed === 0) { | ||
$("#examSpace").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />"); | $("#examSpace").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />"); | ||
parseQuestions( | parseQuestions(); | ||
} else { | } else { | ||
var htmlStuff = " | var htmlStuff = "<b>Question " + (window.exam.currentQuestion - -1) + " / " + (window.exam.examQuestions.length) + "</b><br /><br />" + obj.Prompt + "<br />"; | ||
if (obj.AnswerA && obj.AnswerA.length > 0) { | 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>"; | 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") { | if (obj.AnswerAExp && obj.AnswerAExp.length > 0 && window.exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='Ae'> | htmlStuff += "<div class='answerExp explanationHide' id='Ae'>" + trimP(obj.AnswerAExp) + "</div>"; | ||
} | } | ||
if (obj.AnswerB && obj.AnswerB.length > 0) { | 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>"; | 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") { | if (obj.AnswerBExp && obj.AnswerBExp.length > 0 && window.exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='Be'> | htmlStuff += "<div class='answerExp explanationHide' id='Be'>" + trimP(obj.AnswerBExp) + "</div>"; | ||
} | } | ||
if (obj.AnswerC && obj.AnswerC.length > 0) { | 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>"; | 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") { | if (obj.AnswerCExp && obj.AnswerCExp.length > 0 && window.exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='Ce'> | htmlStuff += "<div class='answerExp explanationHide' id='Ce'>" + trimP(obj.AnswerCExp) + "</div>"; | ||
} | } | ||
if (obj.AnswerD && obj.AnswerD.length > 0) { | 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>"; | 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") { | if (obj.AnswerDExp && obj.AnswerDExp.length > 0 && window.exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='De'> | htmlStuff += "<div class='answerExp explanationHide' id='De'>" + trimP(obj.AnswerDExp) + "</div>"; | ||
} | } | ||
if (obj.AnswerEExp && obj.AnswerE.length > 0) { | 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>"; | 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") { | if (obj.AnswerEExp && obj.AnswerEExp.length > 0 && window.exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='Ee'> | htmlStuff += "<div class='answerExp explanationHide' id='Ee'>" + trimP(obj.AnswerEExp) + "</div>"; | ||
} | } | ||
$("#examSpace").html(htmlStuff); | $("#examSpace").html(htmlStuff); | ||
if (exam.examQuestions[exam.currentQuestion].selectedAnswer !== 'F') { | if (window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer !== 'F') { | ||
$("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).addClass("boxed"); | $("#" + window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer).addClass("boxed"); | ||
} | } | ||
$("div.answer").mouseover(function () { | $("div.answer").mouseover(function () { | ||
$(this).css({ | $(this).css({ | ||
'border' : ' | 'border' : '0px solid #000' | ||
}) | }) | ||
}).mouseout(function () { | }).mouseout(function () { | ||
$(this).css({ | $(this).css({ | ||
'border' : ' | 'border' : '0px solid #FFF' | ||
}) | }) | ||
}); | }); | ||
$("div.answer").click( | $("div.answer").click(answerClicked); | ||
} | } | ||
} | } | ||
function questionReview() { | |||
function questionReview( | |||
var obj = new Object(); | var obj = new Object(); | ||
obj = exam.examQuestions[exam.currentQuestion]; | obj = window.exam.examQuestions[window.exam.currentQuestion]; | ||
if (obj.isParsed === 0) { | if (obj.isParsed === 0) { | ||
$("#examSpace").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />"); | $("#examSpace").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />"); | ||
parseQuestions( | parseQuestions(); | ||
} else { | } else { | ||
$("#examSpace").append("<br /><a href='http://www.wikidoc.org/index.php/Talk:" + obj.PageName + "' target='_blank'>Click here to discuss this question!</a><br />"); | $("#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 />"; | var htmlStuff = "<b>Author:</b> " + obj.PageAuthor + "<br /><br /><b>Question " + (window.exam.currentQuestion - -1) + " / " + (window.exam.examQuestions.length) + "</b><br /><br />" + obj.Prompt + "<br />"; | ||
if (obj.AnswerA && obj.AnswerA.length > 0) { | if (obj.AnswerA && obj.AnswerA.length > 0) { | ||
htmlStuff += "<div class='answer answerNoBorder' id='A'><input type='radio' id='Ar'> " + obj.AnswerA + "</div></input>"; | 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") { | if (obj.AnswerAExp && obj.AnswerAExp.length > 0 && window.exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='Ae'><i> " + obj.AnswerAExp + "</i></div>"; | htmlStuff += "<div class='answerExp explanationHide' id='Ae'><i> " + obj.AnswerAExp + "</i></div>"; | ||
} | } | ||
Line 555: | Line 605: | ||
htmlStuff += "<div class='answer answerNoBorder' id='B'><input type='radio' id='Br'> " + obj.AnswerB + "</input></div>"; | 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") { | if (obj.AnswerBExp && obj.AnswerBExp.length > 0 && window.exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='Be'><i> " + obj.AnswerBExp + "</div></i>"; | htmlStuff += "<div class='answerExp explanationHide' id='Be'><i> " + obj.AnswerBExp + "</div></i>"; | ||
} | } | ||
Line 561: | Line 611: | ||
htmlStuff += "<div class='answer answerNoBorder' id='C'><input type='radio' id='Cr'> " + obj.AnswerC + "</input></div>"; | 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") { | if (obj.AnswerCExp && obj.AnswerCExp.length > 0 && window.exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='Ce'><i> " + obj.AnswerCExp + "</i></div>"; | htmlStuff += "<div class='answerExp explanationHide' id='Ce'><i> " + obj.AnswerCExp + "</i></div>"; | ||
} | } | ||
Line 567: | Line 617: | ||
htmlStuff += "<div class='answer answerNoBorder' id='D'><input type='radio' id='Dr'> " + obj.AnswerD + "</input></div>"; | 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") { | if (obj.AnswerDExp && obj.AnswerDExp.length > 0 && window.exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='De'><i> " + obj.AnswerDExp + "</i></div>"; | htmlStuff += "<div class='answerExp explanationHide' id='De'><i> " + obj.AnswerDExp + "</i></div>"; | ||
} | } | ||
Line 573: | Line 623: | ||
htmlStuff += "<div class='answer answerNoBorder' id='E'><input type='radio' id='Er'> " + obj.AnswerE + "</input></div>"; | 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") { | if (obj.AnswerEExp && obj.AnswerEExp.length > 0 && window.exam.examType === "Tutor") { | ||
htmlStuff += "<div class='answerExp explanationHide' id='Ee'><i> " + obj.AnswerEExp + "</i></div>"; | htmlStuff += "<div class='answerExp explanationHide' id='Ee'><i> " + obj.AnswerEExp + "</i></div>"; | ||
} | } | ||
$("#examSpace").html(htmlStuff); | $("#examSpace").html(htmlStuff); | ||
addRatyRating(exam); | addRatyRating(exam); | ||
if (exam.examQuestions[exam.currentQuestion].selectedAnswer && exam.examQuestions[exam.currentQuestion].RightAnswer == exam.examQuestions[exam.currentQuestion].selectedAnswer) { | if (window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer && window.exam.examQuestions[window.exam.currentQuestion].RightAnswer == window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer) { | ||
$("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).addClass("boxed"); | $("#" + window.exam.examQuestions[window.exam.currentQuestion].RightAnswer).addClass("boxed"); | ||
} else { | } else { | ||
$("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).addClass("redBoxed"); | $("#" + window.exam.examQuestions[window.exam.currentQuestion].RightAnswer).addClass("redBoxed"); | ||
$("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).removeClass("answerNoBorder"); | $("#" + window.exam.examQuestions[window.exam.currentQuestion].RightAnswer).removeClass("answerNoBorder"); | ||
$("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).addClass("boxed"); | $("#" + window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer).addClass("boxed"); | ||
$("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).removeClass("answerNoBorder"); | $("#" + window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer).removeClass("answerNoBorder"); | ||
} | } | ||
$("#examSpace").append("<br /><br />The correct answer is: " + exam.examQuestions[exam.currentQuestion].RightAnswer + "<br /><br />< | $("#examSpace").append("<br /><br />The correct answer is: " + window.exam.examQuestions[window.exam.currentQuestion].RightAnswer + "<br /><br /><b>" + window.exam.examQuestions[window.exam.currentQuestion].Explanation + "</b><br /><br />"); | ||
} | } | ||
} | } | ||
function addRatyRating( | function addRatyRating() { | ||
addFirstResponses(); | |||
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 />" | 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); | $("#examSpace").prepend(ratyLayers); | ||
getRating(window.exam.examQuestions[exam.currentQuestion].PageName, window.exam); | |||
} | |||
function addFirstResponses() { | |||
var api = new mw.Api(); | |||
api.get({ | |||
action : 'firstResponseQuery', | |||
}) | question : window.exam.examQuestions[exam.currentQuestion].PageName, | ||
format : 'json' | |||
}) | |||
.done(function (data) { | |||
if (data.firstResponseQuery.A === null) { | |||
} | data.firstResponseQuery.A = 0; | ||
} | |||
if (data.firstResponseQuery.B === null) { | |||
data.firstResponseQuery.B = 0; | |||
} | |||
if (data.firstResponseQuery.C === null) { | |||
data.firstResponseQuery.C = 0; | |||
} | |||
if (data.firstResponseQuery.D === null) { | |||
data.firstResponseQuery.D = 0; | |||
} | |||
if (data.firstResponseQuery.E === null) { | |||
data.firstResponseQuery.E = 0; | |||
} | |||
data.firstResponseSum = parseInt(data.firstResponseQuery.A) + parseInt(data.firstResponseQuery.B) + parseInt(data.firstResponseQuery.C) + parseInt(data.firstResponseQuery.D) + parseInt(data.firstResponseQuery.E); | |||
$("#Ae").append("<br />Selected as first response:" + parseInt((data.firstResponseQuery.A / data.firstResponseSum) * 100).toString() + "%"); | |||
$("#Be").append("<br />Selected as first response:" + parseInt((data.firstResponseQuery.B / data.firstResponseSum) * 100).toString() + "%"); | |||
$("#Ce").append("<br />Selected as first response:" + parseInt((data.firstResponseQuery.C / data.firstResponseSum) * 100).toString() + "%"); | |||
$("#De").append("<br />Selected as first response:" + parseInt((data.firstResponseQuery.D / data.firstResponseSum) * 100).toString() + "%"); | |||
$("#Ee").append("<br />Selected as first response:" + parseInt((data.firstResponseQuery.E / data.firstResponseSum) * 100).toString() + "%"); | |||
}); | }); | ||
} | |||
function answerClicked(event) { | |||
$(".answer").removeClass("boxed"); | |||
$(event.currentTarget).addClass("boxed"); | |||
$(event.currentTarget.firstChild).prop("checked", true); | |||
window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer = $("div .boxed").attr("id"); | |||
if ($("#exam").find('#submit').length == 0) { | |||
$("#examSpace").append("<div class='noSelect WBRButton' id='submit'><br />Submit</div>"); | |||
$("#submit").click(window.exam, answerSubmitted); | |||
} | |||
} | } | ||
function | 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) { | function answerSubmitted(event) { | ||
$("#submit").remove(); | |||
if (!window.exam.examQuestions[window.exam.currentQuestion].creditRecieved && window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer === window.exam.examQuestions[window.exam.currentQuestion].RightAnswer) { | |||
if (! | window.exam.answeredRight += 1; | ||
window.exam.examQuestions[window.exam.currentQuestion].creditRecieved = true; | |||
} | } | ||
if ( | if (window.exam.examType === "Tutor") { | ||
$(".answerExp").css("height", "auto"); | $(".answerExp").css("height", "auto"); | ||
$(".answerExp").css("visibility", "visible"); | $(".answerExp").css("visibility", "visible"); | ||
$(".answerExp").each(function () { | |||
if ($(this).attr('id') === window.exam.examQuestions[window.exam.currentQuestion].RightAnswer + "e") { | |||
$(this).prepend(" <b>Correct:</b> "); | |||
} else { | |||
$(this).prepend(" <b>Incorrect:</b> "); | |||
} | |||
}); | |||
} | } | ||
$("div.answer").unbind('click'); | $("div.answer").unbind('click'); | ||
var api = new mw.Api(); | var api = new mw.Api(); | ||
api.get({ | api.get({ | ||
action : ' | action : 'answerQuestion', | ||
username : mw.user.getName(), | username : mw.user.getName(), | ||
question : | question : window.exam.examQuestions[window.exam.currentQuestion].PageName, | ||
selected : window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer, | |||
examid : window.exam.examid, | |||
format : 'json' | format : 'json' | ||
}) | }) | ||
Line 656: | Line 759: | ||
console.log('API result:', data); | console.log('API result:', data); | ||
}); | }); | ||
if ( | if (window.exam.examType === "Exam") { | ||
$("#" + | $("#" + window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer).addClass("boxed"); | ||
} else if ( | } else if (window.exam.examType === "Tutor") { | ||
$("#examSpace").append("<br /><br />The correct answer is: " + | $("#examSpace").append("<br /><br />The correct answer is: " + window.exam.examQuestions[window.exam.currentQuestion].RightAnswer + "<br /><br />" + window.exam.examQuestions[window.exam.currentQuestion].Explanation + "<br />"); | ||
$("#" + | $("#examSpace").append("<b>Author:</b> " + window.exam.examQuestions[window.exam.currentQuestion].PageAuthor + "<br /><br /><b>Wiki Page:</b>" + window.exam.examQuestions[window.exam.currentQuestion].PageName + "<br /><br />Discuss this question <a href='http://www.wikidoc.org/index.php/Talk:" + window.exam.examQuestions[window.exam.currentQuestion].PageName + "'>Here</a>"); | ||
$("#" + | $("#" + window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer).addClass("boxed"); | ||
addRatyRating( | $("#" + window.exam.examQuestions[window.exam.currentQuestion].RightAnswer).addClass("redBoxed"); | ||
addRatyRating(window.exam); | |||
} | } | ||
} | } | ||
function questionNavigation(event) { | function questionNavigation(event) { | ||
if ($(this).attr("id") === "back") { | if ($(this).attr("id") === "back") { | ||
window.exam.currentQuestion--; | |||
} else if ($(this).attr("id") === "next") { | } else if ($(this).attr("id") === "next") { | ||
window.exam.currentQuestion++; | |||
} else if ($(this).attr("class") === "navPaneButton") { | } else if ($(this).attr("class") === "navPaneButton") { | ||
window.exam.currentQuestion = $(this).attr("id"); | |||
} | } | ||
questionDisplay(window.exam); | |||
questionDisplay( | |||
} | } | ||
function questionReviewNavigation(event) { | function questionReviewNavigation(event) { | ||
if ($(this).attr("id") === "back") { | if ($(this).attr("id") === "back") { | ||
window.exam.currentQuestion--; | |||
} else if ($(this).attr("id") === "next") { | } else if ($(this).attr("id") === "next") { | ||
window.exam.currentQuestion++; | |||
} else if ($(this).attr("class") === "navPaneButton") { | } else if ($(this).attr("class") === "navPaneButton") { | ||
window.exam.currentQuestion = $(this).attr("id"); | |||
} | } | ||
questionReview(window.exam); | |||
questionReview( | |||
} | } | ||
function endExam(event) { | function endExam(event) { | ||
if ( | if (window.exam.timer) { | ||
$('#timerBox').html(""); | $('#timerBox').html(""); | ||
$('#timerBox').css("visibility", "hidden"); | $('#timerBox').css("visibility", "hidden"); | ||
window.exam.examTimer.stop(); | |||
} | } | ||
$("#examSpace").html(""); | $("#examSpace").html(""); | ||
var datas; | var datas; | ||
datas = ""; | datas = ""; | ||
datas += "<br />You answered " + | datas += "<br />You answered " + window.exam.answeredRight + " out of " + window.exam.examQuestions.length + " correctly.<br /> Your percentage score is: "; | ||
var percent = ( | var percent = (window.exam.answeredRight / window.exam.examQuestions.length) * 100; | ||
datas += percent + "%<br /><br />Click the Navigation Buttons on the left to review the questions you answered."; | datas += percent + "%<br /><br />Click the Navigation Buttons on the left to review the questions you answered."; | ||
var api = new mw.Api(); | var api = new mw.Api(); | ||
api.get({ | api.get({ | ||
action : ' | action : 'endExam', | ||
id : window.exam.examid, | |||
score : percent, | score : percent, | ||
format : 'json' | format : 'json' | ||
Line 716: | Line 816: | ||
$("#examSpace").append(datas); | $("#examSpace").append(datas); | ||
$(".navPaneButton").unbind('click'); | $(".navPaneButton").unbind('click'); | ||
$(".navPaneButton").click( | $(".navPaneButton").click(window.exam, questionReviewNavigation); | ||
} | } | ||
function submitRating(ratingType, score, page) { | function submitRating(ratingType, score, page) { | ||
if (ratingType === "difficulty") { | |||
var api = new mw.Api(); | |||
api.get({ | |||
action : 'wbrinsertrating', | |||
username : mw.user.getName(), | |||
question : page, | |||
difficulty : score, | |||
format : 'json' | |||
}, { | |||
ok : function (res) {} | |||
}); | |||
} else if (ratingType === "yield"){ | } else if (ratingType === "yield") { | ||
var api = new mw.Api(); | |||
api.get({ | |||
action : 'wbrinsertrating', | |||
username : mw.user.getName(), | |||
question : page, | |||
yield : score, | |||
format : 'json' | |||
}, { | |||
ok : function (res) {} | |||
}); | |||
} | } else if (ratingType === "quality") { | ||
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) {} | |||
}); | |||
} | |||
} | |||
} | } | ||
function parseQuestions(examObj) { | function parseQuestions(examObj) { | ||
var tobeParsed = null; | var tobeParsed = null; | ||
Line 885: | Line 972: | ||
} | } | ||
function countCats(event) { | function countCats(event) { | ||
window.exam.timeAmt = parseInt($(this).attr("id"), 10) * 6000; | |||
var temp = | var temp = window.exam.examtype.replace(/ /g, "_"); | ||
var api = new mw.Api(); | var api = new mw.Api(); | ||
api.get({ | api.get({ | ||
Line 895: | Line 982: | ||
}, { | }, { | ||
ok : function (data) { | ok : function (data) { | ||
window.exam.arrCounts = data; | |||
selectCats( | selectCats(window.exam); | ||
} | } | ||
}); | }); | ||
} | } | ||
// 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 urlSwapSpace(swap) { | function urlSwapSpace(swap) { | ||
return swap.split(' ').join('+'); | return swap.split(' ').join('+'); | ||
} | |||
function trimP(data) { | |||
return data.substring(3, data.length - 4).trim(); ; | |||
} | } | ||
$(document).ready(ensureLoggedIn); | $(document).ready(ensureLoggedIn); |