Parcial Participante Puede Ver Sus Pruebas: Commit Authored 1 Day Ago by
Parcial Participante Puede Ver Sus Pruebas: Commit Authored 1 Day Ago by
app/Exceptions/Handler.php
... ... @@ -2,6 +2,7 @@
2 2
3 3 namespace App\Exceptions;
4 4
5 + use Illuminate\Auth\AuthenticationException;
5 6 use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
6 7 use Throwable;
7 8
... ... @@ -52,4 +53,17 @@ class Handler extends ExceptionHandler
52 53 {
53 54 return parent::render($request, $exception);
54 55 }
56 +
57 + protected function unauthenticated($request, AuthenticationException $exception)
58 + {
59 + if ($request->expectsJson()) {
60 + return response()->json(['error' => 'Unauthenticated.'], 401);
61 + }
62 +
63 + if ($request->is('*portal*')) {
64 + return redirect()->guest('/portal/login');
65 + }
66 +
67 + return redirect()->guest(route('login'));
68 + }
55 69 }
app/Http/Controllers/Admin/TestController.php
https://gitlab.com/guille.agudelo/apptalento/-/commit/1f277f3027fdce1ad78924229ab1049b8a8a3105 1/11
1/8/2020 Parcial participante puede ver sus pruebas (1f277f30) · Commits · Guillermo Agudelo / apptalento · GitLab
26 + Mail::to($students[0]->email)->send(new SendPortalLink($students[0]));
27 + dd('bla');
28 + }
14 29 }
app/Http/Controllers/Auth/LoginController.php
... ... @@ -3,9 +3,12 @@
3 3 namespace App\Http\Controllers\Auth;
4 4
5 5 use App\Http\Controllers\Controller;
6 + use App\Models\IdentificationType;
7 + use App\Models\Partaker;
6 8 use App\Models\Support\AccessLog;
7 9 use App\Providers\RouteServiceProvider;
8 10 use Illuminate\Foundation\Auth\AuthenticatesUsers;
11 + use Illuminate\Support\Facades\Auth;
9 12 use Symfony\Component\HttpFoundation\Request;
10 13
11 14 class LoginController extends Controller
... ... @@ -38,5 +41,33 @@ class LoginController extends Controller
38 41 public function __construct()
39 42 {
40 43 $this->middleware('guest')->except('logout');
44 + $this->middleware('guest:partaker')->except('logout');
45 + }
46 +
47 + public function partakerLogin()
48 + {
49 + $identificationTypes = IdentificationType::all();
50 + return view('portal.login', ['url' => 'writer', 'identificationTypes' => $identificationTypes]);
51 + }
52 +
53 + public function partakerPerformLogin(Request $request)
54 + {
55 + $this->validate($request, [
56 + 'identification_type_id' => 'required|exists:identification_types,id',
57 + 'identification' => 'required'
58 + ]);
59 +
60 + $partaker = Partaker::where('identification_type_id', $request->get('identification_type_id'))
61 + ->where('identification', $request->get('identification'))
62 + ->first();
63 +
64 + if ($partaker) {
65 + Auth::guard('partaker')->login($partaker);
66 + return redirect()->intended('/portal');
67 + }
68 +
69 + feedback('error', 'No se pudo autenticar. Intente otra vez.');
70 +
71 + return back();
41 72 }
42 73 }
app/Http/Controllers/Portal/PortalController.php 0 → 100644
1 + <?php
2 +
3 + namespace App\Http\Controllers\Portal;
4 +
5 + use App\Http\Controllers\Controller;
6 + use App\Models\IdentificationType;
7 + use Illuminate\Http\Request;
8 +
9 + class PortalController extends Controller
10 +{
11 + public function index()
12 + {
13 + // \Auth::guard('partaker')->logout();
14 + $tests = auth()->user()->tests;
15 + return view('portal.index', compact('tests'));
16 + }
17 +
18 +}
https://gitlab.com/guille.agudelo/apptalento/-/commit/1f277f3027fdce1ad78924229ab1049b8a8a3105 2/11
1/8/2020 Parcial participante puede ver sus pruebas (1f277f30) · Commits · Guillermo Agudelo / apptalento · GitLab
app/Http/Middleware/RedirectIfAuthenticated.php
app/Mail/SendPortalLink.php 0 → 100644
1 + <?php
2 +
3 + namespace App\Mail;
4 +
5 + use App\Models\Partaker;
6 + use Illuminate\Bus\Queueable;
7 + use Illuminate\Contracts\Queue\ShouldQueue;
8 + use Illuminate\Mail\Mailable;
9 + use Illuminate\Queue\SerializesModels;
10 +
11 + class SendPortalLink extends Mailable
12 +{
13 + use Queueable, SerializesModels;
14 +
15 + public $partaker;
16 +
17 + /**
18 + * Create a new message instance.
19 + *
20 + * @return void
21 + */
22 + public function __construct(Partaker $partaker)
23 + {
24 + $this->partaker = $partaker;
25 + }
26 +
27 + /**
28 + * Build the message.
29 + *
30 + * @return $this
31 + */
32 + public function build()
33 + {
34 + return $this->markdown('mails/send-portal-link');
35 + }
36 +}
app/Models/Partaker.php
... ... @@ -2,11 +2,15 @@
2 2
3 3 namespace App\Models;
4 4
5 - use Illuminate\Database\Eloquent\Model;
5 + use Illuminate\Foundation\Auth\User as Authenticatable;
6 + use Silber\Bouncer\Database\HasRolesAndAbilities;
6 7
7 - class Partaker extends Model
8 + class Partaker extends Authenticatable
8 9 {
10 + use HasRolesAndAbilities;
11 +
9 12 protected $guarded = [];
13 + protected $guard = 'partaker';
10 14
11 15 public function getFullNameAttribute()
12 16 {
... ... @@ -52,4 +56,10 @@ class Partaker extends Model
52 56 {
https://gitlab.com/guille.agudelo/apptalento/-/commit/1f277f3027fdce1ad78924229ab1049b8a8a3105 3/11
1/8/2020 Parcial participante puede ver sus pruebas (1f277f30) · Commits · Guillermo Agudelo / apptalento · GitLab
53 57 return $this->belongsTo(IdentificationType::class);
54 58 }
59 +
60 + public function tests()
61 + {
62 + return $this->hasMany(Test::class);
63 + }
64 +
55 65 }
app/Models/Test.php 0 → 100644
1 + <?php
2 +
3 + namespace App\Models;
4 +
5 + use Illuminate\Database\Eloquent\Model;
6 +
7 + class Test extends Model
8 +{
9 + public function instrument()
10 + {
11 + if($this->pot_instrument_id) {
12 + return $this->belongsTo(PotInstrument::class, 'pot_instrument_id');
13 + } else {
14 + return $this->belongsTo(TalInstrument::class, 'tal_instrument_id');
15 + }
16 + }
17 +}
app/Providers/EventServiceProvider.php
... ... @@ -2,6 +2,7 @@
2 2
3 3 namespace App\Providers;
4 4
5 + use App\User;
5 6 use Illuminate\Auth\Events\Login;
6 7 use Illuminate\Auth\Events\Logout;
7 8 use Illuminate\Auth\Events\Registered;
... ... @@ -32,17 +33,21 @@ class EventServiceProvider extends ServiceProvider
32 33 parent::boot();
33 34
34 35 Event::listen(Login::class, function ($event) {
35 - $event->user->accessLogs()->create([
36 - 'ip' => request()->ip(),
37 - 'type' => 'login'
38 - ]);
36 + if ($event->user instanceof User) {
37 + $event->user->accessLogs()->create([
38 + 'ip' => request()->ip(),
39 + 'type' => 'login'
40 + ]);
41 + }
39 42 });
40 43
41 44 Event::listen(Logout::class, function ($event) {
42 - $event->user->accessLogs()->create([
43 - 'ip' => request()->ip(),
44 - 'type' => 'logout'
45 - ]);
45 + if ($event->user instanceof User) {
46 + $event->user->accessLogs()->create([
47 + 'ip' => request()->ip(),
48 + 'type' => 'logout'
49 + ]);
50 + }
46 51 });
47 52 }
48 53 }
app/Support/Globals.php
... ... @@ -51,11 +51,23 @@ abstract class UserTypes
51 51 }
52 52 }
https://gitlab.com/guille.agudelo/apptalento/-/commit/1f277f3027fdce1ad78924229ab1049b8a8a3105 4/11
1/8/2020 Parcial participante puede ver sus pruebas (1f277f30) · Commits · Guillermo Agudelo / apptalento · GitLab
53 53
54 - abstract class PartakerTypes
54 + abstract class SourcesIds
55 55 {
56 - const ESTUDIANTE = 'EstudiantE';
57 - const DOCENTE = 'Docente';
58 - const CUIDADOR = 'Cuidador';
56 + const ESTUDIANTE = 1;
57 + const DOCENTE = 2;
58 + const CUIDADOR = 3;
59 +
60 + public static function getConstants() {
61 + $oClass = new ReflectionClass(__CLASS__);
62 + return array_values($oClass->getConstants());
63 + }
64 +}
65 +
66 + abstract class TestStatus
67 +{
68 + const TO_DO = 'Por Hacer';
69 + const INCOMPLETE = 'Incompleta';
70 + const DONE = 'Terminada';
59 71
60 72 public static function getConstants() {
61 73 $oClass = new ReflectionClass(__CLASS__);
... ...
config/auth.php
database/migrations/2020_07_30_104941_create_tests_table.php
database/seeds/DatabaseSeeder.php
https://gitlab.com/guille.agudelo/apptalento/-/commit/1f277f3027fdce1ad78924229ab1049b8a8a3105 5/11
1/8/2020 Parcial participante puede ver sus pruebas (1f277f30) · Commits · Guillermo Agudelo / apptalento · GitLab
database/seeds/TestSeeder.php 0 → 100644
1 + <?php
2 +
3 + use Illuminate\Database\Seeder;
4 +
5 + class TestSeeder extends Seeder
6 +{
7 + /**
8 + * Run the database seeds.
9 + *
10 + * @return void
11 + */
12 + public function run()
13 + {
14 + DB::table('tests')->insert([
15 + [
16 + 'partaker_id' => 3,
17 + 'student_id' => null,
18 + 'pot_instrument_id' => 3, //estudiante 8 a 10
19 + 'tal_instrument_id' => null,
20 + 'status' => TestStatus::TO_DO,
21 + 'created_at' => now(),
22 + 'updated_at' => now(),
23 + ],
24 + [
25 + 'partaker_id' => 2,
26 + 'student_id' => 3,
27 + 'pot_instrument_id' => 5, //familiar 8 a 10
28 + 'tal_instrument_id' => null,
29 + 'status' => TestStatus::TO_DO,
30 + 'created_at' => now(),
31 + 'updated_at' => now(),
32 + ],
33 + [
34 + 'partaker_id' => 1,
35 + 'student_id' => 3,
36 + 'pot_instrument_id' => 6, //docente 8 a 10
37 + 'tal_instrument_id' => null,
38 + 'status' => TestStatus::TO_DO,
39 + 'created_at' => now(),
40 + 'updated_at' => now(),
41 + ],
42 + [
43 + 'partaker_id' => 3,
44 + 'student_id' => null,
45 + 'pot_instrument_id' => null,
46 + 'tal_instrument_id' => 1,
47 + 'status' => TestStatus::TO_DO,
48 + 'created_at' => now(),
49 + 'updated_at' => now(),
50 + ],
51 + [
52 + 'partaker_id' => 3,
53 + 'student_id' => null,
54 + 'pot_instrument_id' => null,
55 + 'tal_instrument_id' => 2,
56 + 'status' => TestStatus::TO_DO,
57 + 'created_at' => now(),
58 + 'updated_at' => now(),
59 + ],
60 + [
61 + 'partaker_id' => 3,
62 + 'student_id' => null,
63 + 'pot_instrument_id' => null,
64 + 'tal_instrument_id' => 3,
65 + 'status' => TestStatus::TO_DO,
https://gitlab.com/guille.agudelo/apptalento/-/commit/1f277f3027fdce1ad78924229ab1049b8a8a3105 6/11
1/8/2020 Parcial participante puede ver sus pruebas (1f277f30) · Commits · Guillermo Agudelo / apptalento · GitLab
notas.txt
1 + . que no se pueda borrar instrumento si tiene preguntas
2 + . que permita editar participantes y usuario sin cambiar email
3 + . debe poder desactivar todos los permisos para admin en permisos y roles
1 4
2 5 hecho
3 6 .quitar lo que no funcione (mi perfil, instituciones)
... ...
resources/views/admin/tests/index.blade.php
... ... @@ -2,6 +2,12 @@
2 2 @section('content')
3 3 <div class="container" id="roles">
4 4 <h2>Enviar pruebas a participantes</h2>
5 - <a href="#" class="btn btn-primary">Enviar pruebas</a>
5 +
6 + <form action="{{route('admin.tests.send-tests')}}" method="post">
7 + @csrf
8 + <p>Destino: Todos los participantes (Estudiantes, cuidadores, docentes)<br>
9 + Tipo de Prueba: Potencial de Aprendizaje y Campo de Talento</p>
10 + <button class="btn btn-primary" type="submit">Enviar Pruebas</button>
11 + </form>
6 12 </div>
7 13 @endsection
resources/views/layouts/headers/cards.blade.php
... ... @@ -131,7 +131,11 @@
131 131 </div>
132 132 @else
133 133 @guest
134 - <div class="header bg-gradient-primary pb-3 pt-5 d-flex">
134 + @if(request()->is('*portal*'))
135 + <div class="header bg-gradient-primary pb-6 pt-5 d-flex">
136 + @else
137 + <div class="header bg-gradient-primary pb-3 pt-5 d-flex">
138 + @endif
135 139 <div class="container-fluid">
136 140 <div class="header-body">
137 141 <!-- Card stats -->
... ... @@ -142,7 +146,11 @@
142 146 </div>
143 147 @endguest
144 148 @auth
145 - <div class="header bg-primary py-6 py-md-5" id="navbar-container">
149 + @if(request()->is('*portal*'))
150 + <div class="header bg-primary py-6 pt-md-5 pb-md-6" id="navbar-container">
151 + @else
152 + <div class="header bg-primary py-6 py-md-5" id="navbar-container">
153 + @endif
146 154 <div class="container-fluid">
147 155 <div class="header-body">
148 156 <!-- Card stats -->
... ...
resources/views/layouts/portal.blade.php 0 → 100644
1 + <!DOCTYPE html>
https://gitlab.com/guille.agudelo/apptalento/-/commit/1f277f3027fdce1ad78924229ab1049b8a8a3105 7/11
1/8/2020 Parcial participante puede ver sus pruebas (1f277f30) · Commits · Guillermo Agudelo / apptalento · GitLab
https://gitlab.com/guille.agudelo/apptalento/-/commit/1f277f3027fdce1ad78924229ab1049b8a8a3105 8/11
1/8/2020 Parcial participante puede ver sus pruebas (1f277f30) · Commits · Guillermo Agudelo / apptalento · GitLab
75 + <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.15.2/axios.js"></script>
76 + <script src="{{ asset('argon') }}/vendor/jquery/dist/jquery.min.js"></script>
77 + <script src="{{ asset('argon') }}/vendor/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
78 + <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap-
select.min.js"></script>
79 + <script src="https://cdn.jsdelnameivr.net/npm/[email protected]/dist/js/i18n/defaults-
es_ES.min.js"></script>
80 + <script src="https://cdnjs.cloudflare.com/ajax/libs/ajax-bootstrap-select/1.4.5/js/ajax-bootstrap-
select.min.js"></script>
81 + @include('layouts._includes.js')
82 + @include('_includes.feedback')
83 +
84 + @stack('js')
85 +
86 + <!-- Argon JS -->
87 + <script src="{{ asset('argon') }}/js/argon.js?v=1.0.0"></script>
88 + </body>
89 + </html>
resources/views/mails/send-portal-link.blade.php 0 → 100644
1 + @component('mail::message')
2 + # Hola, {{$partaker->first_name}}
3 +
4 + Te hemos asignado unas prueba para que las realices. Por favor, da click en el botón para entrar al portal
y realizar las pruebas.
5 +
6 + @component('mail::button', ['url' => route('portal.login')])
7 + Ver Pruebas
8 + @endcomponent
9 +
10 + Gracias,<br>
11 + {{ config('app.name') }}
12 + @endcomponent
resources/views/portal/index.blade.php 0 → 100644
1 + @extends('layouts.portal', ['title' => 'Realizar Pruebas', 'titleIcon' =>
asset('images/icons/Prueba_3.png')])
2 + @section('content')
3 + <div class="container" id="tests">
4 + <h2>Realizar Pruebas</h2>
5 +
6 + <p>Bienvenido, a continuación se listan las pruebas asignadas a usted.</p>
7 +
8 + <x-table>
9 + <!-- <x-slot name="headerRight"> -->
10 + <!-- <a class="btn btn-primary" href="#" @click.prevent="showModalCreate"> -->
11 + <!-- <i class="fa fa-plus"></i> Agregar Nuevo Rol -->
12 + <!-- </a> -->
13 + <!-- </x-slot> -->
14 + <table class="table align-items-center table-flush table-hover">
15 + <thead class="thead-light">
16 + <tr>
17 + <th>#</th>
18 + <th><i class="fa fa-eye"></i> Tipo</th>
19 + <th><i class="fa fa-file-alt"></i> Prueba</th>
20 + <th><i class="fa fa-check"></i> Estado</th>
21 + <th></th>
22 + </tr>
23 + </thead>
24 + <tbody>
25 + @foreach($tests as $test)
26 + <tr>
27 + <td>{{$loop->iteration}}</td>
28 + <td>{{$test->instrument->name}}</td>
29 + <td>{{$test->instrument->name}}</td>
30 + <td>{{$test->status}}</td>
31 + <td class="text-right">
32 + <a href="#"
33 + class="btn btn-primary py-1 px-2 mr-1"
34 + title="Hacer prueba">
35 + <i class="fa fa-check-circle"></i> Empezar
36 + </a>
37 + </td>
https://gitlab.com/guille.agudelo/apptalento/-/commit/1f277f3027fdce1ad78924229ab1049b8a8a3105 9/11
1/8/2020 Parcial participante puede ver sus pruebas (1f277f30) · Commits · Guillermo Agudelo / apptalento · GitLab
38 + </tr>
39 + @endforeach
40 + </tbody>
41 + </table>
42 + </x-table>
43 + </div>
44 + @endsection
resources/views/portal/login.blade.php 0 → 100644
1 + @extends('layouts.portal', ['title' => 'Autenticación - Realizar Pruebas', 'titleIconClass' => 'eye'])
2 + @section('content')
3 + <div class="container" id="roles">
4 +
5 + <form action="{{route('portal.perform-login')}}"
6 + method="post"
7 + class="form-group mx-auto my-4"
8 + style="max-width: 400px">
9 + @csrf
10 +
11 + <h2>Bienvenido, Fulano</h2>
12 +
13 + <p>Ingrese su número de documento para autenticarse.</p>
14 +
15 + <div class="form-group">
16 + <label for="">Tipo de Identificación</label>
17 + <select id="" name="identification_type_id" class="form-control" required>
18 + @foreach($identificationTypes as $type)
19 + <option value="{{$type->id}}">
20 + {{$type->name}} - {{$type->description}}
21 + </option>
22 + @endforeach
23 + </select>
24 + </div>
25 +
26 + <div class="form-group">
27 + <label for="">Número de Identificación</label>
28 + <input type="text" name="identification" class="form-control" required>
29 + </div>
30 +
31 + <button class="btn btn-primary">Ingresar</button>
32 + </form>
33 +
34 +
35 + </div>
36 + @endsection
routes/web.php
... ... @@ -18,6 +18,8 @@ Route::get('/', function () {
18 18 });
19 19
20 20 Auth::routes();
21 + Route::get('/portal/login', 'Auth\LoginController@partakerLogin')->name('portal.login');
22 + Route::post('/portal/login', 'Auth\LoginController@partakerPerformLogin')->name('portal.perform-login');
21 23
22 24 Route::get('/home', 'HomeController@index')->name('home');
23 25
... ... @@ -41,6 +43,7 @@ Route::group([
41 43 'prefix' => 'admin',
42 44 'as' => 'admin.',
43 45 'namespace' => 'Admin',
46 + 'middleware' => 'auth'
44 47 ], function() {
45 48 Route::resource('institutions', 'InstitutionController')
46 49 ->middleware(['can:'.ability('MANAGE_INSTITUTIONS')]);
... ... @@ -123,10 +126,19 @@ Route::group([
123 126 'as' => 'tests.',
124 127 ], function() {
125 128 Route::get('', 'TestController@index')->name('index');
129 + Route::post('send-tests', 'TestController@sendTests')->name('send-tests');
126 130 });
127 131
128 132 });
129 133
https://gitlab.com/guille.agudelo/apptalento/-/commit/1f277f3027fdce1ad78924229ab1049b8a8a3105 10/11
1/8/2020 Parcial participante puede ver sus pruebas (1f277f30) · Commits · Guillermo Agudelo / apptalento · GitLab
134 + Route::group([
135 + 'prefix' => 'portal',
136 + 'as' => 'portal.',
137 + 'middleware' => 'auth:partaker',
138 + 'namespace' => 'Portal',
139 + ], function() {
140 + Route::get('', 'PortalController@index')->name('index');
141 + });
130 142
131 143 Route::group([
132 144 'prefix' => 'api',
... ...
https://gitlab.com/guille.agudelo/apptalento/-/commit/1f277f3027fdce1ad78924229ab1049b8a8a3105 11/11