Newer
Older
ournorth2021 / api / cargar_pregunta_desafio.php
LuisOlaya on 8 Apr 2021 5 KB primer
<?php        
	include("../app/models/connect.php");

    $id_user = $_POST["id_user"];
    $dia = $_POST["dia"];

    $siguiente = 1;
    $queryValidar = mysqli_query($connect,"SELECT * FROM Desafio_Respuestas WHERE dia = '".$dia."' AND id_asistente = '".$id_user."' ORDER BY orden DESC ");
    if($queryValidar->num_rows > 0){
        
        $dataValidar = mysqli_fetch_array($queryValidar);
        $siguiente = $dataValidar["orden"]+1;
    } 

    $queryPregunta = mysqli_query($connect,"SELECT * FROM Desafio_Preguntas WHERE dia = '".$dia."' AND orden = '".$siguiente."' ");
    if($queryPregunta->num_rows > 0){
        
        $dataPregunta = mysqli_fetch_array($queryPregunta);

?>


    


    <div class="col-md-12">
        <h2>Pregunta <?php echo $dataPregunta["orden"] ?> - día <?php echo $dia; ?></h2>
        <div id="hms" style=" font-size: 30px; color: #f3e745;"></div>
    </div>
                    
    <div class="col-md-12" style="margin-bottom: 30px; margin-top: 15px">
        <?php echo $dataPregunta["pregunta"] ?>
        <input type="hidden" id="pregunta" value="<?php echo $dataPregunta["id"] ?>">
        <input type="hidden" id="cr" value="<?php echo $dataPregunta["correcta"]; ?>">
    </div>
                    
    <div class="col-md-6">
                        <table class="opciones" onClick="GuardarRespuesta(1, this)" id="opt_1">
                            <tr>
                                <td width="80" style="font-size: 50px; text-align: center;">
                                    <b>A.</b>
                                </td>
                                <td style="padding: 15px; color: #000000">
                                    <?php echo $dataPregunta["opc_1"] ?>
                                </td>
                            </tr>
                        </table>
    </div>
                    
    <div class="col-md-6">
                        <table class="opciones" onClick="GuardarRespuesta(2, this)" id="opt_2">
                            <tr>
                                <td width="80" style="font-size: 50px; text-align: center;">
                                    <b>B.</b>
                                </td>
                                <td style="padding: 15px; color: #000000">
                                    <?php echo $dataPregunta["opc_2"] ?>
                                </td>
                            </tr>
                        </table>
    </div>
                    
    <div class="col-md-6">
                        <table class="opciones" onClick="GuardarRespuesta(3, this )" id="opt_3">
                            <tr>
                                <td width="80" style="font-size: 50px; text-align: center;">
                                    <b>C.</b>
                                </td>
                                <td style="padding: 15px; color: #000000">
                                    <?php echo $dataPregunta["opc_3"] ?>
                                </td>
                            </tr>
                        </table>
    </div>
                    
    <div class="col-md-6">
                        <table class="opciones" onClick="GuardarRespuesta(4, this )" id="opt_4">
                            <tr>
                                <td width="80" style="font-size: 50px; text-align: center;">
                                    <b>D.</b>
                                </td>
                                <td style="padding: 15px; color: #000000">
                                    <?php echo $dataPregunta["opc_4"] ?>
                                </td>
                            </tr>
                        </table>
    </div>

    <script>
        cronometrar();
    </script>

<?php } else {?>

    <?php
        $queryPuntaje = mysqli_query($connect,"SELECT SUM(puntaje) FROM Desafio_Respuestas WHERE dia = '".$dia."' AND id_asistente = '".$id_user."' ");
        $dataPuntaje = mysqli_fetch_array($queryPuntaje);
    ?>
    <div class="col-md-6">
        <img src="<?php echo $url; ?>/img/desafio/logo_desafio.png" style=" width: 80%; max-width: 390px;"><br>
    </div>

    <div class="col-md-6">
        <div style="border-radius: 20px; border: 2px solid #ffffff; padding: 30px 10px; font-size: 30px; margin-top: 30px;">
            Usted ha conseguido<br>
            <div style="font-size: 50px"><?php echo $dataPuntaje["SUM(puntaje)"]; ?> Puntos</div>
            <img src="<?php echo $url; ?>/img/desafio/bt_volver.png" width="200" style="padding: 10px" onClick="Home()" class="bt_interface">
            <br>
            <?php 
                if($dia == 1){
                    echo '
                    <a href="'.$url.'/desafio_ournorth/2">
                        <img src="'.$url.'/img/desafio/bt_dia_2.png" width="200" style="padding: 10px" class="bt_interface" >
                    </a>
                    ';
                }
        
                if($dia == 2){
                    echo '
                    <a href="'.$url.'/desafio_ournorth/3">
                        <img src="'.$url.'/img/desafio/bt_dia_3.png" width="200" style="padding: 10px" class="bt_interface" >
                    </a>
                    ';
                }
            ?>
        </div>
    </div>
<?php
    }
?>