Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Trivia en JS

Estas en el tema de Trivia en JS en el foro de Frameworks JS en Foros del Web. Amigos, como les va? soy muy nuevo en programación y estoy haciendo una trivia con un código abierto que encontré en internet. la trivia es ...
  #1 (permalink)  
Antiguo 20/11/2012, 05:29
 
Fecha de Ingreso: abril-2009
Ubicación: Buenos Aires, Argentina
Mensajes: 33
Antigüedad: 15 años
Puntos: 1
Exclamación Trivia en JS

Amigos, como les va?
soy muy nuevo en programación y estoy haciendo una trivia con un código abierto que encontré en internet.
la trivia es en php y javascript. lee un xml donde tiene todas las respuestas y datos.

El inconveniente es que la trivia recorre todas las preguntas hasta llegar al final y allí realiza el conteo y da resultados. lo que yo quisiera hacer es que directamente en cualquier pregunta, cuando un usuario responde mal vaya directamente al final.. o sea que no vaya a la siguiente pregunta sino que directamente lo de como perdido.

Como soy muy nuevo y no soy muy ducho en js no encuentro como hacer ni como identificar el lugar donde se hace esa validación

les dejo la función del js que creo que es donde se debe realizar esta validación
me ayudan?

Código Javascript:
Ver original
  1. function checkQuestion()
  2. {
  3.     //the user has selOpt selected on question curQuestion
  4.     //on the quizIndex'th quiz in quizFile
  5.    
  6.     //make sure the user selected one
  7.     if( $('.quizzy_q_opt_b:checked').length == 0 )
  8.         return;
  9.    
  10.     //unbind the click event
  11.     $(this).unbind();
  12.    
  13.     //hide the button
  14.     $('#quizzy_q' + curQuestion + '_foot_chk').fadeOut(fadeSpeed, function() {
  15.         $(this).attr('disabled', true);
  16.     });
  17.    
  18.     //put up throbber
  19.     $('#quizzy').loading(true);
  20.    
  21.     //get the explanation for this option, it will set the correctOpt variable
  22.     //parameters passed in GET:
  23.     //  _GET['quizFile']       xml file to open
  24.     //  _GET['quizIndex']      index of requested quiz in xml file
  25.     //  _GET['questNo']        question to return (first is 1)
  26.     //  _GET['selOpt']               the option for which to retrieve the explanation
  27.     $.get('quizzy/serveExplanation.php',  {quizFile: quizFile, quizIndex: quizIndex, questNo: curQuestion, selOpt: selOpt}, function(data) {
  28.        
  29.         //have the data returned by that ajax query, set the proper div info
  30.         $('#quizzy_q' + curQuestion + '_exp').html(data);
  31.         //that should have set the correctOpt and addScore variables
  32.        
  33.         //add to score
  34.         score += addScore;
  35.        
  36.         //determine if this question has partial credit
  37.         var partialCredit = false;
  38.         for(var i in optValues)
  39.             if(optValues[i] != 0 && optValues[i] != bestScore)
  40.                 partialCredit = true;
  41.            
  42.         //show the values
  43.         for( i in optValues ) {
  44.            
  45.             //if the question no partial credit, use an X or a ✓ to indicate correctness
  46.             var toWrite = optValues[i];
  47.             if(!partialCredit)
  48.                 toWrite = (optValues[i] == bestScore) ? '<img src="img/si.png">' : '<img src="img/no.png">';
  49.            
  50.             //if it was best score, use quizzy_opt_best
  51.             //in between best and worst, use quizzy_opt_mid
  52.             //or the worst, use quizzy_opt_worst
  53.             var useClass = 'quizzy_opt_worst';
  54.             if(optValues[i] == bestScore)
  55.                 useClass = 'quizzy_opt_best';
  56.             if(optValues[i] > 0 && optValues[i] < bestScore)
  57.                 useClass = 'quizzy_opt_mid';
  58.            
  59.             $('#quizzy_q' + curQuestion + '_opt' + i + '_val').html('<span class="' + useClass + '">' + toWrite + '</span>');
  60.         }
  61.         $('.quizzy_q_opt_val').fadeIn(fadeSpeed);
  62.        
  63.        
  64.         //wait slideUpWait millisec
  65.         setTimeout(function() {
  66.             //scroll up all but the selected answer and the best answer
  67.             var correctSel = '[id!=quizzy_q' + curQuestion + '_opt' + correctOpt + ']';
  68.             var pickedSel = '[id!=quizzy_q' + curQuestion + '_opt' + selOpt + ']';
  69.             if(addScore == bestScore)
  70.                 correctSel = '';
  71.             $('.quizzy_q_opt' + correctSel + pickedSel).slideUp(slideSpeed);
  72.            
  73.             //wait expFadeInWait millisec
  74.             setTimeout(function() {
  75.                
  76.                 //fade in explanation
  77.                 $('#quizzy_q' + curQuestion + '_exp').fadeIn(fadeSpeed);
  78.                
  79.                 //wait nextFadeInWait millisec
  80.                 setTimeout(function() {
  81.                    
  82.                     //fade in next button
  83.                     $('#quizzy_q' + curQuestion + '_foot_nxt').attr('disabled', false).fadeIn(fadeSpeed);
  84.                    
  85.                 }, nextFadeInWait); //wait nextFadeInWait ms to fade in the next button
  86.                
  87.             }, expFadeInWait);      //wait expFadeInWait ms to fade in explanation
  88.            
  89.         }, slideUpWait);            //wait scrollupwait ms to scroll up all but best answer
  90.        
  91.     });
  92. }
  #2 (permalink)  
Antiguo 20/11/2012, 15:18
Avatar de llorcasantana  
Fecha de Ingreso: octubre-2012
Mensajes: 45
Antigüedad: 11 años, 5 meses
Puntos: 2
Respuesta: Trivia en JS

guarda las respuestas en variables y pasalas de formulario en formulario con el parametro get. de lo contrario, has una tabla con las respuestas de cada usuario. Luego al final la sacas y tu decides si todo esta bien o si hay algo mal. espero y te sirva
__________________
Si crees que estuvo bueno el post, no crees que mereceria un poco de karma?

Etiquetas: ajax, juego, questionsphp, trivia
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 09:51.