Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.1 kB
1
Indexable
Never
//For Getting Quiz Question
var textarea = document.querySelectorAll("textarea");

for(var i = 0; i<textarea.length; i++){
    if(textarea[i].getAttribute("style").includes("border-left:")){
        var quizQuestion = textarea[i].innerHTML;
        break;
    }else{

    }
}


//Getting quiz options
var options = [];
for(var i = 0; i<=3; i++){
    options[i] = document.getElementById("lblAnswer"+i).innerHTML;
    if(options[i] == "null" || options[i] == "undefined"){
        options[i] = "null";
    }
}



//Getting Quiz timer
var timer = document.getElementById("lblTime").innerText;


// [{
//     mcqsQuestion:"I am question!",
//     timer:"I am Quiz Timer",
//     options:{
//         1:"option1",
//         2:"option2",
//         3:"option3"
//     }
// }]


var output = `[{
    mcqsQuestion:"`+quizQuestion+`",
    timer:"`+timer+`",
    options:{
        1:"`+options[0]+`",
        2:"`+options[1]+`",
        3:"`+options[2]+`",
        4:"`+options[3]+`
    }
}]`;





console.log(output);