Widget:Sandbox: Difference between revisions

Jump to navigation Jump to search
Matt Pijoan (talk | contribs)
No edit summary
Matt Pijoan (talk | contribs)
No edit summary
Line 599: Line 599:
submitRating("difficulty", score, exam.examQuestions[exam.currentQuestion].PageName)
submitRating("difficulty", score, exam.examQuestions[exam.currentQuestion].PageName)
},
},
score : function(){
                          var api = new mw.Api();
api.get({
action : 'wbrgetrating',
question : exam.examQuestions[exam.currentQuestion].PageName,
format : 'json'
}, {
ok : function (res) {
                      console.log(res.wbrgetrating.difficulty);
                      return res.wbrgetrating.difficulty;
}
});
                },
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
});
});
Line 619: Line 606:
submitRating("yield", score, exam.examQuestions[exam.currentQuestion].PageName)
submitRating("yield", score, exam.examQuestions[exam.currentQuestion].PageName)
},
},
score : function(){
                          var api = new mw.Api();
api.get({
action : 'wbrgetrating',
question : exam.examQuestions[exam.currentQuestion].PageName,
format : 'json'
}, {
ok : function (res) {
                      return res.wbrgetrating.difficulty;
}
});
                },
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
});
});
Line 637: Line 612:
click : function (score, event) {
click : function (score, event) {
submitRating("quality", score, exam.examQuestions[exam.currentQuestion].PageName)
submitRating("quality", score, exam.examQuestions[exam.currentQuestion].PageName)
}, score : function(){
},
                          var api = new mw.Api();
api.get({
action : 'wbrgetrating',
question : exam.examQuestions[exam.currentQuestion].PageName,
format : 'json'
}, {
ok : function (res) {
                      return res.wbrgetrating.difficulty;
}
});
                },
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
hints : ['Very Poor', 'Poor', 'Average', 'Good', 'Very Good']
});
});
 
getRating(exam.examQuestions[exam.currentQuestion].PageName);
}
}
function answerClicked(event){
function answerClicked(event){
Line 666: Line 630:
}
}
}
}
function getRating(type, page) {
function getRating(page) {
var api = new mw.Api();
var api = new mw.Api();
api.get({
api.get({
Line 674: Line 638:
}, {
}, {
ok : function (res) {
ok : function (res) {
                       return res.wbrgetrating;
                       $("#star1 input[name=score]").val(res.wbrgetrating.difficulty);
                      $("#star2 input[name=score]").val(res.wbrgetrating.yield);
                      $("#star3 input[name=score]").val(res.wbrgetrating.quality);
}
}
});
});

Revision as of 22:09, 20 February 2014