Coder Social home page Coder Social logo

m3z0diac / 5sauditer Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 21.83 MB

web application that making Audits of 5S methods automated ans more easier and analyzable for Marines performance teams in Morocco

PHP 40.87% CSS 1.10% JavaScript 6.09% Blade 51.07% Shell 0.86%

5sauditer's Introduction

5SAuditer

web application that making Audits of 5S methods automated ans more easier and analyzable for Marines performance teams in Morocco

5sauditer's People

Contributors

m3z0diac avatar

Stargazers

 avatar  avatar

Watchers

 avatar

5sauditer's Issues

Some problems to solve

Problems

  • The checkslength variable is defined outside of the onload function, but it is only incremented and used within the onchange event listener function that is defined within the onload function. This means that checkslength will not be reset to 0 when the page is reloaded or navigated to, which could cause problems if the user tries to re-take the quiz.
  • The checkslength variable is incremented by 1 each time a checkbox is checked, but it is not decremented when a checkbox is unchecked. This means that checkslength will keep increasing every time a checkbox is checked, even if the user goes back and changes their answers.
  • The checks variable is defined as a list of elements with the class "form-check-input", but it is not clear from the code where these elements come from or what they represent. It is also not clear how many checkboxes there are in total or how they are organized on the page. This could make it difficult to debug any issues that might arise.
  • The code defines separate event listener functions for each group of checkboxes, which could make the code more difficult to maintain if the number of groups or the structure of the form changes. It might be more efficient to define a single event listener function that can be used for all of the checkboxes, rather than repeating the same code multiple times.
  • The code does not seem to have any error handling or validation in place to ensure that the user has correctly answered all of the questions before enabling the "nextbtn" element. It is possible that the user could accidentally or intentionally skip questions and still be able to submit the form.

How can you fix these problems?

  • To reset the checkslength variable to 0 when the page is reloaded or navigated to, you could move the declaration and definition of the checkslength variable inside the onload function, like this:
window.onload = function () {
  var checkslength = 0;
  // rest of the code goes here
};
  • To ensure that the checkslength variable is correctly updated when a checkbox is checked or unchecked, you could modify the onchange event listener function to increment checkslength when a checkbox is checked and decrement it when a checkbox is unchecked, like this:
for(var c =0; c < checks.length; c++) {
  checks[c].onchange = function() {
    if(this.checked) {
      checkslength++;
    } else {
      checkslength--;
    }
    console.log(checkslength);
    if(checkslength == 33) {
      btn.disabled = false;
    } else {
      btn.disabled = true;
    }
  }
}
  • To make the code more efficient and easier to maintain, you could consider refactoring it to use a single event listener function that can be used for all of the checkboxes, rather than defining separate functions for each group of checkboxes. Here is an example of how you might do this:
window.onload = function () {
  var chks = document.querySelectorAll('.form-check-input');
  for (var i = 0; i < chks.length; i++) {
    chks[i].onclick = function () {
      for (var j = 0; j < chks.length; j++) {
        if (chks[j] != this && this.checked) {
          chks[j].checked = false;
        }
      }
    };
  }
};
  • To ensure that the user has correctly answered all of the questions before enabling the "nextbtn" element, you could add some additional validation logic to the onchange event listener function. For example, you could check that each checkbox has been checked before enabling the "nextbtn" element, like this:
for(var c =0; c < checks.length; c++) {
  checks[c].onchange = function() {
    var allChecked = true;
    for (var i = 0; i < checks.length; i++) {
      if (!checks[i].checked) {
        allChecked = false;
        break;
      }
    }
    if (allChecked) {
      btn.disabled = false;
    } else {
      btn.disabled = true;
    }
  }
}

(btw had chi li banli had sa3a + good luck bro <3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.