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();
}

Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source