Widget:WJG Sandbox: Difference between revisions

Jump to navigation Jump to search
(Created page with "<includeonly> <script src="http://wikidoc.org/includes/jquery.timer.js"></script> <script type="text/javascript" src="http://wikidoc.org/includes/raty/lib/jquery.raty.js"></sc...")
 
No edit summary
Line 1: Line 1:
<includeonly>
<includeonly>
<script src="http://wikidoc.org/includes/jquery.timer.js"></script>
<script src="http://wikidoc.org/includes/jquery.timer.js"></script>
<script type="text/javascript" src="http://wikidoc.org/includes/raty/lib/jquery.raty.js"></script>
<script type="text/javascript" src="http://wikidoc.org/includes/raty/jquery.raty.js"></script>
<style type="text/css">
<style type="text/css">
.boxed{
.boxed{
Line 43: Line 43:
position:relative;  
position:relative;  
float:left;
float:left;
width:15%;
width:5%;
}
}
#examSpace{
#examSpace{
position:relative;
position:relative;
float:right;
float:right;
width:84%;
width:94%;
}
#navBar{
position:relative;
float:right;
width:94%;
}
}
.navPaneButton{
.navPaneButton{
Line 54: Line 59:
background-color:#3366CC;
background-color:#3366CC;
padding-top:5px;
padding-top:5px;
margin-bottom:10px;
color:#FFFFFF;
color:#FFFFFF;
font-weight:bold;
font-weight:bold;
Line 75: Line 79:
</style>
</style>
<script type="text/javascript">
<script type="text/javascript">
function ensureLoggedIn(){
function ensureLoggedIn() {
mw.loader.load('mediaWiki.user');
mw.loader.load('mediaWiki.user');
if ($.isEmptyObject(wgUserName)) {
if ($.isEmptyObject(wgUserName)) {
alert("Please Log In To Continue.");
alert("Please Log In To Continue.");
window.location.replace("http://wikidoc.org/index.php?title=Special:UserLogin&returnto=User%3AMatt+Pijoan");
window.location.replace("http://wikidoc.org/index.php?title=Special:UserLogin&returnto=User%3AMatt+Pijoan");
} else {
} else {
curriculumType();
curriculumType();
}
}
}
}
function curriculumType() {
function curriculumType() {
Line 89: Line 93:
timer : null,
timer : null,
qbank : null,
qbank : null,
                searchMethod : null,
searchMethod : null,
timer : null,
timer : null,
                examType : '',
examType : '',
timeAmt : 0,
timeAmt : 0,
questionListAll : new Array(),
questionListAll : new Array(),
Line 116: Line 120:
selectedAnswer : 'F',
selectedAnswer : 'F',
lastParsed : 0,
lastParsed : 0,
                        creditReceived : false
creditReceived : false
}
}
}
}
Line 136: Line 140:
}
}
function tutorOrExam(event) {
function tutorOrExam(event) {
event.data.qbank = $(this).attr('id');
event.data.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(event.data, categoryOrKeyword);
$('.ToE').click(event.data, categoryOrKeyword);
}
}
function categoryOrKeyword(event) {
function categoryOrKeyword(event) {
event.data.examType = $(this).attr('id');
event.data.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(event.data, timerToggle);
$('.CoK').click(event.data, timerToggle);
}
}
function timerToggle(event) {
function timerToggle(event) {
        event.data.searchMethod = $(this).attr('id');
event.data.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 157: Line 162:
}
}
$('#yes').click(event.data, timerDuration);
$('#yes').click(event.data, timerDuration);
 
                        if(event.data.searchMethod === "Category"){
if (event.data.searchMethod === "Category") {
$('#nop').click(event.data, selectCats);
$('#nop').click(event.data, countCats);
                        } else {
} else {
                        $('#nop').click(event.data, Keywords);
$('#nop').click(event.data, Keywords);
                        }
}
}
}
function timerDuration(event) {
function timerDuration(event) {
event.data.timer = true;
event.data.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 />"
if ($("#exam").find('#1').length == 0) {
if ($("#exam").find('#1').length == 0) {
$("#exam").append(form);
$("#exam").append(form);
}
}
                        if(event.data.searchMethod === "Category"){
if (event.data.searchMethod === "Category") {
$('.stepFour').click(event.data, selectCats);
$('.stepFour').click(event.data, countCats);
                        } else {
} else {
                        $('.stepFour').click(event.data, Keywords);
$('.stepFour').click(event.data, Keywords);
                        }
}
}
}
function Keywords(event) {
function Keywords(event) {
        var stuffs ="To search via keywords, place individual terms within the text boxes.<br />Boxes on different lines will use the 'OR' operator, while boxes on the same line will use the 'AND' Operator.<br />Click SHOW to count the number of questions returned.<div id='formSpace'></div><div class='WBRButton' id='orOp'><br />OR</div><div class='WBRButton' id='andOp'><br />AND</div><div class='WBRButton' id='showQueries'><br />SHOW</div><br /><br /><br />";
var stuffs = "<div id='formSpace'></div><div class='WBRButton' id='orOp'><br />OR</div><div class='WBRButton' id='andOp'><br />AND</div><div class='WBRButton' id='showQueries'><br />SHOW</div><br /><br /><br />";
        $("#exam").append(stuffs);
$("#exam").append(stuffs);
var orBox = "<div class='query'> <input type='text' class='queryString' /> </div><br />";
var orBox = "<div class='query'> <input type='text' class='queryString' /> </div><br />";
var andBox = " <input type='text' class='queryString' /> ";
var andBox = " <input type='text' class='queryString' /> ";
Line 223: Line 227:
$("#showQueries").click(event.data, showQueries);
$("#showQueries").click(event.data, showQueries);
function showQueries(event) {
function showQueries(event) {
                $("#removeNum").remove();
$("#removeNum").remove();
                event.data.queries = [];
event.data.queries = [];
                event.data.questionListAll = [];
event.data.questionListAll = [];
                event.data.keyword = {};
event.data.keyword = {};
                event.data.keyword.iterator = 0;
event.data.keyword.iterator = 0;
$.each($(".query"),function (index, value) {
$.each($(".query"), function (index, value) {
                                event.data.queries[index] = "[[ExamType::" + event.data.examtype + "]]";
event.data.queries[index] = "[[ExamType::" + event.data.examtype + "]]";
$.each($(this).children(), function(ind, val){
$.each($(this).children(), function (ind, val) {
                                    event.data.queries[index] += "[[WBRKeyword::" + $(this).val() + "]]";
event.data.queries[index] += "[[WBRKeyword::" + $(this).val() + "]]";
                                });
});
});
                                runQueries(event.data);
});
runQueries(event.data);
}
}
function runQueries(obj) {
function runQueries(obj) {
var api = new mw.Api();
var api = new mw.Api();
api.get({
api.get({
Line 244: Line 248:
})
})
.always(function (data) {
.always(function (data) {
        $.each(data.query.results, function(index, value){
$.each(data.query.results, function (index, value) {
              obj.questionListAll.push(value.fulltext);
obj.questionListAll.push(value.fulltext);
        });
});
if ((obj.keyword.iterator+1) < obj.queries.length) {
if ((obj.keyword.iterator + 1) < obj.queries.length) {
        obj.keyword.iterator++;
obj.keyword.iterator++;
        runQueries(obj);      
runQueries(obj);
} else {
} else {
        removeDuplicates(obj);
removeDuplicates(obj);
        }
}
});
});
}
}
function removeDuplicates(obj){
function removeDuplicates(obj) {
        for(var i=0;i<obj.questionListAll.length;i++){
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'>" + event.data.maxQ + "</span>.</b><br /><br /><br />Number of questions:<input type='text' id='numQues' /><br /><br /><div id='Go' class='noSelect WBRButton'>Click here to begin the exam</div></div>";
              $.each(obj.questionListAll, function(index, value){
                  if(obj.questionListAll[i] === value && i != index){
                    obj.questionListAll.splice(index, 1);
                    return false;
                  }
              });
        }
        var maxQ;
        if(obj.questionListAll.length >= 45){
        maxQ = 45;
        } else {
        maxQ = obj.questionListAll.length;
        }
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'>" + 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);
} else {
} else {
 
alert('Please ensure you have valid keywords entered');
}


alert('Please ensure you have valid keywords entered');
$("#Go").click(obj, TNG);
}
}
           
$("#Go").click(obj, TNG);
}
}
}
function TNG(event){
function TNG(event) {
event.data.numQuestion = $("#numQues").val();
event.data.numQuestion = $("#numQues").val();
        loadNextQuestion(event.data);
loadNextQuestion(event.data);
}
}
function selectCats(event) {
function selectCats(exam) {
var categories = [];
var categories = [];
var table = null;
var table = null;
event.data.timeAmt = parseInt($(this).attr("id"), 10) * 6000;
table = "<br /><b>Select All That Apply:</b><br /><br /><br />"; ;
table = "<br /><b>Select All That Apply:</b><br /><br /><br />"; ;
if (event.data.examtype === "MCAT") {
if (exam.examtype === "MCAT") {
categories['main'] = new Array("Biology", "Cell", "Enzymes", "Microbiology", "Cellular Metabolism", "Reproduction", "Embryology", "Musculoskeletal System", "Digestive System ", "Excretory System", "Respiratory System", "Skin", "Circulatory System", "Immune System", "Homeostasis", "Endocrine System", "Nervous System ", "Genetics", "Evolution", "Organic Chemistry", "Nomenclature", "Bonding/Structure", "Isomers", "Alkanes", "AlkenesAlkynes", "Haloalkanes", "Aromatic Compounds", "Alcohols", "Ethers", "Aldehydes ", "Ketones", "Carboxylic Acid", "Carboxylic Acid Derivatives", "Amines", "Nitrogen Containing Compounds", "Purification", "Spectroscopy", "Separations", "Carbohydrates", "Amino Acids", "Peptides", "Proteins", "Nucleic", "Acids", "Chemistry", "Atomic Structure", "Periodic Table", "Phases", "Gases", "Bonding", "Stoichiometry", "Kinetics", "Thermochemistry", "Phases", "Solutions", "Acids and Bases", "Redox Reactions", "Electrochemistry", "Physics", "Kinematics", "Fluids", "Solids", "Newtonian Mechanics", "Momentum", "Energy", "Thermodynamics", "Electrostatics", "Magnetism", "DC Circuits", "AC Circuits", "Periodic Motion", "Waves", "Sound", "Optics", "Light", "Atomic Phenomena", "Nuclear Phenomena");
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 300: Line 289:
} else {
} else {


if (event.data.examtype === "USMLE Step 1") {
if (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 (event.data.examtype === "USMLE Step 2 CK") {
} else if (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 (event.data.examtype === "USMLE Step 3") {
} else if (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 (event.data.examtype === "Board Review") {
} else if (exam.examtype === "Board Review") {
categories['main'] = new Array("Adolescent Medicine", "Advanced Heart Failure and Transplant Cardiology", "Allergy & Immunology", "Cardiovascular Disease", "Clinical Cardiac Electrophysiology", "Critical Care Medicine", "Endocrinology", "Diabetes and Metabolism", "Gastroenterology", "Geriatric Medicine", "Hematology", "Hospice & Palliative Medicine", "Hospital Medicine", "Focused Practice", "Infectious Disease", "Internal Medicine", "Interventional Cardiology", "Medical Oncology", "Nephrology", "Pulmonary Disease", "Rheumatology", "Sleep Medicine", "Sports Medicine", "Transplant Hepatology");
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 318: Line 307:
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>";
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) {
if (categories['sub'].length >= categories['main'].length) {
for (var i = 0; i < categories['sub'].length; i++) {
for (var i = 0; i < categories['sub'].length; i++) {
catQuestionCount(event.data.examtype, "s", categories['sub'][i]);
if (categories['main'][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] + " ( " + exam.arrCounts['category']['main'][categories['main'][i]] + " ) </td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( " + exam.arrCounts['category']['sub'][categories['sub'][i]] + " )</td></tr>";
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 {
} 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>";
table += "<tr><td></td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + " ( " + exam.arrCounts['category']['sub'][categories['sub'][i]] + " ) </td></tr>";
}
}
}
}
Line 369: Line 357:
});
});


$("#CountQ").click(event.data, selectExamLength);
$("#CountQ").click(exam, selectExamLength);
}
}
function selectExamLength(event) {
function selectExamLength(event) {
var Main = new Array();
var Main = new Array();
Line 384: Line 371:
Sub.push($(this).val());
Sub.push($(this).val());
});
});
var obj = completeQuestionCount(event.data.examtype, Main, Sub);
event.data.mainCat = Main;
$.each(obj.results, function (index, value) {
event.data.subCat = Sub;
event.data.questionListAll.push(value.fulltext);
var api = new mw.Api(event, Main, Sub);
api.get({
action : 'catcount',
main : JSON.stringify(Main),
sub : JSON.stringify(Sub),
exam : event.data.examtype,
format : 'json'
}, {
ok : function (res) {
event.data.maxQ = res.Count;
var output = "<b>Choose the number of questions you would like to answer. The maximum number of questions you can select is <span id='countShow'>" + event.data.maxQ + "</span>.</b><br /><br /><br />Number of questions:<input type='text' id='numQues' /><br /><br /><div id='Go' class='noSelect WBRButton'>Click here to begin the exam</div>";
if ($("#exam").find('#numQues').length == 0) {
$("#exam").append(output);
 
}
$("#Go").click(event.data, inputValidation);
}
});
});
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 {
} else {
alert('Please ensure you have both a main and a sub category selected');
alert('Please ensure you have both a main and a sub category selected');
}}
}
}
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) {
Line 446: Line 437:
return (min > 0 ? pad(min, 2) : "00") + ":" + pad(sec, 2);
return (min > 0 ? pad(min, 2) : "00") + ":" + pad(sec, 2);
}
}
function loadNextQuestion(event) {
function loadNextQuestion(event) {
        console.log(event.questionListAll);
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);
var api = new mw.Api(event);
api.get({
api.get({
action : 'ask',
action : 'load',
query : qs,
main : JSON.stringify(event.mainCat),
async : false,
sub : JSON.stringify(event.subCat),
exam : event.examtype,
num : event.numQuestion,
format : 'json'
format : 'json'
}, {
}, {
ok : function (res) {
ok : function (res) {
$.each(res.query.results, function (index, value) {
var i = 0;
var temp = value.printouts;
event.currentQuestion = 0;
var obj = new Object();
$.each(res.questions.list, function (key, element) {
obj.PageName = value.fulltext;
element.PageName = key;
obj.PageAuthor = temp.PageAuthor[0];
event.examQuestions[i] = element;
obj.RightAnswer = temp.RightAnswer[0];
i++;
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);
}
});
});
addToNavBar(event);
}
}
});
});
}
}
function addToNavBar(exam) {
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>");
$("#exam").html("<div id='navBar'><div id='back' class='noSelect WBRButton'><br />Back</div><div id='next' class='noSelect WBRButton'><br />Next</div><div id='finish' class='noSelect WBRButton'><br />Finish</div></div><div id='navPane'></div><div id='examSpace'></div><span id='timeRem' style='height: 0px; visibility: hidden'>" + exam.timeAmt.toString() + "</span>");
$("#back").click(exam, questionNavigation);
$("#next").click(exam, questionNavigation);
$("#finish").click(exam, endExam);
if (exam.timer) {
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>");
Line 504: Line 471:
}
}
$.each(exam.examQuestions, function (index, value) {
$.each(exam.examQuestions, function (index, value) {
$("#navPane").append("<div id='" + index + "' class='navPaneButton'>" + value.PageName + " : " + (index - -1) + "</div>");
$("#navPane").append("<div id='" + index + "' class='navPaneButton'> " + (index - -1) + "</div>");
});
});
$("#" + exam.currentQuestion).addClass("boxed");
$("#" + exam.currentQuestion).addClass("boxed");
$(".navPaneButton:odd").css("background-color", "#3338CC");
$(".navPaneButton").click(exam, questionNavigation);
$(".navPaneButton").click(exam, questionNavigation);
questionDisplay(exam);
questionDisplay(exam);
}
}
function questionDisplay(exam) {
function questionDisplay(exam) {
var obj = new Object();
var obj = new Object();
Line 520: Line 487:
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 " + (exam.currentQuestion - -1) + " / " + (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'> " + 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 && exam.examType === "Tutor") {
Line 526: Line 493:
}
}
if (obj.AnswerB && obj.AnswerB.length > 0) {
if (obj.AnswerB && obj.AnswerB.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='B'> " + 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 && exam.examType === "Tutor") {
Line 532: Line 499:
}
}
if (obj.AnswerC && obj.AnswerC.length > 0) {
if (obj.AnswerC && obj.AnswerC.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='C'> " + 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 && exam.examType === "Tutor") {
Line 538: Line 505:
}
}
if (obj.AnswerD && obj.AnswerD.length > 0) {
if (obj.AnswerD && obj.AnswerD.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='D'> " + 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 && exam.examType === "Tutor") {
Line 544: Line 511:
}
}
if (obj.AnswerEExp && obj.AnswerE.length > 0) {
if (obj.AnswerEExp && obj.AnswerE.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='E'> " + 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 && exam.examType === "Tutor") {
Line 550: Line 517:
}
}
$("#examSpace").html(htmlStuff);
$("#examSpace").html(htmlStuff);
                if(exam.examQuestions[exam.currentQuestion].selectedAnswer !== 'F'){
if (exam.examQuestions[exam.currentQuestion].selectedAnswer !== 'F') {
                $("#"+exam.examQuestions[exam.currentQuestion].selectedAnswer).addClass("boxed");
$("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).addClass("boxed");
                }
}
                $("div.answer").mouseover(function () {
$("div.answer").mouseover(function () {
$(this).css({
$(this).css({
'border' : '5px solid #000'
'border' : '5px solid #000'
Line 566: Line 533:
}
}


function trimP(data) {
return data.substring(3, data.length - 4).trim(); ;
}
function questionReview(exam) {
function questionReview(exam) {
var obj = new Object();
var obj = new Object();
Line 573: Line 543:
parseQuestions(exam);
parseQuestions(exam);
} 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 " + (exam.currentQuestion - -1) + " / " + (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'>  " + obj.AnswerA + "</div>";
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 && exam.examType === "Tutor") {
Line 583: Line 553:
}
}
if (obj.AnswerB && obj.AnswerB.length > 0) {
if (obj.AnswerB && obj.AnswerB.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='B'> " + obj.AnswerB + "</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 && exam.examType === "Tutor") {
htmlStuff += "<div class='answerExp explanationHide' id='Be'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerBExp + "</i></div>";
htmlStuff += "<div class='answerExp explanationHide' id='Be'><i>&nbsp;&nbsp;&nbsp;&nbsp;" + obj.AnswerBExp + "</div></i>";
}
}
if (obj.AnswerC && obj.AnswerC.length > 0) {
if (obj.AnswerC && obj.AnswerC.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='C'> " + obj.AnswerC + "</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 && exam.examType === "Tutor") {
Line 595: Line 565:
}
}
if (obj.AnswerD && obj.AnswerD.length > 0) {
if (obj.AnswerD && obj.AnswerD.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='D'> " + obj.AnswerD + "</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 && exam.examType === "Tutor") {
Line 601: Line 571:
}
}
if (obj.AnswerEExp && obj.AnswerE.length > 0) {
if (obj.AnswerEExp && obj.AnswerE.length > 0) {
htmlStuff += "<div class='answer answerNoBorder' id='E'> " + obj.AnswerE + "</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 && exam.examType === "Tutor") {
Line 607: Line 577:
}
}
$("#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 (exam.examQuestions[exam.currentQuestion].selectedAnswer && exam.examQuestions[exam.currentQuestion].RightAnswer == exam.examQuestions[exam.currentQuestion].selectedAnswer) {
                $("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).addClass("boxed");
$("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).addClass("boxed");
                } else {
} else {
             


                $("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).addClass("redBoxed");
$("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).addClass("redBoxed");
                $("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).removeClass("answerNoBorder");
$("#" + exam.examQuestions[exam.currentQuestion].RightAnswer).removeClass("answerNoBorder");
                $("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).addClass("boxed");
$("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).addClass("boxed");
                $("#" + exam.examQuestions[exam.currentQuestion].selectedAnswer).removeClass("answerNoBorder");
$("#" + 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 />");
$("#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 addRatyRating(exam) {
var ratyLayers = "<center>Rate this question!</center><br /><span style='position:relative; float:left;'>Difficulty: <div id='star1'></div></span><span style='position:relative; float:left;left:33%;'>High Yield: <div id='star2'></div></span><span style='position:relative; float:left;left:66%'>Quality: <div id='star3'></div></span><br /><br /><br />"
$("#examSpace").prepend(ratyLayers);
$("#star1").raty({
path : 'http://www.wikidoc.org/includes/raty/img/',
click : function (score, event) {
submitRating("difficulty", score, "Buh")
},
score : function (event) {
getRating("difficulty", exam.examQuestions[exam.currentQuestion].PageName);
},
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
});
$("#star2").raty({
path : 'http://www.wikidoc.org/includes/raty/img/',
click : function (score, event) {
submitRating("yield", score, "Buh")
},
score : function (event) {
getRating("yield", exam.examQuestions[exam.currentQuestion].PageName);
},
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
});
$("#star3").raty({
path : 'http://www.wikidoc.org/includes/raty/img/',
click : function (score, event) {
submitRating("quality", score, "Buh")
},
score : function (event) {
getRating("quality", exam.examQuestions[exam.currentQuestion].PageName);
},
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
});


function addRatyRating(exam){
}
var ratyLayers = "<center>Rate this question!</center><br /><span style='position:relative; float:left;'>Difficulty: <div id='star1'></div></span><span style='position:relative; float:left;left:33%;'>High Yield: <div id='star2'></div></span><span style='position:relative; float:left;left:66%'>Quality: <div id='star3'></div></span><br /><br /><br />"
function answerClicked(event){
$("#examSpace").prepend(ratyLayers);
$(".answer").removeClass("boxed");
$("#star1").raty({
$('input[type=radio]').prop('checked', function () {
path : 'http://www.wikidoc.org/includes/raty/lib/img/',
    return this.getAttribute('checked') == 'checked';
click : function (score, event) {
submitRating("difficulty", score, "Buh")
},
        score : function (event) {
                getRating("difficulty",exam.examQuestions[exam.currentQuestion].PageName);
        },
        hints: ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
});
});
$("#star2").raty({
$(this).addClass("boxed");
path : 'http://www.wikidoc.org/includes/raty/lib/img/',
$(this).find("#Ar").prop("checked",true);
click : function (score, event) {
console.log($(this).children());          
submitRating("yield", score, "Buh")
if($("#exam").find('#submit').length == 0){  
},
$("#examSpace").append("<div class='noSelect WBRButton' id='submit'><br />Submit</div>");
        score : function (event) {
                 $("#submit").click(event.data, answerSubmitted);
                getRating("yield",exam.examQuestions[exam.currentQuestion].PageName);
}
        },
        hints: ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
});
$("#star3").raty({
path : 'http://www.wikidoc.org/includes/raty/lib/img/',
click : function (score, event) {
submitRating("quality", score, "Buh")
},
        score : function (event) {
                 getRating("quality",exam.examQuestions[exam.currentQuestion].PageName);
        },
        hints: ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
});
 
}
}
 
function answerSubmitted(event) {
function answerClicked(event) {
         $("#submit").remove();
         $(".answer").removeClass("boxed");
event.data.examQuestions[event.data.currentQuestion].selectedAnswer = $("div .boxed").attr("id");
event.data.examQuestions[event.data.currentQuestion].selectedAnswer = $(this).attr("id");
if (!event.data.examQuestions[event.data.currentQuestion].creditRecieved && event.data.examQuestions[event.data.currentQuestion].selectedAnswer === event.data.examQuestions[event.data.currentQuestion].RightAnswer) {
if (!event.data.examQuestions[event.data.currentQuestion].creditRecieved && event.data.examQuestions[event.data.currentQuestion].selectedAnswer === event.data.examQuestions[event.data.currentQuestion].RightAnswer) {
event.data.answeredRight += 1;
event.data.answeredRight += 1;
                event.data.examQuestions[event.data.currentQuestion].creditRecieved = true;
event.data.examQuestions[event.data.currentQuestion].creditRecieved = true;
}
}
if (event.data.examType === "Tutor") {
if (event.data.examType === "Tutor") {
Line 682: Line 650:
}
}
$("div.answer").unbind('click');
$("div.answer").unbind('click');
        var api = new mw.Api();
var api = new mw.Api();
api.get({
api.get({
action : 'wbrinsertmetric',
action : 'wbrinsertmetric',
Line 695: Line 663:
if (event.data.examType === "Exam") {
if (event.data.examType === "Exam") {
$("#" + event.data.examQuestions[event.data.currentQuestion].selectedAnswer).addClass("boxed");
$("#" + event.data.examQuestions[event.data.currentQuestion].selectedAnswer).addClass("boxed");
        } else if (event.data.examType === "Tutor") {
} 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 />");
$("#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].selectedAnswer).addClass("boxed");
                $("#" + event.data.examQuestions[event.data.currentQuestion].RightAnswer).addClass("redBoxed");
$("#" + event.data.examQuestions[event.data.currentQuestion].RightAnswer).addClass("redBoxed");
                addRatyRating(event.data);
addRatyRating(event.data);
}
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) {
function questionNavigation(event) {
$("#" + event.data.currentQuestion).removeClass("boxed");
$("#" + event.data.currentQuestion).removeClass("boxed");
Line 743: Line 695:
}
}
function endExam(event) {
function endExam(event) {
        if(event.data.timer){
if (event.data.timer) {
        $('#timerBox').html("");
$('#timerBox').html("");
        $('#timerBox').css("visibility","hidden");
$('#timerBox').css("visibility", "hidden");
        event.data.examTimer.stop();
event.data.examTimer.stop();
        }
}
$("#examSpace").html("");
$("#examSpace").html("");
var datas;
var datas;
datas = "";
datas = "";
        datas += "<br />You answered " + event.data.answeredRight + " out of " + event.data.examQuestions.length + " correctly.<br /> Your percentage score is: ";
datas += "<br />You answered " + event.data.answeredRight + " out of " + event.data.examQuestions.length + " correctly.<br /> Your percentage score is: ";
var percent = (event.data.answeredRight / event.data.numQuestion) * 100;
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.";
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({
Line 766: Line 718:
console.log('API result:', data);
console.log('API result:', data);
});
});


$("#examSpace").append(datas);
$("#examSpace").append(datas);
        $(".navPaneButton").unbind('click');
$(".navPaneButton").unbind('click');
        $(".navPaneButton").click(event.data, questionReviewNavigation);
$(".navPaneButton").click(event.data, questionReviewNavigation);
}
}
function submitRating(type, score, page) {
function submitRating(type, score, page) {
var api = new mw.Api();
var api = new mw.Api();
Line 783: Line 732:
format : 'json'
format : 'json'
}, {
}, {
ok : function (res) {
ok : function (res) {}
}
});
});
}
}
 
function getRating(type, page) {
function getRating(type, page) {
var api = new mw.Api();
var api = new mw.Api();
Line 805: Line 752:
return res.yield;
return res.yield;
}
}
}});
}
}
});
 
}
function parseQuestions(examObj) {
function parseQuestions(examObj) {
var tobeParsed = null;
var tobeParsed = null;
Line 849: Line 796:
tobeParsed = examObj.examQuestions[q].AnswerEExp;
tobeParsed = examObj.examQuestions[q].AnswerEExp;
break;
break;
        case 12:
case 12:
                tobeParsed = examObj.examQuestions[q].Author
tobeParsed = examObj.examQuestions[q].Author
}
}
if (tobeParsed && tobeParsed.length > 0) {
if (tobeParsed && tobeParsed.length > 0) {
Line 901: Line 848:
examObj.examQuestions[q].AnswerEExp = parsed;
examObj.examQuestions[q].AnswerEExp = parsed;
break;
break;
                                case 12:
case 12:
                                        examObj.examQuestions[q].Author = parsed;
examObj.examQuestions[q].Author = parsed;
                                        break
break
}
}
if (examObj.examQuestions[q].lastParsed < 13) {
if (examObj.examQuestions[q].lastParsed < 13) {
Line 924: Line 871:
}
}
}
}
 
function countCats(event) {
function catQuestionCount(exam, type, cat) {
event.data.timeAmt = parseInt($(this).attr("id"), 10) * 6000;
var queryString = "[[ExamType::" + exam + "]] ";
var temp = event.data.examtype.replace(/ /g, "_");
if (type === "m") {
queryString += "[[MainCategory::" + cat + "]]";
} else {
queryString += "[[SubCategory::" + cat + "]]";
}
var api = new mw.Api();
var api = new mw.Api();
api.get({
api.get({
action : 'ask',
action : 'singlecat',
query : queryString,
exam : temp,
format : 'json'
format : 'json',
async : false
}, {
}, {
ok : function (data) {
ok : function (data) {
$.each(data.query.results, function (index, value) {
event.data.arrCounts = data;
var count = parseInt(document.getElementById(cat).innerHTML);
selectCats(event.data);
count = count + 1;
document.getElementById(cat).innerHTML = count.toString();
});
}
}
});
});
}
}


function completeQuestionCount(exam, main, sub) {
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) {
function urlSwapSpace(swap) {
return swap.split(' ').join('+');
return swap.split(' ').join('+');

Revision as of 00:58, 19 February 2014