Skip to content

Commit

Permalink
Merge pull request #272 from yungifez/dev
Browse files Browse the repository at this point in the history
System generates slightly better and more random test data
  • Loading branch information
yungifez authored Feb 16, 2023
2 parents 73cbae5 + 830ad06 commit cac4156
Show file tree
Hide file tree
Showing 34 changed files with 115 additions and 166 deletions.
4 changes: 2 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Kernel extends ConsoleKernel
*
* @return void
*/
protected function schedule(Schedule $schedule)
protected function schedule(Schedule $schedule): void
{
// $schedule->command('inspire')->hourly();
}
Expand All @@ -23,7 +23,7 @@ protected function schedule(Schedule $schedule)
*
* @return void
*/
protected function commands()
protected function commands(): void
{
$this->load(__DIR__.'/Commands');

Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Handler extends ExceptionHandler
*
* @return void
*/
public function register()
public function register(): void
{
$this->reportable(function (Throwable $e) {
//
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/AcademicYearResultTabulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function mount(MyClassService $myClassService)
if (!$this->classes->isEmpty()) {
$this->class = $this->classes[0]->id;
$this->sections = $this->classes[0]->sections;
$this->section = $this->sections[0]->id;
$this->updatedClass();
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/ExamTabulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function mount(ExamService $examService, SectionService $sectionService,
if (!$this->classes->isEmpty()) {
$this->class = $this->classes[0]->id;
$this->sections = $this->classes[0]->sections;
$this->section = $this->sections[0]->id;
$this->updatedClass();
}
}

Expand Down
8 changes: 5 additions & 3 deletions app/Http/Livewire/ManageTimetable.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ class ManageTimetable extends Component
{
protected $listeners = ['timetableCellClicked' => 'setSelectFields'];

protected $queryString = ['weekday', 'type', 'timeSlot'];

public Timetable $timetable;

public $timeSlots;

public ?int $timeSlot;
public $timeSlot;

public $weekdays;

Expand All @@ -33,13 +35,13 @@ public function mount(TimetableService $timetableService)
{
$this->timeSlots = $this->timetable->timeSlots->sortBy('start_time')->load('weekdays');
if ($this->timeSlots->isNotEmpty()) {
$this->timeSlot = $this->timeSlots->first()->id;
$this->timeSlot ?? $this->timeSlot = $this->timeSlots->first()->id;
}
$this->weekdays = Weekday::all();
$this->subjects = $this->timetable->MyClass->subjects;
$this->customItems = $timetableService->getAllCustomTimetableItem();
$this->types = ['subject', 'customTimetableItem'];
$this->type = $this->types[0];
$this->type ?? $this->types[0];
}

public function setSelectFields($records)
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Livewire/SemesterResultTabulation.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function mount(SectionService $sectionService, MyClassService $myClassSer
if (!$this->classes->isEmpty()) {
$this->class = $this->classes[0]->id;
$this->sections = $this->classes[0]->sections;
$this->section = $this->sections[0]->id;
$this->updatedClass();
}
}

Expand Down
3 changes: 3 additions & 0 deletions app/Http/Middleware/EnsureDefaultPasswordIsChanged.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class EnsureDefaultPasswordIsChanged
*/
public function handle(Request $request, Closure $next)
{
if (app()->isLocal() && app()->hasDebugModeEnabled()) {
return $next($request);
}
if (Hash::check('password', auth()->user()->password)) {
session()->flash('danger', 'Please change your password to proceed.');

Expand Down
2 changes: 1 addition & 1 deletion app/Services/Exam/ExamService.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getAllExamsInSemester(int $semester_id)
* Get active exams in a semester.
*
*
* @return void
* @return mixed
*/
public function getActiveExamsInSemester(int $semester_id)
{
Expand Down
16 changes: 4 additions & 12 deletions app/Services/Notice/NoticeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Services\Notice;

use App\Models\Notice;
use Illuminate\Support\Facades\DB;

class NoticeService
{
Expand Down Expand Up @@ -34,23 +33,16 @@ public function getPresentNotices()
/**
* Store notice.
*
*
* @return void
* @return App\Model\Notice
*/
public function storeNotice(array $data)
{
if (isset($data['attachment'])) {
$data['attachment'] = $data['attachment']->store(
'notice/',
'public'
);
$data['attachment'] = $data['attachment']->store('notice/', 'public');
} else {
$data['attachment'] = null;
}

DB::beginTransaction();

Notice::create([
$notice = Notice::create([
'title' => $data['title'],
'content' => $data['content'],
'start_date' => $data['start_date'],
Expand All @@ -59,7 +51,7 @@ public function storeNotice(array $data)
'school_id' => auth()->user()->school_id,
]);

DB::commit();
return $notice;
}

/**
Expand Down
12 changes: 7 additions & 5 deletions database/factories/ExamFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ public function definition()
$stop = $this->faker->dateTimeBetween($start, $start->format('Y-m-d H:i:s').' +10 days');

return [
'name' => $this->faker->word,
'description' => $this->faker->sentence,
'semester_id' => '1',
'start_date' => $start,
'stop_date' => $stop,
'name' => $this->faker->word,
'description' => $this->faker->sentence,
'semester_id' => '1',
'start_date' => $start,
'stop_date' => $stop,
'active' => $this->faker->boolean(),
'publish_result' => $this->faker->boolean(),
];
}
}
7 changes: 5 additions & 2 deletions database/factories/ExamSlotFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Database\Factories;

use App\Models\Exam;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
Expand All @@ -16,11 +17,13 @@ class ExamSlotFactory extends Factory
*/
public function definition()
{
$exam = Exam::query()->whereRelation('semester', 'id', 1)->inRandomOrder()->first();

return [
'name' => $this->faker->name,
'description' => $this->faker->sentence,
'total_marks' => $this->faker->numberBetween(1, 1000),
'exam_id' => 1,
'total_marks' => $this->faker->numberBetween(1, 100),
'exam_id' => $exam->id,
];
}
}
5 changes: 4 additions & 1 deletion database/factories/MyClassFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Database\Factories;

use App\Models\ClassGroup;
use Illuminate\Database\Eloquent\Factories\Factory;

class MyClassFactory extends Factory
Expand All @@ -13,9 +14,11 @@ class MyClassFactory extends Factory
*/
public function definition()
{
$classGroup = ClassGroup::query()->where('school_id', 1)->inRandomOrder()->first();

return [
'name' => $this->faker->name,
'class_group_id' => '1',
'class_group_id' => $classGroup->id,
];
}
}
4 changes: 3 additions & 1 deletion database/factories/NoticeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Database\Factories;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
Expand All @@ -17,7 +18,8 @@ class NoticeFactory extends Factory
public function definition()
{
$startDate = $this->faker->dateTimeThisYear('+2 months');
$stopDate = $startDate->add(date_interval_create_from_date_string('10 days'));
$days = mt_rand(1, 30);
$stopDate = Carbon::instance($startDate)->addDays($days);

return [
'title' => $this->faker->sentence,
Expand Down
5 changes: 4 additions & 1 deletion database/factories/SectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Database\Factories;

use App\Models\MyClass;
use Illuminate\Database\Eloquent\Factories\Factory;

class SectionFactory extends Factory
Expand All @@ -13,9 +14,11 @@ class SectionFactory extends Factory
*/
public function definition()
{
$class = MyClass::query()->whereRelation('classGroup', 'school_id', 1)->inRandomOrder()->first();

return [
'name' => $this->faker->name,
'my_class_id' => 1,
'my_class_id' => $class->id,
];
}
}
11 changes: 3 additions & 8 deletions database/factories/StudentFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Database\Factories;

use App\Models\MyClass;
use App\Models\Section;
use App\Models\StudentRecord;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
Expand All @@ -23,13 +23,8 @@ class StudentFactory extends Factory
public function definition()
{
$student = User::factory()->create();
$class = MyClass::query()->inRandomOrder()->first();
//if class doesnt have a section, create one (for testing sake)
if ($class->sections->isEmpty() || $class->sections == null) {
$class->sections()->create([
'name' => $this->faker->name(),
]);
}
$section = Section::query()->inRandomOrder()->whereRelation('myClass.classGroup', 'school_id', 1)->first();
$class = $section->myClass;
$student->assignRole('student');

return [
Expand Down
2 changes: 1 addition & 1 deletion database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function run()
MyClassSeeder::class,
SectionSeeder::class,
UserSeeder::class,
// StudentSeeder::class,
StudentSeeder::class,
SubjectSeeder::class,
AcademicYearSeeder::class,
SemesterSeeder::class,
Expand Down
7 changes: 7 additions & 0 deletions database/seeders/ExamSlotSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ public function run()
'exam_id' => 1,
]);

ExamSlot::firstOrCreate([
'name' => 'Theory',
'description' => 'lol',
'total_marks' => 60,
'exam_id' => 1,
]);

ExamSlot::factory()->count(10)->create();
}
}
1 change: 1 addition & 0 deletions database/seeders/MyClassSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ public function run()
'name' => 'Primary 2',
'class_group_id' => 4,
]);
MyClass::factory()->count(5)->create();
}
}
2 changes: 2 additions & 0 deletions database/seeders/SectionSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ public function run()
'name' => 'Ruby',
'my_class_id' => 1,
]);

Section::factory()->count(10)->create();
}
}
2 changes: 1 addition & 1 deletion database/seeders/StudentSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class StudentSeeder extends Seeder
*/
public function run()
{
StudentRecord::factory()->count(10)->create();
StudentRecord::factory()->count(30)->create();
}
}
2 changes: 1 addition & 1 deletion resources/views/components/loading-spinner.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="w-full" wire:loading.delay {{$attributes}}>
<div role="status" class="flex justify-center w-full" >
<div role="status" class="flex justify-center w-full animate- " >
<svg aria-hidden="true" class="w-10 h-10 my-2 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
Expand Down
4 changes: 2 additions & 2 deletions resources/views/components/modal.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
$sizeClass = "h-[60%] w-11/12 md:w-10/12 lg:w-8/12 xl:w-6/12";
break;
case 'lg':
$sizeClass = "h-[90%] w-11/12 ";
$sizeClass = "h-[90%] w-11/12 lg:w-9/12";
default:
$sizeClass = "h-[90%] w-11/12";
$sizeClass = "h-[90%] w-11/12 lg:w-9/12";
break;
}
@endphp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@endisset
</x-select>
</div>
<x-button label="View records" theme="primary" type="submit" class="w-full md:w-3/12"/>
<x-button label="View records" theme="primary" type="submit" class="w-full md:w-5/12"/>
</form>
{{-- table to display tabulation --}}
@if ($createdTabulation === true)
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/datatable.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
@if ($column['type'] == 'delete')
<x-modal title="Confirm {{$column['name']}}" background-colour="bg-red-600">
<div class="text-gray-700 dark:text-white">
<i class="fa fa-trash text-7xl" aria-hidden="true"></i>
<i class="fa fa-trash text-7xl" aria-hidden="true"></i>
<p class="my-2">Are you sure you want to {{Str::lower($column['name'])}} this resource</p>
</div>
<x-slot:footer>
Expand Down
2 changes: 1 addition & 1 deletion resources/views/livewire/exam-tabulation.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@endisset
</x-select>

<x-button label="View records" theme="primary" type="submit" class="w-full md:w-3/12"/>
<x-button label="View records" theme="primary" type="submit" class="w-full md:w-5/12"/>
</form>
{{-- table to display tabulation --}}
@if($tabulatedRecords && $createdTabulation == true)
Expand Down
4 changes: 2 additions & 2 deletions resources/views/livewire/list-exam-records-table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
</thead>
<tbody>
@foreach ($students->load('studentRecord') as $student)
<tr>
<tr id="student-{{$student->id}}">
<th class="border whitespace-nowrap p-4">{{ $students->perPage() * ($students->currentPage() - 1) + $loop->iteration }}</th>
<td class="border whitespace-nowrap p-4">{{$student->name}}</td>
<td class="border whitespace-nowrap p-4">{{$student->studentRecord->admission_number}}</td>
Expand All @@ -82,7 +82,7 @@
@can('update exam record', )
<td class="border whitespace-nowrap p-4">
<x-modal title="Exam Records For {{$student->name}}" background-colour="bg-blue-600" button-text="Manage Marks" size="lg" :wire:key="Str::Random(10)">
<form action="{{route('exam-records.store')}}" method="POST" class="overflow-y-scroll w-full p-4 text-left">
<form action="{{route('exam-records.store')}}#student-{{$student->id}}" method="POST" class="overflow-y-scroll beautify-scrollbar w-full p-4 text-left">
@foreach ($examSlots as $examSlot)
@php
$examRecord = $examRecords->where('user_id',$student->id)->where('subject_id', $subjectSelected->id)->where('exam_slot_id', $examSlot->id)->first();
Expand Down
1 change: 1 addition & 0 deletions resources/views/livewire/list-notices-table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<div class="card-body">
@can (['update notice', 'delete notice'])
<livewire:datatable :model="App\Models\Notice::class"
uniqueId="List-notice-table"
:filters="[
['name' => 'where', 'arguments' => ['school_id' , auth()->user()->school_id]]
]"
Expand Down
Loading

0 comments on commit cac4156

Please sign in to comment.