Newer
Older
ournorth2021 / api / ranking_trip.php
LuisOlaya on 23 Apr 2021 17 KB boto movil
<?php        
	include("../app/models/connect.php");
?>

<div class="col-md-12">



        <?php echo $rersp; ?>

        <div class="row">

            <div class="col-md-12" align="center">
                <h1 style="color: #ffffff;">RANKING</h1>

            </div>

            <div class="col-md-12" align="center" style="color: #fff; ">

                <h3>Virtual Trip</h3>
                <hr>
                <div class="table-responsive" style="background-color: #fff; border-radius: 12px; overflow: hidden; padding: 5px 30px;">


                    <table class="table">
                        <thead>
                            <tr>
                                <th scope="col">Posición</th>
                                <th scope="col">Equipo</th>
                                <th scope="col">Puntaje</th>
                                <th scope="col">Tiempo</th>
                                <th scope="col" style="width:150px">Progreso</th>
                                <th scope="col">P1</th>
                                <th scope="col">P2</th>
                                <th scope="col">P3</th>
                                <th scope="col">P4</th>
                                <th scope="col">P5</th>
                                <th scope="col">P6</th>
                                <th scope="col">P7</th>
                                <th scope="col">P8</th>
                                <th scope="col">P9</th>
                                <th scope="col">P10</th>
                                <th scope="col">P11</th>
                                <th scope="col">P12</th>
                                <th scope="col">P13</th>
                                <th scope="col">P14</th>
                                <th scope="col">P15</th>
                                <th scope="col">Imágenes</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php

                            $count = 1;
                            $q = "select distinct(rm.equipo),
                                    subtime((select hora_fin from respuesta_map as r where r.equipo = rm.equipo order by r.juego_id DESC limit 1),
                                    (select hora_inicia from respuesta_map as r where r.equipo = rm.equipo order by r.juego_id limit 1)) as tiempo,
                                    (select sum(r.puntaje) from respuesta_map as r where r.equipo=rm.equipo) as puntaje,
                                    obtain_questions(rm.equipo, 1) 'pregunta1',
                                    obtain_questions(rm.equipo, 2) 'pregunta2',
                                    obtain_questions(rm.equipo, 3) 'pregunta3',
                                    obtain_questions(rm.equipo, 4) 'pregunta4',
                                    obtain_questions(rm.equipo, 5) 'pregunta5',
                                    obtain_questions(rm.equipo, 6) 'pregunta6',
                                    obtain_questions(rm.equipo, 7) 'pregunta7',
                                    obtain_questions(rm.equipo, 8) 'pregunta8',
                                    obtain_questions(rm.equipo, 9) 'pregunta9',
                                    obtain_questions(rm.equipo, 10) 'pregunta10',
                                    obtain_questions(rm.equipo, 11) 'pregunta11',
                                    obtain_questions(rm.equipo, 12) 'pregunta12',
                                    obtain_questions(rm.equipo, 13) 'pregunta13',
                                    obtain_questions(rm.equipo, 14) 'pregunta14',
                                    obtain_questions(rm.equipo, 15) 'pregunta15'
                            from respuesta_map as rm
                            where rm.equipo <> ''
                            order by 3 DESC,2";
                            $queryR1 = mysqli_query($connect, $q);
                            while ($dataR1 = mysqli_fetch_array($queryR1)) {
                                $suma = $dataR1["pregunta1"]+$dataR1["pregunta2"]+$dataR1["pregunta3"]+$dataR1["pregunta4"]+$dataR1["pregunta5"]+$dataR1["pregunta6"]+$dataR1["pregunta7"]+$dataR1["pregunta8"]+$dataR1["pregunta9"]+$dataR1["pregunta10"]+$dataR1["pregunta11"]+$dataR1["pregunta12"]+$dataR1["pregunta13"]+$dataR1["pregunta14"]+$dataR1["pregunta15"];
                                $val = 100*$suma/15;
                                $bg_color = "";
                                $color = "";
                                if ($val < 30 ) {
                                    $bg_color = "#d91e49";
                                    $color = "#000";
                                }
                                if ($val >= 30 && $val < 70 ) {
                                    $bg_color = "#ff8000";
                                    $color = "#000";
                                }
                                if ($val >= 70 ) {
                                    $bg_color = "#008f39";
                                    $color = "#fff";
                                }
                                $val = number_format ( $val , 2 );
                                echo '
                                    <tr>
                                        <td>' . $count . '</td>
                                        <td>' . $dataR1["equipo"] . '</td>
                                        <td>' . round($dataR1["puntaje"]) . ' pts.</td>
                                        <td>' . $dataR1["tiempo"] . '</td>
                                        <td>
                                            <div class="progress" style="background-color: #a7a9ac;">
                                                <div class="progress-bar" style="background-color: '.$bg_color.'; color: '.$color.'; width: '.$val.'%;" role="progressbar" aria-valuemin="0" aria-valuemax="15">'.$val.'%</div>
                                            </div>
                                        </td>
                                        <td>' . ($dataR1["pregunta1"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta2"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta3"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta4"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta5"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta6"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta7"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta8"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta9"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta10"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta11"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta12"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta13"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta14"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td>' . ($dataR1["pregunta15"] == 1 ? '<i style="color: #008f39;" class="fa fa-check" aria-hidden="true"></i>': '<i style="color: #d91e49;" class="fa fa-times" aria-hidden="true"></i>') . '</td>
                                        <td><a href="/mostrar_imagen/' . $dataR1["equipo"] . '" target="_blank" class="btn btn_juegos">Ver</a></td>
                                        
                                    <tr>
                                    ';
                                $count++;
                            }


                            ?>

                        </tbody>

                    </table>
                </div>




            </div>

        </div>
        <?php $grafica =[] ?>
        <div class="row" style="margin-top: 30px;">

            

            <div class="col-md-12" align="center" style="color: #fff; ">
            <h3>Ranking Respuestas Correctas</h3>
                <hr>
                
                <div class="table-responsive" style="background-color: #fff; border-radius: 12px; overflow: hidden; padding: 5px 30px;">


                    <table class="table">
                        <thead>
                            <tr>
                                <th scope="col">Posición</th>
                                <th scope="col">Equipo</th>
                                <th scope="col">Puntaje</th>
                                <th scope="col">P1</th>
                                <th scope="col">P2</th>
                                <th scope="col">P3</th>
                                <th scope="col">P4</th>
                                <th scope="col">P5</th>
                                <th scope="col">P6</th>
                                <th scope="col">P7</th>
                                <th scope="col">P8</th>
                                <th scope="col">P9</th>
                                <th scope="col">P10</th>
                                <th scope="col">P11</th>
                                <th scope="col">P12</th>
                                <th scope="col">P13</th>
                                <th scope="col">P14</th>
                                <th scope="col">P15</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php

                            $count = 1;
                            $q = "select distinct(rm.equipo),
                                    (select sum(r.puntaje) from respuesta_map as r where r.equipo=rm.equipo) as puntaje,
                                    sum_questions(rm.equipo, 1) 'pregunta1',
                                    sum_questions(rm.equipo, 2) 'pregunta2',
                                    sum_questions(rm.equipo, 3) 'pregunta3',
                                    sum_questions(rm.equipo, 4) 'pregunta4',
                                    sum_questions(rm.equipo, 5) 'pregunta5',
                                    sum_questions(rm.equipo, 6) 'pregunta6',
                                    sum_questions(rm.equipo, 7) 'pregunta7',
                                    sum_questions(rm.equipo, 8) 'pregunta8',
                                    sum_questions(rm.equipo, 9) 'pregunta9',
                                    sum_questions(rm.equipo, 10) 'pregunta10',
                                    sum_questions(rm.equipo, 11) 'pregunta11',
                                    sum_questions(rm.equipo, 12) 'pregunta12',
                                    sum_questions(rm.equipo, 13) 'pregunta13',
                                    sum_questions(rm.equipo, 14) 'pregunta14',
                                    sum_questions(rm.equipo, 15) 'pregunta15'
                            from respuesta_map as rm
                            where rm.equipo <> ''
                            order by 3 DESC,2";
                            $queryR1 = mysqli_query($connect, $q);
                            while ($dataR1 = mysqli_fetch_array($queryR1)) {
                                $suma = ($dataR1["pregunta1"] == null?0: $dataR1["pregunta1"])+
                                ($dataR1["pregunta2"] == null?0: $dataR1["pregunta2"])+
                                ($dataR1["pregunta3"] == null?0: $dataR1["pregunta3"])+
                                ($dataR1["pregunta4"] == null?0: $dataR1["pregunta4"])+
                                ($dataR1["pregunta5"] == null?0: $dataR1["pregunta5"])+
                                ($dataR1["pregunta6"] == null?0: $dataR1["pregunta6"])+
                                ($dataR1["pregunta7"] == null?0: $dataR1["pregunta7"])+
                                ($dataR1["pregunta8"] == null?0: $dataR1["pregunta8"])+
                                ($dataR1["pregunta9"] == null?0: $dataR1["pregunta9"])+
                                ($dataR1["pregunta10"] == null?0: $dataR1["pregunta10"])+
                                ($dataR1["pregunta11"] == null?0: $dataR1["pregunta11"])+
                                ($dataR1["pregunta12"] == null?0: $dataR1["pregunta12"])+
                                ($dataR1["pregunta13"] == null?0: $dataR1["pregunta13"])+
                                ($dataR1["pregunta14"] == null?0: $dataR1["pregunta14"])+
                                ($dataR1["pregunta15"] == null?0: $dataR1["pregunta15"]);
                                
                                //$temp = [""];
                                //$grafica[] = 
                                
                                
                                echo '
                                    <tr>
                                        <td>' . $count . '</td>
                                        <td>' . $dataR1["equipo"] . '</td>
                                        <td>' . round($dataR1["puntaje"]) . ' pts.</td>
                                        <td>' . ($dataR1["pregunta1"] == null ? '0/4': $dataR1['pregunta1']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta2"] == null ? '0/4': $dataR1['pregunta2']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta3"] == null ? '0/4': $dataR1['pregunta3']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta4"] == null ? '0/4': $dataR1['pregunta4']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta5"] == null ? '0/4': $dataR1['pregunta5']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta6"] == null ? '0/4': $dataR1['pregunta6']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta7"] == null ? '0/4': $dataR1['pregunta7']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta8"] == null ? '0/4': $dataR1['pregunta8']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta9"] == null ? '0/4': $dataR1['pregunta9']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta10"] == null ? '0/4': $dataR1['pregunta10']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta11"] == null ? '0/4': $dataR1['pregunta11']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta12"] == null ? '0/4': $dataR1['pregunta12']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta13"] == null ? '0/4': $dataR1['pregunta13']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta14"] == null ? '0/4': $dataR1['pregunta14']."/4") . '</td>
                                        <td>' . ($dataR1["pregunta15"] == null ? '0/4': $dataR1['pregunta15']."/4") . '</td>
                                        
                                    <tr>
                                    ';
                                $count++;
                            }


                            ?>

                        </tbody>

                    </table>
                </div>




            </div>

        </div>
        <a href="/lobby" class="btn btn_juegos">Volver</a>

   

</div>