// ====================================================================================================ç
// JOCS - ESTADISTIQUES dels resultats
// ====================================================================================================
include "includes_jocs.php";
//print_r($_REQUEST);
$preg = intval ($_REQUEST["preg"]);
$usrid = intval ($_REQUEST["usrid"]);
$usrct = intval ($_REQUEST["usrct"]);
$ha_respost = 0;
$mostrar_xuleta = 0;
// LLEGIM i mirem si ha ha contestat
if ($preg > 0) {
$row_pregunta = $QIZ->get_quiz_pregunta ( $preg, "", "1" );
$title = utf8_encode($row_pregunta["qip_titol"]);
$tipus_quiz = $row_pregunta["qip_tipus"];
$subtipus_quiz = $row_pregunta["qip_subtipus"];
$tau_r["pregunta"] = $preg;
$tau_r["usr_ciutat"] = $_SESSION['CATS_USER_CIUTAT'];
$tau_r["usr_id"] = $_SESSION['CATS_USER'];
$id_resposta = $QIZ->buscar_quiz_respostes ($tau_r);
if ($id_resposta) {
$ha_respost = 1;
}
// que mostri la xuleta si es tipus=1 (que no es concurs) o si ja lha respost
if ($tipus_quiz == 1 OR $ha_respost) {
$mostrar_xuleta = 1;
}
} else {
$title = "Jocs a Catalansalmon";
}
if ($id_resposta) {
$row = $QIZ-> get_quiz_respostes ($id_resposta, $opcio) ;
$opcio1 = $row["qir_resposta1"];
$opcio2 = $row["qir_resposta2"];
$opcio3 = $row["qir_resposta3"];
$opcio4 = $row["qir_resposta4"];
$opcio5 = $row["qir_resposta5"];
$opcio6 = $row["qir_resposta6"];
$opcio7 = $row["qir_resposta7"];
$opcio8 = $row["qir_resposta8"];
$opcio9 = $row["qir_resposta9"];
$opcio10 = $row["qir_resposta10"];
}
// --- llista de preguntes
$t["opcio"] = 3;
$t["status"] = 1;
$t["orderby"] = "qip_ordre DESC";
$taula_preg = $QIZ->llistar_quiz_preguntes($t);
$total_quizs = count($taula_preg);
//print_r($taula_preg);
$select_preguntes = '';
$select_preguntes.=' - tria una pregunta - ';
foreach ($taula_preg as $key=>$value) {
$sel = ($key==$preg) ? " SELECTED " : "";
$select_preguntes.=''.$value.' ';
}
$select_preguntes.=' ';
$prev = $preg - 1;
$next = $preg + 1;
$preg_prev = ($taula_preg[$prev] !="") ? '< ANTERIOR ' : "";
$preg_next = ($taula_preg[$next] !="") ? 'SEGÜENT > ' : "";
// llista de usuaris que han respost -------
$tu["opcio"] = 1;
//$tu["tipus"] = "2,3,4"; // nomes els que tenen respostes correctes/incorrectes
$tu["status"] = 1;
$tu["groupby"] = "qir_usr_ciutat, qir_usr_id";
$tu["orderby"] = " total DESC";
$resu = $QIZ->llistar_quiz_respostes ($tu);
$i = 0;
while ($row = mysql_fetch_array($resu)) {
$i++;
$nom = utf8_encode($USR->get_usuari( $row["qir_usr_id"], $row["qir_usr_ciutat"], "usr_nom", "", "", 1 ));
$nom_a_pel = utf8_encode($USR->get_usuari( $row["qir_usr_id"], $row["qir_usr_ciutat"], "usr_nom", "", "", 2 )); // sense colors
$taula_usuaris[$i]["ciutat"] = $row["qir_usr_ciutat"];
$taula_usuaris[$i]["id"] = $row["qir_usr_id"];
$taula_usuaris[$i]["nom"] = $nom;
$taula_usuaris[$i]["nom_a_pel"] = $nom_a_pel;
}
// ordenem la taula de dos dimensions pel nom
foreach ($taula_usuaris as $clave => $fila) {
$nomx[$clave] = $fila['nom'];
}
// Ordenar los datos con volumen descendiente, edición ascendiente
array_multisort($nomx, SORT_ASC, $taula_usuaris);
$select_usuaris = '';
$select_usuaris.=' - tria un usuari - ';
foreach ($taula_usuaris as $key=>$value) {
$usr = "?usrct=".$taula_usuaris[$key]["ciutat"]."&usrid=".$taula_usuaris[$key]["id"];
$sel = ($taula_usuaris[$key]["id"] == $usrid AND $taula_usuaris[$key]["ciutat"] == $usrct) ? " SELECTED " : "";
$select_usuaris.=''.$taula_usuaris[$key]["nom_a_pel"].' ';
}
$select_usuaris.=' ';
// dades generals -----------------------
$t1["opcio"] = 2;
$t1["status"] = 1;
$t1["groupby"] = "qir_usr_ciutat, qir_usr_id";
$total_jugadors = $QIZ->llistar_quiz_respostes ($t1);
$t2["opcio"] = 2;
$t2["status"] = 1;
$total_respostes_quiz = $QIZ->llistar_quiz_respostes ($t2);
// mes respostes
$t3["opcio"] = 4;
$t3["status"] = 1;
$t3["groupby"] = "qir_pregunta";
$t3["orderby"] = " total DESC ";
$row3 = $QIZ->llistar_quiz_respostes ($t3);
$top_quiz_n = $row3["qir_pregunta"];
$top_quiz = $QIZ->get_quiz_pregunta ( $top_quiz_n, "qip_titol", "1" );
// menyss respostes
$t4["opcio"] = 4;
$t4["status"] = 1;
$t4["groupby"] = "qir_pregunta";
$t4["orderby"] = " total, qir_data ";
$row4 = $QIZ->llistar_quiz_respostes ($t4);
$bottom_quiz_n = $row4["qir_pregunta"];
$bottom_quiz = $QIZ->get_quiz_pregunta ( $bottom_quiz_n, "qip_titol", "1" );
$t5["opcio"] = 1;
$t5["status"] = 1;
$t5["groupby"] = "qir_usr_ciutat, qir_usr_id";
$t5["orderby"] = " total DESC";
$res = $QIZ->llistar_quiz_respostes ($t5);
$row = mysql_fetch_array($res);
$top_jugador = utf8_encode($USR->get_usuari( $row["qir_usr_id"], $row["qir_usr_ciutat"], "usr_nom", "", "", 1 )). " (".$row["total"].")";
// ============================================
// funcions
// ============================================
// aixo anira a la classe_quiz.php. haura de ser recursiva!
// -----------------------------------------------------------------------
// es pateja totes es respostes d'un usuari i mira quantes te de correctes i quantes incorrectes
// -----------------------------------------------------------------------
function get_respostes_correctes_usuari ( $ok_nok, $usr_ciutat, $usr_id ) {
GLOBAL $QIZ;
//echo " ============ GET RESPOSTES CORRECTES USUARI: cit=$usr_ciutat / id=$usr_id --- ok_nok=$ok_nok ============";
if ($usr_id==0) {
echo ' ERROR usuari=0 a fx get_respostes_correctes_usuari';
return 0;
}
$tf["opcio"] = 1;
$tf["status"] = 1;
$tf["usr_ciutat"] = $usr_ciutat;
$tf["usr_id"] = $usr_id;
$res = $QIZ->llistar_quiz_respostes ($tf);
while ($row = mysql_fetch_array($res)) {
//echo ' ---mirem respostes del usuari '.$usr_id.' a la pregunta: '.$row["qir_pregunta"];
$total+= get_respostes_correctes_pregunta ( $ok_nok, $usr_ciutat, $usr_id, $row["qir_pregunta"]);
}
return $total;
}
// -----------------------------------------------------------------------
// aqui veiem QUANTES respostes d'un usuari i pregunta han estat correctes
// -----------------------------------------------------------------------
function get_respostes_correctes_pregunta ( $ok_nok, $usr_ciutat, $usr_id, $pregunta) {
GLOBAL $QIZ;
$total = 0;
//echo " PREGUNTA: $pregunta --- usr ciutat/id=$usr_ciutat / $usr_id - ok_nok=$ok_nok ";
$t_opc = $QIZ->get_quiz_opcions ($pregunta, 1); // respostes correctes
if ($pregunta > 0) {
// respostes d'un usuari a una pregunta
$taula["pregunta"] = $pregunta;
$taula["usr_ciutat"] = $usr_ciutat;
$taula["usr_id"] = $usr_id;
$taula["status"] = 1;
$result = $QIZ->llistar_quiz_respostes ($taula) ;
$row = mysql_fetch_array($result);
for ($k=1;$k<=10;$k++) { // recorrem les respsotes del usuari
$field = "qir_resposta".$k;
if ($row[$field] == $t_opc[$k]) { // si es correcta
if ($ok_nok == 1) { // si busquem respostes correctes
$total++;
}
} else { // si es incorrecta
if ($ok_nok == 2) { // si busquem respostes INcorrectes
$total++;
}
}
//echo ' '.$field.'->'.$row[$field].' - resp correcta='.$t_opc[$k];
}
}
return $total;
}
?>
include "head_jocs.php"; ?>
include "capcelera_jocs.php" ?>
Tria una quiz del desplegable de sota
echo $select_preguntes;?>
o be
echo $select_usuaris;?>
$tau2["pregunta"] = $preg;
$tau2["status"] = 1;
$result = $QIZ->llistar_quiz_respostes ($tau2);
$total_respostes = mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
$i++;
$t_respostes[$i]["id"] = $row["qir_id"];
$t_respostes[$i]["nom"] = utf8_encode($USR->get_usuari( $row["qir_usr_id"], $row["qir_usr_ciutat"], "usr_nom", "", "", 1 ));
for ($k=1;$k<=10;$k++){
$field = "qir_resposta".$k;
$t_respostes[$i][$field] = $row[$field];
}
}
//print_r($t_respostes);
if ($preg > 0) {
$t_opc = $QIZ->get_quiz_opcions ($preg, 1);
echo '';
}
?>
if ($usrid > 0) {
echo ''.utf8_encode($USR->get_usuari( $usrid, $usrct, "usr_nom", "", "", 1 )).' ';
} else {
if ($esmobil) {
echo 'RESPON AQUEST QUIZ ';
echo ' ';
echo $preg_prev;
echo " ";
echo $preg_next;
} else {
echo $preg_prev;
echo 'RESPON AQUEST QUIZ ';
echo $preg_next;
}
}
?>
// si han selecciona usuari mostre la info del usuari -------
if ($usrid > 0) {
echo '';
echo ' ';
echo '';
//echo 'estadistiques personals OK NO OK encert ';
echo '';
echo ' estadistiques personals ';
echo ' OK ';
echo ' NO OK ';
echo ' encert ';
echo ' ';
echo '';
echo ' Respostres ';
echo ' ';
$tux["opcio"] = 1;
$tux["status"] = 1;
$tux["usr_id"] = $usrid;
$tux["usr_ciutat"] = $usrct;
$tux["orderby"] = " qir_data DESC";
$resux = $QIZ->llistar_quiz_respostes ($tux);
while ($row = mysql_fetch_array($resux)) {
$total_respostes = 0;
$respostes_ok = 0;
$respostes_nok = 0;
if ($row["qip_tipus"]==1) {
for ($k=1;$k<=10;$k++) { // recorrem les respsotes del usuari
$field = "qir_resposta".$k;
if ($row["qip_tipus"]==1) {
if ($row[$field] == 1) {
$total_respostes++;
}
}
}
} else {
$respostes_ok = get_respostes_correctes_pregunta ( 1, $row["qir_usr_ciutat"], $row["qir_usr_id"], $row["qir_pregunta"]);
$respostes_nok = get_respostes_correctes_pregunta ( 2, $row["qir_usr_ciutat"], $row["qir_usr_id"], $row["qir_pregunta"]);
$encert = $respostes_ok * 10;
}
echo '';
echo ' '.$row["qir_data"].' ';
echo ' '.utf8_encode($row["qip_titol"]).' ';
if ($row["qip_tipus"]==1) {
echo ' '.$total_respostes.' ';
} else {
echo ' '.$respostes_ok.' ';
echo ' '.$respostes_nok.' ';
echo ' '.$encert.' % ';
}
echo ' ';
echo ' ';
}
echo '
';
}
?>
echo '';
echo 'estadistiques generals ';
echo 'Total quizs '.$total_quizs.' ';
echo 'Total jugadors '.$total_jugadors.' ';
echo 'Total respostes '.$total_respostes_quiz.' ';
echo 'Quiz amb MES respostes '.$top_quiz.' ';
echo 'Quiz amb MENYS respostes '.$bottom_quiz.' ';
echo 'Jugador amb MES respostes '.$top_jugador.' ';
echo '
';
?>
// --- llista de preguntes ----------------------
$t["opcio"] = 1;
$t["status"] = 1;
$t["orderby"] = "qip_ordre DESC";
$result = $QIZ->llistar_quiz_preguntes($t);
//print_r($taula_preg);
echo '';
echo 'Per Quiz ';
echo 'Quiz respostes Correctes incorrectes % ';
while ($row = mysql_fetch_array($result)) {
$taux["opcio"] = 1;
$taux["pregunta"] = $row["qip_id"];
$taux["status"] = 1;
$result2 = $QIZ->llistar_quiz_respostes ($taux);
$gran_total_respostes = mysql_num_rows($result2);
echo '';
echo ' '.utf8_encode($row["qip_titol"]).' ';
echo ' '.$gran_total_respostes.' ';
if ($row["qip_tipus"] == 1) {
echo ' (no s\'aplica) ';
} else {
echo ' '.$total_respostes_ok.'* ';
echo ' '.$total_respostes_nok.'* ';
echo ' '.$perc_total_respostes.'* % ';
}
echo ' ';
}
echo '
';
echo '(* = Pendent)
';
?>
// ==========================================
// =========== PER JUGADORS =================
// ==========================================
echo '';
echo 'Per jugadors que han respost questionaris ';
echo 'jugadores ';
echo 'Total Respostes ';
echo 'Questionaris ';
echo 'Correctes * ';
echo 'incorrectes * ';
echo '% encert ';
echo ' ';
$t5["opcio"] = 1;
$t5["tipus"] = "2,3,4"; // nomes els que tenen respostes correctes/incorrectes
$t5["status"] = 1;
$t5["groupby"] = "qir_usr_ciutat, qir_usr_id";
$t5["orderby"] = " total DESC";
$res = $QIZ->llistar_quiz_respostes ($t5);
while ($row = mysql_fetch_array($res)) {
$total_respostes = "xxx";
$total_quizs = $row["total"];
$respostes_ok = get_respostes_correctes_usuari( 1, $row["qir_usr_ciutat"], $row["qir_usr_id"] );
$respostes_nok = get_respostes_correctes_usuari( 2, $row["qir_usr_ciutat"], $row["qir_usr_id"] );
$encert = ($respostes_ok / $total_quizs * 10);
$encert = number_format($encert, 1);
echo '';
echo ' '.utf8_encode($USR->get_usuari( $row["qir_usr_id"], $row["qir_usr_ciutat"], "usr_nom", "", "", 1 )).' ';
echo ' '.$total_respostes.' ';
echo ' '.$total_quizs.' ';
echo ' '.$respostes_ok.' ';
echo ' '.$respostes_nok.' ';
echo ' '.$encert.' % ';
echo ' ';
}
echo '
';
echo '* Hi ha quizs que són de preguntes, i per tant de respostes correctes i incorrectes, pero d\'altres son de llocs visitats, per
tant no són avaluables. En les estadistiques d\'encerts valorem només els Quizs que fan preguntes del tipus correcte/incorrecte.
';
?>
include "peu_jocs.php"; ?>