Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin Study Monitoring #385

Merged
merged 32 commits into from
Jul 21, 2022
Merged

Plugin Study Monitoring #385

merged 32 commits into from
Jul 21, 2022

Conversation

christhofer
Copy link
Contributor

@christhofer christhofer commented Jun 30, 2022

Step saat merge

1. Run

composer require masbug/flysystem-google-drive-ext:"^1.0.0"
php artisan migrate
php artisan migrate --database=tenant --path=database/migrations/tenant

2. (Optional) Re cache config and routes

php artisan optimize

3. Enable google drive api

https://console.cloud.google.com/apis/library/drive.googleapis.com

4. Tambah Authorised redirect URIs

Go to https://console.cloud.google.com/apis/credentials
Click client name in OAuth 2.0 Client IDs
Add https://cloud.point.red/oauth/google/callback in Authorised redirect URIs (base app url, without tenant subdomain)

5. Edit .env tambahkan

image

GOOGLE_PROJECT_ID=
GOOGLE_DRIVE_ROOT=POINT_DEV # default location file dalam google drive user

6. Insert plugin study to database

$plugin = [
    'name' => 'STUDY',
    'description' => 'Document your child learning activities',
];

7. Insert permission (maybe with php artisan tinker)

$permissions = [
    'menu study',
    'read study sheets',
    'create study sheets',
    'edit study sheets',
    'delete study sheets',
    'read study subjects',
    'create study subjects',
    'edit study subjects',
    'delete study subjects',
];

foreach ($permissions as $permission) {
    \App\Model\Auth\Permission::create(['name' => $permission, 'guard_name' => 'api']);
}

8. Insert role (maybe with php artisan tinker)

$role = \App\Model\Auth\Role::create(['name' => 'Parent', 'guard_name' => 'api']);

9. Give permission (maybe with php artisan tinker)

$role = \App\Model\Auth\Role::findByName('Parent', 'api');
$role->givePermissionTo([
    'menu plugin',
    'menu study',
    'read study sheets',
    'create study sheets',
    'edit study sheets',
    'delete study sheets',
]);

10. (Optional) Seed default subjects (maybe with php artisan tinker)

\App\Model\Plugin\Study\StudySubject::create(['name' => 'Math']),
\App\Model\Plugin\Study\StudySubject::create(['name' => 'English']),
\App\Model\Plugin\Study\StudySubject::create(['name' => 'Physics']),
\App\Model\Plugin\Study\StudySubject::create(['name' => 'Biology']),
\App\Model\Plugin\Study\StudySubject::create(['name' => 'Chemistry']),
\App\Model\Plugin\Study\StudySubject::create(['name' => 'History']),
\App\Model\Plugin\Study\StudySubject::create(['name' => 'Geography']),
\App\Model\Plugin\Study\StudySubject::create(['name' => 'Sociology'])

@christhofer christhofer changed the title WIP: study migration and seeder WIP: Plugin Study Monitoring Jun 30, 2022
christhofer and others added 28 commits July 1, 2022 13:32
… sheet

# Conflicts:
#	app/Http/Controllers/Api/Plugin/Study/StudySheetController.php
#	app/Model/Plugin/Study/StudySheet.php
#	database/factories/Plugin/Study/StudySheetFactory.php
#	database/migrations/tenant/2022_06_30_150001_create_study_sheets_table.php
#	database/seeds/PluginSeeder.php
#	tests/Feature/Http/Plugins/Study/StudySheetControllerTest.php
@christhofer christhofer changed the title WIP: Plugin Study Monitoring Plugin Study Monitoring Jul 8, 2022
@christhofer
Copy link
Contributor Author

API documentation

Routes

Route Study Subject

Method Path Description Notes
GET /subject Get subject list API collection Ordered by name ascending. See Request & Response
GET /subject/{subject} Unused, return nothing
POST /subject Create subject See Request & Response
PUT /subject/{subject} Update subject See Request & Response
DELETE /subject/{subject} Delete subject Permanently delete the subject, existing sheet will have no subject

Route Study Sheet

Method Path Description Notes
GET /sheet Get study sheet list Extends eloquent filter. See Response
GET /sheet/{sheet} Get detail study sheet See Response
POST /sheet Create study sheet See Request & Response
PUT /sheet/{sheet} Update study sheet See Request & Response
DELETE /sheet/{sheet} Delete study sheet

Requests & Responses

Create Study Subject Requests & Responses

REQUEST BODY

Query Notes
- No query params

RESPONSE BODY

{
  "data": [
    {
      "id": 1,
      "name": "Math",
      "created_at": "2022-07-01T06:00:00.000Z",
      "updated_at": "2022-07-01T06:00:00.000Z",
    }
  ],
}
Attribute Notes
id Unsigned BigInt, auto increment
name String
created_at Timestamp, format: ISO String
updated_at Timestamp, format: ISO String

Create Study Subject Requests & Responses

REQUEST BODY

Fields Validation Rules
name required, string, max length 255
{
  "name": "Math",
}

RESPONSE BODY

{
  "id": 1,
  "name": "Math",
  "created_at": "2022-07-01T06:00:00.000Z",
  "updated_at": "2022-07-01T06:00:00.000Z",
}

Study Sheet Index Requests & Responses

REQUEST BODY

{
  "id": 1,
  "is_draft": true,
  "started_at": "2022-07-01T06:00:00.000Z",
  "ended_at": "2022-07-01T06:30:00.000Z",
  "subject_id": 1,
  "subject": {
    "id": 1,
    "name": "Math",
  },
  "institution": "ruangguru.com",
  "teacher": "John Doe",
  "competency": "Algebra",
  "learning_goals": "understand basic algebra",
  "activities": "classroom",
  "grade": 90,
  "behavior": "A",
  "remarks": "can follow the learning session",
  "created_at": "2022-07-01T06:00:00.000Z",
  "updated_at": "2022-07-01T06:00:00.000Z",
}

RESPONSE BODY

{
  "data": [
    {
      "id": 1,
      "is_draft": true,
      "started_at": "2022-07-01T06:00:00.000Z", // timestamp, ISO string
      "ended_at": "2022-07-01T06:30:00.000Z", // timestamp, ISO string
      "subject_id": 1,
      "subject": {
        "id": 1,
        "name": "Math",
      },
      "institution": "ruangguru.com",
      "teacher": "John Doe",
      "competency": "Algebra",
      "learning_goals": "understand basic algebra",
      "activities": "classroom",
      "grade": 90,
      "behavior": "A",
      "remarks": "can follow the learning session",
      "created_at": "2022-07-01T06:00:00.000Z", // Timestamp, format: ISO String  
      "updated_at": "2022-07-01T06:00:00.000Z", // Timestamp, format: ISO String  
    }
  ],
  "meta": {
    "from": 1,
    "to": 25,
    "total": 250,
    "last_page": 10,
    "current_page": 1,
  },
}

Study Sheet Create Requests & Responses

Used to create sheet

Fields Validation Rules
is_draft required, boolean
started_at required if is_draft = false
ended_at required if is_draft = false
photo nullable, image
audio nullable, audio
video nullable, video
subject_id required if is_draft = false, exists in table study_subjects
institution nullable, string, max: 180
teacher nullable, string, max: 180
competency required if is_draft = false, string, max:180
learning_goals required if is_draft = false, string, max:180
activities nullable, string, max:180
grade nullable, integer, max:100
behavior required if is_draft = false, string, max:1, only "A" / "B" / "C"
remarks nullable, string, max:180

REQUEST BODY

{
  "is_draft": true,
  "started_at": "2022-07-01T06:00:00.000Z", // timestamp, ISO string
  "ended_at": "2022-07-01T06:30:00.000Z", // timestamp, ISO string
  "photo": "<file>", // File, Image. Use multipart/form-data
  "audio": "<file>", // File, Audio. Use multipart/form-data
  "video": "<file>", // File, Video. Use multipart/form-data
  "subject_id": 1,
  "institution": "ruangguru.com",
  "teacher": "John Doe",
  "competency": "Algebra",
  "learning_goals": "understand basic algebra",
  "activities": "classroom",
  "grade": 90,
  "behavior": "A",
  "remarks": "can follow the learning session",
}

RESPONSE BODY

{
  "id": 1,
  "is_draft": true,
  "started_at": "2022-07-01T06:00:00.000Z",
  "ended_at": "2022-07-01T06:30:00.000Z",
  "photo": "<preview_link_to_file_in_gdrive>", // put this link to an iframe
  "audio": "<preview_link_to_file_in_gdrive>", // put this link to an iframe
  "video": "<preview_link_to_file_in_gdrive>", // put this link to an iframe
  "subject_id": 1,
  "subject": {
    "id": 1,
    "name": "Math",
  },
  "institution": "ruangguru.com",
  "teacher": "John Doe",
  "competency": "Algebra",
  "learning_goals": "understand basic algebra",
  "activities": "classroom",
  "grade": 90,
  "behavior": "A",
  "remarks": "can follow the learning session",
  "created_at": "2022-07-01T06:00:00.000Z",
  "updated_at": "2022-07-01T06:00:00.000Z",
}

Study Sheet Update Requests & Responses

Used to update sheet

Fields Validation Rules
is_draft required, boolean
started_at required if is_draft = false
ended_at required if is_draft = false
photo_file_id nullable, string
audio_file_id nullable, string
video_file_id nullable, string
photo nullable, image
audio nullable, audio
video nullable, video
subject_id required if is_draft = false, exists in table study_subjects
institution nullable, string, max: 180
teacher nullable, string, max: 180
competency required if is_draft = false, string, max:180
learning_goals required if is_draft = false, string, max:180
activities nullable, string, max:180
grade nullable, integer, max:100
behavior required if is_draft = false, string, max:1, only "A" / "B" / "C"
remarks nullable, string, max:180

REQUEST BODY

{
  "is_draft": true,
  "started_at": "2022-07-01T06:00:00.000Z", // timestamp, ISO string
  "ended_at": "2022-07-01T06:30:00.000Z", // timestamp, ISO string
  "photo_file_id": "<file>", // if don't want to update the file
  "audio_file_id": "<file>", // if don't want to update the file
  "video_file_id": "<file>", // if don't want to update the file
  "photo": "<file>", // if updating the file
  "audio": "<file>", // if updating the file
  "video": "<file>", // if updating the file
  "subject_id": 1,
  "institution": "ruangguru.com",
  "teacher": "John Doe",
  "competency": "Algebra",
  "learning_goals": "understand basic algebra",
  "activities": "classroom",
  "grade": 90,
  "behavior": "A",
  "remarks": "can follow the learning session",
}

RESPONSE BODY

{
  "id": 1,
  "is_draft": true,
  "started_at": "2022-07-01T06:00:00.000Z",
  "ended_at": "2022-07-01T06:30:00.000Z",
  "photo": "<preview_link_to_file_in_gdrive>", // put this link to an iframe
  "audio": "<preview_link_to_file_in_gdrive>", // put this link to an iframe
  "video": "<preview_link_to_file_in_gdrive>", // put this link to an iframe
  "subject_id": 1,
  "subject": {
    "id": 1,
    "name": "Math",
  },
  "institution": "ruangguru.com",
  "teacher": "John Doe",
  "competency": "Algebra",
  "learning_goals": "understand basic algebra",
  "activities": "classroom",
  "grade": 90,
  "behavior": "A",
  "remarks": "can follow the learning session",
  "created_at": "2022-07-01T06:00:00.000Z",
  "updated_at": "2022-07-01T06:00:00.000Z",
}

@martiendt martiendt merged commit 4596adb into point-red:alpha1 Jul 21, 2022
@christhofer
Copy link
Contributor Author

christhofer commented Dec 1, 2022

Notes to setting up local dev with Laragon

Backend

  • set PHP to v7.3
  • cp .env.example .env
  • set .env API_URL=https://api.point.test
  • set .env WEBSITE_URL=https://point.test
  • set .env TENANT_DOMAIN=point.test:8080
  • set hostfile api.point.test, dev.point.test
  • composer install --ignore-platform-reqs
  • php artisan key:generate
  • php artisan dev:new
  • seed table point_dev.study_subjects (lihat di bawah)
  • seed table point.plugin_project

Frontend

Seed study subject

\App\Model\Plugin\Study\StudySubject::create(['name' => 'Math'])
\App\Model\Plugin\Study\StudySubject::create(['name' => 'English'])
\App\Model\Plugin\Study\StudySubject::create(['name' => 'Physics'])
\App\Model\Plugin\Study\StudySubject::create(['name' => 'Biology'])
\App\Model\Plugin\Study\StudySubject::create(['name' => 'Chemistry'])
\App\Model\Plugin\Study\StudySubject::create(['name' => 'History'])
\App\Model\Plugin\Study\StudySubject::create(['name' => 'Geography'])
\App\Model\Plugin\Study\StudySubject::create(['name' => 'Sociology'])

Set staging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants