Skip to content

Instantly share code, notes, and snippets.

@afzafri
Last active March 10, 2018 14:00
Show Gist options
  • Save afzafri/a90f9b9141d7a939ebf754aebe953479 to your computer and use it in GitHub Desktop.
Save afzafri/a90f9b9141d7a939ebf754aebe953479 to your computer and use it in GitHub Desktop.
Latest i-learn v3.0 UiTM Entrance and Exit Survey autofill form
// Entrance Exit survey autofill form script
// Usage: copy the scripts, go to the Entrance/Exit page, press F12 (open console), paste the code and enter
console.log("Entrance Exit survey autofill form script - Afif Zafri");
var msg = "Choose option: \n" +
"(1) - Entrance Survey \n" +
"(2) - Exit Survey \n";
var opt = prompt(msg);
function autoSurvey(q1, q2)
{
// get number of row, which is number of questions
var table = document.getElementsByTagName('table');
var row = table[0].getElementsByTagName('tr');
var numQ = row.length - 2;
// loop all questions
for(y=0; y<numQ; y++)
{
// get all radios
var questionNo = document.getElementsByName('data['+y+'][check]');
// generate random number,
// then check if the number is odd or even for random check the input
var randnum = Math.floor(Math.random() * (51 - 1 + 1)) + 1;
if(randnum % 2 == 0)
questionNo[q1].checked=true
else
questionNo[q2].checked=true
}
// submit form
document.forms[0].submit();
}
if(parseInt(opt) == 1)
{
console.log("Performing entrance survey...");
autoSurvey(1, 0);
}
else if(parseInt(opt) == 2)
{
console.log("Performing exit survey...");
autoSurvey(4, 3);
}
else
{
alert("Please enter valid option");
}
console.log("Entrance Exit survey autofill form script - Afif Zafri");var msg="Choose option: \n(1) - Entrance Survey \n(2) - Exit Survey \n",opt=prompt(msg);function autoSurvey(e,t){var o=document.getElementsByTagName("table")[0].getElementsByTagName("tr").length-2;for(y=0;y<o;y++){var r=document.getElementsByName("data["+y+"][check]");(Math.floor(51*Math.random())+1)%2==0?r[e].checked=!0:r[t].checked=!0}document.forms[0].submit()}1==parseInt(opt)?(console.log("Performing entrance survey..."),autoSurvey(1,0)):2==parseInt(opt)?(console.log("Performing exit survey..."),autoSurvey(4,3)):alert("Please enter valid option");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment