function addToExam() {
    var examQuestions = document.getElementsByClassName("selected");
    var fieldsFilled = false;
    for(let verify of examQuestions) {
        var points = verify.children[4].firstElementChild.value;
        if(points == "" || points == "0") {
            fieldsFilled = false;
            break;
        }
        else {
            fieldsFilled = true;
        }
    }
    if(fieldsFilled) {
        for(let chosen of examQuestions) {
                var xhttp = new XMLHttpRequest();
                var addRequest = "query=InsertExamQuestion&QuestionID=" + chosen.id + "&Points=" + chosen.children[4].firstElementChild.value;
                var addReq = encodeURI(addRequest);
                xhttp.onreadystatechange = function() {
                    if(this.readyState == 4 && this.status == 200) {
                        var echoed = this.responseText;
                        var response = JSON.parse(echoed);
                        if(response.dbSuccess) {
                            document.getElementById("testWork").innerHTML = "Exam Posted.";
                            teachExamView('editing');
                        }
                        else {
                            document.getElementById("testWork").innerHTML = "Question Already in Exam.";
                        }
                    }
                    else {
                        document.getElementById("testWork").innerHTML = "Error Making Exam.";
                    }
                }
                xhttp.open("POST","betaFrontCurl.php", true);
                xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                xhttp.send(addReq);
        }
        examToggle();
    }
    else {
        document.getElementById("testWork").innerHTML = "All questions going to the Exam must have a valid point value. (At least 1)";
    }
}
// Adding Questions to the Exam and Posting It

Adding Questions to the Exam and Posting It
Adding Questions to the Exam and Posting It
function addToExam() {
    var examQuestions = document.getElementsByClassName("selected");
    var fieldsFilled = false;
    for(let verify of examQuestions) {
        var points = verify.children[4].firstElementChild.value;
        if(points == "" || points == "0") {
            fieldsFilled = false;
            break;
        }
        else {
            fieldsFilled = true;
        }
    }
    if(fieldsFilled) {
        for(let chosen of examQuestions) {
                var xhttp = new XMLHttpRequest();
                var addRequest = "query=InsertExamQuestion&QuestionID=" + chosen.id + "&Points=" + chosen.children[4].firstElementChild.value;
                var addReq = encodeURI(addRequest);
                xhttp.onreadystatechange = function() {
                    if(this.readyState == 4 && this.status == 200) {
                        var echoed = this.responseText;
                        var response = JSON.parse(echoed);
                        if(response.dbSuccess) {
                            document.getElementById("testWork").innerHTML = "Exam Posted.";
                            teachExamView('editing');
                        }
                        else {
                            document.getElementById("testWork").innerHTML = "Question Already in Exam.";
                        }
                    }
                    else {
                        document.getElementById("testWork").innerHTML = "Error Making Exam.";
                    }
                }
                xhttp.open("POST","betaFrontCurl.php", true);
                xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
                xhttp.send(addReq);
        }
        examToggle();
    }
    else {
        document.getElementById("testWork").innerHTML = "All questions going to the Exam must have a valid point value. (At least 1)";
    }
}
function addToExam ( ) { var examQuestions = document . getElementsByClassName ( "selected" ) ; var fieldsFilled = false ; for ( let verify of examQuestions ) { var points = verify . children [ 4 ] . firstElementChild . value ; if ( points == "" || points == "0" ) { fieldsFilled = false ; break ; } else { fieldsFilled = true ; } } if ( fieldsFilled ) { for ( let chosen of examQuestions ) { var xhttp = new XMLHttpRequest ( ) ; var addRequest = "query=InsertExamQuestion&QuestionID=" + chosen . id + "&Points=" + chosen . children [ 4 ] . firstElementChild . value ; var addReq = encodeURI ( addRequest ) ; xhttp . onreadystatechange = function ( ) { if ( this . readyState == 4 && this . status == 200 ) { var echoed = this . responseText ; var response = JSON . parse ( echoed ) ; if ( response . dbSuccess ) { document . getElementById ( "testWork" ) . innerHTML = "Exam Posted." ; teachExamView ( 'editing' ) ; } else { document . getElementById ( "testWork" ) . innerHTML = "Question Already in Exam." ; } } else { document . getElementById ( "testWork" ) . innerHTML = "Error Making Exam." ; } } xhttp . open ( "POST" , "betaFrontCurl.php" , true ) ; xhttp . setRequestHeader ( "Content-Type" , "application/x-www-form-urlencoded" ) ; xhttp . send ( addReq ) ; } examToggle ( ) ; } else { document . getElementById ( "testWork" ) . innerHTML = "All questions going to the Exam must have a valid point value. (At least 1)" ; } }
Adding Questions to the Exam and Posting It
Adding Questions to the Exam and Posting It