Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
how can i allow my code to autosave the selcted answers if the given time is over and the exminer is not submited the answears

in my quiz Django app the quot ions are all loaded in one page and it works when the student start the exam the time is count down and when it is over it closed the exam page and redirect to the result page and if the time is over with out submission the current code is return the previous result or zero but what i want is to track of the selected answers(if the student selected some answers but not submitted) it should be evaluated and give that result!! here is my java script code

<script> 
  
    function saveAns(){  

        var ele = document.getElementsByTagName('input'); 
        for(i = 0; i < ele.length; i++) { 
            if(ele[i].type="radio") { 
                if(ele[i].checked){        
                  setCookie(ele[i].name,ele[i].value,3)
                }
            } 
        } 
          
    }
    
    function setCookie(cname, cvalue, exdays) {
  var d = new Date();
  d.setTime(d.getTime() + (exdays*24*60*60*1000));
  var expires = "expires="+ d.toUTCString();
  document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
window.onload = function begin(){
document.getElementById('timer').innerHTML =
  {{quiz.time_limit_mins}} + ":" + 00;
startTimer();
}

function startTimer() {
  var presentTime = document.getElementById('timer').innerHTML;
  var timeArray = presentTime.split(/[:]+/);
  var m = timeArray[0];
  var s = checkSecond((timeArray[1] - 1));
  if(s==59){m=m-1}
  if(m<0){
    document.getElementById('quiz').submit();
  }
  document.getElementById('timer').innerHTML =
    m + ":" + s;
  setTimeout(startTimer, 1000);
}

function checkSecond(sec) {
  if (sec < 10 && sec >= 0) {sec = "0" + sec}; // add zero in front of numbers < 10
  if (sec < 0) {sec = "59"};
  return sec;
}

</script> 
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda