Vista para ver encuesta respondidad por usuario
这个提交包含在:
父节点
6f3d980784
当前提交
bdd7a0ba03
app
@ -75,6 +75,7 @@ $routes->group('admin', ['filter' => 'admin_filter'], static function ($routes)
|
||||
$routes->match(['get', 'post'], 'encuesta/editar/(:segment)', 'Admin::editarEncuesta/$1', ['as' => 'admin_encuesta_editar']);
|
||||
$routes->get('encuesta/eliminar/(:segment)', 'Admin::eliminarEncuesta/$1', ['as' => 'admin_encuesta_eliminar']);
|
||||
$routes->get('respuestas/', 'Admin::respuestas', ['as' => 'admin_respuestas']);
|
||||
$routes->get('respuesta/(:segment)/(:segment)', 'Admin::respuesta/$1/$2', ['as' => 'admin_respuesta']);
|
||||
|
||||
// PREGUNTAS
|
||||
$routes->match(['get', 'post'], 'encuesta/(:segment)/pregunta/', 'Admin::nuevaPregunta/$1', ['as' => 'admin_pregunta_nueva']);
|
||||
|
@ -9,6 +9,7 @@ use App\Models\PrestadorModel;
|
||||
use App\Models\PrestadorSolicitudModel as ModelsPrestadorSolicitudModel;
|
||||
use App\Models\SurveyUserModel;
|
||||
use App\Models\UserModel;
|
||||
use PHPUnit\Framework\MockObject\Stub\ReturnReference;
|
||||
|
||||
class Admin extends BaseController
|
||||
{
|
||||
@ -313,6 +314,22 @@ class Admin extends BaseController
|
||||
return view('Admin/respuestas', $data);
|
||||
}
|
||||
|
||||
public function respuesta($surveyId, $userId)
|
||||
{
|
||||
if (!$respuestas = model(RespuestaModel::class)->getRespuestas($surveyId, $userId)) {
|
||||
return redirect()->route('admin_respuestas')->with('msg', array(
|
||||
'type' => 'danger',
|
||||
'body' => 'No se encontraron respuestas de este usuario.',
|
||||
));
|
||||
}
|
||||
|
||||
$data = [
|
||||
'respuestas' => $respuestas,
|
||||
];
|
||||
|
||||
return view('Admin/respuesta', $data);
|
||||
}
|
||||
|
||||
// PREGUNTAS
|
||||
|
||||
public function nuevaPregunta($id)
|
||||
|
@ -4,7 +4,7 @@ namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class PreguntaModel extends Model
|
||||
class RespuestaModel extends Model
|
||||
{
|
||||
protected $table = 'answers';
|
||||
protected $primaryKey = 'id';
|
||||
@ -18,4 +18,11 @@ class PreguntaModel extends Model
|
||||
'answer' => 'required',
|
||||
'question_id' => 'required',
|
||||
];
|
||||
|
||||
public function getRespuestas($survey_id, $user_id)
|
||||
{
|
||||
return $this
|
||||
->where(['survey_id' => $survey_id, 'user_id' => $user_id])
|
||||
->findAll();
|
||||
}
|
||||
}
|
||||
|
64
app/Views/Admin/respuesta.php
普通文件
64
app/Views/Admin/respuesta.php
普通文件
@ -0,0 +1,64 @@
|
||||
<?= $this->extend('templates/baseAdmin') ?>
|
||||
|
||||
<?= $this->section('content') ?>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.12.1/js/dataTables.bootstrap5.min.js"></script>
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<table id="table-solicitudes" class="table table-bordered table-striped">
|
||||
<thead>
|
||||
<th>Pregunta ID</th>
|
||||
<th>Respuesta</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php foreach ($respuestas as $respuesta) : ?>
|
||||
<tr>
|
||||
<td><?= $respuesta['question_id'] ?></td>
|
||||
<td><?= $respuesta['answer'] ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
let table = new DataTable('#table-solicitudes', {
|
||||
'searching': true,
|
||||
'ordering': true,
|
||||
'language': {
|
||||
"decimal": "",
|
||||
"emptyTable": "No hay información",
|
||||
"info": "Mostrando _START_ a _END_ de _TOTAL_ registros",
|
||||
"infoEmpty": "Mostrando 0 to 0 of 0 registros",
|
||||
"infoFiltered": "(Filtrado de _MAX_ total registros)",
|
||||
"infoPostFix": "",
|
||||
"thousands": ",",
|
||||
"lengthMenu": "Mostrar _MENU_ registros",
|
||||
"loadingRecords": "Cargando...",
|
||||
"processing": "Procesando...",
|
||||
"search": "Buscar:",
|
||||
"zeroRecords": "No se encontraron resultados",
|
||||
"paginate": {
|
||||
"first": "Primero",
|
||||
"last": "Ultimo",
|
||||
"next": "Siguiente",
|
||||
"previous": "Anterior"
|
||||
}
|
||||
},
|
||||
'order': [],
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<?= $this->endSection() ?>
|
@ -25,7 +25,7 @@
|
||||
<td><?= $respuesta['user_id'] ?></td>
|
||||
<td><?= $respuesta['created_at'] ?></td>
|
||||
<td>
|
||||
<a href="#" class="btn btn-info">Ver respuestas</a>
|
||||
<a href="<?= route_to('admin_respuesta', $respuesta['survey_id'], $respuesta['user_id']) ?>" class="btn btn-info">Ver respuestas</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
|
正在加载...
x
在新工单中引用
屏蔽一个用户