This time I'm not here to ask for help with my code, but to ask you to judge my code. Where can I improve? What should I do better? Where did I do things wrong?
This is a quiz that I had to do as an assignment today. I'm not a professional. I'm still studying, and at the moment, I'm doing an internship.
<? session_start(); ?>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!--<script type="text/javascript" src="quiz.js" /> -->
</head>
<body>
<div class="domande">
<p>Sei ...?
</p>
<div class="option" value="yes" name="domanda0"><button>YES</button></div>
<div class="option" value="no" name="domanda0"><button>NO</button></div>
</div>
<div class="domande">
<p>Sai ...?</p>
<div class="option" value="yes" name="domanda1"><button>YES</button></div>
<div class="option" value="no" name="domanda1"><button>NO</button></div>
</div>
<div class="domande">
<p>Ricerchi...?</p>
<div class="option" value="yes" name="domanda1_1"><button>YES</button></div>
<div class="option" value="no" name="domanda1_1"><button>NO</button></div>
</div>
<div class="domande">
<p>Finita la spesa, tieni sempre gli scontrini?</p>
<div class="option" value="yes" name="domanda1_2"><button>YES</button></div>
<div class="option" value="no" name="domanda1_2"><button>NO</button></div>
</div>
<!-- domanda 2 -->
<div class="domande">
<p>Hai già pensato ..?</p>
<div class="option" value="yes" name="domanda2"><button>YES</button></div>
<div class="option" value="no" name="domanda2"><button>NO</button></div>
</div>
<div class="domande">
<p>Cerchi di...?</p>
<div class="option" value="yes" name="domanda2_1"><button>YES</button></div>
<div class="option" value="no" name="domanda2_1"><button>NO</button></div>
</div>
<div class="domande">
<p>La tua ...?</p>
<div class="option" value="yes" name="domanda2_2"><button>YES</button></div>
<div class="option" value="no" name="domanda2_2"><button>NO</button></div>
</div>
<script>
var risposte = new Object();
var $domande = $('.domande');
$domande.hide();
var totDomande = $('.domande').size();
var domandaOn = 0;
var risultato = "";
var countRisposte = 0;
$($domande.get(domandaOn)).fadeIn();
console.log(domandaOn);
$('.option').click(function(){
countRisposte = countRisposte+1;
console.log(countRisposte);
var risposta = ($(this).attr('value'));
var domanda = ($(this).attr('name'));
if(risposta == "yes"){
risultato += "1";
}
if(risposta == "no"){
risultato += "0";
}
$($domande.get(domandaOn)).fadeOut(function(){
if(domandaOn == 0){
if(risposta == "yes"){
domandaOn = 4;
}else if(risposta == "no"){
domandaOn = 1;
}
}
if((domandaOn == 4 || domandaOn == 1) && countRisposte >1){
if(risposta == "yes"){
domandaOn = domandaOn+2;
}else{
domandaOn = domandaOn+1;
}
}
if((domandaOn == 2 || domandaOn == 5) && countRisposte <3){
domandaOn = domandaOn+1;
}
if((domandaOn == 3 || domandaOn == 6) && countRisposte > 2){
console.log(domandaOn);
var resFinale = "";
console.log("risultato into 6: " +risultato);
switch (risultato)
{
case "000":
resFinale = "result1";
break;
case "001":
resFinale = "result2";
break;
case "010":
resFinale = "result3";
break;
case "011":
resFinale = "result4";
break;
case "100":
resFinale = "result5";
break;
case "101":
resFinale = "result6";
break;
case "110":
resFinale = "result7";
break;
case "111":
resFinale = "result8";
break;
}
console.log(resFinale);
alert("risultato : "+resFinale);
}else{
$($domande.get(domandaOn)).fadeIn();
}
});
});
</script>
</body>
</html>
gericht.beilage(new Sauerkraut()); gericht.beilage(new Knödel()); if (!achtung) alert("Es gibt " + gericht.bezeichnung);
. In other words, I have no idea what your code is supposed to do. \$\endgroup\$gettext
et similia to deal with i18n and l10n. \$\endgroup\$