-
Notifications
You must be signed in to change notification settings - Fork 4
Education #151
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
Open
Munkhorgilb
wants to merge
49
commits into
main
Choose a base branch
from
education
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Education #151
Changes from 42 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
225b096
education UI
Munkhorgilb c10ab04
education backend initial
Munkhorgilb 1f13f73
fixes
Munkhorgilb e61e0e8
merge
Munkhorgilb d827a16
Education UI & Backend fix improvements
Munkhorgilb 7a65009
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 7d665a1
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 14ebb16
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 6469534
course list cursor
Munkhorgilb fd285bf
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 0ea2612
fixes
Munkhorgilb 9591942
merge
Munkhorgilb 2661111
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb caca12c
feat: class schema, apollo
Munkhorgilb ea47a6b
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 4425b47
fixes
Munkhorgilb 823eac9
Adding class UI
Munkhorgilb b818de7
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 1a47cb2
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 4d9d46d
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 6ab9682
feat:education fixes
Munkhorgilb 2ae3dd4
feat: add course category management to education module
Munkhorgilb 1ac9b22
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb c9e9f2e
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 23f58a5
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb d608c36
Refactor CourseDetail module
Munkhorgilb 18b5b60
Enhance course module:
Munkhorgilb 6848457
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb cf6bb52
course, class UI improvement
Munkhorgilb e1aa931
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 48b74f2
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 280bc3c
course tab
Munkhorgilb 28331a0
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 26d1684
Refactor education plugin: restructure GraphQL schema, resolvers, and…
Munkhorgilb d855f1b
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 6de3ba8
upd
Munkhorgilb dbf9567
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb a8e9deb
feat(teachers): add teachers module with GraphQL API and UI integration
Munkhorgilb 3644115
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 1cac5d8
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb f582e87
Refactor and enhance course and class components
Munkhorgilb a0126d2
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb c2ae10d
Refactor and enhance education module: updated class, course, comment…
Munkhorgilb ce494af
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 37bdd83
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 7c4d981
feat(students): implement student module in education plugin
Munkhorgilb 709a548
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 2b7eb6e
Merge branch 'main' of github.com:erxes/erxes-next into education
Munkhorgilb 0971d28
merge
Munkhorgilb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "name": "education", | ||
| "version": "1.0.0", | ||
| "description": "", | ||
| "main": "index.js", | ||
| "scripts": { | ||
| "dev": "tsx watch src/main.ts", | ||
| "build": "tsc --project tsconfig.build.json && tsc-alias -p tsconfig.build.json", | ||
| "start": "node -r tsconfig-paths/register dist/src/main.js" | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "dependencies": { | ||
| "erxes-api-shared": "workspace:^" | ||
| }, | ||
| "devDependencies": {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| { | ||
| "name": "education_api", | ||
| "$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
| "sourceRoot": "backend/plugins/education_api/src", | ||
| "projectType": "application", | ||
| "tags": [], | ||
| "targets": { | ||
| "build": { | ||
| "executor": "nx:run-commands", | ||
| "cache": true, | ||
| "options": { | ||
| "cwd": "backend/plugins/education_api", | ||
| "commands": ["pnpm build"] | ||
| }, | ||
| "dependsOn": ["^build", "build:packageJson"] | ||
| }, | ||
|
|
||
| "build:packageJson": { | ||
| "executor": "@nx/js:tsc", | ||
| "options": { | ||
| "main": "backend/plugins/education_api/dist/src/main.js", | ||
| "tsConfig": "backend/plugins/education_api/tsconfig.build.json", | ||
| "outputPath": "backend/plugins/education_api/dist", | ||
| "updateBuildableProjectDepsInPackageJson": true, | ||
|
|
||
| "buildableProjectDepsInPackageJsonType": "dependencies" | ||
| } | ||
| }, | ||
|
|
||
| "start": { | ||
| "executor": "nx:run-commands", | ||
| "dependsOn": ["typecheck", "build"], | ||
| "options": { | ||
| "cwd": "backend/plugins/education_api", | ||
| "command": "NODE_ENV=development && node dist/src/main.js" | ||
| } | ||
| }, | ||
|
|
||
| "serve": { | ||
| "executor": "nx:run-commands", | ||
|
|
||
| "options": { | ||
| "cwd": "backend/plugins/education_api", | ||
| "command": "NODE_ENV=development && pnpm dev" | ||
| } | ||
| }, | ||
|
|
||
| "docker-build": { | ||
| "dependsOn": ["build"], | ||
| "command": "docker build -f backend/plugins/education_api/Dockerfile . -t education_api" | ||
| } | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
backend/plugins/education_api/src/apollo/resolvers/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { apolloCustomScalars } from 'erxes-api-shared/utils'; | ||
| import { customResolvers } from './resolvers'; | ||
| import { mutations } from './mutations'; | ||
| import { queries } from './queries'; | ||
|
|
||
| const resolvers: any = { | ||
| Mutation: { | ||
| ...mutations, | ||
| }, | ||
| Query: { | ||
| ...queries, | ||
| }, | ||
| ...apolloCustomScalars, | ||
| ...customResolvers, | ||
| }; | ||
|
|
||
| export default resolvers; |
11 changes: 11 additions & 0 deletions
11
backend/plugins/education_api/src/apollo/resolvers/mutations.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { courseMutations } from '@/courses/graphql/resolvers/mutations'; | ||
| import { classMutations } from '@/class/graphql/resolvers/mutations'; | ||
| import { commentMutations } from '@/comments/graphql/resolvers/mutations'; | ||
| import { teacherMutations } from '@/teachers/graphql/resolvers/mutations'; | ||
|
|
||
| export const mutations = { | ||
| ...courseMutations, | ||
| ...classMutations, | ||
| ...commentMutations, | ||
| ...teacherMutations, | ||
| }; |
11 changes: 11 additions & 0 deletions
11
backend/plugins/education_api/src/apollo/resolvers/queries.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| import { courseQueries } from '@/courses/graphql/resolvers/queries'; | ||
| import { classQueries } from '@/class/graphql/resolvers/queries'; | ||
| import { commentQueries } from '@/comments/graphql/resolvers/queries'; | ||
| import { teacherQueries } from '@/teachers/graphql/resolvers/queries'; | ||
|
|
||
| export const queries = { | ||
| ...courseQueries, | ||
| ...classQueries, | ||
| ...commentQueries, | ||
| ...teacherQueries, | ||
| }; |
9 changes: 9 additions & 0 deletions
9
backend/plugins/education_api/src/apollo/resolvers/resolvers.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import courseResolvers from '@/courses/graphql/resolvers/customResolvers'; | ||
| import commentResolvers from '@/comments/graphql/resolvers/customResolvers'; | ||
| import teacherResolvers from '@/teachers/graphql/resolvers/customResolvers'; | ||
|
|
||
| export const customResolvers = { | ||
| ...teacherResolvers, | ||
| ...courseResolvers, | ||
| ...commentResolvers, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { | ||
| mutations as CoursesMutations, | ||
| queries as CoursesQueries, | ||
| types as CoursesTypes, | ||
| } from '@/courses/graphql/schemas/courses'; | ||
| import { | ||
| mutations as ClassMutations, | ||
| queries as ClassQueries, | ||
| types as ClassTypes, | ||
| } from '@/class/graphql/schemas/class'; | ||
| import { | ||
| mutations as CommentMutations, | ||
| queries as CommentQueries, | ||
| types as CommentTypes, | ||
| } from '@/comments/graphql/schemas/comments'; | ||
| import { | ||
| mutations as TeacherMutations, | ||
| queries as TeacherQueries, | ||
| types as TeacherTypes, | ||
| } from '@/teachers/graphql/schemas/teachers'; | ||
|
|
||
| export const types = ` | ||
| enum CacheControlScope { | ||
| PUBLIC | ||
| PRIVATE | ||
| } | ||
|
|
||
| directive @cacheControl( | ||
| maxAge: Int | ||
| scope: CacheControlScope | ||
| inheritMaxAge: Boolean | ||
| ) on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ||
| ${CoursesTypes} | ||
| ${ClassTypes} | ||
| ${CommentTypes} | ||
| ${TeacherTypes} | ||
| `; | ||
|
|
||
| export const queries = ` | ||
| ${CoursesQueries} | ||
| ${ClassQueries} | ||
| ${CommentQueries} | ||
| ${TeacherQueries} | ||
| `; | ||
|
|
||
| export const mutations = ` | ||
| ${CoursesMutations} | ||
| ${ClassMutations} | ||
| ${CommentMutations} | ||
| ${TeacherMutations} | ||
| `; | ||
|
|
||
| export default { types, queries, mutations }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { apolloCommonTypes } from 'erxes-api-shared/utils'; | ||
| import { DocumentNode } from 'graphql'; | ||
| import { gql } from 'graphql-tag'; | ||
| import { mutations, queries, types } from '~/apollo/schema/schema'; | ||
|
|
||
| export const typeDefs = async (): Promise<DocumentNode> => { | ||
| return gql(` | ||
| ${apolloCommonTypes} | ||
| ${types} | ||
| extend type Query { | ||
| ${queries} | ||
| } | ||
| extend type Mutation { | ||
| ${mutations} | ||
| } | ||
| `); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import mongoose from 'mongoose'; | ||
| import { createGenerateModels } from 'erxes-api-shared/utils'; | ||
| import { IMainContext } from 'erxes-api-shared/core-types'; | ||
| import { loadCourseClass, ICourseModel } from '@/courses/db/models/Course'; | ||
| import { | ||
| loadCourseCategoryClass, | ||
| ICourseCategoryModel, | ||
| } from '@/courses/db/models/Categories'; | ||
| import { IClassModel, loadClassesClass } from '@/class/db/models/Classes'; | ||
| import { ICommentModel, loadCommentClass } from '@/comments/db/models/Comments'; | ||
| import { ITeacherModel, loadTeacherClass } from '@/teachers/db/models/Teachers'; | ||
| // | ||
| import { ICourseDocument } from '@/courses/@types/course'; | ||
| import { IClassDocument } from '@/class/@types/classes'; | ||
| import { ICourseCategoryDocument } from '@/courses/@types/category'; | ||
| import { ICommentDocument } from '@/comments/@types/comments'; | ||
| import { ITeacherDocument } from '@/teachers/@types/teachers'; | ||
|
|
||
| export interface IModels { | ||
| Courses: ICourseModel; | ||
| CourseCategories: ICourseCategoryModel; | ||
| Classes: IClassModel; | ||
| Comments: ICommentModel; | ||
| Teachers: ITeacherModel; | ||
| } | ||
|
|
||
| export interface IContext extends IMainContext { | ||
| commonQuerySelector: any; | ||
| models: IModels; | ||
| } | ||
|
|
||
| export const loadClasses = (db: mongoose.Connection): IModels => { | ||
| const models = {} as IModels; | ||
|
|
||
| models.Courses = db.model<ICourseDocument, ICourseModel>( | ||
| 'courses', | ||
| loadCourseClass(models), | ||
| ); | ||
|
|
||
| models.CourseCategories = db.model< | ||
| ICourseCategoryDocument, | ||
| ICourseCategoryModel | ||
| >('course_categories', loadCourseCategoryClass(models)); | ||
|
|
||
| models.Classes = db.model<IClassDocument, IClassModel>( | ||
| 'course_classes', | ||
| loadClassesClass(models), | ||
| ); | ||
|
|
||
| models.Comments = db.model<ICommentDocument, ICommentModel>( | ||
| 'course_comments', | ||
| loadCommentClass(models), | ||
| ); | ||
|
|
||
| models.Teachers = db.model<ITeacherDocument, ITeacherModel>( | ||
| 'course_teachers', | ||
| loadTeacherClass(models), | ||
| ); | ||
|
|
||
| return models; | ||
| }; | ||
|
|
||
| export const generateModels = createGenerateModels<IModels>(loadClasses); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { startPlugin } from 'erxes-api-shared/utils'; | ||
| import resolvers from './apollo/resolvers'; | ||
| import { generateModels } from './connectionResolvers'; | ||
| import { typeDefs } from '~/apollo/typeDefs'; | ||
| import { appRouter } from './trpc/init-trpc'; | ||
|
|
||
| startPlugin({ | ||
| name: 'education', | ||
| port: 3322, | ||
| graphql: async () => ({ | ||
| typeDefs: await typeDefs(), | ||
| resolvers, | ||
| }), | ||
| apolloServerContext: async (subdomain, context) => { | ||
| const models = await generateModels(subdomain); | ||
|
|
||
| context.models = models; | ||
|
|
||
| return context; | ||
| }, | ||
|
|
||
| trpcAppRouter: { | ||
| router: appRouter, | ||
| createContext: async (subdomain, context) => { | ||
| const models = await generateModels(subdomain); | ||
|
|
||
| context.models = models; | ||
|
|
||
| return context; | ||
| }, | ||
| }, | ||
| }); |
25 changes: 25 additions & 0 deletions
25
backend/plugins/education_api/src/modules/class/@types/classes.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { | ||
| ICursorPaginateParams, | ||
| IListParams, | ||
| } from 'erxes-api-shared/core-types'; | ||
| import { Document } from 'mongoose'; | ||
|
|
||
| export interface IClass { | ||
| name: string; | ||
| description: string; | ||
| location: string; | ||
| level: string; | ||
| } | ||
|
|
||
| export interface IClassParams extends IListParams, ICursorPaginateParams { | ||
| name: string; | ||
| description: string; | ||
| location: string; | ||
| level: string; | ||
| } | ||
|
|
||
| export interface IClassDocument extends IClass, Document { | ||
| _id: string; | ||
| createdAt?: Date; | ||
| updatedAt: Date; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| export const CLASS_LEVEL_TYPES = { | ||
| Beginner: 'Beginner', | ||
| Intermediate: 'Intermediate', | ||
| Advanced: 'Advanced', | ||
| ALL: ['Beginner', 'Intermediate', 'Advanced'], | ||
| }; |
24 changes: 24 additions & 0 deletions
24
backend/plugins/education_api/src/modules/class/db/definitions/class.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { Schema } from 'mongoose'; | ||
|
|
||
| import { mongooseStringRandomId } from 'erxes-api-shared/utils'; | ||
| import { CLASS_LEVEL_TYPES } from '../../constants'; | ||
|
|
||
| export const classSchema = new Schema( | ||
| { | ||
| _id: mongooseStringRandomId, | ||
| name: { type: String, required: true, label: 'Name' }, | ||
| description: { type: String, required: true, label: 'Description' }, | ||
| location: { type: String, required: true, label: 'Location' }, | ||
| level: { | ||
| type: String, | ||
| enum: CLASS_LEVEL_TYPES.ALL, | ||
| default: CLASS_LEVEL_TYPES.Beginner, | ||
| label: 'level', | ||
| }, | ||
| createdAt: { type: Date, default: new Date(), label: 'Created at' }, | ||
| updatedAt: { type: Date, default: new Date(), label: 'Updated at' }, | ||
| }, | ||
| { | ||
| timestamps: true, | ||
| }, | ||
| ); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The label for the field
levelis written in lowercase, whereas the other labels (such asName,Description, andLocation) use title case. Consider capitalizingleveltoLevelfor consistency.