Skip to content

Commit

Permalink
Course Management System - Release 2.1.0 (#202)
Browse files Browse the repository at this point in the history
Co-authored-by: IsharaEkanayaka <e20094@eng.pdn.ac.lk>
Co-authored-by: kusaljayawardhana <e20179@eng.pdn.ac.lk>
Co-authored-by: Hasan10100 <150885485+Hasan10100@users.noreply.github.com>
Co-authored-by: Supun Dulara <e20087@eng.pdn.ac.lk>
  • Loading branch information
5 people authored Nov 13, 2024
1 parent 20f6e62 commit 3a569f7
Show file tree
Hide file tree
Showing 66 changed files with 3,464 additions and 1,887 deletions.
17 changes: 10 additions & 7 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,23 @@ LOG_LEVEL=debug
LOG_DISCORD_WEBHOOK_URL=

# Drivers
DB_CONNECTION=mysql
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DRIVER=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

# Database
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
# Database - SQLlite
DB_CONNECTION=sqlite
DB_DATABASE=database/database.sqlite

# DB_CONNECTION=mysql
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=

# Cache
MEMCACHED_HOST=127.0.0.1
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/laravel_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:
jobs:
laravel-tests:
runs-on: ubuntu-latest
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite

steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
Expand All @@ -20,9 +23,17 @@ jobs:
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"

- name: Remove existing composer.lock
run: rm ./composer.lock

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist

- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Generate key
run: php artisan key:generate

Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/laravel_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on: [push]
jobs:
laravel-tests:
runs-on: ubuntu-latest
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite

steps:
- uses: shivammathur/setup-php@15c43e89cdef867065b0213be354c2841860869e
Expand All @@ -13,19 +16,24 @@ jobs:
- uses: actions/checkout@v2
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.example', '.env');"

- name: Remove existing composer.lock
run: rm ./composer.lock

- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Create Database
run: |
mkdir -p database
touch database/database.sqlite
- name: Generate key
run: php artisan key:generate

- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache

- name: Execute tests (Unit and Feature tests) via PHPUnit
env:
DB_CONNECTION: sqlite
DB_DATABASE: database/database.sqlite
run: |
php artisan test -p --colors --debug
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
[![Laravel CI](https://github.com/cepdnaclk/portal.ce.pdn.ac.lk/actions/workflows/laravel_push.yml/badge.svg)](https://github.com/cepdnaclk/portal.ce.pdn.ac.lk/actions/workflows/laravel_push.yml) ![GitHub Release](https://img.shields.io/github/v/release/cepdnaclk/portal.ce.pdn.ac.lk)




# portal.ce.pdn.ac.lk

Internal and Public web service provider of the Department of Computer Engineering

## Team of Developers


To be updated
- [https://portal.ce.pdn.ac.lk/contributors](https://portal.ce.pdn.ac.lk/contributors)

## Useful Commands and Instructions

Expand Down Expand Up @@ -133,6 +137,8 @@ sudo sh ./scripts/deploy-prod.sh

Thanks to all the contributors who have helped with this project!

<a href="https://github.com/cepdnaclk/portal.ce.pdn.ac.lk/graphs/contributors">
<a href="https://portal.ce.pdn.ac.lk/contributors">
https://portal.ce.pdn.ac.lk/contributors
<br/><br/>
<img src="https://contrib.rocks/image?repo=cepdnaclk/portal.ce.pdn.ac.lk" />
</a>
</a>
27 changes: 27 additions & 0 deletions app/DBAL/Types/VersionEnumType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\DBAL\Types;

use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
use App\Domains\AcademicProgram\Course\Models\Course;

class VersionEnumType extends Type
{
const ENUM = 'enum';

public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return "ENUM('" . implode("','", array_keys(Course::getVersions())) . "')";
}

public function convertToPHPValue($value, AbstractPlatform $platform)
{
return $value;
}

public function getName()
{
return self::ENUM;
}
}
27 changes: 22 additions & 5 deletions app/Domains/AcademicProgram/AcademicProgram.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,36 @@ public static function getAcademicPrograms(): array
];
}

public static function getVersions(): array
public static function getVersions($academicProgram = null): array
{
// TODO integrate with Taxonomies
return [
1 => 'Current Curriculum',
2 => 'Curriculum - Effective from E22'
$academicPrograms = [
'undergraduate' => [
1 => 'Current Curriculum',
2 => 'Curriculum - Effective from E22'
],
'postgraduate' => [
3 => 'Current Curriculum - PG',
]
];

if ($academicProgram == null) {
$allAcademicPrograms = [];
foreach ($academicPrograms as $programs) {
foreach ($programs as $key => $value) $allAcademicPrograms[$key] = $value;
}
return $allAcademicPrograms;
} else if (array_key_exists($academicProgram, $academicPrograms)) {
return $academicPrograms[$academicProgram];
} else {
return [];
}
}

public static function getTypes(): array
{
return [
'Found' => 'Foundation',
'Foundation' => 'Foundation',
'Core' => 'Core',
'GE' => 'General Elective',
'TE' => 'Technical Elective'
Expand Down
37 changes: 31 additions & 6 deletions app/Domains/AcademicProgram/Course/Models/Course.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
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;
use App\Domains\AcademicProgram\AcademicProgram;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Domains\AcademicProgram\Semester\Models\Semester;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use App\Domains\AcademicProgram\Course\Models\Traits\Scope\CourseScope;

/**
* Class Course.
Expand All @@ -35,6 +36,8 @@ class Course extends AcademicProgram
'name',
'credits',
'type',
'teaching_methods',
'faq_page',
'content',
'objectives',
'time_allocation',
Expand Down Expand Up @@ -77,8 +80,9 @@ public static function getMarksAllocation(): array
// TODO Get the list from Taxonomies
return [
'practicals' => null,
'tutorials' => null,
'quizzes' => null,
'assignments' => null,
'tutorials' => null,
'projects' => null,
'participation' => null,
'mid_exam' => null,
Expand Down Expand Up @@ -121,14 +125,35 @@ public function semester()

public function version()
{
return $this->getVersions()[$this->version];
$versions = $this->getVersions();
if ($this->version != null && array_key_exists($this->version, $versions)) {
return $versions[$this->version];
} else {
return "Unknown";
}
}

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

/**
* Get the prerequisites for the course.
*/
public function prerequisites(): BelongsToMany
{
return $this->belongsToMany(Course::class, 'course_prerequisites', 'course_id', 'prerequisite_id');
}

/**
* Get the courses where this course is a prerequisite.
*/
public function prerequisiteFor(): BelongsToMany
{
return $this->belongsToMany(Course::class, 'course_prerequisites', 'prerequisite_id', 'course_id');
}

protected static function newFactory()
{
return CourseFactory::new();
Expand Down
4 changes: 2 additions & 2 deletions app/Domains/Auth/Services/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public function destroy(User $user): bool
*/
protected function createUser(array $data = []): User
{
return $this->model::create([
return $this->model::updateOrCreate([
'type' => $data['type'] ?? $this->model::TYPE_USER,
'name' => $data['name'] ?? null,
'email' => $data['email'] ?? null,
Expand All @@ -330,4 +330,4 @@ protected function createUser(array $data = []): User
'active' => $data['active'] ?? true,
]);
}
}
}
13 changes: 13 additions & 0 deletions app/Domains/Event/Models/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Event extends Model
protected $fillable = [
'title',
'url',
'event_type',
'published_at',
'description',
'image',
Expand All @@ -46,8 +47,20 @@ class Event extends Model
*/
protected $casts = [
'enabled' => 'boolean',
'event_type' => 'array',
];

public static function eventTypeMap(): array
{
// TODO integrate with Taxonomies
return [
0 => 'Event',
1 => 'Seminar',
2 => 'ACES',

];
}

public function thumbURL()
{
if ($this->image != null) return '/img/events/' . $this->image;
Expand Down
58 changes: 0 additions & 58 deletions app/Domains/Event/Services/AnnouncementService.php

This file was deleted.

Loading

0 comments on commit 3a569f7

Please sign in to comment.