';
break;
case 'OPCION MULTIPLE':
case 'OPCIÓN MULTIPLE':
case 'OPCIÓN MÚLTIPLE':
case 'OPCION MÚLTIPLE':
case 'OPCIONES':
if (is_numeric($resultado['respuesta']))
$respuesta = Proyecto::estandarizaNumeros(floatval($resultado['respuesta']));
else
$respuesta = Proyecto::estandarizaNumeros($resultado['respuesta']);
break;
case 'ABIERTA':
case 'ABIERTAS':
$respuesta = $resultado['respuesta'];
}
end($resultados);
}
next($resultados);
}
return $respuesta;
}
private static function getPromedio($resultados, $preguntas, $tipoRetorno){
switch ($tipoRetorno){
case 'HTML': $promedio = ''; break;
case 'ARRAY': $promedio = array(); break;
}
if (count($resultados) > 0){
if ($tipoRetorno == 'HTML')
$promedio = '
';
foreach($preguntas as $pregunta){
$cont = 0;
$calif = 0;
foreach ($resultados as $res){
if ($res['idpregunta'] == $pregunta['idpregunta'] && is_numeric($res['respuesta'])){
$calif += $res['respuesta'];
$cont++;
}
}
if ($cont > 0) {
$prom = Proyecto::estandarizaNumeros(round($calif/$cont,1));
switch ($tipoRetorno){
case 'HTML': $promedio .= '
'. $prom . '
'; break;
case 'ARRAY':
array_push($promedio, $prom);
break;
}
} else {
switch ($tipoRetorno){
case 'HTML': $promedio .= '
'; break;
case 'ARRAY': array_push($promedio, ' '); break;
}
}
}
if ($tipoRetorno == 'HTML')
$promedio .= '
';
}
return $promedio;
}
private static function generarSeccion($pdo, $preguntas, $resultados){
$secciones = '';
foreach($preguntas as $pregunta) {
switch (mb_strtoupper($pregunta['tipo'])){
case 'ESTRELLA':
case 'ESTRELLAS':
case 'RANKING':
case 'OPCION MULTIPLE':
case 'OPCIÓN MULTIPLE':
case 'OPCIÓN MÚLTIPLE':
case 'OPCION MÚLTIPLE':
case 'OPCIONES':
$div = self::obtenerEstadistica($pdo, $pregunta, $resultados, 'HTML');
if ($div != ''){
$secciones .= '
' . $div . '
';
}
break;
case 'ABIERTA':
case 'ABIERTAS':
break;
}
}
return $secciones;
}
private static function generarArregloSeccion($pdo, $preguntas, $resultados){
$secciones = array();
foreach($preguntas as $pregunta) {
switch (mb_strtoupper($pregunta['tipo'])){
case 'ESTRELLA':
case 'ESTRELLAS':
case 'RANKING':
case 'OPCION MULTIPLE':
case 'OPCIÓN MULTIPLE':
case 'OPCIÓN MÚLTIPLE':
case 'OPCION MÚLTIPLE':
case 'OPCIONES':
$secciones = self::obtenerEstadistica($pdo, $pregunta, $resultados, 'ARRAY');
break;
case 'ABIERTA':
case 'ABIERTAS':
break;
}
}
return $secciones;
}
private static function obtenerEstadistica($pdo, $pregunta, $resultados, $tipoRetorno){
$valores = self::obtenerValoresOpcionesPregunta($pdo, $pregunta['idpregunta']);
$estadistica = array();
switch ($tipoRetorno){
case 'HTML': $div = ''; break;
case 'ARRAY': $div = array(); break;
}
if (count($valores) > 0){
foreach ($valores as $valor){
array_push($estadistica, array('texto' => $valor['opcion'],'valor' => $valor['valor'], 'porcentaje' => 0, 'cantidad' => 0));
}
reset($estadistica);
while($est = current($estadistica)){
$index = key($estadistica);
foreach ($resultados as $res){
if ($res['respuesta'] == $est['valor'])
$estadistica[$index]['cantidad']++;
}
next($estadistica);
}
$max = max(array_column($estadistica, 'cantidad'));
reset($estadistica);
while($est = current($estadistica)){
$index = key($estadistica);
$estadistica[$index]['porcentaje'] = Proyecto::estandarizaNumeros(round($estadistica[$index]['cantidad']/$max,1)*100);
switch (mb_strtoupper($pregunta['tipo'])){
case 'ESTRELLA':
case 'ESTRELLAS':
case 'RANKING':
$estrellas = intval($estadistica[$index]['valor']);
switch ($tipoRetorno){
case 'HTML':
$estadistica[$index]['valor'] = '';
for($cont = 0; $cont < $estrellas; $cont++){
$estadistica[$index]['valor'] .= '';
}
break;
case 'ARRAY':
$estadistica[$index]['valor'] = '';
for($cont = 0; $cont < $estrellas; $cont++){
$estadistica[$index]['valor'] .= '★';
}
break;
}
break;
case 'OPCION MULTIPLE':
case 'OPCIÓN MULTIPLE':
case 'OPCIÓN MÚLTIPLE':
case 'OPCION MÚLTIPLE':
case 'OPCIONES':
$estadistica[$index]['valor'] = Proyecto::estandarizaNumeros($estadistica[$index]['valor']);
break;
}
next($estadistica);
}
if (count($estadistica) > 0){
switch ($tipoRetorno){
case 'HTML':
$div .= '