Exemplo n.º 1
0
 public static function post_respondida($recibido)
 {
     $opcion = $recibido->opcion;
     unset($recibido->opcion);
     $respondida = new RespondidaReto();
     $respondida->add_data($recibido);
     $respuesta = new stdClass();
     $respuesta->result = $respondida->save();
     if ($respuesta->result) {
         $participante = Participante::where('EMAIL', $recibido->email)->where('CODRETO', $recibido->codreto);
         $campo = '';
         if ($opcion->VALIDEZ == 'CORRECTA') {
             $campo = 'CORRECTAS';
         } else {
             $campo = 'INCORRECTAS';
         }
         $respuesta->result_2 = $participante->increment($campo);
         $respuesta->mensaje = "Respuesta guardada correctamente.";
         //true si termino, false si no.
         $respuesta->respondidas = $participante->sum('CORRECTAS') + $participante->sum('INCORRECTAS');
         $respuesta->termino = $respuesta->respondidas >= 10;
     } else {
         $respuesta->mensaje = "No se pudo guardar la respuesta.";
     }
     return $respuesta;
 }
Exemplo n.º 2
0
 public static function get_resultados_participante($id)
 {
     $respuesta = new stdClass();
     $participante = Participante::where("EMAIL", $id)->get();
     if (count($participante) != 0) {
         $respuesta->result = false;
         $respuesta->correctas = $participante->sum('CORRECTAS');
         $respuesta->incorrectas = $participante->sum('INCORRECTAS');
         $respuesta->resultados = Participante::selectRaw('participantes.EMAIL, areas.NOMAREA, sum(CORRECTAS) as CORRECTAS, sum(INCORRECTAS) as INCORRECTAS')->join('retos', 'retos.CODRETO', '=', 'participantes.CODRETO')->join('areas', 'areas.CODAREA', '=', 'retos.CODAREA')->where('participantes.EMAIL', $id)->groupBy('areas.CODAREA')->get();
     } else {
         $respuesta->result = false;
         $respuesta->mensaje = "No hay resultados que mostrar.";
     }
     return $respuesta;
 }