function detalleExamen()
 {
     $vista = file_get_contents("app/vistas/DetalleExamenes.php");
     $header = file_get_contents("app/vistas/Header.php");
     $menu = file_get_contents(devuelveMenu());
     $footer = file_get_contents("app/vistas/Footer.php");
     $inicio_fila = strrpos($vista, '<tr>');
     $fin_fila = strrpos($vista, '</tr>') + 5;
     $fila = substr($vista, $inicio_fila, $fin_fila - $inicio_fila);
     $Examenes = $this->modelo->detalleExamen();
     $filas = '';
     $newFila = '';
     if (isset($Examenes) && is_array($Examenes)) {
         foreach ($Examenes as $examen) {
             $newFila = $fila;
             $diccionario = array('{Categoria}' => $examen['Categoria'], '{Examen}' => $examen['Examen'], '{Num_Preguntas}' => $examen['Num_Preguntas'], '{Aciertos}' => $examen['Aciertos'], '{Estado}' => $examen['Estado'], '{Calificacion}' => $examen['Calificacion']);
             $newFila = strtr($newFila, $diccionario);
             $filas .= $newFila;
         }
         $vista = str_replace($fila, $filas, $vista);
     } else {
         $vista = str_replace($fila, '', $vista);
     }
     $vista = $header . $menu . $vista . $footer;
     echo $vista;
 }
Example #2
0
 /**
  *Busca en la base de datos los exámenes que estén guardados y que cumplan con el criterio de busqueda
  */
 function buscar()
 {
     //Si no se recibe nada por POST mostramos solo la vista
     if (empty($_POST)) {
         require_once 'app/vistas/ModElimExamen.php';
     } else {
         //Cargamos los archivos necesarios para la vista
         $vista = file_get_contents('app/vistas/ModElimExamen.php');
         $header = file_get_contents('app/vistas/Header.php');
         $menu = file_get_contents(devuelveMenu());
         $footer = file_get_contents('app/vistas/Footer.php');
         //Guardamos los valores obtenidos por POST
         $ID = $_POST['id'];
         $Nombre = $_POST['nombre'];
         $Categoria = $_POST['categoria'];
         //Mostramos las categorías que están registradas en la base de datos, esto se hace cada que ingresa a la pagina
         $categorias = $this->modelo->obtenerCategorias();
         $vista = $this->llenarCategoria($categorias, $vista);
         //Guardamos lo que nos regresó el modelo
         $Examenes = $this->modelo->buscar($ID, $Nombre, $Categoria);
         //Buscamos la fila en la tabla para mostrar lo obtenido del modelo
         $inicio_fila = strrpos($vista, '<tr>');
         $fin_fila = strrpos($vista, '</tr>') + 5;
         $fila = substr($vista, $inicio_fila, $fin_fila - $inicio_fila);
         $filas = "";
         //Si nos regresó algo el modelo lo mostramos
         if (isset($Examenes)) {
             $new_fila = "";
             foreach ($Examenes as $row) {
                 $new_fila = $fila;
                 $diccionario = array('{ID}' => $row['ID'], '{Nombre}' => $row['Nombre'], '{Categoria}' => $row['Categoria'], '{Preguntas}' => $row['Preguntas'], '{Tiempo}' => $row['Duracion'], '{Calificacion}' => $row['Calificacion']);
                 //var_dump($diccionario);
                 $new_fila = strtr($new_fila, $diccionario);
                 $filas .= $new_fila;
             }
             $vista = str_replace($fila, $filas, $vista);
         } else {
             //Si no mostramos un mensaje
             $vista = str_replace($fila, '<p>No se encontro el examen</p>', $vista);
         }
         $vista = $header . $menu . $vista . $footer;
         echo $vista;
     }
 }
 function muestraPanel($tipo)
 {
     if (isset($tipo)) {
         $header = file_get_contents("app/vistas/Header.php");
         $menu = file_get_contents(devuelveMenu());
         $vista = file_get_contents("app/vistas/AdministrarCategoria.php");
         $footer = file_get_contents("app/vistas/Footer.php");
         $Ultimo_ID = $this->modelo->buscaUltimo();
         $Notificacion = $this->devNotificacion($tipo);
         $inicioFila = strrpos($vista, '{inicia_FilaTabla}');
         $finFila = strrpos($vista, '{fin_FilaTabla}') + 15;
         $Fila = substr($vista, $inicioFila, $finFila - $inicioFila);
         $newFilas = '';
         $vista = str_replace($Fila, $newFilas, $vista);
         $Diccionario = array('{inicia_FilaTabla}' => '', '{ID_Categoria}' => '', '{Nombre}' => '', '{fin_FilaTabla}' => '', '{valorID}' => $Ultimo_ID, '{valorCategoria}' => '', '{Notificacion}' => $Notificacion);
         $vista = strtr($vista, $Diccionario);
         echo $header . $menu . $vista . $footer;
     }
 }