test mode for classes added

This commit is contained in:
s416422 2019-12-20 15:46:32 +01:00
parent 1cbbfe6186
commit 70f0248b8f
10 changed files with 80 additions and 10 deletions

View File

@ -7,6 +7,6 @@ use Illuminate\Database\Eloquent\Model;
class Classes extends Model
{
protected $fillable = [
'subject_id', 'date', 'classes_code'
'subject_id', 'date', 'classes_code', 'test_mode'
];
}

View File

@ -41,9 +41,11 @@ class UserClassesController extends Controller
{
$subject_id = $request->input('subject_id');
$date = $request->input('date');
$test_mode = $request->input('test_mode');
$classes_id = Classes::create([
'subject_id' => $subject_id,
'date' => $date
'date' => $date,
'test_mode' => $test_mode
])->id;
return redirect(route('user_start_classes', ['classes_id' => $classes_id]));
}
@ -81,6 +83,23 @@ class UserClassesController extends Controller
$attendances = Attendance::where('classes_id', $classes->id)->get();
$seat_numbers = $attendances->pluck('seat_number')->toArray();
$subject = Subject::find($classes->subject_id);
if($classes->test_mode) {
$room_capacity = Room::find($subject->room_id)->capacity;
$random_seat = rand(1, $room_capacity);
while(in_array($random_seat, $seat_numbers)) {
$random_seat = rand(1, $room_capacity);
}
Attendance::create([
'classes_id' => $classes->id,
'student_id_number' => $student_id_number,
'student_name' => $student_name,
'student_surname' => $student_surname,
'seat_number' => $random_seat
]);
return view('map.summary_map', ['student_name' => $student_name, 'student_surname' => $student_surname, 'seat_number' => $random_seat, 'student_id_number' => $student_id_number, 'classes_id' => $classes->id]);
}
$room_arrangement = Room::find($subject->room_id)->arrangement;
if(!$room_arrangement) {
$room_arrangement = Room::where('name', 'Inna sala')->first()->arrangement;
@ -101,6 +120,21 @@ class UserClassesController extends Controller
$attendances = Attendance::where('classes_id', $classes->id)->get();
$seat_numbers = $attendances->pluck('seat_number')->toArray();
$subject = Subject::find($classes->subject_id);
if($classes->test_mode) {
$room_capacity = Room::find($subject->room_id)->capacity;
$random_seat = rand(1, $room_capacity);
while(in_array($random_seat, $seat_numbers)) {
$random_seat = rand(1, $room_capacity);
}
Attendance::create([
'classes_id' => $classes->id,
'student_id_number' => $student_id_number,
'student_name' => $student_name,
'student_surname' => $student_surname,
'seat_number' => $random_seat
]);
return view('map.summary_map', ['student_name' => $student_name, 'student_surname' => $student_surname, 'seat_number' => $random_seat, 'student_id_number' => $student_id_number, 'classes_id' => $classes->id]);
}
$room_arrangement = Room::find($subject->room_id)->arrangement;
if(!$room_arrangement) {
$room_arrangement = Room::where('name', 'Inna sala')->first()->arrangement;

View File

@ -18,6 +18,7 @@ class CreateClassesTable extends Migration
$table->integer('subject_id');
$table->date('date');
$table->string('classes_code')->nullable();
$table->boolean('test_mode')->nullable();
$table->timestamps();
});
}

View File

@ -14,11 +14,13 @@ class ClassesTableSeeder extends Seeder
DB::table('classes')->insert([
'subject_id' => 1,
'date' => '2019-12-02',
'test_mode' => false
]);
DB::table('classes')->insert([
'subject_id' => 2,
'date' => '2019-12-02',
'test_mode' => false
]);
}
}

View File

@ -11199,3 +11199,17 @@ main {
padding-top: 20px;
}
.badge {
padding: 5px;
font-size: 85%;
}
.test-mode-div {
display: flex;
justify-content: flex-start;
align-items: center;
}
.test-mode-div input {
width: 20px;
}

View File

@ -67,4 +67,8 @@ $(document).ready(function(){
});
}
setSelectedOptionGroup();
$('input[type="checkbox"]').on('change', function() {
$('input[type="checkbox"]').not(this).prop('checked', false);
});
});

View File

@ -21,16 +21,17 @@
</p>
<p></p>
<p> Sprawdzanie obecności możesz rozpocząć w zakładce <a href="{{ route('user_classes') }}"><b>Sprawdź obecność</b></a>.
<br> Po rozpoczęciu zapisów zostanie wygenerowany i wyświetlony na ekranie kod weryfikacyjny.
<br> W <b>trybe egzaminu</b> studenci nie będą sami wybierać sobie miejsc, lecz miejsca zostaną im przydzielone w sposób losowy.
<br> Po rozpoczęciu zapisów zostanie wygenerowany i wyświetlony na ekranie <b>kod weryfikacyjny</b>.
Należy go wprowadzić do programu obsługującego odczyt danych z legitymacji studenckich.
Kod jest ważny 1,5 godziny od momentu utworzenia zajęć.
Dopóki kod jest aktywny, zapisy można przerywać i ponownie kontynuować, gdy zajdzie taka potrzeba.
<br> W tej zakładce znajdziesz także listę wszystkich minionych zajęć.
<br> W każdym momencie możesz zobaczyć podgląd sali i listę obecności dla konkretnych zajęć. Taką listę możesz wyeksportować do formatu xlsx.
<br> W każdym momencie możesz zobaczyć <b>podgląd sali</b> i listę obecności dla konkretnych zajęć. Taką listę możesz sortować i wyeksportować do formatu xlsx.
</p>
<p>
Dane dotyczące obecności znajdziesz także w zakładce <a href="{{ route('user_attendances') }}"><b>Obecności</b></a>.
<br> Do każdej obecności możesz dodać notatkę.
<br> Do każdej obecności możesz dodać <b>notatkę</b> i później edytować.
<br> Rekordy dotyczące wszystkich obecności możesz grupować i wyeksportować. Przy eksporcie każda tabela-grupa trafi do pliku xlsx jako osobny arkusz.
</p>
@endsection

View File

@ -10,10 +10,10 @@
<div class="map-buttons">
<a href="{{ route('user_classes') }}" class="checkout-button end-button"> Zakończ zapisy </a>
</div>
<h2>{{ $student_name }} {{ $student_surname }}</h2>
<h3>{{ $student_id_number }} </h3>
<h3>wybrane miejsce:</h3>
<ul id="sel-seat"> {{ $seat_number }}</ul>
<h2> {{ $student_name }} {{ $student_surname }} </h2>
<h3> {{ $student_id_number }} </h3>
<h3> miejsce: </h3>
<ul id="sel-seat"> {{ $seat_number }} </ul>
<a href="{{ route('user_start_classes', [$classes_id]) }}"><button type="button" class="checkout-button">Następny student &raquo;</button></a>
</div>
@endsection

View File

@ -44,6 +44,14 @@
</div>
</div>
<div class="form-group row">
<label for="test_mode" class="col-md-4 col-form-label text-md-right form-check-label">{{ __('Tryb egzaminu') }}</label>
<div class="col-md-6 test-mode-div">
<input id="test_mode" type="checkbox" class="form-control" name="test_mode" value="true">
</div>
</div>
<div class="form-group row mb-0">
<div class="col-md-6 offset-md-4">
<button type="submit" class="btn btn-primary" title="Dodaj zajęcia i rozpocznij zapisy">
@ -91,7 +99,10 @@
@foreach ($classes_list as $classes_item)
<tr>
<td> {{ App\Subject::find($classes_item->subject_id)->name }},
{{ App\Subject::find($classes_item->subject_id)->weekday }} {{ App\Subject::find($classes_item->subject_id)->time }}, sala {{ App\Room::find(App\Subject::find($classes_item->subject_id)->room_id)->name }}</td>
{{ App\Subject::find($classes_item->subject_id)->weekday }} {{ App\Subject::find($classes_item->subject_id)->time }}, sala {{ App\Room::find(App\Subject::find($classes_item->subject_id)->room_id)->name }}
@if($classes_item->test_mode)
<span class="badge badge-warning" title="Zajęcia w trybie egzaminu"> Egzamin </span>
@endif</td>
<td> {{ $classes_item->date }} </td>
<td>
@if($classes_item->classes_code)

View File

@ -21,6 +21,9 @@
{{ App\Subject::find(App\Classes::find($classes_id)->subject_id)->weekday }}
{{ App\Classes::find($classes_id)->date }} {{ App\Subject::find(App\Classes::find($classes_id)->subject_id)->time }},
<b>sala {{ App\Room::find(App\Subject::find(App\Classes::find($classes_id)->subject_id)->room_id)->name }}</b>
@if(App\Classes::find($classes_id)->test_mode)
<span class="badge badge-warning" title="Zajęcia w trybie egzaminu"> Egzamin </span>
@endif
</p>
</div>