Skip to content

No more running out of time while submitting in MS Forms ;)

License

Notifications You must be signed in to change notification settings

Raj-Srikar/MS-Forms-Deadline-Saver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MS-Forms-Deadline-Saver

It really breaks our hearts, when we attempt the questions in a quizz which we're confident about and leave the doubtful questions for later inspection, only to realise while we're trying to come up with a satisfying answer for the doubtful questions, that we've actually ran out of time and could no longer submit the form, making all our efforts go in vain. Well, we no longer have to worry about the deadlines. This tool will help you avoid this pain by saving you from running out of deadlines while submitting in MS Forms.

Working

The tool will be triggered automatically, few seconds prior to the deadline of the MS Form. After it's on, it will identify all the required and unattempted questions in the form and randomly selects a single option of each unattempted question that is marked as "required" and submits the form by itself.

Note: The options will be selected randomly. So, obviously the answers have equal chances of being either right or wrong.

Usage

Save a bookmark in your browser with any desired name and paste the following in the URL/address section and save it:

javascript:(function () {var script = document.createElement('script');script.innerHTML='var timeOut,hrs,mins,secs,givenHr,givenMin,timeNow,given,now,x,countDown,ok,dlChk,subInps,subTime,timer,timerChk,timerlbl,timerInterval,is30=false,isOk=false;function DLcheckbox() {dlChk=document.getElementById(\'DLcheckbox\');timerLbl=document.getElementById(\'timerLbl\');subTime=document.getElementById(\'subTime\');if(!dlChk.checked){timer.innerHTML=\'-:--:--\';timerChk.click();clearTimeout(timeOut);clearInterval(timerInterval);x.disabled=true;subInps.disabled=true;ok.disabled=true;timerChk.disabled=true;subTime.style.color=\'#aaa\';ok.style.backgroundColor=\'#aaa\';timerLbl.style.color=\'#aaa\';}else{x.disabled=false;subInps.disabled=false;ok.disabled=false;timerChk.disabled=false;subTime.style.color=\'#000\';timerLbl.style.color=\'#000\';ok.style.backgroundColor=\'#03787c\';timer.style.color=\'#32cd32\';isOk=false;}}function tmrCheckbox() {timer=document.getElementById(\'timer\');if (timerChk.checked){timer.style.display=\'block\';}else{timer.style.display=\'none\';}}function runTimer() {clearInterval(timerInterval);timerInterval=setInterval(function(){timer=document.getElementById(\"timer\");var hours=Math.floor((countDown%(1000*60*60*24))/(1000*60*60));var minutes=Math.floor((countDown%(1000*60*60))/(1000*60));var seconds=Math.floor((countDown%(1000*60))/1000);if(minutes<10){minutes=\'0\'+minutes}if(seconds<10){seconds=\'0\'+seconds}var noHr=minutes+\":\"+seconds;if(hours==0){timer.innerHTML=noHr}else{timer.innerHTML=hours+\":\"+noHr}if (countDown/1000<60 && countDown/1000>0 && !is30){timer.style.color=\'red\';}else if (countDown/1000<60*5 && countDown/1000>0 && !is30){timer.style.color=\'orange\';}else if (countDown<0 || is30) {timer.style.color=\'#32cd32\';timer.innerHTML=\'-:--:--\';clearInterval(timerInterval);}else{timer.style.color=\'#32cd32\';}countDown-=1000;},1000);}function timing(){clearTimeout(timeOut);is30=false;ok.style.backgroundColor=\'#000\';givenHr=x.value.substr(0,2);givenMin=x.value.substr(3,5);hrs=new Date().getHours();mins=new Date().getMinutes();secs=new Date().getSeconds();timeNow =hrs+\":\"+mins;given=new Date(null,null,null,givenHr,givenMin-1,60-subInps.value);now=new Date(null,null,null,hrs,mins,secs);countDown=given-now;if (countDown>0 && countDown<30000){ok.style.backgroundColor=\'#03787c\';alert(\'Cannot set timer below 30 seconds. Please provide a higher value!\');isOk=false;is30=true;return 86400000;}else if (countDown>0) {return countDown;}else{ok.style.backgroundColor=\'#03787c\';alert(\'INVALID Deadline!\');clearTimeout(timeOut);isOk=false;return 86400000;}}function isAttempted(qsn) {var onPC=qsn.getElementsByClassName(\'office-form-question-choice\');var onMobile=qsn.getElementsByClassName(\'office-form-question-choice-mobile\');var options=[];let mLength=onMobile.length;let pcLength=onPC.length;if(pcLength != 0){options=onPC}else if (mLength != 0){options=onMobile}var attempted=false;if (pcLength != 0 || mLength != 0) {for (var i=0; i<options.length; i++) {var radio=options[i].getElementsByTagName(\'input\');var selected=radio[0].ariaChecked == \"true\";attempted=attempted || selected;if (attempted) {break;}}return attempted;}else{return true;}}function unattemptedQs() {var questions=document.getElementsByClassName(\'__question__\');var unattempted=[];let isReq;for (var i=0; i<questions.length; i++) {isReq=questions[i].getElementsByClassName(\'required-star\').length;if (!isAttempted(questions[i]) && isReq) {unattempted[unattempted.length]=questions[i];}}return unattempted;}function randomSelect(unattempted) {for (var i=0; i<unattempted.length; i++) {var onPC =unattempted[i].getElementsByClassName(\'office-form-question-choice\');var onMobile =unattempted[i].getElementsByClassName(\'office-form-question-choice-mobile\');var choice=[];if(onPC.length != 0){choice=onPC;}else if (onMobile.length != 0){choice=onMobile}choice[Math.floor(Math.random()*(choice.length))].click();}}function clickSubmit() {randomSelect(unattemptedQs());var button=document.getElementsByClassName(\'__submit-button__\')[0];button.click();ok.style.backgroundColor=\'#03787c\';}function setTimer() {isOk=true;timeOut=setTimeout(clickSubmit,timing());}function HTMLinjector() {var inject=\'<div style=\"padding-top:35px;position:relative;\"><div style=\"padding-left:20px;padding-right:20px;\"><div class=\"question-title-box\"><label style=\"font-weight:NORMAL;margin-left:-10px;\"><input type=\"checkbox\" id=\"DLcheckbox\" style=\"bottom:0;height:18px;margin:auto 0 auto 0;position:absolute;top:0;width:20px;cursor:pointer\" checked onclick=\"DLcheckbox()\"><div class=\"office-form-question-title\" style=\"margin-left:30px;margin-top:2px;cursor:pointer\"><span>Deadline:</span></div></label></div><div class=\"office-form-question-element\"><input type=\"time\" id=\"deadLine\" onchange=\"if(isOk){setTimer();runTimer()}\"><br><label style=\"margin:25px 0 10px;font-weight:NORMAL;\"><div style=\"font-size:14px;margin-top:1px;white-space: normal;margin-left:0px;display:inline;\" class=\"office-form-question-title\"><span id=\"subTime\">Submit before:</span></div></label><select id=\"subInps\" style=\"width:100px;margin-left:5px;border-radius:5px;\" onchange=\"if(isOk){setTimer();runTimer()}\"><option value=\"10\">10 seconds</option><option value=\"20\">20 seconds</option><option value=\"30\">30 seconds</option><option value=\"45\">45 seconds</option></select><br><label style=\"margin:10px 0\"><input type=\"checkbox\" checked=\"\" id=\"timerChk\" style=\"height:12px;position:absolute;width:20px;cursor:pointer;\" onclick=\"tmrCheckbox()\"><div style=\"margin-left:25px;cursor:pointer;font-weight:NORMAL;font-size:14px;margin-top:1px;white-space:normal;\" class=\"office-form-question-title\"><span id=\"timerLbl\">SHOW TIMER</span></div></label></div><button id=\"okButton\" class=\"light-background-button\" onclick=\"setTimer();runTimer();\">OK</button></div></div><style type=\"text/css\">#deadLine{background-color:#fff;text-align:center;font-size:15px;height:40px;padding:12px;width:15%}#okButton{margin:10px 0 0 20px;background:#03787c;color:#fff;font-size:15px;height:35px;text-align:center;width:50px}#timer{font-size:60px;top:-50px;color:#32cd32;background-color:black;right:25px;position:fixed;line-height:normal;z-index:1;padding:0 15px;border-radius:15px;font-family:monospace;}@media only screen and (max-width:375px){#deadLine{width:50%}#okButton{margin-left:0px}#timer{top:-35px;font-size:45px;right:10px;padding:0 15px;}}</style>\';document.getElementsByClassName(\"office-form-notice-container\")[0].innerHTML += inject;document.getElementsByClassName(\"__title__\")[0].innerHTML += \'<p id=\"timer\">-:--:--</p>\'}HTMLinjector();timerChk=document.getElementById(\'timerChk\');subInps=document.getElementById(\'subInps\');ok=document.getElementById(\'okButton\');x=document.getElementById(\'deadLine\');';document.body.appendChild(script);})();

After you open an MS Form, just click on this bookmark and it will create a time input field, using which you can provide the deadline time of that form and Submit before drop down menu (set to 10 seconds by default) and a new OK button, that looks similar to the submit button in the form.

On clicking the OK button, the timer will be set and the color (of this button) changes to black, indicating that the timer is active. And the timer display will start running. When few seconds (number of seconds given in the Submit before drop down menu) are remaining to hit the deadline, any one option of each required and unattempted question, will be selected randomly and the form will be submitted automatically. To disable the timer, check the checkbox besides the word 'Deadline'. To clear the timer, disable and enable the timer one time.

Timer Display

  • If the time remaining is more than 5 minutes, the color of the Timer Display will stay green.

Screenshot 2021-07-29 234234

  • If the time remaining is less than 5 minutes, the color changes to orange.

Screenshot 2021-07-29 234313

  • If the time remaining is less than 1 minute, the color changes to red.

Screenshot 2021-07-29 234338

Editing the URL of a Bookmark in different browsers (PC):

Editing the URL of a Bookmark in different browsers (Mobile):

Advantages

  • No more running out of time.
  • No more losing grades of the questions, that you know the answers of.
  • Helps you concentrate more on the questions that you might be familiar with.
  • No more worrying about the questions, you're not confident about.
  • Helps in saving time.

Note from the Developer

  • Before using this tool make sure that you know the exact deadline of the form and also that you set the timer accordingly.
  • Before completely relying upon this tool, if the form has any text fields that are mandatory to be answered before submitting, make sure you fill them all. Else, when this tool tries to submit the form, it will not get submitted.
  • If you're having issues with your internet connection and think it might take some time for the form to be submitted after clicking the submit button, you can make the tool submit the form few seconds before the deadline, by selecting your desired time (in seconds) in the "Submit before" dropdown menu.
  • If clicking on the bookmark doesn't work, type the name of the bookmark in your browser's address bar and find the bookmark in the suggestions and click on it.
  • While on PC, you can also use this tool by copying the code in submitter.js file and pasting it in the developer tools console of your browser (inspect element) and executing it.
  • Please don't deploy the tool more than once. Else, multiple clones of the tool will be created and they may missbehave. In this case, just reload the page and deploy the tool again.

Feature Updates (New --> Old)

  • (29-07-2021) Added Timer Display - Most crucial and major update so far. Now the tool can show the time remaining to submit the form as a timer, that is present on the screen all the time, even if scrolled. Can also be turned off.
  • (28-07-2021) Added "Submit before" option - Considering many students are having network issues, this feature was added so that they can make the tool submit the form, a few seconds prior to the deadline (instead of only 10 seconds), according to their internet connectivity.
  • (25-07-2021) Removed random selection - Almost removed the random selection functionality. Now the tool selects the options randomly, only for the questions that are both required and are left unattempted.
  • (25-07-2021) Optional random selection - Now it's optional to choose whether the tool should select the options randomly before submitting or not. [REMOVED in future updates]
  • (25-07-2021) Color Indicator for OK button - Color of the OK button will change to black, when the timer is active. Default button color changed to green.
  • (23-07-2021) Added Mobile compatibility - Now supported on mobile devices as well.

Bug Fixes

  • (25-07-2021) [FIXED] Old timer staying active even after new timer is set, causing the form to be submitted automatically when the clock hits the previously set deadline time.