function query() {
    //document.getElementById("version").innerHTML = "testing for cache";

    var xhttp = new XMLHttpRequest();
    var qRequest = "query=GetQuestions";
    var kw = document.getElementById("s").value;
    var tpc = document.getElementById("t").value;
    var dif = document.getElementById("d").value;

    if(kw !== "") {
        qRequest += "&Question=" + kw;
    }
    if(tpc !== "") {
        qRequest += "&Topic=" + tpc;
    }
    if(dif !== "") {
        qRequest += "&Difficulty=" + dif;
    }
    xhttp.onreadystatechange = function() {
        if(this.readyState == 4 && this.status == 200) {
            var JSONresults = this.responseText;
            var resultsObj = JSON.parse(JSONresults);
            var searchResults = resultsObj.Questions;
            var queryTable = document.getElementById("qResults");
            document.getElementById("testWork").innerHTML = "";

            // Clears the table to receive the other questions
            while(queryTable.children.length > 0) {
                queryTable.removeChild(queryTable.firstChild);
            }

            for(q = 0; q < searchResults.length-1; q++) {
                
                // All Info
                var questionName = searchResults[q].Question;
                var questionTopic = searchResults[q].Topic;
                var questionDifficulty = searchResults[q].Difficulty;
                var questionID = searchResults[q].ID;
                var fName = searchResults[q].FunctionName;
                var questionTC = searchResults[q].TestCases;
                var questionNoNo = searchResults[q].Constraints;
                console.log(questionTC);
                console.log(questionNoNo);

                // Row
                var row = document.createElement("TR");
                row.id = questionID;

                // ID Column
                var rID = document.createElement("TD");
                var rIDContent = document.createTextNode(questionID);
                rID.appendChild(rIDContent);
                row.appendChild(rID);

                // Question Column
                var rName = document.createElement("TD");
                var rNameCollapse = document.createElement("BUTTON");
                rNameCollapse.className = "collapse";
                var rNameLabel = document.createTextNode(fName);
                rNameCollapse.appendChild(rNameLabel);
                rName.appendChild(rNameCollapse);

                // Full Question Info in Question Column
                var rNameContainer = document.createElement("DIV");
                rNameContainer.className = "content";
                var textSection = document.createElement("P");
                var rNameContent = document.createTextNode(questionName);
                textSection.appendChild(rNameContent);
                rNameContainer.appendChild(textSection);  

                var inSection = document.createElement("DIV");
                var inString = "Input: " + JSON.stringify(questionTC.Input);
                var inText = document.createTextNode(inString);
                inSection.appendChild(inText);
                rNameContainer.appendChild(inSection);

                var outSection = document.createElement("DIV");
                var outString = "Output: " + JSON.stringify(questionTC.Output);
                var outText = document.createTextNode(outString);
                outSection.appendChild(outText);
                rNameContainer.appendChild(outSection);

                var constraintSection = document.createElement("DIV");
                var constraintString = "";
                if(questionNoNo.for) {
                    constraintString += "For Loop";
                }
                if(questionNoNo.print) {
                    if(constraintString.length > 0) {
                        constraintString += ", ";
                    }
                    constraintString += "Print Statement";
                }
                if(questionNoNo.while) {
                    if(constraintString.length > 0) {
                        constraintString += ", ";
                    }
                    constraintString += "While Loop";
                }  
                var constraintText = document.createTextNode("Must Use: " + constraintString);
                constraintSection.appendChild(constraintText);
                rNameContainer.appendChild(constraintSection);

                rName.appendChild(rNameContainer);
                row.appendChild(rName);

                // Topic Column
                var rTopic = document.createElement("TD");
                var rTopicContent = document.createTextNode(questionTopic);
                rTopic.appendChild(rTopicContent);
                row.appendChild(rTopic);

                // Difficulty Column
                var rDifficulty = document.createElement("TD");
                var rDifficultyContent = document.createTextNode(questionDifficulty);
                rDifficulty.appendChild(rDifficultyContent);
                row.appendChild(rDifficulty);

                // Points Column
                var rPoints = document.createElement("TD");
                var rPointsBox = document.createElement("INPUT");
                rPointsBox.type = "text";
                rPointsBox.style.width = "1rem";
                rPoints.appendChild(rPointsBox);
                rPoints.style.display = "none";
                row.appendChild(rPoints);

                // Delete Button
                var delQ = document.createElement("TD");
                var delQBut = document.createElement("BUTTON");
                var delQSymbol = document.createTextNode("X");
                delQBut.appendChild(delQSymbol);
                delQBut.className = "rm";
                delQBut.setAttribute("onClick", "delQuestion()");
                delQ.appendChild(delQBut);
                row.appendChild(delQ); 

                queryTable.appendChild(row);
            }
            var coll = document.getElementsByClassName("collapse");
            for(let bar of coll) {
                bar.addEventListener("click", function() {
                    this.classList.toggle("open");
                    var content = this.nextElementSibling;
                    if(content.style.maxHeight) {
                        content.style.maxHeight = null;
                    } else {
                        content.style.maxHeight = content.scrollHeight + "px";
                    }
                });
            }
        }
    }
    xhttp.open("POST","betaFrontCurl.php", true);
    xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xhttp.send(qRequest);
}
// For searching through the question bank

For searching through the question bank
For searching through the question bank
function query() {
    var xhttp = new XMLHttpRequest();
    var qRequest = "query=GetQuestions";
    var kw = document.getElementById("s").value;
    var tpc = document.getElementById("t").value;
    var dif = document.getElementById("d").value;
    if(kw !== "") {
        qRequest += "&Question=" + kw;
    }
    if(tpc !== "") {
        qRequest += "&Topic=" + tpc;
    }
    if(dif !== "") {
        qRequest += "&Difficulty=" + dif;
    }
    xhttp.onreadystatechange = function() {
        if(this.readyState == 4 && this.status == 200) {
            var JSONresults = this.responseText;
            var resultsObj = JSON.parse(JSONresults);
            var searchResults = resultsObj.Questions;
            var queryTable = document.getElementById("qResults");
            document.getElementById("testWork").innerHTML = "";
            while(queryTable.children.length > 0) {
                queryTable.removeChild(queryTable.firstChild);
            }
            for(q = 0; q < searchResults.length-1; q++) {
                var questionName = searchResults[q].Question;
                var questionTopic = searchResults[q].Topic;
                var questionDifficulty = searchResults[q].Difficulty;
                var questionID = searchResults[q].ID;
                var fName = searchResults[q].FunctionName;
                var questionTC = searchResults[q].TestCases;
                var questionNoNo = searchResults[q].Constraints;
                console.log(questionTC);
                console.log(questionNoNo);
                var row = document.createElement("TR");
                row.id = questionID;
                var rID = document.createElement("TD");
                var rIDContent = document.createTextNode(questionID);
                rID.appendChild(rIDContent);
                row.appendChild(rID);
                var rName = document.createElement("TD");
                var rNameCollapse = document.createElement("BUTTON");
                rNameCollapse.className = "collapse";
                var rNameLabel = document.createTextNode(fName);
                rNameCollapse.appendChild(rNameLabel);
                rName.appendChild(rNameCollapse);
                var rNameContainer = document.createElement("DIV");
                rNameContainer.className = "content";
                var textSection = document.createElement("P");
                var rNameContent = document.createTextNode(questionName);
                textSection.appendChild(rNameContent);
                rNameContainer.appendChild(textSection);  
                var inSection = document.createElement("DIV");
                var inString = "Input: " + JSON.stringify(questionTC.Input);
                var inText = document.createTextNode(inString);
                inSection.appendChild(inText);
                rNameContainer.appendChild(inSection);
                var outSection = document.createElement("DIV");
                var outString = "Output: " + JSON.stringify(questionTC.Output);
                var outText = document.createTextNode(outString);
                outSection.appendChild(outText);
                rNameContainer.appendChild(outSection);
                var constraintSection = document.createElement("DIV");
                var constraintString = "";
                if(questionNoNo.for) {
                    constraintString += "For Loop";
                }
                if(questionNoNo.print) {
                    if(constraintString.length > 0) {
                        constraintString += ", ";
                    }
                    constraintString += "Print Statement";
                }
                if(questionNoNo.while) {
                    if(constraintString.length > 0) {
                        constraintString += ", ";
                    }
                    constraintString += "While Loop";
                }  
                var constraintText = document.createTextNode("Must Use: " + constraintString);
                constraintSection.appendChild(constraintText);
                rNameContainer.appendChild(constraintSection);
                rName.appendChild(rNameContainer);
                row.appendChild(rName);
                var rTopic = document.createElement("TD");
                var rTopicContent = document.createTextNode(questionTopic);
                rTopic.appendChild(rTopicContent);
                row.appendChild(rTopic);
                var rDifficulty = document.createElement("TD");
                var rDifficultyContent = document.createTextNode(questionDifficulty);
                rDifficulty.appendChild(rDifficultyContent);
                row.appendChild(rDifficulty);
                var rPoints = document.createElement("TD");
                var rPointsBox = document.createElement("INPUT");
                rPointsBox.type = "text";
                rPointsBox.style.width = "1rem";
                rPoints.appendChild(rPointsBox);
                rPoints.style.display = "none";
                row.appendChild(rPoints);
                var delQ = document.createElement("TD");
                var delQBut = document.createElement("BUTTON");
                var delQSymbol = document.createTextNode("X");
                delQBut.appendChild(delQSymbol);
                delQBut.className = "rm";
                delQBut.setAttribute("onClick", "delQuestion()");
                delQ.appendChild(delQBut);
                row.appendChild(delQ); 
                queryTable.appendChild(row);
            }
            var coll = document.getElementsByClassName("collapse");
            for(let bar of coll) {
                bar.addEventListener("click", function() {
                    this.classList.toggle("open");
                    var content = this.nextElementSibling;
                    if(content.style.maxHeight) {
                        content.style.maxHeight = null;
                    } else {
                        content.style.maxHeight = content.scrollHeight + "px";
                    }
                });
            }
        }
    }
    xhttp.open("POST","betaFrontCurl.php", true);
    xhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    xhttp.send(qRequest);
}
function query ( ) { var xhttp = new XMLHttpRequest ( ) ; var qRequest = "query=GetQuestions" ; var kw = document . getElementById ( "s" ) . value ; var tpc = document . getElementById ( "t" ) . value ; var dif = document . getElementById ( "d" ) . value ; if ( kw !== "" ) { qRequest += "&Question=" + kw ; } if ( tpc !== "" ) { qRequest += "&Topic=" + tpc ; } if ( dif !== "" ) { qRequest += "&Difficulty=" + dif ; } xhttp . onreadystatechange = function ( ) { if ( this . readyState == 4 && this . status == 200 ) { var JSONresults = this . responseText ; var resultsObj = JSON . parse ( JSONresults ) ; var searchResults = resultsObj . Questions ; var queryTable = document . getElementById ( "qResults" ) ; document . getElementById ( "testWork" ) . innerHTML = "" ; while ( queryTable . children . length > 0 ) { queryTable . removeChild ( queryTable . firstChild ) ; } for ( q = 0 ; q < searchResults . length - 1 ; q ++ ) { var questionName = searchResults [ q ] . Question ; var questionTopic = searchResults [ q ] . Topic ; var questionDifficulty = searchResults [ q ] . Difficulty ; var questionID = searchResults [ q ] . ID ; var fName = searchResults [ q ] . FunctionName ; var questionTC = searchResults [ q ] . TestCases ; var questionNoNo = searchResults [ q ] . Constraints ; console . log ( questionTC ) ; console . log ( questionNoNo ) ; var row = document . createElement ( "TR" ) ; row . id = questionID ; var rID = document . createElement ( "TD" ) ; var rIDContent = document . createTextNode ( questionID ) ; rID . appendChild ( rIDContent ) ; row . appendChild ( rID ) ; var rName = document . createElement ( "TD" ) ; var rNameCollapse = document . createElement ( "BUTTON" ) ; rNameCollapse . className = "collapse" ; var rNameLabel = document . createTextNode ( fName ) ; rNameCollapse . appendChild ( rNameLabel ) ; rName . appendChild ( rNameCollapse ) ; var rNameContainer = document . createElement ( "DIV" ) ; rNameContainer . className = "content" ; var textSection = document . createElement ( "P" ) ; var rNameContent = document . createTextNode ( questionName ) ; textSection . appendChild ( rNameContent ) ; rNameContainer . appendChild ( textSection ) ; var inSection = document . createElement ( "DIV" ) ; var inString = "Input: " + JSON . stringify ( questionTC . Input ) ; var inText = document . createTextNode ( inString ) ; inSection . appendChild ( inText ) ; rNameContainer . appendChild ( inSection ) ; var outSection = document . createElement ( "DIV" ) ; var outString = "Output: " + JSON . stringify ( questionTC . Output ) ; var outText = document . createTextNode ( outString ) ; outSection . appendChild ( outText ) ; rNameContainer . appendChild ( outSection ) ; var constraintSection = document . createElement ( "DIV" ) ; var constraintString = "" ; if ( questionNoNo . for ) { constraintString += "For Loop" ; } if ( questionNoNo . print ) { if ( constraintString . length > 0 ) { constraintString += ", " ; } constraintString += "Print Statement" ; } if ( questionNoNo . while ) { if ( constraintString . length > 0 ) { constraintString += ", " ; } constraintString += "While Loop" ; } var constraintText = document . createTextNode ( "Must Use: " + constraintString ) ; constraintSection . appendChild ( constraintText ) ; rNameContainer . appendChild ( constraintSection ) ; rName . appendChild ( rNameContainer ) ; row . appendChild ( rName ) ; var rTopic = document . createElement ( "TD" ) ; var rTopicContent = document . createTextNode ( questionTopic ) ; rTopic . appendChild ( rTopicContent ) ; row . appendChild ( rTopic ) ; var rDifficulty = document . createElement ( "TD" ) ; var rDifficultyContent = document . createTextNode ( questionDifficulty ) ; rDifficulty . appendChild ( rDifficultyContent ) ; row . appendChild ( rDifficulty ) ; var rPoints = document . createElement ( "TD" ) ; var rPointsBox = document . createElement ( "INPUT" ) ; rPointsBox . type = "text" ; rPointsBox . style . width = "1rem" ; rPoints . appendChild ( rPointsBox ) ; rPoints . style . display = "none" ; row . appendChild ( rPoints ) ; var delQ = document . createElement ( "TD" ) ; var delQBut = document . createElement ( "BUTTON" ) ; var delQSymbol = document . createTextNode ( "X" ) ; delQBut . appendChild ( delQSymbol ) ; delQBut . className = "rm" ; delQBut . setAttribute ( "onClick" , "delQuestion()" ) ; delQ . appendChild ( delQBut ) ; row . appendChild ( delQ ) ; queryTable . appendChild ( row ) ; } var coll = document . getElementsByClassName ( "collapse" ) ; for ( let bar of coll ) { bar . addEventListener ( "click" , function ( ) { this . classList . toggle ( "open" ) ; var content = this . nextElementSibling ; if ( content . style . maxHeight ) { content . style . maxHeight = null ; } else { content . style . maxHeight = content . scrollHeight + "px" ; } } ) ; } } } xhttp . open ( "POST" , "betaFrontCurl.php" , true ) ; xhttp . setRequestHeader ( "Content-Type" , "application/x-www-form-urlencoded" ) ; xhttp . send ( qRequest ) ; }
For searching through the question bank
For searching through the question bank
//document.getElementById("version").innerHTML = "testing for cache";
 // Clears the table to receive the other questions
 // All Info
 // Row
 // ID Column
 // Question Column
 // Full Question Info in Question Column
 // Topic Column
 // Difficulty Column
 // Points Column
 // Delete Button
