Skip to content

Commit

Permalink
Course management system - Release 2.0.0 (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
NuwanJ authored Oct 9, 2024
1 parent 281203d commit 20f6e62
Show file tree
Hide file tree
Showing 103 changed files with 25,198 additions and 477 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ SEED_NEWS_EDITOR_PASSWORD="news_editor"
SEED_EVENT_EDITOR_EMAIL="[email protected]"
SEED_EVENT_EDITOR_PASSWORD="events_editor"

SEED_COURSE_MANAGER_EMAIL="[email protected]"
SEED_COURSE_MANAGER_PASSWORD="course_manager"

SEED_USER_EMAIL=[email protected]
SEED_USER_PASSWORD=regular_user

Expand All @@ -22,6 +25,7 @@ APP_READ_ONLY_LOGIN=true
DEBUGBAR_ENABLED=false
LOG_CHANNEL=daily
LOG_LEVEL=debug
LOG_DISCORD_WEBHOOK_URL=

# Drivers
DB_CONNECTION=mysql
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ Homestead.json
.phpunit.result.cache

package-lock.json
composer.lock

/.idea
_ide_helper.php
Expand Down
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ Please make sure you already created a Database and a Database User Account.

#### Install Dependencies

```
```bash
// Install PHP dependencies
composer install

// Install Node dependencies (development mode)
npm install
npm run dev
// Install Node dependencies (development mode, can use `npm` as well, but recommended to use `pnpm` here)
pnpm install
pnpm run dev
```

##### Additional useful commands

```
```bash
// If you received mmap() error, use this command
php -d memory_limit=-1 /usr/local/bin/composer install

Expand All @@ -42,7 +42,7 @@ First you need to copy `.env.example` and save as `.env` in the root folder, and

Next follow the below commands

```
```bash
// Prepare the public link for storage
php artisan storage:link

Expand All @@ -56,20 +56,20 @@ git config --local core.hooksPath .githooks

#### Serve in the Local environment

```
```bash
// Serve PHP web server
php artisan serve

// Serve PHP web server, in a specific IP & port
php artisan serve --host=0.0.0.0 --port=8000

// To work with Vue components, you need to run this in parallel
npm run watch
// To work with Vue components, you need to run this in parallel (can use `npm` as well, but recommended to use `pnpm` here)
pnpm run watch
```

#### Cache and optimization

```
```bash
// Remove dev dependencies
composer install --optimize-autoloader --no-dev

Expand All @@ -84,14 +84,14 @@ php artisan view:clear

#### Maintenance related commands

```
```bash
php artisan down --message="{Message}" --retry=60
php artisan up
```

#### Other useful instructions

```
```bash
// Create Model, Controller and Database Seeder
php artisan make:model {name} --migration --controller --seed

Expand All @@ -106,6 +106,15 @@ php artisan test

```

#### Maintenance Scripts

Can be found under `./scripts.` folder. In the production environment, scripts need to be run with `sudo` from the base directory to work correctly.

Ex:
```bash
sudo sh ./scripts/deploy-prod.sh
```

#### Resource Routes - Standardard Pattern

| Verb | URI | Action | Route Name |
Expand Down
38 changes: 38 additions & 0 deletions app/Domains/AcademicProgram/AcademicProgram.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace App\Domains\AcademicProgram;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class AcademicProgram extends Model
{
use HasFactory;

public static function getAcademicPrograms(): array
{
return [
'undergraduate' => 'Undergraduate',
'postgraduate' => 'Postgraduate'
];
}

public static function getVersions(): array
{
// TODO integrate with Taxonomies
return [
1 => 'Current Curriculum',
2 => 'Curriculum - Effective from E22'
];
}

public static function getTypes(): array
{
return [
'Found' => 'Foundation',
'Core' => 'Core',
'GE' => 'General Elective',
'TE' => 'Technical Elective'
];
}
}
136 changes: 136 additions & 0 deletions app/Domains/AcademicProgram/Course/Models/Course.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<?php

namespace App\Domains\AcademicProgram\Course\Models;

use App\Domains\Auth\Models\User;
use App\Domains\AcademicProgram\AcademicProgram;
use App\Domains\AcademicProgram\Course\Models\Traits\Scope\CourseScope;
use App\Domains\AcademicProgram\Semester\Models\Semester;
use Database\Factories\CourseFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Spatie\Activitylog\Traits\LogsActivity;

/**
* Class Course.
*/
class Course extends AcademicProgram
{
use CourseScope,
HasFactory,
LogsActivity;

protected static $logFillable = true;
protected static $logOnlyDirty = true;

protected $table = 'courses';

/**
* @var string[]
*/
protected $fillable = [
'code',
'semester_id',
'academic_program',
'version',
'name',
'credits',
'type',
'content',
'objectives',
'time_allocation',
'marks_allocation',
'ilos',
'references',
'created_by',
'updated_by',
'created_at',
'updated_at',
];

/**
* @var string[]
*/
protected $casts = [
'academic_program' => 'string',
'type' => 'string',
'objectives' => 'json',
'time_allocation' => 'json',
'marks_allocation' => 'json',
'ilos' => 'json',
'references' => 'json',
'created_at' => 'datetime',
'updated_at' => 'datetime',
];

public static function getILOTemplate(): array
{
// TODO Get the list from Taxonomies
return [
'general' => [],
'knowledge' => [],
'skills' => [],
'attitudes' => [],
];
}
public static function getMarksAllocation(): array
{
// TODO Get the list from Taxonomies
return [
'practicals' => null,
'tutorials' => null,
'quizzes' => null,
'projects' => null,
'participation' => null,
'mid_exam' => null,
'end_exam' => null,
];
}

public static function getTimeAllocation(): array
{
// TODO Get the list from Taxonomies
return [
'lecture' => null,
'tutorial' => null,
'practical' => null,
'design' => null,
'assignment' => null,
'independent_learning' => null
];
}

public function academicProgram()
{
return $this->getAcademicPrograms()[$this->academic_program];
}

public function createdUser()
{
return $this->belongsTo(User::class, 'created_by');
}

public function updatedUser()
{
return $this->belongsTo(User::class, 'updated_by');
}

public function semester()
{
return $this->belongsTo(Semester::class, 'semester_id');
}

public function version()
{
return $this->getVersions()[$this->version];
}

public function modules()
{
return $this->hasMany(CourseModule::class);
}

protected static function newFactory()
{
return CourseFactory::new();
}
}
56 changes: 56 additions & 0 deletions app/Domains/AcademicProgram/Course/Models/CourseModule.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php

namespace App\Domains\AcademicProgram\Course\Models;

use App\Domains\AcademicProgram\Course\Models\Traits\Scope\CourseScope;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Spatie\Activitylog\Traits\LogsActivity;

/**
* Class CourseModule.
*/
class CourseModule extends Model
{
use CourseScope,
HasFactory,
LogsActivity;

protected static $logFillable = true;
protected static $logOnlyDirty = true;

protected $table = 'course_modules';

/**
* @var string[]
*/
protected $fillable = [
'course_id',
'topic',
'description',
'time_allocation',
'created_by',
'updated_by',
'created_at',
'updated_at',
];

/**
* @var string[]
*/
protected $casts = [
'course_id' => 'integer',
'topic' => 'string',
'description' => 'string',
'time_allocation' => 'json',
'created_at' => 'datetime',
'updated_at' => 'datetime',
'created_by' => 'integer',
'updated_by' => 'integer',
];

public function course()
{
return $this->belongsTo(Course::class);
}
}
Loading

0 comments on commit 20f6e62

Please sign in to comment.