Widget:WJG Sandbox Merge: Difference between revisions

Jump to navigation Jump to search
No edit summary
No edit summary
Line 1,102: 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,120: Line 1,139:
$(".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);
$(".navPaneButton").unbind('click');
$(".navPaneButton").click(window.exam, questionReviewNavigation);
}
function submitRating(ratingType, score, page) {
      if(ratingType === "difficulty"){
var api = new mw.Api();
api.get({
action : 'wbrinsertrating',
username : mw.user.getName(),
question : page,
difficulty : score,
format : 'json'
}, {
ok : function (res) {}
});
} else if (ratingType === "yield"){
var api = new mw.Api();
api.get({
action : 'wbrinsertrating',
username : mw.user.getName(),
question : page,
yield : score,
format : 'json'
}, {
ok : function (res) {}
});
}
else if (ratingType === "quality"){
var api = new mw.Api();
api.get({
action : 'wbrinsertrating',
username : mw.user.getName(),
question : page,
quality : score,
format : 'json'
}, {
ok : function (res) {}
});
}
}
function submitRating(ratingType, score, page) {
function submitRating(ratingType, score, page) {
if (ratingType === "difficulty") {
if (ratingType === "difficulty") {

Revision as of 02:00, 11 August 2014