User:Matt Pijoan: Difference between revisions
Matt Pijoan (talk | contribs) No edit summary |
Matt Pijoan (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
{{widget:sandbox}} | |||
Revision as of 17:40, 11 October 2012
<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"> .boxed{ border:0px solid black !important; } .redBoxed{ border:0px solid #F00 !important; }
.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: pointer; color:#FFFFFF; text-align: center; vertical-align: middle; 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{
z-index:-1; }
- navPane{
position:relative; float:left; width:5%; }
- examSpace{
position:relative; float:right; width:94%; }
- navBar{
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;
}
div.answerNoBorder{
border:0px solid #FFF;
}
div.answerBorder{
border:0px solid #000;
}
div.explanationHide{
height:0px;
visibility:hidden;
}
div.explanationShow{
height:auto;
visibility:visible;
}
</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://wikidoc.org/index.php?title=Special:UserLogin&returnto=User%3AMatt+Pijoan");
} else {
curriculumType();
}
}
function curriculumType() {
var options = {
examtype : null,
timer : null,
qbank : null,
searchMethod : null,
timer : null,
examType : ,
timeAmt : 0,
questionListAll : new Array(),
numQuestion : null,
currentQuestion : 0,
examQuestions : new Array(),
isParsed : 0,
answeredRight : 0,
Question : {
PageName : null,
PageAuthor : null,
Prompt : null,
RightAnswer : ' ',
AnswerA : null,
AnswerB : null,
AnswerC : null,
AnswerD : null,
AnswerE : null,
AnswerAExp : null,
AnswerBExp : null,
AnswerCExp : null,
AnswerDExp : null,
AnswerEExp : null,
selectedAnswer : 'F',
lastParsed : 0,
creditReceived : false
}
}
var stuffs = "<a href='#' class='Curric' id='USMLE Step 1'></a>";
stuffs += "<a href='#' class='Curric' id='USMLE Step 2 CK'></a>";
stuffs += "<a href='#' class='Curric' id='USMLE Step 3'></a>";
stuffs += "<a href='#' class='Curric' id='Board Review'></a>";
stuffs += "<a href='#' class='Curric' id='MCAT'></a>
";
$("#exam").html(stuffs);
$('.Curric').click(options, chooseQBank);
} function chooseQBank(event) { window.exam.examtype = $(this).attr('id'); var divs = null;
divs = "
Build your own exam!
USMLE Format
Flash Cards
";
$("#exam").html(divs); $('.stepTwo').click(window.exam, tutorOrExam); } function tutorOrExam(event) {
window.exam.qbank = $(this).attr('id'); var buttons = ;
buttons = "
Tutor Mode
Exam Mode
";
$("#exam").append(buttons); $('.ToE').click(window.exam, categoryOrKeyword); } function categoryOrKeyword(event) { window.exam.examType = $(this).attr('id'); var buttons = ;
buttons = "
Category
Keyword
";
$("#exam").append(buttons); $('.CoK').click(window.exam, timerToggle); } function timerToggle(event) { window.exam.searchMethod = $(this).attr('id'); var form = null;
form = "
Enable Timer
Disable Timer
";
if ($("#exam").find('#yes').length == 0) { $("#exam").append(form); } $('#yes').click(window.exam, timerDuration);
if (window.exam.searchMethod === "Category") { $('#nop').click(window.exam, countCats); } else { $('#nop').click(window.exam, Keywords); } } function timerDuration(event) { window.exam.timer = true; var form = null;
form = "
1 Minute
10 Minute
20 Minutes
40 Minutes
"
if ($("#exam").find('#1').length == 0) { $("#exam").append(form); } if (window.exam.searchMethod === "Category") { $('.stepFour').click(window.exam, countCats); } else { $('.stepFour').click(window.exam, Keywords); } } function Keywords(event) {
var stuffs = "
OR
AND
SHOW
";
$("#exam").append(stuffs);
var orBox = "
";
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(); } }); });
$("#orOp").click(function () { $("#formSpace").append(orBox); $(".queryString").focus(function () { $(".focused").removeClass("focused"); $(this).parent().addClass("focused"); $(".queryString").focusout(function () { if ($(this).val().length <= 1) { $(this).remove(); } }); }); });
$("#andOp").click(function () { var andBox = "<input type='text' class='queryString' />"; $(".focused").append(andBox); $(".queryString").focus(function () { $(".focused").removeClass("focused"); $(this).parent().addClass("focused"); $(".queryString").focusout(function () { if ($(this).val().length <= 1) { $(this).remove(); } }); }); });
$("#showQueries").click(window.exam, showQueries); function showQueries(event) { $("#removeNum").remove(); window.exam.queries = []; window.exam.questionListAll = []; window.exam.keyword = {}; window.exam.keyword.iterator = 0; $.each($(".query"), function (index, value) { window.exam.queries[index] = "ExamType::" + window.exam.examtype + ""; $.each($(this).children(), function (ind, val) { window.exam.queries[index] += "WBRKeyword::" + $(this).val() + ""; }); }); runQueries(window.exam); } 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; }
var output = "
Number of questions:<input type='text' id='numQues' />
";
if ($("#exam").find('#numQues').length == 0) { $("#exam").append(output); } else {
alert('Please ensure you have valid keywords entered'); }
$("#Go").click(obj, TNG);
}
}
function TNG(event) {
window.exam.numQuestion = $("#numQues").val();
if (window.exam.numQuestion > 0 && window.exam.numQuestion <= 45) {
loadNextQuestion(window.exam);
} else {
alert('Invalid number of questions entered.');
}
}
function selectCats() {
var categories = [];
var table = null;
table = "
Select All That Apply:
"; ;
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");
for (var i = 0; i < categories['main'].length; i++) {
table += "<input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + "";
if ((i + 1) % 4 == 0) {
table += ""; } } } else { 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['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 (window.exam.examtype === "USMLE Step 2 CK") { categories['main'] = new Array("Internal medicine", "Surgery", "OB/GYN", "Pediatrics", "Psychiatry"); categories['sub'] = new Array("Allergy/Immunology", "Cardiovascular", "Dermatology", "Endocrine", "Gastrointestinal", "Hepatology", "Genitourinary", "Head and Neck", "Hematology", "Infectious Disease", "Musculoskeletal/Rheumatology", "Neurology", "Obstetrics and Gynecology", "Oncology", "Ophthalmology", "Pediatrics", "Poisoning", "Preventive Medicine", "Psychiatry", "Respiratory", "Surgery", "Biostatistics/ Epidemiology", "Ethics", "Electrolytes", "Genetics", "Miscellaneous"); } else if (window.exam.examtype === "USMLE Step 3") { categories['main'] = new Array("Community Medical Health Center", "Primary Care Office", "Inpatient Facilities", "Emergency Room"); categories['sub'] = new Array("Allergy/Immunology", "Cardiovascular", "Dermatology", "Endocrine", "Gastrointestinal", "Hepatology", "Genitourinary", "Head and Neck", "Hematology", "Infectious Disease", "Musculoskeletal/Rheumatology", "Neurology", "Obstetrics and Gynecology", "Oncology", "Ophthalmology", "Pediatrics", "Poisoning", "Preventive Medicine", "Psychiatry", "Respiratory", "Surgery", "Biostatistics/Epidemiology", "Ethics", "Electrolytes", "Genetics", "Miscellaneous"); } else if (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['sub'] = new Array("Anesthesiology", "Dermatology", "Emergency Medicine", "Emergency Medicine/Critical Care Medicine", "Family Medicine", "Medical Genetics", "Neurology", "Nuclear Medicine", "Pediatrics", "Physical Medicine & Rehab", "Preventative Medicine", "Psychiatry"); } table += "
"; if (categories['sub'].length >= categories['main'].length) {}
var table = "
Select All That Apply:
";
Main Category | Sub Category |
if (categories['sub'].length >= categories['main'].length) {
for (var i = 0; i < categories['sub'].length; i++) { if (categories['main'][i]) {
table += "";} else {
table += "";} } } else { for (var i = 0; i < categories['main'].length; i++) { if (categories['sub'][i]) {
table += "";} else {
table += "";} } }
table += "Main Category | Sub Category |
<input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + " ( " + exam.arrCounts['category']['main'][categories['main'][i]] + " ) | <input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( " + exam.arrCounts['category']['sub'][categories['sub'][i]] + " ) |
<input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( " + exam.arrCounts['category']['sub'][categories['sub'][i]] + " ) | |
<input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + " | <input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " |
<input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + " |
Second: Click the Count Question Button below to calculate number of questions available:
"
if ($("#exam").find('#SelectAll').length == 0) { $("#exam").append(table); } } $("#SelectAll").click(function () { if ($("#SelectAll").html() === "Select All Main Categories") { $("[name=MainCat]").each(function () { $(this).attr('checked', true); $("#SelectAll").html("Clear All Main Categories"); }); } else { $("[name=MainCat]").each(function () { $(this).attr('checked', false); $("#SelectAll").html("Select All Main Categories"); }); } });
$("#UnselectAll").click(function () { if ($("#UnselectAll").html() === "Select All Sub Categories") { $("[name=SubCat]").each(function () { $(this).attr('checked', true); $("#UnselectAll").html("Clear All Sub Categories"); }); } else { $("[name=SubCat]").each(function () { $(this).attr('checked', false); $("#UnselectAll").html("Select All Sub Categories"); }); } });
$("#CountQ").click(window.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()); }); window.exam.mainCat = Main; window.exam.subCat = Sub; var api = new mw.Api(event, Main, Sub); api.get({ action : 'catcount', main : JSON.stringify(Main), sub : JSON.stringify(Sub), exam : window.exam.examtype, format : 'json' }, { ok : function (res) { if (res.Count > 45) { window.exam.maxQ = 45; } else { window.exam.maxQ = res.Count; }
var output = "Choose the number of questions you would like to answer. The maximum number of questions you can select is " + window.exam.maxQ + ".
Number of questions:<input type='text' id='numQues' />
";
if ($("#exam").find('#numQues').length == 0) { $("#exam").append(output);
} $("#Go").click(window.exam, inputValidation); } }); } else { alert('Please ensure you have both a main and a sub category selected'); } } function inputValidation(event) { 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(""); if (window.exam.timer) { window.exam.examTimer = $.timer(function () { var rem = parseInt($("#timeRem").html()); $('#timerBox').css("visibility", "visible"); $('#timerBox').html(formatTime(rem)); if (rem == 0) { window.exam.examTimer.stop(); $("#content").click(window.exam, endExam); } else { var temp = rem - 7; $("#timeRem").html(temp.toString()); if (rem < 0) { $("#timeRem").html("0"); } } }, 70, false);
window.exam.examTimer.toggle(); } loadNextQuestion(); } else { alert('Invalid entry in number of questions input'); } } function loadNextQuestion() { window.exam.examQuestions = []; 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 addToNavBar() {
$("#exam").html("
" + exam.timeAmt.toString() + "");
$("#flag").click(function () { alert("Coming Soon!") }); $("#back").click(questionNavigation); $("#next").click(questionNavigation); $("#finish").click(endExam); if (window.exam.timer) {
$("#bodyContent").append("
");
$("#timerBox").click(function () { window.exam.examTimer.toggle(); }); } $.each(window.exam.examQuestions, function (index, value) {
$("#navPane").append("
");
});
$(".navPaneButton").click(questionNavigation);
$(".navPaneButton:odd").css("background-color", "#3338CC");
$(".navPaneButton:odd").css("background-color", "#B0B0B0");
questionDisplay();
}
function questionDisplay() {
var obj = new Object();
obj = window.exam.examQuestions[window.exam.currentQuestion];
if (obj.isParsed === 0) {
$("#examSpace").html("");
parseQuestions();
} else {
var htmlStuff = "Question " + (window.exam.currentQuestion - -1) + " / " + (window.exam.examQuestions.length) + "
" + obj.Prompt + "
";
if (obj.AnswerA && obj.AnswerA.length > 0) {
htmlStuff += "
";
} if (obj.AnswerAExp && obj.AnswerAExp.length > 0 && window.exam.examType === "Tutor") {
htmlStuff += "
";
} if (obj.AnswerB && obj.AnswerB.length > 0) {
htmlStuff += "
";
} if (obj.AnswerBExp && obj.AnswerBExp.length > 0 && window.exam.examType === "Tutor") {
htmlStuff += "
";
} if (obj.AnswerC && obj.AnswerC.length > 0) {
htmlStuff += "
";
} if (obj.AnswerCExp && obj.AnswerCExp.length > 0 && window.exam.examType === "Tutor") {
htmlStuff += "
";
} if (obj.AnswerD && obj.AnswerD.length > 0) {
htmlStuff += "
";
} if (obj.AnswerDExp && obj.AnswerDExp.length > 0 && window.exam.examType === "Tutor") {
htmlStuff += "
";
} if (obj.AnswerEExp && obj.AnswerE.length > 0) {
htmlStuff += "
";
} if (obj.AnswerEExp && obj.AnswerEExp.length > 0 && window.exam.examType === "Tutor") {
htmlStuff += "
";
}
$("#examSpace").html(htmlStuff);
if (window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer !== 'F') {
$("#" + window.exam.examQuestions[window.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(answerClicked);
}
}
function questionReview() {
var obj = new Object();
obj = window.exam.examQuestions[window.exam.currentQuestion];
if (obj.isParsed === 0) {
$("#examSpace").html("");
parseQuestions();
} else {
$("#examSpace").append("
<a href='http://www.wikidoc.org/index.php/Talk:" + obj.PageName + "' target='_blank'>Click here to discuss this question!</a>
");
var htmlStuff = "Author: " + obj.PageAuthor + "
Question " + (window.exam.currentQuestion - -1) + " / " + (window.exam.examQuestions.length) + "
" + obj.Prompt + "
";
if (obj.AnswerA && obj.AnswerA.length > 0) {
htmlStuff += "
</input>";
} if (obj.AnswerAExp && obj.AnswerAExp.length > 0 && window.exam.examType === "Tutor") {
htmlStuff += "
";
} if (obj.AnswerB && obj.AnswerB.length > 0) {
htmlStuff += "
";
} if (obj.AnswerBExp && obj.AnswerBExp.length > 0 && window.exam.examType === "Tutor") {
htmlStuff += "
";
} if (obj.AnswerC && obj.AnswerC.length > 0) {
htmlStuff += "
";
} if (obj.AnswerCExp && obj.AnswerCExp.length > 0 && window.exam.examType === "Tutor") {
htmlStuff += "
";
} if (obj.AnswerD && obj.AnswerD.length > 0) {
htmlStuff += "
";
} if (obj.AnswerDExp && obj.AnswerDExp.length > 0 && window.exam.examType === "Tutor") {
htmlStuff += "
";
} if (obj.AnswerEExp && obj.AnswerE.length > 0) {
htmlStuff += "
";
} if (obj.AnswerEExp && obj.AnswerEExp.length > 0 && window.exam.examType === "Tutor") {
htmlStuff += "
";
} $("#examSpace").html(htmlStuff); addRatyRating(exam); if (window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer && window.exam.examQuestions[window.exam.currentQuestion].RightAnswer == window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer) { $("#" + window.exam.examQuestions[window.exam.currentQuestion].RightAnswer).addClass("boxed"); } else {
$("#" + window.exam.examQuestions[window.exam.currentQuestion].RightAnswer).addClass("redBoxed");
$("#" + window.exam.examQuestions[window.exam.currentQuestion].RightAnswer).removeClass("answerNoBorder");
$("#" + window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer).addClass("boxed");
$("#" + window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer).removeClass("answerNoBorder");
}
$("#examSpace").append("
The correct answer is: " + window.exam.examQuestions[window.exam.currentQuestion].RightAnswer + "
" + window.exam.examQuestions[window.exam.currentQuestion].Explanation + "
");
}
}
function addRatyRating() {
addFirstResponses();
var 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("
Selected as first response:" + parseInt((data.firstResponseQuery.A / data.firstResponseSum) * 100).toString() + "%");
$("#Be").append("
Selected as first response:" + parseInt((data.firstResponseQuery.B / data.firstResponseSum) * 100).toString() + "%");
$("#Ce").append("
Selected as first response:" + parseInt((data.firstResponseQuery.C / data.firstResponseSum) * 100).toString() + "%");
$("#De").append("
Selected as first response:" + parseInt((data.firstResponseQuery.D / data.firstResponseSum) * 100).toString() + "%");
$("#Ee").append("
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("
Submit
");
$("#submit").click(window.exam, answerSubmitted); } } 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(); if (!window.exam.examQuestions[window.exam.currentQuestion].creditRecieved && window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer === window.exam.examQuestions[window.exam.currentQuestion].RightAnswer) { window.exam.answeredRight += 1; window.exam.examQuestions[window.exam.currentQuestion].creditRecieved = true; } if (window.exam.examType === "Tutor") { $(".answerExp").css("height", "auto"); $(".answerExp").css("visibility", "visible"); $(".answerExp").each(function () { if ($(this).attr('id') === window.exam.examQuestions[window.exam.currentQuestion].RightAnswer + "e") { $(this).prepend(" Correct: "); } else { $(this).prepend(" Incorrect: "); } });
}
$("div.answer").unbind('click');
var api = new mw.Api();
api.get({
action : 'answerQuestion',
username : mw.user.getName(),
question : window.exam.examQuestions[window.exam.currentQuestion].PageName,
selected : window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer,
examid : window.exam.examid,
format : 'json'
})
.done(function (data) {
console.log('API result:', data);
});
if (window.exam.examType === "Exam") {
$("#" + window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer).addClass("boxed");
} else if (window.exam.examType === "Tutor") {
$("#examSpace").append("
The correct answer is: " + window.exam.examQuestions[window.exam.currentQuestion].RightAnswer + "
" + window.exam.examQuestions[window.exam.currentQuestion].Explanation + "
");
$("#examSpace").append("Author: " + window.exam.examQuestions[window.exam.currentQuestion].PageAuthor + "
Wiki Page:" + window.exam.examQuestions[window.exam.currentQuestion].PageName + "
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");
$("#" + window.exam.examQuestions[window.exam.currentQuestion].RightAnswer).addClass("redBoxed");
addRatyRating(window.exam);
}
}
function questionNavigation(event) {
if ($(this).attr("id") === "back") {
window.exam.currentQuestion--;
} else if ($(this).attr("id") === "next") {
window.exam.currentQuestion++;
} else if ($(this).attr("class") === "navPaneButton") {
window.exam.currentQuestion = $(this).attr("id");
}
questionDisplay(window.exam);
}
function questionReviewNavigation(event) {
if ($(this).attr("id") === "back") {
window.exam.currentQuestion--;
} else if ($(this).attr("id") === "next") {
window.exam.currentQuestion++;
} else if ($(this).attr("class") === "navPaneButton") {
window.exam.currentQuestion = $(this).attr("id");
}
questionReview(window.exam);
}
function endExam(event) {
if (window.exam.timer) {
$('#timerBox').html("");
$('#timerBox').css("visibility", "hidden");
window.exam.examTimer.stop();
}
$("#examSpace").html("");
var datas;
datas = "";
datas += "
You answered " + window.exam.answeredRight + " out of " + window.exam.examQuestions.length + " correctly.
Your percentage score is: ";
var percent = (window.exam.answeredRight / window.exam.examQuestions.length) * 100;
datas += percent + "%
Click the Navigation Buttons on the left to review the questions you answered.";
var api = new mw.Api();
api.get({ action : 'endExam', id : window.exam.examid, score : percent, format : 'json' }) .done(function (data) { console.log('API result:', data); });
$("#examSpace").append(datas); $(".navPaneButton").unbind('click'); $(".navPaneButton").click(window.exam, questionReviewNavigation); } 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") { 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") { 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) { var tobeParsed = null; var parsed = null; var q = examObj.currentQuestion; switch (examObj.examQuestions[q].lastParsed) { case 0: tobeParsed = examObj.examQuestions[q].Prompt; break; case 1: tobeParsed = "A. " + examObj.examQuestions[q].AnswerA; break; case 2: tobeParsed = "B. " + examObj.examQuestions[q].AnswerB; break; case 3: tobeParsed = "C. " + examObj.examQuestions[q].AnswerC; break; case 4: tobeParsed = "D. " + examObj.examQuestions[q].AnswerD; break; case 5: tobeParsed = "E. " + examObj.examQuestions[q].AnswerE; break; case 6: tobeParsed = examObj.examQuestions[q].Explanation; break; case 7: tobeParsed = examObj.examQuestions[q].AnswerAExp; break; case 8: tobeParsed = examObj.examQuestions[q].AnswerBExp; break; case 9: tobeParsed = examObj.examQuestions[q].AnswerCExp; break; case 10: tobeParsed = examObj.examQuestions[q].AnswerDExp; break; case 11: tobeParsed = examObj.examQuestions[q].AnswerEExp; break; 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['*'];
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) { window.exam.timeAmt = parseInt($(this).attr("id"), 10) * 6000; var temp = window.exam.examtype.replace(/ /g, "_"); var api = new mw.Api(); api.get({ action : 'singlecat', exam : temp, format : 'json', async : false }, { ok : function (data) { window.exam.arrCounts = data; 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) { return swap.split(' ').join('+'); } function trimP(data) { return data.substring(3, data.length - 4).trim(); ; } $(document).ready(ensureLoggedIn); </script>