Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I managed to solve the QwO issue. #7

Open
WinnaXL opened this issue Apr 19, 2024 · 1 comment
Open

I managed to solve the QwO issue. #7

WinnaXL opened this issue Apr 19, 2024 · 1 comment

Comments

@WinnaXL
Copy link

WinnaXL commented Apr 19, 2024

If anyone encountered the QwO problem (with questions and options request), here are the solutions:
getGF.js:
First, open the file getGF.js, then change this line of code:

if (typeof element[4][0] !== 'undefined' || element[4][0] !== null) {

to:

if (element[4] !== null && typeof element[4][0] !== 'undefined') {

Then open helpers.js

helpers.js:
In the helpers.js file, find the line:

function convertArrytoIncVotes (arr) {
const initialArray = arr;
let qOV = [];
qOV = initialArray.map(qObj => {
let options = []
options = qObj.ops.forEach(opt => {
return {
option: opt,
upVotes: 0,
downVotes: 0,
}
})
return {
q: qObj.q,
ops: options
}
})
}

Replace it with:

function convertArrytoIncVotes (arr) {
const initialArray = arr;
let qOV = initialArray.map(qObj => {
let options = qObj.ops.map(opt => {
return {
option: opt,
upVotes: 0,
downVotes: 0,
}
});
return {
q: qObj.q,
ops: options
}
});
return qOV;
}

Then find this line of code:

function printAllInConsole(arr, type) {
if (type === "onlyQ") {
arr.forEach((element, index) => {
console.log(Q.${index+1}, JSON.stringify(element,undefined,2))
console.log("")
console.log("------------------------------------------")
});
} else if (type === "qWithO") {
arr.forEach((element, index) => {
console.log(Q.${index+1}, JSON.stringify(element.q,undefined,2))
element.ops.forEach((el, index) => {
const letter = String.fromCharCode(index + 97)
console.log(${letter}) ,el)
})
console.log("")
console.log("------------------------------------------")
});
} else {
console.log("The array you passed is,", JSON.stringify(arr, undefined, 2))
console.log("Invalid type passed")
console.log("The types are:")
console.log("onlyQs -----> When the array has only Questions");
console.log("qWithO -----> When the array passed has Questions and options")
}
}

Replace it with:

function printAllInConsole(arr, type) {
if (!Array.isArray(arr)) {
console.log("The array you passed is not valid.");
return;
}

if (type === "onlyQ") {
    arr.forEach((element, index) => {
        console.log(`Q.${index+1}`, JSON.stringify(element, undefined, 2));
        console.log("");
        console.log("------------------------------------------");
    });
} else if (type === "qWithO") {
    arr.forEach((element, index) => {
        console.log(`Q.${index+1}`, JSON.stringify(element.q, undefined, 2));
        if (Array.isArray(element.ops)) {
            element.ops.forEach((el, index) => {
                if (Array.isArray(el)) {
                    el.forEach((opt, idx) => {
                        const letter = String.fromCharCode(idx + 97);
                        console.log(`${letter}) `, opt);
                    });
                } else {
                    const letter = String.fromCharCode(index + 97);
                    console.log(`${letter}) `, el);
                }
            });
        } else {
            console.log("Options array is not valid.");
        }
        console.log("");
        console.log("------------------------------------------");
    });
} else {
    console.log("Invalid type passed.");
    console.log("The types are:");
    console.log("onlyQs -----> When the array has only Questions");
    console.log("qWithO -----> When the array passed has Questions and options");
} 

}

That's it! You can now run the command "node getGF.js QwO"
btw I'm not sure what to do for Microsoft Forms.
I don't guarantee that this will help you specifically!

@WinnaXL
Copy link
Author

WinnaXL commented Apr 19, 2024

I don't know how it works, but it worked for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant