Widget:WJG Sandbox Merge: Difference between revisions

Jump to navigation Jump to search
No edit summary
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 238: Line 238:
background-color:#3366CC;
background-color:#3366CC;
height:40px;
height:40px;
line-height: 15px;
border-radius: 15px;
font-weight:bold;
font-weight:bold;
width:150px;
width:150px;
Line 388: Line 390:
}
}
}
}
 
window.exam=options;
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>";
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);
Line 764: Line 766:
function addToNavBar() {
function addToNavBar() {
$("#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>");
$("#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(alert("coming soon!"));
$("#back").click(questionNavigation);
$("#back").click(questionNavigation);
$("#next").click(questionNavigation);
$("#next").click(questionNavigation);
$("#flag").click(flagQ);
$("#lab_vals").click(showLabs)
$("#finish").click(endExam);
$("#finish").click(endExam);
if (window.exam.timer) {
if (window.exam.timer) {
Line 776: Line 779:
$.each(window.exam.examQuestions, function (index, value) {
$.each(window.exam.examQuestions, function (index, value) {
$("#navPane").append("<div id='" + index + "' class='navPaneButton'> " + (index - -1) + "</div>");
$("#navPane").append("<div id='" + index + "' class='navPaneButton'> " + (index - -1) + "</div>");
console.log(index)
window.exam.examQuestions[index].creditReceived=false
});
});
$(".navPaneButton").click(questionNavigation);
$(".navPaneButton").click(questionNavigation);
Line 821: Line 826:
}
}
$("#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 (window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer !== 'F') {
if (window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer !== 'F') {
$("#" + window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer).addClass("boxed");
$("#" + window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer).addClass("boxed");
Line 988: Line 996:
function answerSubmitted(event) {
function answerSubmitted(event) {
$("#submit").remove();
$("#submit").remove();
if (!window.exam.examQuestions[window.exam.currentQuestion].creditRecieved && window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer === window.exam.examQuestions[window.exam.currentQuestion].RightAnswer) {
if (!window.exam.examQuestions[window.exam.currentQuestion].creditReceived && window.exam.examQuestions[window.exam.currentQuestion].selectedAnswer === String(window.exam.examQuestions[window.exam.currentQuestion].RightAnswer)) {
console.log("You answered a question correctly")
window.exam.answeredRight += 1;
window.exam.answeredRight += 1;
window.exam.examQuestions[window.exam.currentQuestion].creditRecieved = true;
window.exam.examQuestions[window.exam.currentQuestion].creditReceived = true;
}
}
if (window.exam.examType === "Tutor") {
if (window.exam.examType === "Tutor") {
Line 1,049: Line 1,058:
}
}
function flagQ(event) {
function flagQ(event) {
$("#" + window.exam.currentQuestion-1).toggleClass("flagged");
$("#" + window.exam.currentQuestion).toggleClass("flagged");
}
}


Line 1,056: Line 1,065:
$("#details").slideToggle("slow");
$("#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 (window.exam.timer) {
if (window.exam.timer) {
Line 1,066: Line 1,102:
datas = "";
datas = "";
datas += "<br />You answered " + window.exam.answeredRight + " out of " + window.exam.examQuestions.length + " correctly.<br /> Your percentage score is: ";
datas += "<br />You answered " + window.exam.answeredRight + " out of " + window.exam.examQuestions.length + " correctly.<br /> Your percentage score is: ";
var percent = (window.exam.answeredRight / window.exam.examQuestions.length) * 100;
var percent = Math.round((window.exam.answeredRight / window.exam.examQuestions.length) * 100);
datas += percent + "%<br /><br />Click the Navigation Buttons on the left to review the questions you answered.";
testlength=window.exam.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=window.exam.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>";
 
 
var api = new mw.Api();
var api = new mw.Api();


Line 1,083: Line 1,138:
$(".navPaneButton").unbind('click');
$(".navPaneButton").unbind('click');
$(".navPaneButton").click(window.exam, questionReviewNavigation);
$(".navPaneButton").click(window.exam, questionReviewNavigation);
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);
}
}
function submitRating(ratingType, score, page) {
function submitRating(ratingType, score, page) {
if (ratingType === "difficulty") {
if (ratingType === "difficulty") {

Latest revision as of 02:08, 11 August 2014