Widget:WJG Sandbox: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Undo revision 1008029 by William J Gibson (talk) |
||
(117 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
<script src="http://www.wikidoc.org/includes/raty/jquery.timer.js"></script> | <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> | <script type="text/javascript" src="http://www.wikidoc.org/includes/raty/jquery.raty.js"></script> | ||
<script | |||
<script src='http://dl.dropboxusercontent.com/u/1874620/ChartNew.js'></script> | |||
<script type="text/javascript" src="http://wikidoc.org/extensions/WGTextHighlight/jquery.textHighlighter.js"></script> | <script type="text/javascript" src="http://wikidoc.org/extensions/WGTextHighlight/jquery.textHighlighter.js"></script> | ||
<head> | |||
<link rel="stylesheet" href="http://dl.dropboxusercontent.com/u/1874620/animate.css"> | |||
</head> | |||
<style type="text/css"> | <style type="text/css"> | ||
input[type=radio].css-checkbox { | |||
display:none; | |||
} | |||
input[type=radio].css-checkbox + label.css-label { | |||
display: inline-block; | |||
*display: inline; | |||
vertical-align: middle; | |||
margin: 0; | |||
width: 20px; | |||
height: 20px; | |||
background-repeat: no-repeat; | |||
background: url(http://dl.dropboxusercontent.com/u/1874620/iCheck/flat/blue.png) no-repeat; | |||
border: none; | |||
cursor: pointer; | |||
background-position: -88px 0; | |||
} | |||
input[type=radio].css-checkbox:checked + label.css-label { | |||
background-position: -110px 0; | |||
} | |||
label.css-label { | |||
background-image:url(http://dl.dropboxusercontent.com/u/1874620/iCheck/flat/blue.png); | |||
-webkit-touch-callout: none; | |||
-webkit-user-select: none; | |||
-khtml-user-select: none; | |||
-moz-user-select: none; | |||
-ms-user-select: none; | |||
user-select: none; | |||
} | |||
.examOptionButton { | |||
font:14px/20px'MontserratRegular', Helvetica, Arial, sans-serif; | |||
color: #444; | |||
} | |||
.examOptionTitle { | |||
font:24px'MontserratRegular', Helvetica, Arial, sans-serif; | |||
color:#222 | |||
} | |||
@media (-o-min-device-pixel-ratio: 5/4), (-webkit-min-device-pixel-ratio: 1.25), (min-resolution: 120dpi) { | |||
input[type=radio].css-checkbox + label.css-label { | |||
background-image: url(http://dl.dropboxusercontent.com/u/1874620/iCheck/flat/blue@2x.png); | |||
-webkit-background-size: 176px 22px; | |||
background-size: 176px 22px; | |||
} | |||
} | |||
a{ | a{ | ||
Line 16: | Line 72: | ||
background-color:#FFFFFF; | background-color:#FFFFFF; | ||
} | } | ||
#details{ | |||
position:absolute; background:white; border: 1px solid #D1C9C2; border-top: 0; width: 400px; margin: 0 auto; padding: 7px 15px; text-align: left; -webkit-border-bottom-right-radius: 6px; -webkit-border-bottom-left-radius: 6px; -moz-border-radius-bottomright: 6px; -moz-border-radius-bottomleft: 6px; border-bottom-right-radius: 6px; border-bottom-left-radius: 6px; | |||
} | |||
#content.mw-body{ | #content.mw-body{ | ||
width:100%; | width:100%; | ||
Line 26: | Line 87: | ||
width:100%; | width:100%; | ||
height:90%; | height:90%; | ||
margin:0; | |||
} | } | ||
Line 90: | Line 152: | ||
background: white; | background: white; | ||
} | } | ||
#spacer{ | #spacer{ | ||
margin:10px | margin:10px | ||
Line 140: | Line 204: | ||
} | } | ||
.answer{display: inline} | .answer{display: inline} | ||
.ans_text{display: inline} | .ans_text{ | ||
display: inline; | |||
cursor: pointer; | |||
} | |||
.choice_elim{ | .choice_elim{ | ||
opacity:0. | opacity:0.9; | ||
text-decoration:line-through; | text-decoration:line-through; | ||
} | } | ||
Line 148: | Line 215: | ||
color:#FF0000; | color:#FF0000; | ||
} | } | ||
.labvalson{ | |||
display:visible; | |||
} | |||
Line 206: | Line 275: | ||
height:90%; | height:90%; | ||
border:none; | border:none; | ||
padding:0; | |||
} | } | ||
#mw-content-text{ | #mw-content-text{ | ||
height:100%;} | height:100%;} | ||
#navPane{ | #navPane{ | ||
position:relative; | position:relative; | ||
float:left; | float:left; | ||
width:5%; | width:5%; | ||
height:100%; | |||
overflow-y:scroll; | |||
} | } | ||
#examSpace{ | #examSpace{ | ||
Line 234: | Line 307: | ||
width:100%; | width:100%; | ||
background-color:#3366CC; | background-color:#3366CC; | ||
} | |||
#pauseButton{ | |||
float:right; | |||
margin-bottom:0px; | |||
height:95%; | |||
} | |||
#stopButton{ | |||
float:right; | |||
margin-right: 5%; | |||
height=95%; | |||
margin-bottom:0px; | |||
} | } | ||
.navPaneButton{ | .navPaneButton{ | ||
Line 256: | Line 340: | ||
visibility:visible; | visibility:visible; | ||
} | } | ||
#tutorOrExamContainer{ | |||
background-color:#E3E5E5; | |||
} | |||
</style> | </style> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
Line 302: | Line 390: | ||
} | } | ||
} | } | ||
var background_html="<div class='container'><header><h1>Wikidoc Board Review </br> <span>Please select an exam below</span></h1></header></div>"; | var background_html="<div class='container'><header><h1 class='animated bounceInDown'>Wikidoc Board Review </br> <span>Please select an exam below</span></h1></header></div>"; | ||
$("#chooseQBank").html(background_html); | $("#chooseQBank").html(background_html); | ||
var bottom_html="<div id='bottomwelcome'></div>"; | var bottom_html="<div id='bottomwelcome'></div>"; | ||
var stuffs = "<div class='round-button Curric' id='USMLE Step 1'><div class='round-button-circle'><p class='round-button'>1</p></div></div><div id='spacer' style='display: inline'></div>"; | |||
var stuffs = "<div class='round-button Curric' id='MCAT'><div class='round-button-circle'><p class='round-button' style='font-size:2.5em;'>MCAT</p></div></div><div id='spacer' style='display: inline'></div>"; | |||
stuffs += "<div class='round-button Curric' id='USMLE Step 1'><div class='round-button-circle'><p class='round-button'>1</p></div></div><div id='spacer' style='display: inline'></div>"; | |||
stuffs += "<div class='round-button Curric' id='USMLE Step 2 CK'><div class='round-button-circle'><p class='round-button'>2</p></div></div><div id='spacer' style='display: inline'></div>"; | stuffs += "<div class='round-button Curric' id='USMLE Step 2 CK'><div class='round-button-circle'><p class='round-button'>2</p></div></div><div id='spacer' style='display: inline'></div>"; | ||
stuffs += "<div class='round-button Curric' id='USMLE Step 3'><div class='round-button-circle'><p class='round-button'>3</p></div></div><div id='spacer' style='display: inline'></div>"; | stuffs += "<div class='round-button Curric' id='USMLE Step 3'><div class='round-button-circle'><p class='round-button'>3</p></div></div><div id='spacer' style='display: inline'></div>"; | ||
stuffs += "<div class='round-button Curric' id=' | stuffs += "<div class='round-button Curric' id='Board Review'><div class='round-button-circle'><p class='round-button' style='font-size:2.5em;'>ABIM</p></div></div><div id='spacer' style='display: inline'></div><br /><br />"; | ||
stuffs+="<div class='stepBar'><img src='http://static.wikidoc.org/f/f3/Step_bar_5_22_14.png' /></div>"; | |||
// $("#chooseQBank").hide(); | // $("#chooseQBank").hide(); | ||
Line 325: | Line 415: | ||
$("#exam").show(); | $("#exam").show(); | ||
var divs = null; | var divs = null; | ||
divs = "<div class= 'container'><header><h1>" +event.data.examtype+ " </br> <span> Select your options below</span></h1></header></div><div id='Pat' class='noSelect WBRButton stepTwo'><br />USMLE Format</div><div id='Flash' class='noSelect WBRButton stepTwo'><br />Flash Cards</div><br /><br /><br />"; | divs = "<div class= 'container' id='optionScreenHeader' style='height:200px' ><header><h1>" +event.data.examtype+ " </br> <span> Select your options below</span></h1></header></div><div id='Pat' class='noSelect WBRButton stepTwo'><br />USMLE Format</div><div id='Flash' class='noSelect WBRButton stepTwo'><br />Flash Cards</div><br /><br /><br />"; | ||
$("#exam").html(divs); | $("#exam").html(divs); | ||
var temp_str="<div id= 'examOptions'></div>"; | |||
//$("#exam").append(temp_str); | |||
var tutorOrExam="<div class='container' id='tutorOrExamContainer' style='height:110px'>"+ | |||
"<div class='round-button Curric' id='tutorModeBigButton' style='margin-left:calc(50% - 100px); margin-top:5px'><div class='round-button-circle'><p class='round-button' style='font-size:1.5em;'>Tutor \n Mode</p></div></div><div id='spacer' style='display: inline'></div>"+ | |||
"<div class='round-button Curric' id='examModeBigButton'><div class='round-button-circle'><p class='round-button' style='font-size:1.5em;'>Exam \n Mode</p></div></div><div id='spacer' style='display: inline'></div>"+ | |||
"</div>" | |||
$("#optionScreenHeader").after(tutorOrExam); | |||
var examOptionButtons = "<div style='background:#fafafa; color:#222; padding:10px;'>"+ | |||
" <h3 class='examOptionTitle'>Exam Mode</h3>"+ | |||
" <form id='examModeForm'>"+ | |||
" <input type='radio' name='examMode' value='exam' id='examModeButton' class='css-checkbox' />"+ | |||
" <label for='examModeButton' class='css-label cb0 radGroup2'></label>"+ | |||
" <p class='examOptionButton' style='display:inline'>  Exam</p>"+ | |||
" <br />"+ | |||
" <input type='radio' name='examMode' value='tutor' id='tutor' class='css-checkbox' />"+ | |||
" <label for='tutor' class='css-label cb0 radGroup2'></label>"+ | |||
" <p class='examOptionButton' style='display:inline'>  Tutor</p>"+ | |||
" <br />"+ | |||
" </form>" + | |||
"</div>"+ | |||
"<div style='background:#fafafa; color:#222; padding:10px;'>"+ | |||
" <h3 class='examOptionTitle'>Question Selection</h3>"+ | |||
" <form id='CatKeyForm'>"+ | |||
" <input type='radio' name='CatKey' value='category' id='category' class='css-checkbox' />"+ | |||
" <label for='category' class='css-label cb0 radGroup2'></label>"+ | |||
" <p class='examOptionButton' style='display:inline'>  Category</p>"+ | |||
" <br />"+ | |||
" <input type='radio' name='CatKey' value='keyword' id='keyword' class='css-checkbox' />"+ | |||
" <label for='keyword' class='css-label cb0 radGroup2'></label>"+ | |||
" <p class='examOptionButton' style='display:inline'>  Keyword</p>"+ | |||
" </form>"+ | |||
"</div>"; | |||
$("#tutorOrExamContainer").after(examOptionButtons); | |||
recordResponses() | |||
$('.stepTwo').click(event.data, tutorOrExam); | $('.stepTwo').click(event.data, tutorOrExam); | ||
} | |||
function recordResponses(){ | |||
$("input:radio[name=examMode]").click(function() { | |||
var value = $(this).val(); | |||
console.log(value) | |||
}); | |||
$("input:radio[name=CatKey]").click(function() { | |||
var value = $(this).val(); | |||
console.log(value) | |||
}); | |||
} | } | ||
function chooseExamOptions(event) { | |||
$("#chooseQBank").remove();//Once the QBank is picked, we'll remove the div that held it. | |||
$("#exam").show(); | |||
$("#examOptions").append(""+ | |||
"<select id ='ToE' name='Exam Type'>" + | |||
"<option value='Tutor'>Tutor Mode</option>" + | |||
"<option value='Exam'>Exam Mode</option>" + | |||
"</select>" + | |||
"<select id ='catOrKey' name='Question Selection'>" + | |||
"<option value='Category'>Category</option>" + | |||
"<option value='Keyword'>Keyword</option>" + | |||
"</select>" + | |||
"<select id ='Timed' name='Timer'>" + | |||
"<option value='Untimed'>Untimed</option>" + | |||
"<option value='Timed'>Timed</option>" + | |||
"</select>"); | |||
//$("#exam").append("<div id='displayVals'></div>"); | |||
} | |||
function displayVals() { | |||
var tutor_or_exam_val = $( "#ToE" ).val(); | |||
var cat_or_key_val= $( "#catOrKey" ).val(); | |||
var timerSetting=$("#Timed").val(); | |||
$( "#displayVals" ).html( "<b>Tutor or Exam:</b> " + tutor_or_exam_val + "<br>" + | |||
" <b>Category or Keyword:</b> " + cat_or_key_val + "<br>" + | |||
"<b> Timed or Untimed: </b>" + timerSetting); | |||
} | |||
function tutorOrExam(event) { | function tutorOrExam(event) { | ||
Line 684: | Line 856: | ||
} | } | ||
function addToNavBar(exam) { | function addToNavBar(exam) { | ||
$("#exam").html("<div id='navBar'><div id='flag' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/ | $("#exam").html("<div id='navBar'><div id='flag' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/3/34/Flag_5_19_14.png' /></div><div id='back' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/f/f9/Leftarrow_3_29_b.png' /></div><div id='next' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/a/ae/Rightarrow_3_29_14_b.png' /></div><div id='lab_vals' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/8/8b/Lab_values_3_29_14.png' /></div><div id='notes' class='noSelect WBRImgButton'><img src='http://static.wikidoc.org/e/eb/Pencil_3_29_14_trimwspace.png' /></div><div id='finish' class='noSelect WBRButton'><br />Finish</div></div><div id='navPane'></div><div id='examSpace'></div><span id='timeRem' style='height: 0px; visibility: hidden'>" + exam.timeAmt.toString() + "</span>"); | ||
//$("#flag").click(function(){alert("Coming Soon!")}); | //$("#flag").click(function(){alert("Coming Soon!")}); | ||
$("<div id='bottomBar'></div>").insertAfter("#exam"); | $("<div id='bottomBar'><div id='stopButton' class= 'noSelect WBRImgButton'><img src='http://static.wikidoc.org/0/09/Stopbutton2.svg' ></div><div id='pauseButton' class= 'noSelect WBRImgButton'><img src='http://static.wikidoc.org/e/e3/Pausebutton6.svg' ></div></div>").insertAfter("#exam"); | ||
$("#back").click(exam, questionNavigation); | $("#back").click(exam, questionNavigation); | ||
$("#next").click(exam, questionNavigation); | $("#next").click(exam, questionNavigation); | ||
$("#finish").click(exam, endExam); | $("#finish").click(exam, endExam); | ||
$("#flag").click(exam, flagQ); | |||
$("#lab_vals").click(exam, showLabs); | |||
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 700: | Line 874: | ||
$("#navPane").append("<div id='" + index + "' class='navPaneButton'> " + (index - -1) + "</div>"); | $("#navPane").append("<div id='" + index + "' class='navPaneButton'> " + (index - -1) + "</div>"); | ||
}); | }); | ||
// I think there might be a bug with this line. | |||
$(".navPaneButton").click(exam, questionNavigation); | $(".navPaneButton").click(exam, questionNavigation); | ||
$("#" + exam.currentQuestion).addClass("boxed"); | $("#" + exam.currentQuestion).addClass("boxed"); | ||
Line 714: | Line 889: | ||
parseQuestions(exam); | parseQuestions(exam); | ||
} else { | } else { | ||
var htmlStuff = "<b>Question " + (exam.currentQuestion - -1) + " / " + (exam.examQuestions.length) + "</b><br /><br />" + "< | var htmlStuff = "<b>Question " + (exam.currentQuestion - -1) + " / " + (exam.examQuestions.length) + "</b><br /><br />" + "<div id='highlightable'>" + obj.Prompt +"</div>"+"<br />"; | ||
if (obj.AnswerA && obj.AnswerA.length > 0) { | if (obj.AnswerA && obj.AnswerA.length > 0) { | ||
Line 747: | Line 922: | ||
} | } | ||
$("#examSpace").html(htmlStuff); | $("#examSpace").html(htmlStuff); | ||
$("#examSpace").prepend("<div id='details' style='display:none'> <table class='tg'> <tr> <th class='tg-031e'>Analyte</th> <th class='tg-031e'>Reference Range</th> </tr> <tr> <td class='tg-031e'>Sodium (Na+)</td> <td class='tg-031e'>136-145 mEq/L</td> </tr> <tr> <td class='tg-031e'>Potassium (K+)</td> <td class='tg-031e'>3.5-5.0 mEq/L</td> </tr> <tr> <td class='tg-031e'>Chloride (Cl-)</td> <td class='tg-031e'>95-105 mEq/L</td> </tr> <tr> <td class='tg-031e'>Bicarbonate (HCO3-)</td> <td class='tg-031e'>22-28 mEq/L</td> </tr> <tr> <td class='tg-031e'>Magnesium (Mg2+)</td> <td class='tg-031e'>1.5-2.0mEq/L</td> </tr> <tr> <td class='tg-031e'>Calcium (Ca2+)</td> <td class='tg-031e'></td> </tr></table></div>"); | |||
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"); | ||
Line 765: | Line 942: | ||
}); | }); | ||
$(' | $('#highlightable').textHighlighter({ | ||
color: '#FFFF00' | color: '#FFFF00' | ||
}); | }); | ||
} | } | ||
} | } | ||
Line 841: | Line 1,010: | ||
getRating(exam.examQuestions[exam.currentQuestion].PageName, exam); | getRating(exam.examQuestions[exam.currentQuestion].PageName, exam); | ||
addFirstResponses(); | |||
} | |||
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; | |||
} | |||
var sumFS=data.firstResponseQuery.A+data.firstResponseQuery.B+data.firstResponseQuery.C+data.firstResponseQuery.D+data.firstResponseQuery.E; | |||
var firstResponses = "<table><th colspan='5'>First Responses</th><tr><td>A</td><td>B</td><td>C</td><td>D</td><td>E</td></tr><tr><td>" + data.firstResponseQuery.A + "</td><td>"+ data.firstResponseQuery.B + "</td><td>"+ data.firstResponseQuery.C + "</td><td>"+ data.firstResponseQuery.D + "</td><td>"+ data.firstResponseQuery.E + "</td><td></tr></table>"; | |||
$("#examSpace").prepend(firstResponses); | |||
}); | |||
} | } | ||
function answerClicked(event){ | function answerClicked(event){ | ||
$(".answer").removeClass("boxed"); | $(".answer").removeClass("boxed"); | ||
Line 895: | Line 1,094: | ||
function answerSubmitted(event) { | function answerSubmitted(event) { | ||
$("#submit").remove(); | $("#submit").remove(); | ||
event.data.examQuestions[event.data.currentQuestion].selectedAnswer = $(" | event.data.examQuestions[event.data.currentQuestion].selectedAnswer = $(".answer.boxed").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; | ||
Line 959: | Line 1,159: | ||
questionReview(event.data); | questionReview(event.data); | ||
} | } | ||
// $('#flag').click(function(){ | |||
//var cur_q=exam.currentQuestion; | |||
// var temp_flag_div_id='.navPaneButton#'+cur_q; | |||
// $("#" + event.data.currentQuestion).toggleClass('flagged'); | |||
//alert("You clicked the flag!"+temp_flag_div_id); | |||
// }) | |||
function flagQ(event) { | |||
$("#" + event.data.currentQuestion).toggleClass("flagged"); | |||
} | |||
function showLabs(event) { | |||
$("#details").stop(); | |||
$("#details").slideToggle("slow");} | |||
function convolve_bernouli(qprobs){ | |||
//takes in an array of probabilities of guessing questions correct | |||
for (var counter = 0; counter < qprobs.length; counter++) { | |||
//if the loop is in the first iteration, then initialize the array | |||
if (counter==0){ | |||
var pdfArray=[1-qprobs[0],qprobs[0]]; | |||
}else{ | |||
//initialize new Array for pdfs | |||
var newpdfArray= []; | |||
for (var i = 0; i < pdfArray.length+1; i+=1) { | |||
newpdfArray[i]=0; | |||
} | |||
//multiply by ones first | |||
for (var i = 0; i < pdfArray.length; i+=1) { | |||
newpdfArray[i+1]+=pdfArray[i]*qprobs[counter]; //probability of adding a success | |||
newpdfArray[i]+=pdfArray[i]*(1-qprobs[counter]); | |||
} | |||
pdfArray=newpdfArray; | |||
} | |||
} | |||
console.log(pdfArray); | |||
return(pdfArray); | |||
}//ends convolve_bernouli | |||
function endExam(event) { | function endExam(event) { | ||
if (event.data.timer) { | if (event.data.timer) { | ||
Line 969: | Line 1,210: | ||
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.examQuestions.length) * 100; | var percent = Math.round((event.data.answeredRight / event.data.examQuestions.length) * 100); | ||
datas += percent + "%<br /><br />Click the Navigation Buttons on the left to review the questions you answered."; | testlength=event.data.examQuestions.length; | ||
var question_probs=[]; | |||
for (var j = 0; j < testlength; j+=1){ | |||
question_probs[j]=Math.random(); | |||
} | |||
qdist=convolve_bernouli(question_probs); | |||
var myTotal = 0; //Variable to hold your total | |||
for(var i=0, len=event.data.answeredRight+1; i<len; i++){ | |||
myTotal += qdist[i]; //Iterate over your first array and then grab the second element add the values up | |||
} | |||
datas += percent + "%<br /><br />Click the Navigation Buttons on the left to review the questions you answered.<br />"; | |||
datas += "<br />You scored in the " + Math.round(myTotal*100) + " percentile. <br /><br />"; | |||
datas += "<canvas id='simExams' width='600' height='400'></canvas>"; | |||
$("#examSpace").append(datas); | |||
var api = new mw.Api(); | var api = new mw.Api(); | ||
Line 983: | Line 1,243: | ||
console.log('API result:', data); | console.log('API result:', data); | ||
}); | }); | ||
// Here's some code to create the labels for the graph (recall that qdist is the distribution of points). | |||
point_labels=[]; | |||
for (var j = 0; j < qdist.length; j+=1){ | |||
point_labels[j]=j.toString(); | |||
} | |||
var simExamData = { | |||
labels : point_labels, | |||
datasets : [ | |||
{ | |||
fillColor : "rgba(220,220,220,0.5)", | |||
strokeColor : "rgba(220,220,220,1)", | |||
pointColor : "rgba(220,220,220,1)", | |||
pointStrokeColor : "#fff", | |||
data : qdist, | |||
title: "Percent of test takers" | |||
} | |||
] | |||
} | |||
var newopts = { | |||
yAxisLabel : "Percent of test takers", | |||
yAxisFontFamily : "'Arial'", | |||
yAxisFontSize : 16, | |||
yAxisFontStyle : "normal", | |||
yAxisFontColor : "#666", | |||
xAxisLabel : "Number of correct answers", | |||
legend : false, | |||
legendFontFamily : "'Arial'", | |||
legendFontSize : 12, | |||
legendFontStyle : "normal", | |||
legendFontColor : "#666", | |||
legendBlockSize : 15, | |||
legendBorders : false, | |||
legendBordersColor : "#666", | |||
graphTitle : "Peer Performance", | |||
graphTitleFontFamily : "'Arial'", | |||
graphTitleFontSize : 24, | |||
graphTitleFontStyle : "bold", | |||
graphTitleFontColor : "#666", | |||
} | |||
// get line chart canvas | |||
var simExams = document.getElementById('simExams').getContext('2d'); | |||
// draw line chart | |||
new Chart(simExams).Line(simExamData,newopts); | |||
$(".navPaneButton").unbind('click'); | $(".navPaneButton").unbind('click'); | ||
$(".navPaneButton").click(event.data, questionReviewNavigation); | $(".navPaneButton").click(event.data, questionReviewNavigation); | ||
Line 1,175: | Line 1,491: | ||
$("#firstHeading").hide(); | $("#firstHeading").hide(); | ||
$("#wikidocNav").hide(); | $("#wikidocNav").hide(); | ||
$("#contentSub").hide(); | |||
Line 1,185: | Line 1,502: | ||
$("#firstHeading").show(); | $("#firstHeading").show(); | ||
$("#wikidocNav").show(); | $("#wikidocNav").show(); | ||
$("#contentSub").hide() | |||
}) | }) | ||
}) | }) |