studyislandbot code example
Example 1: studyislandbot
function options_page() {
$("#quesNum option").each(function() {
if (this.value == '10') {
$(this).val(200);
$(this).attr("selected", "selected");
}
});
$("#testSessionNextBtn").trigger("click");
}
function test_page() {
var q_num = $('#spanCurrentItemNumber').text();
var item = $.session.items[q_num];
var question_string = item.question;
var ansobject = item.answers;
var answers = $.map(ansobject, function (value, key) { return value; });
var ans_string = SI_ANSWERS[question_string];
if (ans_string) {
var ans_pos = answers.indexOf(ans_string);
if (ans_pos != -1) {
var answerdiv = "#answerSelection_"+q_num+"_"+(ans_pos+1);
$(answerdiv).trigger("click");
$(document).ajaxStop(function () {
$("#buttonNext").trigger("click");
$(document).ajaxStop(function() {
$('span.ui-button-text').each(function(){
if($(this).text() == 'End Session') {
$(this).trigger("click");
return;
}
});
});
test_page();
});
} else {
console.log('WTF...unable to find answer in answerlist...\n');
console.log(item);
console.log(ansobject);
$("#buttonNext").trigger("click"); // Skip it
}
} else {
console.log('Unable to find answer in cache...data:\n');
console.log(item);
console.log(ansobject);
$("#buttonNext").trigger("click"); // Skip it
}
}
function results_page() {
tryAgain();
}
if (window.location.href.indexOf("options") != -1) {
// If we're on the options page
options_page();
} else if (window.location.href.indexOf("practice-session-results") != -1) {
// If we're on the results page
results_page();
} else if (window.location.href.indexOf("practice-session") != -1) {
// If we're on the test page itself
test_page();
}
Example 2: studyislandbot
function options_page() {
$("#quesNum option").each(function() {
if (this.value == '10') {
$(this).val(200);
$(this).attr("selected", "selected");
}
});
$("#testSessionNextBtn").trigger("click");
}
function test_page() {
var q_num = $('#spanCurrentItemNumber').text();
var item = $.session.items[q_num];
var question_string = item.question;
var ansobject = item.answers;
var answers = $.map(ansobject, function (value, key) { return value; });
var ans_string = SI_ANSWERS[question_string];
if (ans_string) {
var ans_pos = answers.indexOf(ans_string);
if (ans_pos != -1) {
var answerdiv = "#answerSelection_"+q_num+"_"+(ans_pos+1);
$(answerdiv).trigger("click");
$(document).ajaxStop(function () {
$("#buttonNext").trigger("click");
$(document).ajaxStop(function() {
$('span.ui-button-text').each(function(){
if($(this).text() == 'End Session') {
$(this).trigger("click");
return;
}
});
});
test_page();
});
} else {
console.log('WTF...unable to find answer in answerlist...\n');
console.log(item);
console.log(ansobject);
$("#buttonNext").trigger("click"); // Skip it
}
} else {
console.log('Unable to find answer in cache...data:\n');
console.log(item);
console.log(ansobject);
$("#buttonNext").trigger("click"); // Skip it
}
}
function results_page() {
tryAgain();
}
if (window.location.href.indexOf("options") != -1) {
// If we're on the options page
options_page();
} else if (window.location.href.indexOf("practice-session-results") != -1) {
// If we're on the results page
results_page();
} else if (window.location.href.indexOf("practice-session") != -1) {
// If we're on the test page itself
test_page();
}
Example 3: studyislandbot
function options_page() {
$("#quesNum option").each(function() {
if (this.value == '10') {
$(this).val(200);
$(this).attr("selected", "selected");
}
});
$("#testSessionNextBtn").trigger("click");
}
function test_page() {
var q_num = $('#spanCurrentItemNumber').text();
var item = $.session.items[q_num];
var question_string = item.question;
var ansobject = item.answers;
var answers = $.map(ansobject, function (value, key) { return value; });
var ans_string = SI_ANSWERS[question_string];
if (ans_string) {
var ans_pos = answers.indexOf(ans_string);
if (ans_pos != -1) {
var answerdiv = "#answerSelection_"+q_num+"_"+(ans_pos+1);
$(answerdiv).trigger("click");
$(document).ajaxStop(function () {
$("#buttonNext").trigger("click");
$(document).ajaxStop(function() {
$('span.ui-button-text').each(function(){
if($(this).text() == 'End Session') {
$(this).trigger("click");
return;
}
});
});
test_page();
});
} else {
console.log('WTF...unable to find answer in answerlist...\n');
console.log(item);
console.log(ansobject);
$("#buttonNext").trigger("click"); // Skip it
}
} else {
console.log('Unable to find answer in cache...data:\n');
console.log(item);
console.log(ansobject);
$("#buttonNext").trigger("click"); // Skip it
}
}
function results_page() {
tryAgain();
}
if (window.location.href.indexOf("options") != -1) {
// If we're on the options page
options_page();
} else if (window.location.href.indexOf("practice-session-results") != -1) {
// If we're on the results page
results_page();
} else if (window.location.href.indexOf("practice-session") != -1) {
// If we're on the test page itself
test_page();
}