Widget:CJPSandbox: Difference between revisions

Jump to navigation Jump to search
Christopher Popma (talk | contribs)
Created page with "<includeonly> <script src="http://wikidoc.org/includes/jquery.timer.js"></script> <style type="text/css"> .boxed{ border:2px solid black !important; } .redBoxed{ border:2px so..."
 
Christopher Popma (talk | contribs)
No edit summary
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>
{{#display_map:
<script src="http://wikidoc.org/includes/jquery.timer.js"></script>
<googlemap>
<style type="text/css">
http://www.wikidoc.org/images/e/e9/DirectionsESC2013.kml
.boxed{
</googlemap>
border:2px solid black !important;
}}
}
.redBoxed{
border:2px solid #F00 !important;
}


.unboxed{
border:0px;
}
#go{
width:150px;
height:50px;
background-color:#0f0;
}


.imageDiv{
<includeonly>
margin:5px 5px 5px 5px;
<link type="text/css" rel="stylesheet" href="extensions/Geoxmlv3/gmap.css" />
}
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false<!--{if isset($apikey)}-->&key=<!--{$apikey}--><!--{/if}-->"></script>
 
<script type="text/javascript" src="extensions/Geoxmlv3/geoxmlv3.js"></script>
.WBRButton{
<script type="text/javascript" charset="utf-8">
font-family:Arial;
this.publishdirectory = "extensions/Geoxmlv3/";
float:left;
<!--{if isset($alticon)}-->var alticon = new google.maps.MarkerImage("<!--{$alticon}-->",
background-color:#3366CC;
    new google.maps.Size(32,32), //size
height:40px;
    new google.maps.Point(0,0), //origin
font-weight:bold;
    new google.maps.Point(16,32),//anchor
width:150px;
    new google.maps.Size(32,32) //scaledsize
display: table-cell;
    );<!--{/if}-->
cursor: pointer;
        function sidebarmap_init(){
color:#FFFFFF;
            var latlng = new google.maps.LatLng(0,0);
text-align: center;
            var myOptions = {
vertical-align: middle;
              zoom: 8,
margin-right:10px;
              center: latlng,
}
              mapTypeId: google.maps.MapTypeId.ROADMAP
#globalWrapper{
            };
z-index:-1;
            map = new google.maps.Map(document.getElementById("map_canvas"),
}
                 myOptions);
#navPane{
           
position:relative;
            exml = new GeoXml("exml", map, null, {sidebarid:"sidebar",allfoldersopen:true,sortbyname:true,alwaysinfopop:false,iwwidth:<!--{$infowindowwidth|default:'250'}-->,<!--{if isset($alticon)}-->baseicon:alticon,<!--{/if}--><!--{$otheroption}-->});
float:left;
            exml.urls = [<!--{if is_array($file)}--><!--{foreach from=$file item=i}-->'',<!--{/foreach}--><!--{else}-->'<!--{$file|replace:'http':'extensions/Geoxmlv3/proxy.php?url=http'}-->'<!--{/if}-->];
width:15%;
            exml.parse();
}
#examSpace{
position:relative;
float:right;
width:84%;
}
.navPaneButton{
height:30px;
background-color:#3366CC;
padding-top:5px;
margin-bottom:10px;
color:#FFFFFF;
font-weight:bold;
text-align: center;
}
div.answerNoBorder{
border:5px solid #FFF;
}
div.answerBorder{
border:5px 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,
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'><img src='http://static.wikidoc.org/8/87/Step1.png' /></a>";
stuffs += "<a href='#' class='Curric' id='USMLE Step 2 CK'><img src='http://static.wikidoc.org/0/07/Step2CK.png' /></a>";
stuffs += "<a href='#' class='Curric' id='USMLE Step 3'><img src='http://static.wikidoc.org/0/08/Step3.png' /></a>";
stuffs += "<a href='#' class='Curric' id='Board Review'><img src='http://static.wikidoc.org/7/75/Boardcertification.png' /></a>";
stuffs += "<a href='#' class='Curric' id='MCAT'><img src='http://static.wikidoc.org/4/4b/MCAT.png' /></a><br />";
$("#exam").html(stuffs);
$('.Curric').click(options, chooseQBank);
 
}
function chooseQBank(event) {
event.data.examtype = $(this).attr('id');
var divs = null;
divs = "<center><h1>Build your own exam!</h1></center><div id='Pat' class='noSelect WBRButton stepTwo'><br />USMLE Format</div><div id='Flash' class='noSelect WBRButton stepTwo'><br />Flash Cards</div><br /><br /><br />";
$("#exam").html(divs);
$('.stepTwo').click(event.data, tutorOrExam);
}
function tutorOrExam(event) {
event.data.qbank = $(this).attr('id');
        var buttons = '';
        buttons = "<div id='Tutor' class='noSelect WBRButton ToE'><br />Tutor Mode</div><div id='Exam' class='noSelect WBRButton ToE'><br />Exam Mode</div><br /><br /><br />";
$("#exam").append(buttons);
        $('.ToE').click(event.data, timerToggle);
}
function timerToggle(event) {
        event.data.examType = $(this).attr('id');
var form = null;
form = "<div id='yes' class='noSelect WBRButton stepThree'><br />Enable Timer</div><div id='nop' class='noSelect WBRButton stepThree'><br />Disable Timer</div><br /><br /><br />";
if ($("#exam").find('#yes').length == 0) {
$("#exam").append(form);
}
$('#yes').click(event.data, timerDuration);
$('#nop').click(event.data, selectCats);
}
function timerDuration(event) {
event.data.timer = true;
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 />"
if ($("#exam").find('#1').length == 0) {
$("#exam").append(form);
}
$('.stepFour').click(event.data, selectCats);
}
function selectCats(event) {
var categories = [];
var table = null;
event.data.timeAmt = parseInt($(this).attr("id"), 10) * 6000;
table = "<br /><b>Select All That Apply:</b><br /><br /><br />"; ;
if (event.data.examtype === "MCAT") {
categories['main'] = new Array("Biology", "Cell", "Enzymes", "Microbiology", "Cellular Metabolism", "Reproduction", "Embryology", "Musculoskeletal System", "Digestive System ", "Excretory System", "Respiratory System", "Skin", "Circulatory System", "Immune System", "Homeostasis", "Endocrine System", "Nervous System ", "Genetics", "Evolution", "Organic Chemistry", "Nomenclature", "Bonding/Structure", "Isomers", "Alkanes", "AlkenesAlkynes", "Haloalkanes", "Aromatic Compounds", "Alcohols", "Ethers", "Aldehydes ", "Ketones", "Carboxylic Acid", "Carboxylic Acid Derivatives", "Amines", "Nitrogen Containing Compounds", "Purification", "Spectroscopy", "Separations", "Carbohydrates", "Amino Acids", "Peptides", "Proteins", "Nucleic", "Acids", "Chemistry", "Atomic Structure", "Periodic Table", "Phases", "Gases", "Bonding", "Stoichiometry", "Kinetics", "Thermochemistry", "Phases", "Solutions", "Acids and Bases", "Redox Reactions", "Electrochemistry", "Physics", "Kinematics", "Fluids", "Solids", "Newtonian Mechanics", "Momentum", "Energy", "Thermodynamics", "Electrostatics", "Magnetism", "DC Circuits", "AC Circuits", "Periodic Motion", "Waves", "Sound", "Optics", "Light", "Atomic Phenomena", "Nuclear Phenomena");
for (var i = 0; i < categories['main'].length; i++) {
table += "<td><input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + "</td>";
if ((i + 1) % 4 == 0) {
table += "</tr><tr>";
}
}
} else {
 
if (event.data.examtype === "USMLE Step 1") {
categories['main'] = new Array("Anatomy", "Behavioral Science/Psychiatry", "Biochemistry", "Biostatistics/Epidemiology", "Embryology", "Ethics", "Genetics", "Histology", "Immunology", "Microbiology", "Pathology", "Pathophysiology", "Pharmacology", "Physiology");
categories['sub'] = new Array("Cardiology", "Dermatology", "Endocrine", "Gastrointestinal", "Genitourinary", "Head and Neck", "Hematology", "Musculoskeletal/Rheumatology", "Neurology", "Oncology", "Pulmonology", "Reproductive", "Renal", "Vascular", "General Principles", "Infectious Disease");
} else if (event.data.examtype === "USMLE Step 2 CK") {
categories['main'] = new Array("Internal medicine", "Surgery", "OB/GYN", "Pediatrics", "Psychiatry");
categories['sub'] = new Array("Allergy/Immunology", "Cardiovascular", "Dermatology", "Endocrine", "Gastrointestinal", "Hepatology", "Genitourinary", "Head and Neck", "Hematology", "Infectious Disease", "Musculoskeletal/Rheumatology", "Neurology", "Obstetrics and Gynecology", "Oncology", "Ophthalmology", "Pediatrics", "Poisoning", "Preventive Medicine", "Psychiatry", "Respiratory", "Surgery", "Biostatistics/ Epidemiology", "Ethics", "Electrolytes", "Genetics", "Miscellaneous");
} else if (event.data.examtype === "USMLE Step 3") {
categories['main'] = new Array("Community Medical Health Center", "Primary Care Office", "Inpatient Facilities", "Emergency Room");
categories['sub'] = new Array("Allergy/Immunology", "Cardiovascular", "Dermatology", "Endocrine", "Gastrointestinal", "Hepatology", "Genitourinary", "Head and Neck", "Hematology", "Infectious Disease", "Musculoskeletal/Rheumatology", "Neurology", "Obstetrics and Gynecology", "Oncology", "Ophthalmology", "Pediatrics", "Poisoning", "Preventive Medicine", "Psychiatry", "Respiratory", "Surgery", "Biostatistics/Epidemiology", "Ethics", "Electrolytes", "Genetics", "Miscellaneous");
} else if (event.data.examtype === "Board Review") {
categories['main'] = new Array("Adolescent Medicine", "Advanced Heart Failure and Transplant Cardiology", "Allergy & Immunology", "Cardiovascular Disease", "Clinical Cardiac Electrophysiology", "Critical Care Medicine", "Endocrinology", "Diabetes and Metabolism", "Gastroenterology", "Geriatric Medicine", "Hematology", "Hospice & Palliative Medicine", "Hospital Medicine", "Focused Practice", "Infectious Disease", "Internal Medicine", "Interventional Cardiology", "Medical Oncology", "Nephrology", "Pulmonary Disease", "Rheumatology", "Sleep Medicine", "Sports Medicine", "Transplant Hepatology");
categories['sub'] = new Array("Anesthesiology", "Dermatology", "Emergency Medicine", "Emergency Medicine/Critical Care Medicine", "Family Medicine", "Medical Genetics", "Neurology", "Nuclear Medicine", "Pediatrics", "Physical Medicine & Rehab", "Preventative Medicine", "Psychiatry");
}
table += "<table style='width:100%;'><tr><td style='width:49%;'><b>Main Category</b></td><td style='width:49%;'><b>Sub Category</b></td></tr>";
if (categories['sub'].length >= categories['main'].length) {}
var table = "<br /><br /><b>Select All That Apply:</b><br /><br /><br />";
table += "<table style='width:100%;'><tr><td style='width:49%;'><b>Main Category</b></td><td style='width:49%;'><b>Sub Category</b></td></tr>";
if (categories['sub'].length >= categories['main'].length) {
for (var i = 0; i < categories['sub'].length; i++) {
catQuestionCount(event.data.examtype, "s", categories['sub'][i]);
if (categories['main'][i]) {
catQuestionCount(event.data.examtype, "m", categories['main'][i]);
table += "<tr><td><input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + " ( <span id='" + categories['main'][i] + "'>0 </span> ) </td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( <span id='" + categories['sub'][i] + "'> 0 </span> )</td></tr>";
} else {
table += "<tr><td></td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( <span id='" + categories['sub'][i] + "'> 0 </span> ) </td></tr>";
}
}
} else {
for (var i = 0; i < categories['main'].length; i++) {
if (categories['sub'][i]) {
table += "<tr><td><input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + "</td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + "</td></tr>";
} else {
table += "<tr><td><input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + "</td><td></td></tr>";
}
}
}
table += "</table><div id='SelectAll' class='noSelect WBRButton'>Select All Main Categories</div><div id='UnselectAll' class='noSelect WBRButton'>Select All Sub Categories</div><br /><br /><br />Second: Click the Count Question Button below to calculate number of questions available:<br /><br /><br /><div id='CountQ' class='noSelect WBRButton'>Count Questions</div><br /><br /><br /><br />"
if ($("#exam").find('#SelectAll').length == 0) {
$("#exam").append(table);
}
}
$("#SelectAll").click(function () {
if ($("#SelectAll").html() === "Select All Main Categories") {
$("[name=MainCat]").each(function () {
$(this).attr('checked', true);
$("#SelectAll").html("Clear All Main Categories");
});
} else {
$("[name=MainCat]").each(function () {
$(this).attr('checked', false);
$("#SelectAll").html("Select All Main Categories");
});
}
});
 
$("#UnselectAll").click(function () {
if ($("#UnselectAll").html() === "Select All Sub Categories") {
$("[name=SubCat]").each(function () {
$(this).attr('checked', true);
$("#UnselectAll").html("Clear All Sub Categories");
});
} else {
$("[name=SubCat]").each(function () {
$(this).attr('checked', false);
$("#UnselectAll").html("Select All Sub Categories");
});
}
});
 
$("#CountQ").click(event.data, 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());
});
var obj = completeQuestionCount(event.data.examtype, Main, Sub);
$.each(obj.results, function (index, value) {
event.data.questionListAll.push(value.fulltext);
});
var maxQ;
if (obj.rows == 0) {
alert('Insufficient questions in currently selected categories. Please select more Categories.');
} else if (obj.rows >= 45) {
maxQ = 45;
} else {
maxQ = obj.rows;
}
var output = "<b>Choose the number of questions you would like to answer. The maximum number of questions you can select is <span id='countShow'>" + maxQ + "</span>.</b><br /><br /><br />Number of questions:<input type='text' id='numQues' /><br /><br /><div id='Go' class='noSelect WBRButton'>Click here to begin the exam</div>";
if ($("#exam").find('#numQues').length == 0) {
$("#exam").append(output);
}
$("#Go").click(event.data, 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) {
event.data.numQuestion = $("#numQues").val();
$("#exam").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />");
if (event.data.timer) {
event.data.examTimer = $.timer(function () {
var rem = parseInt($("#timeRem").html());
$('#timerBox').css("visibility", "visible");
$('#timerBox').html(formatTime(rem));
if (rem == 0) {
event.data.examTimer.stop();
$("#content").click(event.data, endExam);
} else {
var temp = rem - 7;
$("#timeRem").html(temp.toString());
if (rem < 0) {
$("#timeRem").html("0");
}
}
}, 70, false);
 
event.data.examTimer.toggle();
}
loadNextQuestion(event.data);
} else {
alert('Invalid entry in number of questions input');
}
}
// Common functions
function pad(number, length) {
var str = '' + number;
while (str.length < length) {
str = '0' + str;
}
return str;
}
function formatTime(time) {
var min = parseInt(time / 6000),
sec = parseInt(time / 100) - (min * 60),
hundredths = pad(time - (sec * 100) - (min * 6000), 2);
return (min > 0 ? pad(min, 2) : "00") + ":" + pad(sec, 2);
}
 
function loadNextQuestion(event) {
var rand = null;
rand = Math.floor(Math.random() * event.questionListAll.length);
var name = null;
name = event.questionListAll[rand];
event.questionListAll.splice(rand, 1);
var qs = "[[" + name + "]]|?PageAuthor|?Prompt|?RightAnswer|?AnswerA|?AnswerB|?AnswerC|?AnswerD|?AnswerE|?Explanation|?AnswerAExp|?AnswerBExp|?AnswerCExp|?AnswerDExp|?AnswerEExp";
var api = new mw.Api(event);
api.get({
action : 'ask',
query : qs,
async : false,
format : 'json'
}, {
ok : function (res) {
$.each(res.query.results, function (index, value) {
var temp = value.printouts;
var obj = new Object();
obj.PageName = value.fulltext;
obj.PageAuthor = temp.PageAuthor[0];
obj.RightAnswer = temp.RightAnswer[0];
obj.Prompt = temp.Prompt[0];
obj.AnswerA = temp.AnswerA[0];
obj.AnswerB = temp.AnswerB[0];
obj.AnswerC = temp.AnswerC[0];
obj.AnswerD = temp.AnswerD[0];
obj.AnswerE = temp.AnswerE[0];
obj.Explanation = temp.Explanation[0];
obj.AnswerAExp = temp.AnswerAExp[0];
obj.AnswerBExp = temp.AnswerBExp[0];
obj.AnswerCExp = temp.AnswerCExp[0];
obj.AnswerDExp = temp.AnswerDExp[0];
obj.AnswerEExp = temp.AnswerEExp[0];
obj.isParsed = 0;
obj.lastParsed = 0;
                                obj.creditReceived = 0;
                                obj.selectedAnswer = 'F';
event.examQuestions[event.examQuestions.length] = obj;
if (event.examQuestions.length < event.numQuestion) {
loadNextQuestion(event);
} else {
addToNavBar(event);
}
});
}
});
}
function addToNavBar(exam) {
$("#exam").html("<div id='navPane'></div><div id='examSpace'></div><span id='timeRem' style='height: 0px; visibility: hidden'>" + exam.timeAmt.toString() + "</span>");
if (exam.timer) {
$("#bodyContent").append("<div style='position:absolute; z-index:1000; width:300px; height:50px; top:0px; right:0px; border: 1px solid #000; background-color:#EEE; float:right; visibility:hidden;' id='timerBox'>Testing.</div>");
$("#timerBox").click(function () {
exam.examTimer.toggle();
});
}
$.each(exam.examQuestions, function (index, value) {
$("#navPane").append("<div id='" + index + "' class='navPaneButton'>" + value.PageName + " : " + (index - -1) + "</div>");
});
$("#" + exam.currentQuestion).addClass("boxed");
$(".navPaneButton").click(exam, questionNavigation);
questionDisplay(exam);
}
 
function questionDisplay(exam) {
var obj = new Object();
obj = exam.examQuestions[exam.currentQuestion];
if (obj.isParsed === 0) {
$("#examSpace").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />");
parseQuestions(exam);
} else {
var htmlStuff = "<b>Author:</b> " + obj.PageAuthor + "<br /><br /><b>Question " + (exam.currentQuestion - -1) + " / " + (exam.examQuestions.length) + "</b><br /><br />" + obj.Prompt + "<br />";
if (obj.AnswerA && obj.AnswerA.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='A'>  " + obj.AnswerA + "</div>";
}
if (obj.AnswerAExp && obj.AnswerAExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Ae'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerAExp + "</i></div>";
}
if (obj.AnswerB && obj.AnswerB.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='B'> " + obj.AnswerB + "</div>";
}
if (obj.AnswerBExp && obj.AnswerBExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Be'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerBExp + "</i></div>";
}
if (obj.AnswerC && obj.AnswerC.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='C'> " + obj.AnswerC + "</div>";
}
if (obj.AnswerCExp && obj.AnswerCExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Ce'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerCExp + "</i></div>";
}
if (obj.AnswerD && obj.AnswerD.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='D'> " + obj.AnswerD + "</div>";
}
if (obj.AnswerDExp && obj.AnswerDExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='De'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerDExp + "</i></div>";
}
if (obj.AnswerEExp && obj.AnswerE.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='E'> " + obj.AnswerE + "</div>";
}
if (obj.AnswerEExp && obj.AnswerEExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Ee'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerEExp + "</i></div>";
}
$("#examSpace").html(htmlStuff);
                if(exam.examQuestions[exam.currentQuestion].selectedAnswer !== 'F'){
                $("#"+exam.examQuestions[exam.currentQuestion].selectedAnswer).addClass("boxed");
                }
                $("div.answer").mouseover(function () {
$(this).css({
'border' : '5px solid #000'
})
}).mouseout(function () {
$(this).css({
'border' : '5px solid #FFF'
})
});
$("div.answer").click(exam, answerClicked);
}
}
 
function questionReview(exam) {
var obj = new Object();
obj = exam.examQuestions[exam.currentQuestion];
if (obj.isParsed === 0) {
$("#examSpace").html("<img src='http://static.wikidoc.org/5/51/Index.gif' />");
parseQuestions(exam);
} else {
var htmlStuff = "<b>Author:</b> " + obj.PageAuthor + "<br /><br /><b>Question " + (exam.currentQuestion - -1) + " / " + (exam.examQuestions.length) + "</b><br /><br />" + obj.Prompt + "<br />";
if (obj.AnswerA && obj.AnswerA.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='A'>  " + obj.AnswerA + "</div>";
}
if (obj.AnswerAExp && obj.AnswerAExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Ae'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerAExp + "</i></div>";
}
if (obj.AnswerB && obj.AnswerB.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='B'> " + obj.AnswerB + "</div>";
}
if (obj.AnswerBExp && obj.AnswerBExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Be'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerBExp + "</i></div>";
}
if (obj.AnswerC && obj.AnswerC.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='C'> " + obj.AnswerC + "</div>";
}
if (obj.AnswerCExp && obj.AnswerCExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Ce'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerCExp + "</i></div>";
}
if (obj.AnswerD && obj.AnswerD.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='D'> " + obj.AnswerD + "</div>";
}
if (obj.AnswerDExp && obj.AnswerDExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='De'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerDExp + "</i></div>";
}
if (obj.AnswerEExp && obj.AnswerE.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='E'> " + obj.AnswerE + "</div>";
}
if (obj.AnswerEExp && obj.AnswerEExp.length > 0 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Ee'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerEExp + "</i></div>";
}
$("#examSpace").html(htmlStuff);
                if(exam.examQuestions[exam.currentQuestion].selectedAnswer && exam.examQuestions[exam.currentQuestion].RightAnswer == exam.examQuestions[exam.currentQuestion].selectedAnswer){
                $("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).addClass("boxed");
                } else {
             
 
                $("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).addClass("redBoxed");
                $("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).removeClass("answerNoBorder");
                $("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).addClass("boxed");
                $("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).removeClass("answerNoBorder");
                }
$("#examSpace").append("<br /><br />The correct answer is: " + exam.examQuestions[exam.currentQuestion].RightAnswer + "<br /><br /><i>" + exam.examQuestions[exam.currentQuestion].Explanation + "</i><br />");
if (exam.currentQuestion > 0) {
$("#examSpace").append("<div id='back' class='noSelect WBRButton'><br />Back</div>");
$("#back").click(exam, questionReviewNavigation);
}
if (exam.currentQuestion < exam.examQuestions.length - 1) {
$("#examSpace").append("<div id='next' class='noSelect WBRButton'><br />Next</div>");
$("#next").click(exam, questionReviewNavigation);
}
$("#examSpace").append("<div id='finish' class='noSelect WBRButton'><br />Finish</div>");
$("#finish").click(function () {
window.location.replace("http://wikidoc.org/index.php?title=Special:UserLogin&returnto=User%3AMatt+Pijoan");
});
}
}
 
function answerClicked(event) {
        $(".answer").removeClass("boxed");
event.data.examQuestions[event.data.currentQuestion].selectedAnswer = $(this).attr("id");
if (event.data.examQuestions[event.data.currentQuestion].creditRecieved === false && event.data.examQuestions[event.data.currentQuestion].selectedAnswer === event.data.examQuestions[event.data.currentQuestion].RightAnswer) {
event.data.answeredRight += 1;
                event.data.examQuestions[event.data.currentQuestion].creditRecieved = true;
}
if (event.data.examType === "Tutor") {
$(".answerExp").css("height", "auto");
$(".answerExp").css("visibility", "visible");
}
$("div.answer").unbind('click');
if (event.data.examType === "Exam") {
$("#" + event.data.examQuestions[event.data.currentQuestion].selectedAnswer).addClass("boxed");
        } else if (event.data.examType === "Tutor") {
$("#examSpace").append("<br /><br />The correct answer is: " + event.data.examQuestions[event.data.currentQuestion].RightAnswer + "<br /><br /><i>" + event.data.examQuestions[event.data.currentQuestion].Explanation + "</i><br />");
                $("#" + event.data.examQuestions[event.data.currentQuestion].selectedAnswer).addClass("boxed");
                $("#" + event.data.examQuestions[event.data.currentQuestion].RightAnswer).addClass("redBoxed");
}
if (event.data.currentQuestion > 0) {
$("#examSpace").append("<div id='back' class='noSelect WBRButton'><br />Back</div>");
$("#back").click(event.data, questionNavigation);
}
if (event.data.currentQuestion < event.data.examQuestions.length - 1) {
$("#examSpace").append("<div id='next' class='noSelect WBRButton'><br />Next</div>");
$("#next").click(event.data, questionNavigation);
}
if (event.data.currentQuestion == (event.data.examQuestions.length - 1)) {
$("#examSpace").append("<div id='finish' class='noSelect WBRButton'><br />Finish</div>");
$("#finish").click(event.data, endExam);
}
 
}
 
 
 
function questionNavigation(event) {
$("#" + event.data.currentQuestion).removeClass("boxed");
if ($(this).attr("id") === "back") {
event.data.currentQuestion--;
} else if ($(this).attr("id") === "next") {
event.data.currentQuestion++;
} else if ($(this).attr("class") === "navPaneButton") {
event.data.currentQuestion = $(this).attr("id");
}
$("#" + event.data.currentQuestion).addClass("boxed");
questionDisplay(event.data);
}
function questionReviewNavigation(event) {
$("#" + event.data.currentQuestion).removeClass("boxed");
if ($(this).attr("id") === "back") {
event.data.currentQuestion--;
} else if ($(this).attr("id") === "next") {
event.data.currentQuestion++;
} else if ($(this).attr("class") === "navPaneButton") {
event.data.currentQuestion = $(this).attr("id");
}
$("#" + event.data.currentQuestion).addClass("boxed");
questionReview(event.data);
}
function endExam(event) {
        if(event.data.timer){
        $('#timerBox').html("");
        $('#timerBox').css("visibility","hidden");
        event.data.examTimer.stop();
         }
         }
$("#examSpace").html("");
var datas;
datas = "You answered " + event.data.answeredRight + " out of " + event.data.examQuestions.length + " correctly.<br /> Your percentage score is: ";
var percent = (event.data.answeredRight / event.data.numQuestion) * 100;
datas += percent + "%<br /><br />Click the Navigation Buttons on the left to review the questions you answered.";
$("#examSpace").append(datas);
        $(".navPaneButton").unbind('click');
        $(".navPaneButton").click(event.data, questionReviewNavigation);
}
function parseQuestions(examObj) {
var tobeParsed = null;
var parsed = null;
var q = examObj.currentQuestion;
switch (examObj.examQuestions[q].lastParsed) {
case 0:
tobeParsed = examObj.examQuestions[q].Prompt;
break;
case 1:
tobeParsed = "A. " + examObj.examQuestions[q].AnswerA;
break;
case 2:
tobeParsed = "B. " + examObj.examQuestions[q].AnswerB;
break;
case 3:
tobeParsed = "C. " + examObj.examQuestions[q].AnswerC;
break;
case 4:
tobeParsed = "D. " + examObj.examQuestions[q].AnswerD;
break;
case 5:
tobeParsed = "E. " + examObj.examQuestions[q].AnswerE;
break;
case 6:
tobeParsed = examObj.examQuestions[q].Explanation;
break;
case 7:
tobeParsed = examObj.examQuestions[q].AnswerAExp;
break;
case 8:
tobeParsed = examObj.examQuestions[q].AnswerBExp;
break;
case 9:
tobeParsed = examObj.examQuestions[q].AnswerCExp;
break;
case 10:
tobeParsed = examObj.examQuestions[q].AnswerDExp;
break;
case 11:
tobeParsed = examObj.examQuestions[q].AnswerEExp;
break;
}
if (tobeParsed && tobeParsed.length > 0) {
var api = new mw.Api();
api.get({
action : 'parse',
text : tobeParsed,
disablepp : 'disablepp',
format : 'json'
}, {
ok :
function (html) {
parsed = html.parse.text['*'];
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;
}
if (examObj.examQuestions[q].lastParsed < 12) {
examObj.examQuestions[q].lastParsed += 1;
parseQuestions(examObj);
} else {
examObj.examQuestions[q].isParsed = 1;
questionDisplay(examObj);
}
}
});
} else {
if (examObj.examQuestions[q].lastParsed < 12) {
examObj.examQuestions[q].lastParsed += 1;
parseQuestions(examObj);
} else {
examObj.examQuestions[q].isParsed = 1;
questionDisplay(examObj);
}
}
}
function catQuestionCount(exam, type, cat) {
var queryString = "[[ExamType::" + exam + "]] ";
if (type === "m") {
queryString += "[[MainCategory::" + cat + "]]";
} else {
queryString += "[[SubCategory::" + cat + "]]";
}
var api = new mw.Api();
api.get({
action : 'ask',
query : queryString,
format : 'json'
}, {
ok : function (data) {
$.each(data.query.results, function (index, value) {
var count = parseInt(document.getElementById(cat).innerHTML);
count = count + 1;
document.getElementById(cat).innerHTML = count.toString();
});
}
});
}


function completeQuestionCount(exam, main, sub) {
window.onload = sidebarmap_init;
var queryString = "http://www.wikidoc.org/index.php?title=Special:Ask&q=[[ExamType::" + urlSwapSpace(exam) + "]][[MainCategory::";
for (var j = 0; j < main.length; j++) {
queryString += urlSwapSpace(main[j]);
if (j != main.length - 1) {
queryString += "||";
}
}
queryString += "]][[SubCategory::";
for (var i = 0; i < sub.length; i++) {
queryString += urlSwapSpace(sub[i]);
if (i != sub.length - 1) {
queryString += "||";
}
}
queryString += "]]&eq=yes&p[format]=json";
var obj;
$.ajax({
url : queryString,
async : false
}).done(function (data) {
obj = jQuery.parseJSON(data);
});
return obj;
}
function urlSwapSpace(swap) {
return swap.split(' ').join('+');
}
$(document).ready(ensureLoggedIn);
</script>
</script>
<div id="exam">pewp</div>
<!--{if $defaultmap == true}--><div id="map-container">
            <div id="sidebar" style="overflow-y:auto;height:500px;width:<!--{$sidebarwidth|default:'300px'}-->;float:<!--{$sidebarfloat|default:'left'}-->;"></div>
            <div id="map_canvas" style="width:<!--{$mapwidth|default:'700px'}-->;height:500px"></div>
</div><!--{/if}-->
</includeonly>
</includeonly>

Latest revision as of 12:23, 9 September 2013

{{#display_map: <googlemap> http://www.wikidoc.org/images/e/e9/DirectionsESC2013.kml </googlemap> }}