diff --git a/backend/src/db/migrations/1774262568375.js b/backend/src/db/migrations/1774262568375.js new file mode 100644 index 0000000..e6bfba3 --- /dev/null +++ b/backend/src/db/migrations/1774262568375.js @@ -0,0 +1,36 @@ +module.exports = { + /** + * @param {QueryInterface} queryInterface + * @param {Sequelize} Sequelize + * @returns {Promise} + */ + async up(queryInterface, Sequelize) { + /** + * @type {Transaction} + */ + const transaction = await queryInterface.sequelize.transaction(); + try { + await transaction.commit(); + } catch (err) { + await transaction.rollback(); + throw err; + } + }, + /** + * @param {QueryInterface} queryInterface + * @param {Sequelize} Sequelize + * @returns {Promise} + */ + async down(queryInterface, Sequelize) { + /** + * @type {Transaction} + */ + const transaction = await queryInterface.sequelize.transaction(); + try { + await transaction.commit(); + } catch (err) { + await transaction.rollback(); + throw err; + } + }, +}; diff --git a/backend/src/db/seeders/20200430130760-user-roles.js b/backend/src/db/seeders/20200430130760-user-roles.js index 35306ae..23260d2 100644 --- a/backend/src/db/seeders/20200430130760-user-roles.js +++ b/backend/src/db/seeders/20200430130760-user-roles.js @@ -1,5 +1,4 @@ - -const { v4: uuid } = require("uuid"); +const { v4: uuid } = require('uuid'); module.exports = { /** @@ -26,26 +25,35 @@ module.exports = { return id; } - await queryInterface.bulkInsert("roles", [ - - - { id: getId("Administrator"), name: "Administrator", createdAt, updatedAt }, - - - - { id: getId("PlatformOwner"), name: "Platform Owner", createdAt, updatedAt }, - - { id: getId("OpsManager"), name: "Ops Manager", createdAt, updatedAt }, - - { id: getId("LeadInstructor"), name: "Lead Instructor", createdAt, updatedAt }, - - { id: getId("Instructor"), name: "Instructor", createdAt, updatedAt }, - - { id: getId("Learner"), name: "Learner", createdAt, updatedAt }, - - - - { id: getId("Public"), name: "Public", createdAt, updatedAt }, + await queryInterface.bulkInsert('roles', [ + { + id: getId('Administrator'), + name: 'Administrator', + createdAt, + updatedAt, + }, + + { + id: getId('PlatformOwner'), + name: 'Platform Owner', + createdAt, + updatedAt, + }, + + { id: getId('OpsManager'), name: 'Ops Manager', createdAt, updatedAt }, + + { + id: getId('LeadInstructor'), + name: 'Lead Instructor', + createdAt, + updatedAt, + }, + + { id: getId('Instructor'), name: 'Instructor', createdAt, updatedAt }, + + { id: getId('Learner'), name: 'Learner', createdAt, updatedAt }, + + { id: getId('Public'), name: 'Public', createdAt, updatedAt }, ]); /** @@ -53,22 +61,78 @@ module.exports = { */ function createPermissions(name) { return [ - { id: getId(`CREATE_${name.toUpperCase()}`), createdAt, updatedAt, name: `CREATE_${name.toUpperCase()}` }, - { id: getId(`READ_${name.toUpperCase()}`), createdAt, updatedAt, name: `READ_${name.toUpperCase()}` }, - { id: getId(`UPDATE_${name.toUpperCase()}`), createdAt, updatedAt, name: `UPDATE_${name.toUpperCase()}` }, - { id: getId(`DELETE_${name.toUpperCase()}`), createdAt, updatedAt, name: `DELETE_${name.toUpperCase()}` } + { + id: getId(`CREATE_${name.toUpperCase()}`), + createdAt, + updatedAt, + name: `CREATE_${name.toUpperCase()}`, + }, + { + id: getId(`READ_${name.toUpperCase()}`), + createdAt, + updatedAt, + name: `READ_${name.toUpperCase()}`, + }, + { + id: getId(`UPDATE_${name.toUpperCase()}`), + createdAt, + updatedAt, + name: `UPDATE_${name.toUpperCase()}`, + }, + { + id: getId(`DELETE_${name.toUpperCase()}`), + createdAt, + updatedAt, + name: `DELETE_${name.toUpperCase()}`, + }, ]; } const entities = [ - "users","roles","permissions","courses","course_sections","lessons","enrollments","lesson_progress","course_reviews","course_announcements","quizzes","quiz_questions","quiz_options","quiz_attempts","assignment_submissions","marketing_pages","contact_messages","pricing_plans","plan_features",, + 'roles', + 'permissions', + 'courses', + 'course_sections', + 'lessons', + 'enrollments', + 'lesson_progress', + 'course_reviews', + 'course_announcements', + 'quizzes', + 'quiz_questions', + 'quiz_options', + 'quiz_attempts', + 'assignment_submissions', + 'marketing_pages', + 'contact_messages', + 'pricing_plans', + 'plan_features', + 'users', + , ]; -await queryInterface.bulkInsert("permissions", entities.flatMap(createPermissions)); -await queryInterface.bulkInsert("permissions", [{ id: getId(`READ_API_DOCS`), createdAt, updatedAt, name: `READ_API_DOCS` }]); -await queryInterface.bulkInsert("permissions", [{ id: getId(`CREATE_SEARCH`), createdAt, updatedAt, name: `CREATE_SEARCH`}]); + await queryInterface.bulkInsert( + 'permissions', + entities.flatMap(createPermissions), + ); + await queryInterface.bulkInsert('permissions', [ + { + id: getId(`READ_API_DOCS`), + createdAt, + updatedAt, + name: `READ_API_DOCS`, + }, + ]); + await queryInterface.bulkInsert('permissions', [ + { + id: getId(`CREATE_SEARCH`), + createdAt, + updatedAt, + name: `CREATE_SEARCH`, + }, + ]); - -await queryInterface.sequelize.query(`create table "rolesPermissionsPermissions" + await queryInterface.sequelize + .query(`create table "rolesPermissionsPermissions" ( "createdAt" timestamp with time zone not null, "updatedAt" timestamp with time zone not null, @@ -77,1798 +141,1874 @@ await queryInterface.sequelize.query(`create table "rolesPermissionsPermissions" primary key ("roles_permissionsId", "permissionId") );`); + await queryInterface.bulkInsert('rolesPermissionsPermissions', [ + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_COURSES'), + }, -await queryInterface.bulkInsert("rolesPermissionsPermissions", [ - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_USERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_USERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_USERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_USERS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_USERS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_USERS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('UPDATE_USERS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_USERS') }, - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('UPDATE_USERS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_COURSES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_COURSES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_COURSES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_COURSES') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_COURSES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_COURSES') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('CREATE_COURSES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('READ_COURSES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('UPDATE_COURSES') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_COURSES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_COURSES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_COURSES') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('READ_COURSES') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_COURSE_SECTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_COURSE_SECTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_COURSE_SECTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_COURSE_SECTIONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_COURSE_SECTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_COURSE_SECTIONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('CREATE_COURSE_SECTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('READ_COURSE_SECTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('UPDATE_COURSE_SECTIONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_COURSE_SECTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_COURSE_SECTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_COURSE_SECTIONS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('READ_COURSE_SECTIONS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_LESSONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_LESSONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_LESSONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_LESSONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_LESSONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_LESSONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('CREATE_LESSONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('READ_LESSONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('UPDATE_LESSONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_LESSONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_LESSONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_LESSONS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('READ_LESSONS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_ENROLLMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_ENROLLMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_ENROLLMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_ENROLLMENTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_ENROLLMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_ENROLLMENTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('READ_ENROLLMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('UPDATE_ENROLLMENTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_ENROLLMENTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_ENROLLMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('READ_ENROLLMENTS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_LESSON_PROGRESS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_LESSON_PROGRESS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_LESSON_PROGRESS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_LESSON_PROGRESS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_LESSON_PROGRESS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_LESSON_PROGRESS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('READ_LESSON_PROGRESS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('UPDATE_LESSON_PROGRESS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_LESSON_PROGRESS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_LESSON_PROGRESS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('READ_LESSON_PROGRESS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('UPDATE_LESSON_PROGRESS') }, - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_COURSE_REVIEWS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_COURSE_REVIEWS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_COURSE_REVIEWS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_COURSE_REVIEWS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_COURSE_REVIEWS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_COURSE_REVIEWS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('READ_COURSE_REVIEWS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('UPDATE_COURSE_REVIEWS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_COURSE_REVIEWS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_COURSE_REVIEWS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('READ_COURSE_REVIEWS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_COURSE_ANNOUNCEMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_COURSE_ANNOUNCEMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_COURSE_ANNOUNCEMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_COURSE_ANNOUNCEMENTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_COURSE_ANNOUNCEMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_COURSE_ANNOUNCEMENTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('CREATE_COURSE_ANNOUNCEMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('READ_COURSE_ANNOUNCEMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('UPDATE_COURSE_ANNOUNCEMENTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_COURSE_ANNOUNCEMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_COURSE_ANNOUNCEMENTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_COURSE_ANNOUNCEMENTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('READ_COURSE_ANNOUNCEMENTS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_QUIZZES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_QUIZZES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_QUIZZES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_QUIZZES') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_QUIZZES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_QUIZZES') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('CREATE_QUIZZES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('READ_QUIZZES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('UPDATE_QUIZZES') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_QUIZZES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_QUIZZES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_QUIZZES') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('READ_QUIZZES') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_QUIZ_QUESTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_QUIZ_QUESTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_QUIZ_QUESTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_QUIZ_QUESTIONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_QUIZ_QUESTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_QUIZ_QUESTIONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('CREATE_QUIZ_QUESTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('READ_QUIZ_QUESTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('UPDATE_QUIZ_QUESTIONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_QUIZ_QUESTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_QUIZ_QUESTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_QUIZ_QUESTIONS') }, - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_QUIZ_OPTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_QUIZ_OPTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_QUIZ_OPTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_QUIZ_OPTIONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_QUIZ_OPTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_QUIZ_OPTIONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('CREATE_QUIZ_OPTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('READ_QUIZ_OPTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('UPDATE_QUIZ_OPTIONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_QUIZ_OPTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_QUIZ_OPTIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_QUIZ_OPTIONS') }, - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_QUIZ_ATTEMPTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_QUIZ_ATTEMPTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_QUIZ_ATTEMPTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_QUIZ_ATTEMPTS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_QUIZ_ATTEMPTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_QUIZ_ATTEMPTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('READ_QUIZ_ATTEMPTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('UPDATE_QUIZ_ATTEMPTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_QUIZ_ATTEMPTS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_QUIZ_ATTEMPTS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('READ_QUIZ_ATTEMPTS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_ASSIGNMENT_SUBMISSIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_ASSIGNMENT_SUBMISSIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_ASSIGNMENT_SUBMISSIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_ASSIGNMENT_SUBMISSIONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_ASSIGNMENT_SUBMISSIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_ASSIGNMENT_SUBMISSIONS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('READ_ASSIGNMENT_SUBMISSIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('UPDATE_ASSIGNMENT_SUBMISSIONS') }, - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('READ_ASSIGNMENT_SUBMISSIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('UPDATE_ASSIGNMENT_SUBMISSIONS') }, - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_ASSIGNMENT_SUBMISSIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('READ_ASSIGNMENT_SUBMISSIONS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('UPDATE_ASSIGNMENT_SUBMISSIONS') }, - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_MARKETING_PAGES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_MARKETING_PAGES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_MARKETING_PAGES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_MARKETING_PAGES') }, - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('CREATE_MARKETING_PAGES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_MARKETING_PAGES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_MARKETING_PAGES') }, - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('READ_MARKETING_PAGES') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_CONTACT_MESSAGES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_CONTACT_MESSAGES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_CONTACT_MESSAGES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_CONTACT_MESSAGES') }, - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('CREATE_CONTACT_MESSAGES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_CONTACT_MESSAGES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_CONTACT_MESSAGES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('DELETE_CONTACT_MESSAGES') }, - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_CONTACT_MESSAGES') }, - - - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_PRICING_PLANS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_PRICING_PLANS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_PRICING_PLANS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_PRICING_PLANS') }, - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('CREATE_PRICING_PLANS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_PRICING_PLANS') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_PRICING_PLANS') }, - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('READ_PRICING_PLANS') }, - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_PLAN_FEATURES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('READ_PLAN_FEATURES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('UPDATE_PLAN_FEATURES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('DELETE_PLAN_FEATURES') }, - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('CREATE_PLAN_FEATURES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('READ_PLAN_FEATURES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('UPDATE_PLAN_FEATURES') }, - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('READ_PLAN_FEATURES') }, - - - - - - - - - - - - - - - - - - { createdAt, updatedAt, roles_permissionsId: getId("PlatformOwner"), permissionId: getId('CREATE_SEARCH') }, - - { createdAt, updatedAt, roles_permissionsId: getId("OpsManager"), permissionId: getId('CREATE_SEARCH') }, - - { createdAt, updatedAt, roles_permissionsId: getId("LeadInstructor"), permissionId: getId('CREATE_SEARCH') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Instructor"), permissionId: getId('CREATE_SEARCH') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Learner"), permissionId: getId('CREATE_SEARCH') }, - - - - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_USERS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_USERS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_USERS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_USERS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ROLES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ROLES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ROLES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ROLES') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_PERMISSIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PERMISSIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PERMISSIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PERMISSIONS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_COURSES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_COURSES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_COURSES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_COURSES') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_COURSE_SECTIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_COURSE_SECTIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_COURSE_SECTIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_COURSE_SECTIONS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_LESSONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_LESSONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_LESSONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_LESSONS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ENROLLMENTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ENROLLMENTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ENROLLMENTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ENROLLMENTS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_LESSON_PROGRESS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_LESSON_PROGRESS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_LESSON_PROGRESS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_LESSON_PROGRESS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_COURSE_REVIEWS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_COURSE_REVIEWS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_COURSE_REVIEWS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_COURSE_REVIEWS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_COURSE_ANNOUNCEMENTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_COURSE_ANNOUNCEMENTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_COURSE_ANNOUNCEMENTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_COURSE_ANNOUNCEMENTS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_QUIZZES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_QUIZZES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_QUIZZES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_QUIZZES') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_QUIZ_QUESTIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_QUIZ_QUESTIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_QUIZ_QUESTIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_QUIZ_QUESTIONS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_QUIZ_OPTIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_QUIZ_OPTIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_QUIZ_OPTIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_QUIZ_OPTIONS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_QUIZ_ATTEMPTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_QUIZ_ATTEMPTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_QUIZ_ATTEMPTS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_QUIZ_ATTEMPTS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_ASSIGNMENT_SUBMISSIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_ASSIGNMENT_SUBMISSIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_ASSIGNMENT_SUBMISSIONS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_ASSIGNMENT_SUBMISSIONS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_MARKETING_PAGES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_MARKETING_PAGES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_MARKETING_PAGES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_MARKETING_PAGES') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_CONTACT_MESSAGES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_CONTACT_MESSAGES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_CONTACT_MESSAGES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_CONTACT_MESSAGES') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_PRICING_PLANS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PRICING_PLANS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PRICING_PLANS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PRICING_PLANS') }, - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_PLAN_FEATURES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_PLAN_FEATURES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('UPDATE_PLAN_FEATURES') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('DELETE_PLAN_FEATURES') }, - - - - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('READ_API_DOCS') }, - { createdAt, updatedAt, roles_permissionsId: getId("Administrator"), permissionId: getId('CREATE_SEARCH') }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_COURSES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_COURSES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_COURSES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_COURSES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_COURSES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('CREATE_COURSES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('READ_COURSES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('UPDATE_COURSES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('CREATE_COURSES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('READ_COURSES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('UPDATE_COURSES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('READ_COURSES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('CREATE_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('READ_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('UPDATE_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('CREATE_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('READ_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('UPDATE_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('READ_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('CREATE_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('READ_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('UPDATE_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('CREATE_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('READ_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('UPDATE_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('READ_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_ENROLLMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_ENROLLMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_ENROLLMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_ENROLLMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_ENROLLMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_ENROLLMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('READ_ENROLLMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('UPDATE_ENROLLMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('READ_ENROLLMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('CREATE_ENROLLMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('READ_ENROLLMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_LESSON_PROGRESS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_LESSON_PROGRESS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_LESSON_PROGRESS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_LESSON_PROGRESS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_LESSON_PROGRESS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_LESSON_PROGRESS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('READ_LESSON_PROGRESS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('UPDATE_LESSON_PROGRESS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('READ_LESSON_PROGRESS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('CREATE_LESSON_PROGRESS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('READ_LESSON_PROGRESS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('UPDATE_LESSON_PROGRESS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_COURSE_REVIEWS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_COURSE_REVIEWS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_COURSE_REVIEWS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_COURSE_REVIEWS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_COURSE_REVIEWS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_COURSE_REVIEWS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('READ_COURSE_REVIEWS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('UPDATE_COURSE_REVIEWS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('READ_COURSE_REVIEWS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('CREATE_COURSE_REVIEWS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('READ_COURSE_REVIEWS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('CREATE_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('READ_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('UPDATE_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('CREATE_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('READ_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('UPDATE_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('READ_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('CREATE_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('READ_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('UPDATE_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('CREATE_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('READ_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('UPDATE_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('READ_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_QUIZ_QUESTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_QUIZ_QUESTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_QUIZ_QUESTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_QUIZ_QUESTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_QUIZ_QUESTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_QUIZ_QUESTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('CREATE_QUIZ_QUESTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('READ_QUIZ_QUESTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('UPDATE_QUIZ_QUESTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('CREATE_QUIZ_QUESTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('READ_QUIZ_QUESTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('UPDATE_QUIZ_QUESTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_QUIZ_OPTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_QUIZ_OPTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_QUIZ_OPTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_QUIZ_OPTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_QUIZ_OPTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_QUIZ_OPTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('CREATE_QUIZ_OPTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('READ_QUIZ_OPTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('UPDATE_QUIZ_OPTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('CREATE_QUIZ_OPTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('READ_QUIZ_OPTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('UPDATE_QUIZ_OPTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_QUIZ_ATTEMPTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_QUIZ_ATTEMPTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_QUIZ_ATTEMPTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_QUIZ_ATTEMPTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_QUIZ_ATTEMPTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_QUIZ_ATTEMPTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('READ_QUIZ_ATTEMPTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('UPDATE_QUIZ_ATTEMPTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('READ_QUIZ_ATTEMPTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('CREATE_QUIZ_ATTEMPTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('READ_QUIZ_ATTEMPTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('READ_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('UPDATE_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('READ_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('UPDATE_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('CREATE_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('READ_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('UPDATE_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_MARKETING_PAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_MARKETING_PAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_MARKETING_PAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_MARKETING_PAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('CREATE_MARKETING_PAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_MARKETING_PAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_MARKETING_PAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('READ_MARKETING_PAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_CONTACT_MESSAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_CONTACT_MESSAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_CONTACT_MESSAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_CONTACT_MESSAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('CREATE_CONTACT_MESSAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_CONTACT_MESSAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_CONTACT_MESSAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('DELETE_CONTACT_MESSAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('CREATE_CONTACT_MESSAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_PRICING_PLANS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_PRICING_PLANS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_PRICING_PLANS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_PRICING_PLANS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('CREATE_PRICING_PLANS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_PRICING_PLANS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_PRICING_PLANS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('READ_PRICING_PLANS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_PLAN_FEATURES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_PLAN_FEATURES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_PLAN_FEATURES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_PLAN_FEATURES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('CREATE_PLAN_FEATURES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_PLAN_FEATURES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_PLAN_FEATURES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('READ_PLAN_FEATURES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('READ_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('UPDATE_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('DELETE_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('READ_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('UPDATE_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('UPDATE_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('UPDATE_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('UPDATE_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('PlatformOwner'), + permissionId: getId('CREATE_SEARCH'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('OpsManager'), + permissionId: getId('CREATE_SEARCH'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('LeadInstructor'), + permissionId: getId('CREATE_SEARCH'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Instructor'), + permissionId: getId('CREATE_SEARCH'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Learner'), + permissionId: getId('CREATE_SEARCH'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_ROLES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_ROLES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_ROLES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_ROLES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_PERMISSIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_PERMISSIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_PERMISSIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_PERMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_COURSES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_COURSES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_COURSES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_COURSES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_COURSE_SECTIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_COURSE_SECTIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_COURSE_SECTIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_COURSE_SECTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_LESSONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_LESSONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_LESSONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_LESSONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_ENROLLMENTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_ENROLLMENTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_ENROLLMENTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_ENROLLMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_LESSON_PROGRESS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_LESSON_PROGRESS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_LESSON_PROGRESS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_LESSON_PROGRESS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_COURSE_REVIEWS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_COURSE_REVIEWS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_COURSE_REVIEWS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_COURSE_REVIEWS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_COURSE_ANNOUNCEMENTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_COURSE_ANNOUNCEMENTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_COURSE_ANNOUNCEMENTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_COURSE_ANNOUNCEMENTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_QUIZZES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_QUIZZES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_QUIZZES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_QUIZZES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_QUIZ_QUESTIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_QUIZ_QUESTIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_QUIZ_QUESTIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_QUIZ_QUESTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_QUIZ_OPTIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_QUIZ_OPTIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_QUIZ_OPTIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_QUIZ_OPTIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_QUIZ_ATTEMPTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_QUIZ_ATTEMPTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_QUIZ_ATTEMPTS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_QUIZ_ATTEMPTS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_ASSIGNMENT_SUBMISSIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_ASSIGNMENT_SUBMISSIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_ASSIGNMENT_SUBMISSIONS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_ASSIGNMENT_SUBMISSIONS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_MARKETING_PAGES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_MARKETING_PAGES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_MARKETING_PAGES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_MARKETING_PAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_CONTACT_MESSAGES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_CONTACT_MESSAGES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_CONTACT_MESSAGES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_CONTACT_MESSAGES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_PRICING_PLANS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_PRICING_PLANS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_PRICING_PLANS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_PRICING_PLANS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_PLAN_FEATURES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_PLAN_FEATURES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_PLAN_FEATURES'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_PLAN_FEATURES'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_USERS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_USERS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('UPDATE_USERS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('DELETE_USERS'), + }, + + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('READ_API_DOCS'), + }, + { + createdAt, + updatedAt, + roles_permissionsId: getId('Administrator'), + permissionId: getId('CREATE_SEARCH'), + }, ]); + await queryInterface.sequelize.query( + `UPDATE "users" SET "app_roleId"='${getId( + 'SuperAdmin', + )}' WHERE "email"='super_admin@flatlogic.com'`, + ); + await queryInterface.sequelize.query( + `UPDATE "users" SET "app_roleId"='${getId( + 'Administrator', + )}' WHERE "email"='admin@flatlogic.com'`, + ); - await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("SuperAdmin")}' WHERE "email"='super_admin@flatlogic.com'`); - await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("Administrator")}' WHERE "email"='admin@flatlogic.com'`); - - - - - - - await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("PlatformOwner")}' WHERE "email"='client@hello.com'`); - await queryInterface.sequelize.query(`UPDATE "users" SET "app_roleId"='${getId("OpsManager")}' WHERE "email"='john@doe.com'`); - - - - -} + await queryInterface.sequelize.query( + `UPDATE "users" SET "app_roleId"='${getId( + 'PlatformOwner', + )}' WHERE "email"='client@hello.com'`, + ); + await queryInterface.sequelize.query( + `UPDATE "users" SET "app_roleId"='${getId( + 'OpsManager', + )}' WHERE "email"='john@doe.com'`, + ); + }, }; - diff --git a/backend/src/db/seeders/20231127130745-sample-data.js b/backend/src/db/seeders/20231127130745-sample-data.js index 279cea5..3c8d406 100644 --- a/backend/src/db/seeders/20231127130745-sample-data.js +++ b/backend/src/db/seeders/20231127130745-sample-data.js @@ -1,33 +1,6 @@ - - - - - - - - - - - - - - - - - - - - - - const db = require('../models'); const Users = db.users; - - - - - const Courses = db.courses; const CourseSections = db.course_sections; @@ -60,4540 +33,2575 @@ const PricingPlans = db.pricing_plans; const PlanFeatures = db.plan_features; - - - - - - const CoursesData = [ - - { - - - - - "title": "Grace Hopper", - - - - - - - "slug": "Ada Lovelace", - - - - - - - "short_description": "Marie Curie", - - - - - - - "description": "Grace Hopper", - - - - - - - // type code here for "images" field - - - - - - - "level": "all_levels", - - - - - - - "status": "archived", - - - - - - - "price": 9.62, - - - - - - - "currency": "Marie Curie", - - - - - - - "is_free": true, - - - - - - - "published_at": new Date(Date.now()), - - - - - - - // type code here for "relation_one" field - - - - }, - - { - - - - - "title": "Marie Curie", - - - - - - - "slug": "Grace Hopper", - - - - - - - "short_description": "Marie Curie", - - - - - - - "description": "Grace Hopper", - - - - - - - // type code here for "images" field - - - - - - - "level": "beginner", - - - - - - - "status": "published", - - - - - - - "price": 8.14, - - - - - - - "currency": "Ada Lovelace", - - - - - - - "is_free": false, - - - - - - - "published_at": new Date(Date.now()), - - - - - - - // type code here for "relation_one" field - - - - }, - - { - - - - - "title": "Alan Turing", - - - - - - - "slug": "Ada Lovelace", - - - - - - - "short_description": "Marie Curie", - - - - - - - "description": "Ada Lovelace", - - - - - - - // type code here for "images" field - - - - - - - "level": "all_levels", - - - - - - - "status": "draft", - - - - - - - "price": 9.38, - - - - - - - "currency": "Grace Hopper", - - - - - - - "is_free": false, - - - - - - - "published_at": new Date(Date.now()), - - - - - - - // type code here for "relation_one" field - - - - }, - + { + title: 'William Herschel', + + slug: 'Christiaan Huygens', + + short_description: 'Robert Koch', + + description: 'Ernest Rutherford', + + // type code here for "images" field + + level: 'intermediate', + + status: 'draft', + + price: 13.63, + + currency: 'Franz Boas', + + is_free: true, + + published_at: new Date(Date.now()), + + // type code here for "relation_one" field + }, + + { + title: 'Lynn Margulis', + + slug: 'John Bardeen', + + short_description: 'Marcello Malpighi', + + description: 'Theodosius Dobzhansky', + + // type code here for "images" field + + level: 'advanced', + + status: 'draft', + + price: 26.36, + + currency: 'Stephen Hawking', + + is_free: true, + + published_at: new Date(Date.now()), + + // type code here for "relation_one" field + }, + + { + title: 'Alfred Wegener', + + slug: 'Ernst Mayr', + + short_description: 'Gertrude Belle Elion', + + description: 'Francis Crick', + + // type code here for "images" field + + level: 'all_levels', + + status: 'draft', + + price: 67.36, + + currency: 'Joseph J. Thomson', + + is_free: true, + + published_at: new Date(Date.now()), + + // type code here for "relation_one" field + }, + + { + title: 'William Herschel', + + slug: 'Neils Bohr', + + short_description: 'Tycho Brahe', + + description: 'Marcello Malpighi', + + // type code here for "images" field + + level: 'intermediate', + + status: 'draft', + + price: 38.63, + + currency: 'Stephen Hawking', + + is_free: true, + + published_at: new Date(Date.now()), + + // type code here for "relation_one" field + }, + + { + title: 'Carl Gauss (Karl Friedrich Gauss)', + + slug: 'Louis Victor de Broglie', + + short_description: 'Marie Curie', + + description: 'Alexander Fleming', + + // type code here for "images" field + + level: 'all_levels', + + status: 'draft', + + price: 39.13, + + currency: 'Albrecht von Haller', + + is_free: false, + + published_at: new Date(Date.now()), + + // type code here for "relation_one" field + }, ]; - - const CourseSectionsData = [ - - { - - - - - "title": "Marie Curie", - - - - - - - "position": 6, - - - - - - - // type code here for "relation_one" field - - - - }, - - { - - - - - "title": "Grace Hopper", - - - - - - - "position": 8, - - - - - - - // type code here for "relation_one" field - - - - }, - - { - - - - - "title": "Alan Turing", - - - - - - - "position": 2, - - - - - - - // type code here for "relation_one" field - - - - }, - + { + title: 'Carl Gauss (Karl Friedrich Gauss)', + + position: 9, + + // type code here for "relation_one" field + }, + + { + title: 'Werner Heisenberg', + + position: 1, + + // type code here for "relation_one" field + }, + + { + title: 'Edward Teller', + + position: 6, + + // type code here for "relation_one" field + }, + + { + title: 'Isaac Newton', + + position: 9, + + // type code here for "relation_one" field + }, + + { + title: 'Lynn Margulis', + + position: 7, + + // type code here for "relation_one" field + }, ]; - - const LessonsData = [ - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "title": "Grace Hopper", - - - - - - - "slug": "Grace Hopper", - - - - - - - "lesson_type": "assignment", - - - - - - - "content": "Marie Curie", - - - - - - - "video_url": "Grace Hopper", - - - - - - - // type code here for "files" field - - - - - - - "duration_minutes": 7, - - - - - - - "is_preview": true, - - - - - - - "status": "draft", - - - - - - - "position": 8, - - - - - - - "published_at": new Date(Date.now()), - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "title": "Ada Lovelace", - - - - - - - "slug": "Grace Hopper", - - - - - - - "lesson_type": "video", - - - - - - - "content": "Ada Lovelace", - - - - - - - "video_url": "Alan Turing", - - - - - - - // type code here for "files" field - - - - - - - "duration_minutes": 9, - - - - - - - "is_preview": false, - - - - - - - "status": "archived", - - - - - - - "position": 7, - - - - - - - "published_at": new Date(Date.now()), - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "title": "Grace Hopper", - - - - - - - "slug": "Ada Lovelace", - - - - - - - "lesson_type": "article", - - - - - - - "content": "Ada Lovelace", - - - - - - - "video_url": "Grace Hopper", - - - - - - - // type code here for "files" field - - - - - - - "duration_minutes": 5, - - - - - - - "is_preview": false, - - - - - - - "status": "draft", - - - - - - - "position": 9, - - - - - - - "published_at": new Date(Date.now()), - - - - }, - + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + title: 'Franz Boas', + + slug: 'Wilhelm Wundt', + + lesson_type: 'article', + + content: 'Paul Dirac', + + video_url: 'Alexander Fleming', + + // type code here for "files" field + + duration_minutes: 1, + + is_preview: true, + + status: 'published', + + position: 6, + + published_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + title: 'Joseph J. Thomson', + + slug: 'Charles Sherrington', + + lesson_type: 'video', + + content: 'Christiaan Huygens', + + video_url: 'Carl Linnaeus', + + // type code here for "files" field + + duration_minutes: 1, + + is_preview: true, + + status: 'draft', + + position: 4, + + published_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + title: 'Sheldon Glashow', + + slug: 'Frederick Gowland Hopkins', + + lesson_type: 'assignment', + + content: 'Robert Koch', + + video_url: 'Pierre Simon de Laplace', + + // type code here for "files" field + + duration_minutes: 9, + + is_preview: false, + + status: 'draft', + + position: 3, + + published_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + title: 'Jonas Salk', + + slug: 'Theodosius Dobzhansky', + + lesson_type: 'article', + + content: 'Max von Laue', + + video_url: 'Karl Landsteiner', + + // type code here for "files" field + + duration_minutes: 9, + + is_preview: false, + + status: 'archived', + + position: 2, + + published_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + title: 'Lynn Margulis', + + slug: 'Antoine Laurent Lavoisier', + + lesson_type: 'article', + + content: 'Neils Bohr', + + video_url: 'Euclid', + + // type code here for "files" field + + duration_minutes: 1, + + is_preview: true, + + status: 'published', + + position: 3, + + published_at: new Date(Date.now()), + }, ]; - - const EnrollmentsData = [ - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "status": "completed", - - - - - - - "enrolled_at": new Date(Date.now()), - - - - - - - "completed_at": new Date(Date.now()), - - - - - - - "progress_percent": 4.12, - - - - - - - "last_activity_at": new Date(Date.now()), - - - - - - - "notes": "Ada Lovelace", - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "status": "completed", - - - - - - - "enrolled_at": new Date(Date.now()), - - - - - - - "completed_at": new Date(Date.now()), - - - - - - - "progress_percent": 2.11, - - - - - - - "last_activity_at": new Date(Date.now()), - - - - - - - "notes": "Grace Hopper", - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "status": "active", - - - - - - - "enrolled_at": new Date(Date.now()), - - - - - - - "completed_at": new Date(Date.now()), - - - - - - - "progress_percent": 6.35, - - - - - - - "last_activity_at": new Date(Date.now()), - - - - - - - "notes": "Grace Hopper", - - - - }, - + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'active', + + enrolled_at: new Date(Date.now()), + + completed_at: new Date(Date.now()), + + progress_percent: 46.23, + + last_activity_at: new Date(Date.now()), + + notes: 'William Bayliss', + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'refunded', + + enrolled_at: new Date(Date.now()), + + completed_at: new Date(Date.now()), + + progress_percent: 10.63, + + last_activity_at: new Date(Date.now()), + + notes: 'Andreas Vesalius', + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'active', + + enrolled_at: new Date(Date.now()), + + completed_at: new Date(Date.now()), + + progress_percent: 78.31, + + last_activity_at: new Date(Date.now()), + + notes: 'Marie Curie', + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'active', + + enrolled_at: new Date(Date.now()), + + completed_at: new Date(Date.now()), + + progress_percent: 29.49, + + last_activity_at: new Date(Date.now()), + + notes: 'Jean Baptiste Lamarck', + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'cancelled', + + enrolled_at: new Date(Date.now()), + + completed_at: new Date(Date.now()), + + progress_percent: 66.34, + + last_activity_at: new Date(Date.now()), + + notes: 'Robert Koch', + }, ]; - - const LessonProgressData = [ - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "status": "in_progress", - - - - - - - "progress_percent": 7.64, - - - - - - - "started_at": new Date(Date.now()), - - - - - - - "completed_at": new Date(Date.now()), - - - - - - - "last_viewed_at": new Date(Date.now()), - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "status": "completed", - - - - - - - "progress_percent": 9.39, - - - - - - - "started_at": new Date(Date.now()), - - - - - - - "completed_at": new Date(Date.now()), - - - - - - - "last_viewed_at": new Date(Date.now()), - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "status": "completed", - - - - - - - "progress_percent": 2.49, - - - - - - - "started_at": new Date(Date.now()), - - - - - - - "completed_at": new Date(Date.now()), - - - - - - - "last_viewed_at": new Date(Date.now()), - - - - }, - + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'completed', + + progress_percent: 16.09, + + started_at: new Date(Date.now()), + + completed_at: new Date(Date.now()), + + last_viewed_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'not_started', + + progress_percent: 51.17, + + started_at: new Date(Date.now()), + + completed_at: new Date(Date.now()), + + last_viewed_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'in_progress', + + progress_percent: 51.31, + + started_at: new Date(Date.now()), + + completed_at: new Date(Date.now()), + + last_viewed_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'in_progress', + + progress_percent: 15.28, + + started_at: new Date(Date.now()), + + completed_at: new Date(Date.now()), + + last_viewed_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'completed', + + progress_percent: 31.17, + + started_at: new Date(Date.now()), + + completed_at: new Date(Date.now()), + + last_viewed_at: new Date(Date.now()), + }, ]; - - const CourseReviewsData = [ - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "rating": 1, - - - - - - - "title": "Ada Lovelace", - - - - - - - "comment": "Marie Curie", - - - - - - - "is_published": false, - - - - - - - "published_at": new Date(Date.now()), - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "rating": 4, - - - - - - - "title": "Grace Hopper", - - - - - - - "comment": "Ada Lovelace", - - - - - - - "is_published": true, - - - - - - - "published_at": new Date(Date.now()), - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "rating": 9, - - - - - - - "title": "Ada Lovelace", - - - - - - - "comment": "Grace Hopper", - - - - - - - "is_published": false, - - - - - - - "published_at": new Date(Date.now()), - - - - }, - + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + rating: 7, + + title: 'Antoine Laurent Lavoisier', + + comment: 'Louis Pasteur', + + is_published: false, + + published_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + rating: 9, + + title: 'Marie Curie', + + comment: 'Gustav Kirchhoff', + + is_published: true, + + published_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + rating: 3, + + title: 'Joseph J. Thomson', + + comment: 'Lucretius', + + is_published: true, + + published_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + rating: 2, + + title: 'Jonas Salk', + + comment: 'Sigmund Freud', + + is_published: false, + + published_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + rating: 2, + + title: 'Jean Piaget', + + comment: 'John Dalton', + + is_published: false, + + published_at: new Date(Date.now()), + }, ]; - - const CourseAnnouncementsData = [ - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "title": "Ada Lovelace", - - - - - - - "message": "Grace Hopper", - - - - - - - "visibility": "all_students", - - - - - - - "publish_at": new Date(Date.now()), - - - - - - - "expires_at": new Date(Date.now()), - - - - - - - "is_published": true, - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "title": "Alan Turing", - - - - - - - "message": "Marie Curie", - - - - - - - "visibility": "instructors_only", - - - - - - - "publish_at": new Date(Date.now()), - - - - - - - "expires_at": new Date(Date.now()), - - - - - - - "is_published": false, - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "title": "Grace Hopper", - - - - - - - "message": "Grace Hopper", - - - - - - - "visibility": "instructors_only", - - - - - - - "publish_at": new Date(Date.now()), - - - - - - - "expires_at": new Date(Date.now()), - - - - - - - "is_published": true, - - - - }, - + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + title: 'Paul Dirac', + + message: 'Claude Levi-Strauss', + + visibility: 'all_students', + + publish_at: new Date(Date.now()), + + expires_at: new Date(Date.now()), + + is_published: false, + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + title: 'Dmitri Mendeleev', + + message: 'Willard Libby', + + visibility: 'instructors_only', + + publish_at: new Date(Date.now()), + + expires_at: new Date(Date.now()), + + is_published: false, + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + title: 'Edwin Hubble', + + message: 'Carl Linnaeus', + + visibility: 'instructors_only', + + publish_at: new Date(Date.now()), + + expires_at: new Date(Date.now()), + + is_published: true, + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + title: 'Claude Levi-Strauss', + + message: 'Max Delbruck', + + visibility: 'enrolled_only', + + publish_at: new Date(Date.now()), + + expires_at: new Date(Date.now()), + + is_published: false, + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + title: 'John Bardeen', + + message: 'Robert Koch', + + visibility: 'all_students', + + publish_at: new Date(Date.now()), + + expires_at: new Date(Date.now()), + + is_published: false, + }, ]; - - const QuizzesData = [ - - { - - - - - // type code here for "relation_one" field - - - - - - - "title": "Alan Turing", - - - - - - - "instructions": "Ada Lovelace", - - - - - - - "time_limit_minutes": 2, - - - - - - - "pass_percent": 5.17, - - - - - - - "status": "draft", - - - - - - - "published_at": new Date(Date.now()), - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - "title": "Grace Hopper", - - - - - - - "instructions": "Alan Turing", - - - - - - - "time_limit_minutes": 8, - - - - - - - "pass_percent": 3.45, - - - - - - - "status": "archived", - - - - - - - "published_at": new Date(Date.now()), - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - "title": "Alan Turing", - - - - - - - "instructions": "Alan Turing", - - - - - - - "time_limit_minutes": 7, - - - - - - - "pass_percent": 5.22, - - - - - - - "status": "archived", - - - - - - - "published_at": new Date(Date.now()), - - - - }, - + { + // type code here for "relation_one" field + + title: 'Sheldon Glashow', + + instructions: 'Alfred Binet', + + time_limit_minutes: 9, + + pass_percent: 58.89, + + status: 'published', + + published_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + title: 'Emil Kraepelin', + + instructions: 'Erwin Schrodinger', + + time_limit_minutes: 8, + + pass_percent: 57.45, + + status: 'published', + + published_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + title: 'Marcello Malpighi', + + instructions: 'Gertrude Belle Elion', + + time_limit_minutes: 2, + + pass_percent: 75.24, + + status: 'published', + + published_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + title: 'Gertrude Belle Elion', + + instructions: 'Sheldon Glashow', + + time_limit_minutes: 1, + + pass_percent: 63.22, + + status: 'published', + + published_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + title: 'Claude Levi-Strauss', + + instructions: 'Sheldon Glashow', + + time_limit_minutes: 3, + + pass_percent: 46.65, + + status: 'published', + + published_at: new Date(Date.now()), + }, ]; - - const QuizQuestionsData = [ - - { - - - - - // type code here for "relation_one" field - - - - - - - "prompt": "Alan Turing", - - - - - - - "question_type": "multiple_choice", - - - - - - - "points": 3, - - - - - - - "position": 2, - - - - - - - "explanation": "Alan Turing", - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - "prompt": "Marie Curie", - - - - - - - "question_type": "multiple_choice", - - - - - - - "points": 3, - - - - - - - "position": 9, - - - - - - - "explanation": "Marie Curie", - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - "prompt": "Alan Turing", - - - - - - - "question_type": "multiple_choice", - - - - - - - "points": 2, - - - - - - - "position": 8, - - - - - - - "explanation": "Ada Lovelace", - - - - }, - + { + // type code here for "relation_one" field + + prompt: 'William Bayliss', + + question_type: 'multiple_choice', + + points: 8, + + position: 7, + + explanation: 'Pierre Simon de Laplace', + }, + + { + // type code here for "relation_one" field + + prompt: 'Max Delbruck', + + question_type: 'short_answer', + + points: 6, + + position: 3, + + explanation: 'Theodosius Dobzhansky', + }, + + { + // type code here for "relation_one" field + + prompt: 'Alexander Fleming', + + question_type: 'single_choice', + + points: 8, + + position: 2, + + explanation: 'Rudolf Virchow', + }, + + { + // type code here for "relation_one" field + + prompt: 'Sheldon Glashow', + + question_type: 'multiple_choice', + + points: 5, + + position: 2, + + explanation: 'Wilhelm Wundt', + }, + + { + // type code here for "relation_one" field + + prompt: 'Gustav Kirchhoff', + + question_type: 'multiple_choice', + + points: 5, + + position: 6, + + explanation: 'Alfred Wegener', + }, ]; - - const QuizOptionsData = [ - - { - - - - - // type code here for "relation_one" field - - - - - - - "label": "Marie Curie", - - - - - - - "is_correct": true, - - - - - - - "position": 8, - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - "label": "Grace Hopper", - - - - - - - "is_correct": true, - - - - - - - "position": 7, - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - "label": "Ada Lovelace", - - - - - - - "is_correct": true, - - - - - - - "position": 6, - - - - }, - + { + // type code here for "relation_one" field + + label: 'Arthur Eddington', + + is_correct: true, + + position: 8, + }, + + { + // type code here for "relation_one" field + + label: 'Euclid', + + is_correct: false, + + position: 5, + }, + + { + // type code here for "relation_one" field + + label: 'Heike Kamerlingh Onnes', + + is_correct: true, + + position: 9, + }, + + { + // type code here for "relation_one" field + + label: 'Frederick Gowland Hopkins', + + is_correct: false, + + position: 3, + }, + + { + // type code here for "relation_one" field + + label: 'George Gaylord Simpson', + + is_correct: true, + + position: 1, + }, ]; - - const QuizAttemptsData = [ - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "status": "submitted", - - - - - - - "started_at": new Date(Date.now()), - - - - - - - "submitted_at": new Date(Date.now()), - - - - - - - "score_percent": 0.45, - - - - - - - "passed": true, - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "status": "graded", - - - - - - - "started_at": new Date(Date.now()), - - - - - - - "submitted_at": new Date(Date.now()), - - - - - - - "score_percent": 0.86, - - - - - - - "passed": true, - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - "status": "graded", - - - - - - - "started_at": new Date(Date.now()), - - - - - - - "submitted_at": new Date(Date.now()), - - - - - - - "score_percent": 9.43, - - - - - - - "passed": false, - - - - }, - + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'graded', + + started_at: new Date(Date.now()), + + submitted_at: new Date(Date.now()), + + score_percent: 65.99, + + passed: true, + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'in_progress', + + started_at: new Date(Date.now()), + + submitted_at: new Date(Date.now()), + + score_percent: 87.75, + + passed: true, + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'in_progress', + + started_at: new Date(Date.now()), + + submitted_at: new Date(Date.now()), + + score_percent: 50.22, + + passed: true, + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'submitted', + + started_at: new Date(Date.now()), + + submitted_at: new Date(Date.now()), + + score_percent: 81.13, + + passed: false, + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + status: 'in_progress', + + started_at: new Date(Date.now()), + + submitted_at: new Date(Date.now()), + + score_percent: 42.89, + + passed: true, + }, ]; - - const AssignmentSubmissionsData = [ - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "files" field - - - - - - - "submission_text": "Alan Turing", - - - - - - - "status": "reviewed", - - - - - - - "grade_percent": 4.98, - - - - - - - "instructor_feedback": "Alan Turing", - - - - - - - "submitted_at": new Date(Date.now()), - - - - - - - "reviewed_at": new Date(Date.now()), - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "files" field - - - - - - - "submission_text": "Alan Turing", - - - - - - - "status": "needs_changes", - - - - - - - "grade_percent": 2.71, - - - - - - - "instructor_feedback": "Ada Lovelace", - - - - - - - "submitted_at": new Date(Date.now()), - - - - - - - "reviewed_at": new Date(Date.now()), - - - - }, - - { - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "relation_one" field - - - - - - - // type code here for "files" field - - - - - - - "submission_text": "Ada Lovelace", - - - - - - - "status": "reviewed", - - - - - - - "grade_percent": 4.18, - - - - - - - "instructor_feedback": "Alan Turing", - - - - - - - "submitted_at": new Date(Date.now()), - - - - - - - "reviewed_at": new Date(Date.now()), - - - - }, - + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + // type code here for "files" field + + submission_text: 'Paul Dirac', + + status: 'submitted', + + grade_percent: 50.11, + + instructor_feedback: 'Trofim Lysenko', + + submitted_at: new Date(Date.now()), + + reviewed_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + // type code here for "files" field + + submission_text: 'Joseph J. Thomson', + + status: 'submitted', + + grade_percent: 82.75, + + instructor_feedback: 'Linus Pauling', + + submitted_at: new Date(Date.now()), + + reviewed_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + // type code here for "files" field + + submission_text: 'John Bardeen', + + status: 'reviewed', + + grade_percent: 47.56, + + instructor_feedback: 'James Clerk Maxwell', + + submitted_at: new Date(Date.now()), + + reviewed_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + // type code here for "files" field + + submission_text: 'Andreas Vesalius', + + status: 'submitted', + + grade_percent: 99.55, + + instructor_feedback: 'Lynn Margulis', + + submitted_at: new Date(Date.now()), + + reviewed_at: new Date(Date.now()), + }, + + { + // type code here for "relation_one" field + + // type code here for "relation_one" field + + // type code here for "files" field + + submission_text: 'Antoine Laurent Lavoisier', + + status: 'needs_changes', + + grade_percent: 30.49, + + instructor_feedback: 'Paul Dirac', + + submitted_at: new Date(Date.now()), + + reviewed_at: new Date(Date.now()), + }, ]; - - const MarketingPagesData = [ - - { - - - - - "page_type": "features", - - - - - - - "title": "Grace Hopper", - - - - - - - "slug": "Marie Curie", - - - - - - - "hero_headline": "Ada Lovelace", - - - - - - - "hero_subheadline": "Marie Curie", - - - - - - - // type code here for "images" field - - - - - - - "content": "Alan Turing", - - - - - - - "is_published": false, - - - - - - - "published_at": new Date(Date.now()), - - - - }, - - { - - - - - "page_type": "pricing", - - - - - - - "title": "Grace Hopper", - - - - - - - "slug": "Ada Lovelace", - - - - - - - "hero_headline": "Grace Hopper", - - - - - - - "hero_subheadline": "Marie Curie", - - - - - - - // type code here for "images" field - - - - - - - "content": "Ada Lovelace", - - - - - - - "is_published": true, - - - - - - - "published_at": new Date(Date.now()), - - - - }, - - { - - - - - "page_type": "faq", - - - - - - - "title": "Marie Curie", - - - - - - - "slug": "Grace Hopper", - - - - - - - "hero_headline": "Alan Turing", - - - - - - - "hero_subheadline": "Grace Hopper", - - - - - - - // type code here for "images" field - - - - - - - "content": "Alan Turing", - - - - - - - "is_published": false, - - - - - - - "published_at": new Date(Date.now()), - - - - }, - + { + page_type: 'contact', + + title: 'Leonard Euler', + + slug: 'Michael Faraday', + + hero_headline: 'Gustav Kirchhoff', + + hero_subheadline: 'Anton van Leeuwenhoek', + + // type code here for "images" field + + content: 'Charles Sherrington', + + is_published: true, + + published_at: new Date(Date.now()), + }, + + { + page_type: 'faq', + + title: 'Sigmund Freud', + + slug: 'Lucretius', + + hero_headline: 'Jean Piaget', + + hero_subheadline: 'Euclid', + + // type code here for "images" field + + content: 'Joseph J. Thomson', + + is_published: false, + + published_at: new Date(Date.now()), + }, + + { + page_type: 'faq', + + title: 'Andreas Vesalius', + + slug: 'William Harvey', + + hero_headline: 'Marcello Malpighi', + + hero_subheadline: 'Jean Piaget', + + // type code here for "images" field + + content: 'William Herschel', + + is_published: false, + + published_at: new Date(Date.now()), + }, + + { + page_type: 'home', + + title: 'George Gaylord Simpson', + + slug: 'Charles Darwin', + + hero_headline: 'James Watson', + + hero_subheadline: 'Charles Darwin', + + // type code here for "images" field + + content: 'William Bayliss', + + is_published: false, + + published_at: new Date(Date.now()), + }, + + { + page_type: 'features', + + title: 'Marie Curie', + + slug: 'Murray Gell-Mann', + + hero_headline: 'Frederick Sanger', + + hero_subheadline: 'Edward O. Wilson', + + // type code here for "images" field + + content: 'James Clerk Maxwell', + + is_published: false, + + published_at: new Date(Date.now()), + }, ]; - - const ContactMessagesData = [ - - { - - - - - "name": "Alan Turing", - - - - - - - "email": "Marie Curie", - - - - - - - "subject": "Marie Curie", - - - - - - - "message": "Ada Lovelace", - - - - - - - "status": "spam", - - - - - - - "received_at": new Date(Date.now()), - - - - }, - - { - - - - - "name": "Ada Lovelace", - - - - - - - "email": "Grace Hopper", - - - - - - - "subject": "Ada Lovelace", - - - - - - - "message": "Marie Curie", - - - - - - - "status": "resolved", - - - - - - - "received_at": new Date(Date.now()), - - - - }, - - { - - - - - "name": "Grace Hopper", - - - - - - - "email": "Ada Lovelace", - - - - - - - "subject": "Ada Lovelace", - - - - - - - "message": "Marie Curie", - - - - - - - "status": "resolved", - - - - - - - "received_at": new Date(Date.now()), - - - - }, - + { + name: 'Euclid', + + email: 'Charles Darwin', + + subject: 'J. Robert Oppenheimer', + + message: 'William Bayliss', + + status: 'spam', + + received_at: new Date(Date.now()), + }, + + { + name: 'Werner Heisenberg', + + email: 'John Bardeen', + + subject: 'Linus Pauling', + + message: 'Willard Libby', + + status: 'spam', + + received_at: new Date(Date.now()), + }, + + { + name: 'Wilhelm Wundt', + + email: 'Noam Chomsky', + + subject: 'Louis Victor de Broglie', + + message: 'Carl Gauss (Karl Friedrich Gauss)', + + status: 'new', + + received_at: new Date(Date.now()), + }, + + { + name: 'Justus Liebig', + + email: 'Paul Dirac', + + subject: 'B. F. Skinner', + + message: 'Claude Levi-Strauss', + + status: 'resolved', + + received_at: new Date(Date.now()), + }, + + { + name: 'Willard Libby', + + email: 'Carl Gauss (Karl Friedrich Gauss)', + + subject: 'Tycho Brahe', + + message: 'Francis Galton', + + status: 'in_progress', + + received_at: new Date(Date.now()), + }, ]; - - const PricingPlansData = [ - - { - - - - - "name": "Grace Hopper", - - - - - - - "description": "Alan Turing", - - - - - - - "price_monthly": 4.04, - - - - - - - "price_yearly": 1.19, - - - - - - - "currency": "Marie Curie", - - - - - - - // type code here for "relation_many" field - - - - - - - "is_active": true, - - - - - - - "sort_order": 6, - - - - }, - - { - - - - - "name": "Alan Turing", - - - - - - - "description": "Ada Lovelace", - - - - - - - "price_monthly": 9.82, - - - - - - - "price_yearly": 6.87, - - - - - - - "currency": "Ada Lovelace", - - - - - - - // type code here for "relation_many" field - - - - - - - "is_active": true, - - - - - - - "sort_order": 8, - - - - }, - - { - - - - - "name": "Grace Hopper", - - - - - - - "description": "Marie Curie", - - - - - - - "price_monthly": 6.68, - - - - - - - "price_yearly": 7.39, - - - - - - - "currency": "Marie Curie", - - - - - - - // type code here for "relation_many" field - - - - - - - "is_active": false, - - - - - - - "sort_order": 8, - - - - }, - + { + name: 'Richard Feynman', + + description: 'Willard Libby', + + price_monthly: 28.94, + + price_yearly: 92.97, + + currency: 'Jean Baptiste Lamarck', + + // type code here for "relation_many" field + + is_active: false, + + sort_order: 5, + }, + + { + name: 'Marie Curie', + + description: 'Leonard Euler', + + price_monthly: 20.78, + + price_yearly: 75.42, + + currency: 'Alexander Fleming', + + // type code here for "relation_many" field + + is_active: false, + + sort_order: 1, + }, + + { + name: 'Neils Bohr', + + description: 'Charles Darwin', + + price_monthly: 75.31, + + price_yearly: 49.87, + + currency: 'Alfred Wegener', + + // type code here for "relation_many" field + + is_active: false, + + sort_order: 4, + }, + + { + name: 'Karl Landsteiner', + + description: 'Andreas Vesalius', + + price_monthly: 46.58, + + price_yearly: 27.57, + + currency: 'Werner Heisenberg', + + // type code here for "relation_many" field + + is_active: false, + + sort_order: 2, + }, + + { + name: 'Nicolaus Copernicus', + + description: 'Max Planck', + + price_monthly: 63.24, + + price_yearly: 36.03, + + currency: 'Jean Baptiste Lamarck', + + // type code here for "relation_many" field + + is_active: false, + + sort_order: 9, + }, ]; - - const PlanFeaturesData = [ - - { - - - - - "name": "Marie Curie", - - - - - - - "description": "Ada Lovelace", - - - - - - - "is_highlighted": true, - - - - - - - "sort_order": 5, - - - - }, - - { - - - - - "name": "Marie Curie", - - - - - - - "description": "Ada Lovelace", - - - - - - - "is_highlighted": false, - - - - - - - "sort_order": 1, - - - - }, - - { - - - - - "name": "Ada Lovelace", - - - - - - - "description": "Marie Curie", - - - - - - - "is_highlighted": true, - - - - - - - "sort_order": 4, - - - - }, - + { + name: 'Paul Ehrlich', + + description: 'Gertrude Belle Elion', + + is_highlighted: true, + + sort_order: 7, + }, + + { + name: 'Franz Boas', + + description: 'Murray Gell-Mann', + + is_highlighted: false, + + sort_order: 7, + }, + + { + name: 'Max von Laue', + + description: 'James Clerk Maxwell', + + is_highlighted: true, + + sort_order: 5, + }, + + { + name: 'William Bayliss', + + description: 'Willard Libby', + + is_highlighted: true, + + sort_order: 7, + }, + + { + name: 'Michael Faraday', + + description: 'Edwin Hubble', + + is_highlighted: false, + + sort_order: 9, + }, ]; +async function associateCourseWithInstructor() { + const relatedInstructor0 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const Course0 = await Courses.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (Course0?.setInstructor) { + await Course0.setInstructor(relatedInstructor0); + } + const relatedInstructor1 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const Course1 = await Courses.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (Course1?.setInstructor) { + await Course1.setInstructor(relatedInstructor1); + } + const relatedInstructor2 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const Course2 = await Courses.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (Course2?.setInstructor) { + await Course2.setInstructor(relatedInstructor2); + } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Similar logic for "relation_many" - - + const relatedInstructor3 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const Course3 = await Courses.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (Course3?.setInstructor) { + await Course3.setInstructor(relatedInstructor3); + } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - async function associateCoursWithInstructor() { - - const relatedInstructor0 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const Cours0 = await Courses.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (Cours0?.setInstructor) - { - await - Cours0. - setInstructor(relatedInstructor0); - } - - const relatedInstructor1 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const Cours1 = await Courses.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (Cours1?.setInstructor) - { - await - Cours1. - setInstructor(relatedInstructor1); - } - - const relatedInstructor2 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const Cours2 = await Courses.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (Cours2?.setInstructor) - { - await - Cours2. - setInstructor(relatedInstructor2); - } - - } - - + const relatedInstructor4 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const Course4 = await Courses.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (Course4?.setInstructor) { + await Course4.setInstructor(relatedInstructor4); + } +} - - - - - - - - - - async function associateCourseSectionWithCourse() { - - const relatedCourse0 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const CourseSection0 = await CourseSections.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (CourseSection0?.setCourse) - { - await - CourseSection0. - setCourse(relatedCourse0); - } - - const relatedCourse1 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const CourseSection1 = await CourseSections.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (CourseSection1?.setCourse) - { - await - CourseSection1. - setCourse(relatedCourse1); - } - - const relatedCourse2 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const CourseSection2 = await CourseSections.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (CourseSection2?.setCourse) - { - await - CourseSection2. - setCourse(relatedCourse2); - } - - } - - +async function associateCourseSectionWithCourse() { + const relatedCourse0 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseSection0 = await CourseSections.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (CourseSection0?.setCourse) { + await CourseSection0.setCourse(relatedCourse0); + } - - - - - - async function associateLessonWithCourse() { - - const relatedCourse0 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const Lesson0 = await Lessons.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (Lesson0?.setCourse) - { - await - Lesson0. - setCourse(relatedCourse0); - } - - const relatedCourse1 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const Lesson1 = await Lessons.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (Lesson1?.setCourse) - { - await - Lesson1. - setCourse(relatedCourse1); - } - - const relatedCourse2 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const Lesson2 = await Lessons.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (Lesson2?.setCourse) - { - await - Lesson2. - setCourse(relatedCourse2); - } - - } - - - - - async function associateLessonWithSection() { - - const relatedSection0 = await CourseSections.findOne({ - offset: Math.floor(Math.random() * (await CourseSections.count())), - }); - const Lesson0 = await Lessons.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (Lesson0?.setSection) - { - await - Lesson0. - setSection(relatedSection0); - } - - const relatedSection1 = await CourseSections.findOne({ - offset: Math.floor(Math.random() * (await CourseSections.count())), - }); - const Lesson1 = await Lessons.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (Lesson1?.setSection) - { - await - Lesson1. - setSection(relatedSection1); - } - - const relatedSection2 = await CourseSections.findOne({ - offset: Math.floor(Math.random() * (await CourseSections.count())), - }); - const Lesson2 = await Lessons.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (Lesson2?.setSection) - { - await - Lesson2. - setSection(relatedSection2); - } - - } - - - - - - - - - - - - - - - - - - - - - - - - + const relatedCourse1 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseSection1 = await CourseSections.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (CourseSection1?.setCourse) { + await CourseSection1.setCourse(relatedCourse1); + } - - - - - - async function associateEnrollmentWithStudent() { - - const relatedStudent0 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const Enrollment0 = await Enrollments.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (Enrollment0?.setStudent) - { - await - Enrollment0. - setStudent(relatedStudent0); - } - - const relatedStudent1 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const Enrollment1 = await Enrollments.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (Enrollment1?.setStudent) - { - await - Enrollment1. - setStudent(relatedStudent1); - } - - const relatedStudent2 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const Enrollment2 = await Enrollments.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (Enrollment2?.setStudent) - { - await - Enrollment2. - setStudent(relatedStudent2); - } - - } - - - - - async function associateEnrollmentWithCourse() { - - const relatedCourse0 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const Enrollment0 = await Enrollments.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (Enrollment0?.setCourse) - { - await - Enrollment0. - setCourse(relatedCourse0); - } - - const relatedCourse1 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const Enrollment1 = await Enrollments.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (Enrollment1?.setCourse) - { - await - Enrollment1. - setCourse(relatedCourse1); - } - - const relatedCourse2 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const Enrollment2 = await Enrollments.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (Enrollment2?.setCourse) - { - await - Enrollment2. - setCourse(relatedCourse2); - } - - } - - - - - - - - - - - - - - + const relatedCourse2 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseSection2 = await CourseSections.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (CourseSection2?.setCourse) { + await CourseSection2.setCourse(relatedCourse2); + } - - - - - - async function associateLessonProgresWithEnrollment() { - - const relatedEnrollment0 = await Enrollments.findOne({ - offset: Math.floor(Math.random() * (await Enrollments.count())), - }); - const LessonProgres0 = await LessonProgress.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (LessonProgres0?.setEnrollment) - { - await - LessonProgres0. - setEnrollment(relatedEnrollment0); - } - - const relatedEnrollment1 = await Enrollments.findOne({ - offset: Math.floor(Math.random() * (await Enrollments.count())), - }); - const LessonProgres1 = await LessonProgress.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (LessonProgres1?.setEnrollment) - { - await - LessonProgres1. - setEnrollment(relatedEnrollment1); - } - - const relatedEnrollment2 = await Enrollments.findOne({ - offset: Math.floor(Math.random() * (await Enrollments.count())), - }); - const LessonProgres2 = await LessonProgress.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (LessonProgres2?.setEnrollment) - { - await - LessonProgres2. - setEnrollment(relatedEnrollment2); - } - - } - - - - - async function associateLessonProgresWithLesson() { - - const relatedLesson0 = await Lessons.findOne({ - offset: Math.floor(Math.random() * (await Lessons.count())), - }); - const LessonProgres0 = await LessonProgress.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (LessonProgres0?.setLesson) - { - await - LessonProgres0. - setLesson(relatedLesson0); - } - - const relatedLesson1 = await Lessons.findOne({ - offset: Math.floor(Math.random() * (await Lessons.count())), - }); - const LessonProgres1 = await LessonProgress.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (LessonProgres1?.setLesson) - { - await - LessonProgres1. - setLesson(relatedLesson1); - } - - const relatedLesson2 = await Lessons.findOne({ - offset: Math.floor(Math.random() * (await Lessons.count())), - }); - const LessonProgres2 = await LessonProgress.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (LessonProgres2?.setLesson) - { - await - LessonProgres2. - setLesson(relatedLesson2); - } - - } - - - - - - - - - - - - + const relatedCourse3 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseSection3 = await CourseSections.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (CourseSection3?.setCourse) { + await CourseSection3.setCourse(relatedCourse3); + } - - - - - - async function associateCourseReviewWithCourse() { - - const relatedCourse0 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const CourseReview0 = await CourseReviews.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (CourseReview0?.setCourse) - { - await - CourseReview0. - setCourse(relatedCourse0); - } - - const relatedCourse1 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const CourseReview1 = await CourseReviews.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (CourseReview1?.setCourse) - { - await - CourseReview1. - setCourse(relatedCourse1); - } - - const relatedCourse2 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const CourseReview2 = await CourseReviews.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (CourseReview2?.setCourse) - { - await - CourseReview2. - setCourse(relatedCourse2); - } - - } - - - - - async function associateCourseReviewWithStudent() { - - const relatedStudent0 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const CourseReview0 = await CourseReviews.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (CourseReview0?.setStudent) - { - await - CourseReview0. - setStudent(relatedStudent0); - } - - const relatedStudent1 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const CourseReview1 = await CourseReviews.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (CourseReview1?.setStudent) - { - await - CourseReview1. - setStudent(relatedStudent1); - } - - const relatedStudent2 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const CourseReview2 = await CourseReviews.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (CourseReview2?.setStudent) - { - await - CourseReview2. - setStudent(relatedStudent2); - } - - } - - - - - - - - - - - - + const relatedCourse4 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseSection4 = await CourseSections.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (CourseSection4?.setCourse) { + await CourseSection4.setCourse(relatedCourse4); + } +} - - - - - - async function associateCourseAnnouncementWithCourse() { - - const relatedCourse0 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const CourseAnnouncement0 = await CourseAnnouncements.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (CourseAnnouncement0?.setCourse) - { - await - CourseAnnouncement0. - setCourse(relatedCourse0); - } - - const relatedCourse1 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const CourseAnnouncement1 = await CourseAnnouncements.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (CourseAnnouncement1?.setCourse) - { - await - CourseAnnouncement1. - setCourse(relatedCourse1); - } - - const relatedCourse2 = await Courses.findOne({ - offset: Math.floor(Math.random() * (await Courses.count())), - }); - const CourseAnnouncement2 = await CourseAnnouncements.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (CourseAnnouncement2?.setCourse) - { - await - CourseAnnouncement2. - setCourse(relatedCourse2); - } - - } - - - - - async function associateCourseAnnouncementWithAuthor() { - - const relatedAuthor0 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const CourseAnnouncement0 = await CourseAnnouncements.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (CourseAnnouncement0?.setAuthor) - { - await - CourseAnnouncement0. - setAuthor(relatedAuthor0); - } - - const relatedAuthor1 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const CourseAnnouncement1 = await CourseAnnouncements.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (CourseAnnouncement1?.setAuthor) - { - await - CourseAnnouncement1. - setAuthor(relatedAuthor1); - } - - const relatedAuthor2 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const CourseAnnouncement2 = await CourseAnnouncements.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (CourseAnnouncement2?.setAuthor) - { - await - CourseAnnouncement2. - setAuthor(relatedAuthor2); - } - - } - - - - - - - - - - - - - - +async function associateLessonWithCourse() { + const relatedCourse0 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const Lesson0 = await Lessons.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (Lesson0?.setCourse) { + await Lesson0.setCourse(relatedCourse0); + } - - - - - - async function associateQuizzeWithLesson() { - - const relatedLesson0 = await Lessons.findOne({ - offset: Math.floor(Math.random() * (await Lessons.count())), - }); - const Quizze0 = await Quizzes.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (Quizze0?.setLesson) - { - await - Quizze0. - setLesson(relatedLesson0); - } - - const relatedLesson1 = await Lessons.findOne({ - offset: Math.floor(Math.random() * (await Lessons.count())), - }); - const Quizze1 = await Quizzes.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (Quizze1?.setLesson) - { - await - Quizze1. - setLesson(relatedLesson1); - } - - const relatedLesson2 = await Lessons.findOne({ - offset: Math.floor(Math.random() * (await Lessons.count())), - }); - const Quizze2 = await Quizzes.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (Quizze2?.setLesson) - { - await - Quizze2. - setLesson(relatedLesson2); - } - - } - - - - - - - - - - - - - - + const relatedCourse1 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const Lesson1 = await Lessons.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (Lesson1?.setCourse) { + await Lesson1.setCourse(relatedCourse1); + } - - - - - - async function associateQuizQuestionWithQuiz() { - - const relatedQuiz0 = await Quizzes.findOne({ - offset: Math.floor(Math.random() * (await Quizzes.count())), - }); - const QuizQuestion0 = await QuizQuestions.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (QuizQuestion0?.setQuiz) - { - await - QuizQuestion0. - setQuiz(relatedQuiz0); - } - - const relatedQuiz1 = await Quizzes.findOne({ - offset: Math.floor(Math.random() * (await Quizzes.count())), - }); - const QuizQuestion1 = await QuizQuestions.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (QuizQuestion1?.setQuiz) - { - await - QuizQuestion1. - setQuiz(relatedQuiz1); - } - - const relatedQuiz2 = await Quizzes.findOne({ - offset: Math.floor(Math.random() * (await Quizzes.count())), - }); - const QuizQuestion2 = await QuizQuestions.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (QuizQuestion2?.setQuiz) - { - await - QuizQuestion2. - setQuiz(relatedQuiz2); - } - - } - - - - - - - - - - - - + const relatedCourse2 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const Lesson2 = await Lessons.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (Lesson2?.setCourse) { + await Lesson2.setCourse(relatedCourse2); + } - - - - - - async function associateQuizOptionWithQuestion() { - - const relatedQuestion0 = await QuizQuestions.findOne({ - offset: Math.floor(Math.random() * (await QuizQuestions.count())), - }); - const QuizOption0 = await QuizOptions.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (QuizOption0?.setQuestion) - { - await - QuizOption0. - setQuestion(relatedQuestion0); - } - - const relatedQuestion1 = await QuizQuestions.findOne({ - offset: Math.floor(Math.random() * (await QuizQuestions.count())), - }); - const QuizOption1 = await QuizOptions.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (QuizOption1?.setQuestion) - { - await - QuizOption1. - setQuestion(relatedQuestion1); - } - - const relatedQuestion2 = await QuizQuestions.findOne({ - offset: Math.floor(Math.random() * (await QuizQuestions.count())), - }); - const QuizOption2 = await QuizOptions.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (QuizOption2?.setQuestion) - { - await - QuizOption2. - setQuestion(relatedQuestion2); - } - - } - - - - - - - - + const relatedCourse3 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const Lesson3 = await Lessons.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (Lesson3?.setCourse) { + await Lesson3.setCourse(relatedCourse3); + } - - - - - - async function associateQuizAttemptWithQuiz() { - - const relatedQuiz0 = await Quizzes.findOne({ - offset: Math.floor(Math.random() * (await Quizzes.count())), - }); - const QuizAttempt0 = await QuizAttempts.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (QuizAttempt0?.setQuiz) - { - await - QuizAttempt0. - setQuiz(relatedQuiz0); - } - - const relatedQuiz1 = await Quizzes.findOne({ - offset: Math.floor(Math.random() * (await Quizzes.count())), - }); - const QuizAttempt1 = await QuizAttempts.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (QuizAttempt1?.setQuiz) - { - await - QuizAttempt1. - setQuiz(relatedQuiz1); - } - - const relatedQuiz2 = await Quizzes.findOne({ - offset: Math.floor(Math.random() * (await Quizzes.count())), - }); - const QuizAttempt2 = await QuizAttempts.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (QuizAttempt2?.setQuiz) - { - await - QuizAttempt2. - setQuiz(relatedQuiz2); - } - - } - - - - - async function associateQuizAttemptWithStudent() { - - const relatedStudent0 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const QuizAttempt0 = await QuizAttempts.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (QuizAttempt0?.setStudent) - { - await - QuizAttempt0. - setStudent(relatedStudent0); - } - - const relatedStudent1 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const QuizAttempt1 = await QuizAttempts.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (QuizAttempt1?.setStudent) - { - await - QuizAttempt1. - setStudent(relatedStudent1); - } - - const relatedStudent2 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const QuizAttempt2 = await QuizAttempts.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (QuizAttempt2?.setStudent) - { - await - QuizAttempt2. - setStudent(relatedStudent2); - } - - } - - - - - - - - - - - - + const relatedCourse4 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const Lesson4 = await Lessons.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (Lesson4?.setCourse) { + await Lesson4.setCourse(relatedCourse4); + } +} - - - - - - async function associateAssignmentSubmissionWithLesson() { - - const relatedLesson0 = await Lessons.findOne({ - offset: Math.floor(Math.random() * (await Lessons.count())), - }); - const AssignmentSubmission0 = await AssignmentSubmissions.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (AssignmentSubmission0?.setLesson) - { - await - AssignmentSubmission0. - setLesson(relatedLesson0); - } - - const relatedLesson1 = await Lessons.findOne({ - offset: Math.floor(Math.random() * (await Lessons.count())), - }); - const AssignmentSubmission1 = await AssignmentSubmissions.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (AssignmentSubmission1?.setLesson) - { - await - AssignmentSubmission1. - setLesson(relatedLesson1); - } - - const relatedLesson2 = await Lessons.findOne({ - offset: Math.floor(Math.random() * (await Lessons.count())), - }); - const AssignmentSubmission2 = await AssignmentSubmissions.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (AssignmentSubmission2?.setLesson) - { - await - AssignmentSubmission2. - setLesson(relatedLesson2); - } - - } - - - - - async function associateAssignmentSubmissionWithStudent() { - - const relatedStudent0 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const AssignmentSubmission0 = await AssignmentSubmissions.findOne({ - order: [['id', 'ASC']], - offset: 0 - }); - if (AssignmentSubmission0?.setStudent) - { - await - AssignmentSubmission0. - setStudent(relatedStudent0); - } - - const relatedStudent1 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const AssignmentSubmission1 = await AssignmentSubmissions.findOne({ - order: [['id', 'ASC']], - offset: 1 - }); - if (AssignmentSubmission1?.setStudent) - { - await - AssignmentSubmission1. - setStudent(relatedStudent1); - } - - const relatedStudent2 = await Users.findOne({ - offset: Math.floor(Math.random() * (await Users.count())), - }); - const AssignmentSubmission2 = await AssignmentSubmissions.findOne({ - order: [['id', 'ASC']], - offset: 2 - }); - if (AssignmentSubmission2?.setStudent) - { - await - AssignmentSubmission2. - setStudent(relatedStudent2); - } - - } - - - - - - - - - - - - - - - - +async function associateLessonWithSection() { + const relatedSection0 = await CourseSections.findOne({ + offset: Math.floor(Math.random() * (await CourseSections.count())), + }); + const Lesson0 = await Lessons.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (Lesson0?.setSection) { + await Lesson0.setSection(relatedSection0); + } - - - - - - - - - - - - - - - - - - - - - + const relatedSection1 = await CourseSections.findOne({ + offset: Math.floor(Math.random() * (await CourseSections.count())), + }); + const Lesson1 = await Lessons.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (Lesson1?.setSection) { + await Lesson1.setSection(relatedSection1); + } - - - - - - - - - - - - - - - + const relatedSection2 = await CourseSections.findOne({ + offset: Math.floor(Math.random() * (await CourseSections.count())), + }); + const Lesson2 = await Lessons.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (Lesson2?.setSection) { + await Lesson2.setSection(relatedSection2); + } - - - - - - - - - - - - - - - // Similar logic for "relation_many" - - - - - - + const relatedSection3 = await CourseSections.findOne({ + offset: Math.floor(Math.random() * (await CourseSections.count())), + }); + const Lesson3 = await Lessons.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (Lesson3?.setSection) { + await Lesson3.setSection(relatedSection3); + } - - - - - - - - - - - + const relatedSection4 = await CourseSections.findOne({ + offset: Math.floor(Math.random() * (await CourseSections.count())), + }); + const Lesson4 = await Lessons.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (Lesson4?.setSection) { + await Lesson4.setSection(relatedSection4); + } +} +async function associateEnrollmentWithStudent() { + const relatedStudent0 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const Enrollment0 = await Enrollments.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (Enrollment0?.setStudent) { + await Enrollment0.setStudent(relatedStudent0); + } + + const relatedStudent1 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const Enrollment1 = await Enrollments.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (Enrollment1?.setStudent) { + await Enrollment1.setStudent(relatedStudent1); + } + + const relatedStudent2 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const Enrollment2 = await Enrollments.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (Enrollment2?.setStudent) { + await Enrollment2.setStudent(relatedStudent2); + } + + const relatedStudent3 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const Enrollment3 = await Enrollments.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (Enrollment3?.setStudent) { + await Enrollment3.setStudent(relatedStudent3); + } + + const relatedStudent4 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const Enrollment4 = await Enrollments.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (Enrollment4?.setStudent) { + await Enrollment4.setStudent(relatedStudent4); + } +} + +async function associateEnrollmentWithCourse() { + const relatedCourse0 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const Enrollment0 = await Enrollments.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (Enrollment0?.setCourse) { + await Enrollment0.setCourse(relatedCourse0); + } + + const relatedCourse1 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const Enrollment1 = await Enrollments.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (Enrollment1?.setCourse) { + await Enrollment1.setCourse(relatedCourse1); + } + + const relatedCourse2 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const Enrollment2 = await Enrollments.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (Enrollment2?.setCourse) { + await Enrollment2.setCourse(relatedCourse2); + } + + const relatedCourse3 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const Enrollment3 = await Enrollments.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (Enrollment3?.setCourse) { + await Enrollment3.setCourse(relatedCourse3); + } + + const relatedCourse4 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const Enrollment4 = await Enrollments.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (Enrollment4?.setCourse) { + await Enrollment4.setCourse(relatedCourse4); + } +} + +async function associateLessonProgressWithEnrollment() { + const relatedEnrollment0 = await Enrollments.findOne({ + offset: Math.floor(Math.random() * (await Enrollments.count())), + }); + const LessonProgress0 = await LessonProgress.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (LessonProgress0?.setEnrollment) { + await LessonProgress0.setEnrollment(relatedEnrollment0); + } + + const relatedEnrollment1 = await Enrollments.findOne({ + offset: Math.floor(Math.random() * (await Enrollments.count())), + }); + const LessonProgress1 = await LessonProgress.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (LessonProgress1?.setEnrollment) { + await LessonProgress1.setEnrollment(relatedEnrollment1); + } + + const relatedEnrollment2 = await Enrollments.findOne({ + offset: Math.floor(Math.random() * (await Enrollments.count())), + }); + const LessonProgress2 = await LessonProgress.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (LessonProgress2?.setEnrollment) { + await LessonProgress2.setEnrollment(relatedEnrollment2); + } + + const relatedEnrollment3 = await Enrollments.findOne({ + offset: Math.floor(Math.random() * (await Enrollments.count())), + }); + const LessonProgress3 = await LessonProgress.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (LessonProgress3?.setEnrollment) { + await LessonProgress3.setEnrollment(relatedEnrollment3); + } + + const relatedEnrollment4 = await Enrollments.findOne({ + offset: Math.floor(Math.random() * (await Enrollments.count())), + }); + const LessonProgress4 = await LessonProgress.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (LessonProgress4?.setEnrollment) { + await LessonProgress4.setEnrollment(relatedEnrollment4); + } +} + +async function associateLessonProgressWithLesson() { + const relatedLesson0 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const LessonProgress0 = await LessonProgress.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (LessonProgress0?.setLesson) { + await LessonProgress0.setLesson(relatedLesson0); + } + + const relatedLesson1 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const LessonProgress1 = await LessonProgress.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (LessonProgress1?.setLesson) { + await LessonProgress1.setLesson(relatedLesson1); + } + + const relatedLesson2 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const LessonProgress2 = await LessonProgress.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (LessonProgress2?.setLesson) { + await LessonProgress2.setLesson(relatedLesson2); + } + + const relatedLesson3 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const LessonProgress3 = await LessonProgress.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (LessonProgress3?.setLesson) { + await LessonProgress3.setLesson(relatedLesson3); + } + + const relatedLesson4 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const LessonProgress4 = await LessonProgress.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (LessonProgress4?.setLesson) { + await LessonProgress4.setLesson(relatedLesson4); + } +} + +async function associateCourseReviewWithCourse() { + const relatedCourse0 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseReview0 = await CourseReviews.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (CourseReview0?.setCourse) { + await CourseReview0.setCourse(relatedCourse0); + } + + const relatedCourse1 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseReview1 = await CourseReviews.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (CourseReview1?.setCourse) { + await CourseReview1.setCourse(relatedCourse1); + } + + const relatedCourse2 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseReview2 = await CourseReviews.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (CourseReview2?.setCourse) { + await CourseReview2.setCourse(relatedCourse2); + } + + const relatedCourse3 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseReview3 = await CourseReviews.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (CourseReview3?.setCourse) { + await CourseReview3.setCourse(relatedCourse3); + } + + const relatedCourse4 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseReview4 = await CourseReviews.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (CourseReview4?.setCourse) { + await CourseReview4.setCourse(relatedCourse4); + } +} + +async function associateCourseReviewWithStudent() { + const relatedStudent0 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const CourseReview0 = await CourseReviews.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (CourseReview0?.setStudent) { + await CourseReview0.setStudent(relatedStudent0); + } + + const relatedStudent1 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const CourseReview1 = await CourseReviews.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (CourseReview1?.setStudent) { + await CourseReview1.setStudent(relatedStudent1); + } + + const relatedStudent2 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const CourseReview2 = await CourseReviews.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (CourseReview2?.setStudent) { + await CourseReview2.setStudent(relatedStudent2); + } + + const relatedStudent3 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const CourseReview3 = await CourseReviews.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (CourseReview3?.setStudent) { + await CourseReview3.setStudent(relatedStudent3); + } + + const relatedStudent4 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const CourseReview4 = await CourseReviews.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (CourseReview4?.setStudent) { + await CourseReview4.setStudent(relatedStudent4); + } +} + +async function associateCourseAnnouncementWithCourse() { + const relatedCourse0 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseAnnouncement0 = await CourseAnnouncements.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (CourseAnnouncement0?.setCourse) { + await CourseAnnouncement0.setCourse(relatedCourse0); + } + + const relatedCourse1 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseAnnouncement1 = await CourseAnnouncements.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (CourseAnnouncement1?.setCourse) { + await CourseAnnouncement1.setCourse(relatedCourse1); + } + + const relatedCourse2 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseAnnouncement2 = await CourseAnnouncements.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (CourseAnnouncement2?.setCourse) { + await CourseAnnouncement2.setCourse(relatedCourse2); + } + + const relatedCourse3 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseAnnouncement3 = await CourseAnnouncements.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (CourseAnnouncement3?.setCourse) { + await CourseAnnouncement3.setCourse(relatedCourse3); + } + + const relatedCourse4 = await Courses.findOne({ + offset: Math.floor(Math.random() * (await Courses.count())), + }); + const CourseAnnouncement4 = await CourseAnnouncements.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (CourseAnnouncement4?.setCourse) { + await CourseAnnouncement4.setCourse(relatedCourse4); + } +} + +async function associateCourseAnnouncementWithAuthor() { + const relatedAuthor0 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const CourseAnnouncement0 = await CourseAnnouncements.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (CourseAnnouncement0?.setAuthor) { + await CourseAnnouncement0.setAuthor(relatedAuthor0); + } + + const relatedAuthor1 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const CourseAnnouncement1 = await CourseAnnouncements.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (CourseAnnouncement1?.setAuthor) { + await CourseAnnouncement1.setAuthor(relatedAuthor1); + } + + const relatedAuthor2 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const CourseAnnouncement2 = await CourseAnnouncements.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (CourseAnnouncement2?.setAuthor) { + await CourseAnnouncement2.setAuthor(relatedAuthor2); + } + + const relatedAuthor3 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const CourseAnnouncement3 = await CourseAnnouncements.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (CourseAnnouncement3?.setAuthor) { + await CourseAnnouncement3.setAuthor(relatedAuthor3); + } + + const relatedAuthor4 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const CourseAnnouncement4 = await CourseAnnouncements.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (CourseAnnouncement4?.setAuthor) { + await CourseAnnouncement4.setAuthor(relatedAuthor4); + } +} + +async function associateQuizWithLesson() { + const relatedLesson0 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const Quiz0 = await Quizzes.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (Quiz0?.setLesson) { + await Quiz0.setLesson(relatedLesson0); + } + + const relatedLesson1 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const Quiz1 = await Quizzes.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (Quiz1?.setLesson) { + await Quiz1.setLesson(relatedLesson1); + } + + const relatedLesson2 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const Quiz2 = await Quizzes.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (Quiz2?.setLesson) { + await Quiz2.setLesson(relatedLesson2); + } + + const relatedLesson3 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const Quiz3 = await Quizzes.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (Quiz3?.setLesson) { + await Quiz3.setLesson(relatedLesson3); + } + + const relatedLesson4 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const Quiz4 = await Quizzes.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (Quiz4?.setLesson) { + await Quiz4.setLesson(relatedLesson4); + } +} + +async function associateQuizQuestionWithQuiz() { + const relatedQuiz0 = await Quizzes.findOne({ + offset: Math.floor(Math.random() * (await Quizzes.count())), + }); + const QuizQuestion0 = await QuizQuestions.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (QuizQuestion0?.setQuiz) { + await QuizQuestion0.setQuiz(relatedQuiz0); + } + + const relatedQuiz1 = await Quizzes.findOne({ + offset: Math.floor(Math.random() * (await Quizzes.count())), + }); + const QuizQuestion1 = await QuizQuestions.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (QuizQuestion1?.setQuiz) { + await QuizQuestion1.setQuiz(relatedQuiz1); + } + + const relatedQuiz2 = await Quizzes.findOne({ + offset: Math.floor(Math.random() * (await Quizzes.count())), + }); + const QuizQuestion2 = await QuizQuestions.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (QuizQuestion2?.setQuiz) { + await QuizQuestion2.setQuiz(relatedQuiz2); + } + + const relatedQuiz3 = await Quizzes.findOne({ + offset: Math.floor(Math.random() * (await Quizzes.count())), + }); + const QuizQuestion3 = await QuizQuestions.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (QuizQuestion3?.setQuiz) { + await QuizQuestion3.setQuiz(relatedQuiz3); + } + + const relatedQuiz4 = await Quizzes.findOne({ + offset: Math.floor(Math.random() * (await Quizzes.count())), + }); + const QuizQuestion4 = await QuizQuestions.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (QuizQuestion4?.setQuiz) { + await QuizQuestion4.setQuiz(relatedQuiz4); + } +} + +async function associateQuizOptionWithQuestion() { + const relatedQuestion0 = await QuizQuestions.findOne({ + offset: Math.floor(Math.random() * (await QuizQuestions.count())), + }); + const QuizOption0 = await QuizOptions.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (QuizOption0?.setQuestion) { + await QuizOption0.setQuestion(relatedQuestion0); + } + + const relatedQuestion1 = await QuizQuestions.findOne({ + offset: Math.floor(Math.random() * (await QuizQuestions.count())), + }); + const QuizOption1 = await QuizOptions.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (QuizOption1?.setQuestion) { + await QuizOption1.setQuestion(relatedQuestion1); + } + + const relatedQuestion2 = await QuizQuestions.findOne({ + offset: Math.floor(Math.random() * (await QuizQuestions.count())), + }); + const QuizOption2 = await QuizOptions.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (QuizOption2?.setQuestion) { + await QuizOption2.setQuestion(relatedQuestion2); + } + + const relatedQuestion3 = await QuizQuestions.findOne({ + offset: Math.floor(Math.random() * (await QuizQuestions.count())), + }); + const QuizOption3 = await QuizOptions.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (QuizOption3?.setQuestion) { + await QuizOption3.setQuestion(relatedQuestion3); + } + + const relatedQuestion4 = await QuizQuestions.findOne({ + offset: Math.floor(Math.random() * (await QuizQuestions.count())), + }); + const QuizOption4 = await QuizOptions.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (QuizOption4?.setQuestion) { + await QuizOption4.setQuestion(relatedQuestion4); + } +} + +async function associateQuizAttemptWithQuiz() { + const relatedQuiz0 = await Quizzes.findOne({ + offset: Math.floor(Math.random() * (await Quizzes.count())), + }); + const QuizAttempt0 = await QuizAttempts.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (QuizAttempt0?.setQuiz) { + await QuizAttempt0.setQuiz(relatedQuiz0); + } + + const relatedQuiz1 = await Quizzes.findOne({ + offset: Math.floor(Math.random() * (await Quizzes.count())), + }); + const QuizAttempt1 = await QuizAttempts.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (QuizAttempt1?.setQuiz) { + await QuizAttempt1.setQuiz(relatedQuiz1); + } + + const relatedQuiz2 = await Quizzes.findOne({ + offset: Math.floor(Math.random() * (await Quizzes.count())), + }); + const QuizAttempt2 = await QuizAttempts.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (QuizAttempt2?.setQuiz) { + await QuizAttempt2.setQuiz(relatedQuiz2); + } + + const relatedQuiz3 = await Quizzes.findOne({ + offset: Math.floor(Math.random() * (await Quizzes.count())), + }); + const QuizAttempt3 = await QuizAttempts.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (QuizAttempt3?.setQuiz) { + await QuizAttempt3.setQuiz(relatedQuiz3); + } + + const relatedQuiz4 = await Quizzes.findOne({ + offset: Math.floor(Math.random() * (await Quizzes.count())), + }); + const QuizAttempt4 = await QuizAttempts.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (QuizAttempt4?.setQuiz) { + await QuizAttempt4.setQuiz(relatedQuiz4); + } +} + +async function associateQuizAttemptWithStudent() { + const relatedStudent0 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const QuizAttempt0 = await QuizAttempts.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (QuizAttempt0?.setStudent) { + await QuizAttempt0.setStudent(relatedStudent0); + } + + const relatedStudent1 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const QuizAttempt1 = await QuizAttempts.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (QuizAttempt1?.setStudent) { + await QuizAttempt1.setStudent(relatedStudent1); + } + + const relatedStudent2 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const QuizAttempt2 = await QuizAttempts.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (QuizAttempt2?.setStudent) { + await QuizAttempt2.setStudent(relatedStudent2); + } + + const relatedStudent3 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const QuizAttempt3 = await QuizAttempts.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (QuizAttempt3?.setStudent) { + await QuizAttempt3.setStudent(relatedStudent3); + } + + const relatedStudent4 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const QuizAttempt4 = await QuizAttempts.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (QuizAttempt4?.setStudent) { + await QuizAttempt4.setStudent(relatedStudent4); + } +} + +async function associateAssignmentSubmissionWithLesson() { + const relatedLesson0 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const AssignmentSubmission0 = await AssignmentSubmissions.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (AssignmentSubmission0?.setLesson) { + await AssignmentSubmission0.setLesson(relatedLesson0); + } + + const relatedLesson1 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const AssignmentSubmission1 = await AssignmentSubmissions.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (AssignmentSubmission1?.setLesson) { + await AssignmentSubmission1.setLesson(relatedLesson1); + } + + const relatedLesson2 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const AssignmentSubmission2 = await AssignmentSubmissions.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (AssignmentSubmission2?.setLesson) { + await AssignmentSubmission2.setLesson(relatedLesson2); + } + + const relatedLesson3 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const AssignmentSubmission3 = await AssignmentSubmissions.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (AssignmentSubmission3?.setLesson) { + await AssignmentSubmission3.setLesson(relatedLesson3); + } + + const relatedLesson4 = await Lessons.findOne({ + offset: Math.floor(Math.random() * (await Lessons.count())), + }); + const AssignmentSubmission4 = await AssignmentSubmissions.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (AssignmentSubmission4?.setLesson) { + await AssignmentSubmission4.setLesson(relatedLesson4); + } +} + +async function associateAssignmentSubmissionWithStudent() { + const relatedStudent0 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const AssignmentSubmission0 = await AssignmentSubmissions.findOne({ + order: [['id', 'ASC']], + offset: 0, + }); + if (AssignmentSubmission0?.setStudent) { + await AssignmentSubmission0.setStudent(relatedStudent0); + } + + const relatedStudent1 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const AssignmentSubmission1 = await AssignmentSubmissions.findOne({ + order: [['id', 'ASC']], + offset: 1, + }); + if (AssignmentSubmission1?.setStudent) { + await AssignmentSubmission1.setStudent(relatedStudent1); + } + + const relatedStudent2 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const AssignmentSubmission2 = await AssignmentSubmissions.findOne({ + order: [['id', 'ASC']], + offset: 2, + }); + if (AssignmentSubmission2?.setStudent) { + await AssignmentSubmission2.setStudent(relatedStudent2); + } + + const relatedStudent3 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const AssignmentSubmission3 = await AssignmentSubmissions.findOne({ + order: [['id', 'ASC']], + offset: 3, + }); + if (AssignmentSubmission3?.setStudent) { + await AssignmentSubmission3.setStudent(relatedStudent3); + } + + const relatedStudent4 = await Users.findOne({ + offset: Math.floor(Math.random() * (await Users.count())), + }); + const AssignmentSubmission4 = await AssignmentSubmissions.findOne({ + order: [['id', 'ASC']], + offset: 4, + }); + if (AssignmentSubmission4?.setStudent) { + await AssignmentSubmission4.setStudent(relatedStudent4); + } +} + +// Similar logic for "relation_many" + +// Similar logic for "relation_many" module.exports = { - up: async (queryInterface, Sequelize) => { - - - - - - - - await Courses.bulkCreate(CoursesData); - - - - - await CourseSections.bulkCreate(CourseSectionsData); - - - - - await Lessons.bulkCreate(LessonsData); - - - - - await Enrollments.bulkCreate(EnrollmentsData); - - - - - await LessonProgress.bulkCreate(LessonProgressData); - - - - - await CourseReviews.bulkCreate(CourseReviewsData); - - - - - await CourseAnnouncements.bulkCreate(CourseAnnouncementsData); - - - - - await Quizzes.bulkCreate(QuizzesData); - - - - - await QuizQuestions.bulkCreate(QuizQuestionsData); - - - - - await QuizOptions.bulkCreate(QuizOptionsData); - - - - - await QuizAttempts.bulkCreate(QuizAttemptsData); - - - - - await AssignmentSubmissions.bulkCreate(AssignmentSubmissionsData); - - - - - await MarketingPages.bulkCreate(MarketingPagesData); - - - - - await ContactMessages.bulkCreate(ContactMessagesData); - - - - - await PricingPlans.bulkCreate(PricingPlansData); - - - - - await PlanFeatures.bulkCreate(PlanFeaturesData); - - - await Promise.all([ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Similar logic for "relation_many" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - await associateCoursWithInstructor(), - - - - - - - - - - - - await associateCourseSectionWithCourse(), - - - - - - - - await associateLessonWithCourse(), - - - - - await associateLessonWithSection(), - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - await associateEnrollmentWithStudent(), - - - - - await associateEnrollmentWithCourse(), - - - - - - - - - - - - - - - - - - - - await associateLessonProgresWithEnrollment(), - - - - - await associateLessonProgresWithLesson(), - - - - - - - - - - - - - - - - - - await associateCourseReviewWithCourse(), - - - - - await associateCourseReviewWithStudent(), - - - - - - - - - - - - - - - - - - await associateCourseAnnouncementWithCourse(), - - - - - await associateCourseAnnouncementWithAuthor(), - - - - - - - - - - - - - - - - - - - - await associateQuizzeWithLesson(), - - - - - - - - - - - - - - - - - - - - await associateQuizQuestionWithQuiz(), - - - - - - - - - - - - - - - - - - await associateQuizOptionWithQuestion(), - - - - - - - - - - - - - - await associateQuizAttemptWithQuiz(), - - - - - await associateQuizAttemptWithStudent(), - - - - - - - - - - - - - - - - - - await associateAssignmentSubmissionWithLesson(), - - - - - await associateAssignmentSubmissionWithStudent(), - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Similar logic for "relation_many" - - - - - - - - - - - - - - - - - - - ]); - - }, + up: async (queryInterface, Sequelize) => { + await Courses.bulkCreate(CoursesData); - down: async (queryInterface, Sequelize) => { - - - - - - - await queryInterface.bulkDelete('courses', null, {}); - - - await queryInterface.bulkDelete('course_sections', null, {}); - - - await queryInterface.bulkDelete('lessons', null, {}); - - - await queryInterface.bulkDelete('enrollments', null, {}); - - - await queryInterface.bulkDelete('lesson_progress', null, {}); - - - await queryInterface.bulkDelete('course_reviews', null, {}); - - - await queryInterface.bulkDelete('course_announcements', null, {}); - - - await queryInterface.bulkDelete('quizzes', null, {}); - - - await queryInterface.bulkDelete('quiz_questions', null, {}); - - - await queryInterface.bulkDelete('quiz_options', null, {}); - - - await queryInterface.bulkDelete('quiz_attempts', null, {}); - - - await queryInterface.bulkDelete('assignment_submissions', null, {}); - - - await queryInterface.bulkDelete('marketing_pages', null, {}); - - - await queryInterface.bulkDelete('contact_messages', null, {}); - - - await queryInterface.bulkDelete('pricing_plans', null, {}); - - - await queryInterface.bulkDelete('plan_features', null, {}); - - - }, -}; \ No newline at end of file + await CourseSections.bulkCreate(CourseSectionsData); + + await Lessons.bulkCreate(LessonsData); + + await Enrollments.bulkCreate(EnrollmentsData); + + await LessonProgress.bulkCreate(LessonProgressData); + + await CourseReviews.bulkCreate(CourseReviewsData); + + await CourseAnnouncements.bulkCreate(CourseAnnouncementsData); + + await Quizzes.bulkCreate(QuizzesData); + + await QuizQuestions.bulkCreate(QuizQuestionsData); + + await QuizOptions.bulkCreate(QuizOptionsData); + + await QuizAttempts.bulkCreate(QuizAttemptsData); + + await AssignmentSubmissions.bulkCreate(AssignmentSubmissionsData); + + await MarketingPages.bulkCreate(MarketingPagesData); + + await ContactMessages.bulkCreate(ContactMessagesData); + + await PricingPlans.bulkCreate(PricingPlansData); + + await PlanFeatures.bulkCreate(PlanFeaturesData); + + await Promise.all([ + await associateCourseWithInstructor(), + + await associateCourseSectionWithCourse(), + + await associateLessonWithCourse(), + + await associateLessonWithSection(), + + await associateEnrollmentWithStudent(), + + await associateEnrollmentWithCourse(), + + await associateLessonProgressWithEnrollment(), + + await associateLessonProgressWithLesson(), + + await associateCourseReviewWithCourse(), + + await associateCourseReviewWithStudent(), + + await associateCourseAnnouncementWithCourse(), + + await associateCourseAnnouncementWithAuthor(), + + await associateQuizWithLesson(), + + await associateQuizQuestionWithQuiz(), + + await associateQuizOptionWithQuestion(), + + await associateQuizAttemptWithQuiz(), + + await associateQuizAttemptWithStudent(), + + await associateAssignmentSubmissionWithLesson(), + + await associateAssignmentSubmissionWithStudent(), + + // Similar logic for "relation_many" + + // Similar logic for "relation_many" + ]); + }, + + down: async (queryInterface, Sequelize) => { + await queryInterface.bulkDelete('courses', null, {}); + + await queryInterface.bulkDelete('course_sections', null, {}); + + await queryInterface.bulkDelete('lessons', null, {}); + + await queryInterface.bulkDelete('enrollments', null, {}); + + await queryInterface.bulkDelete('lesson_progress', null, {}); + + await queryInterface.bulkDelete('course_reviews', null, {}); + + await queryInterface.bulkDelete('course_announcements', null, {}); + + await queryInterface.bulkDelete('quizzes', null, {}); + + await queryInterface.bulkDelete('quiz_questions', null, {}); + + await queryInterface.bulkDelete('quiz_options', null, {}); + + await queryInterface.bulkDelete('quiz_attempts', null, {}); + + await queryInterface.bulkDelete('assignment_submissions', null, {}); + + await queryInterface.bulkDelete('marketing_pages', null, {}); + + await queryInterface.bulkDelete('contact_messages', null, {}); + + await queryInterface.bulkDelete('pricing_plans', null, {}); + + await queryInterface.bulkDelete('plan_features', null, {}); + }, +}; diff --git a/backend/src/index.js b/backend/src/index.js index 8924aac..c526ee3 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -1,4 +1,3 @@ - const express = require('express'); const cors = require('cors'); const app = express(); @@ -14,15 +13,10 @@ const swaggerJsDoc = require('swagger-jsdoc'); const authRoutes = require('./routes/auth'); const fileRoutes = require('./routes/file'); const searchRoutes = require('./routes/search'); -const sqlRoutes = require('./routes/sql'); const pexelsRoutes = require('./routes/pexels'); const openaiRoutes = require('./routes/openai'); - - -const usersRoutes = require('./routes/users'); - const rolesRoutes = require('./routes/roles'); const permissionsRoutes = require('./routes/permissions'); @@ -59,6 +53,7 @@ const pricing_plansRoutes = require('./routes/pricing_plans'); const plan_featuresRoutes = require('./routes/plan_features'); +const usersRoutes = require('./routes/users'); const getBaseUrl = (url) => { if (!url) return ''; @@ -67,17 +62,18 @@ const getBaseUrl = (url) => { const options = { definition: { - openapi: "3.0.0", - info: { - version: "1.0.0", - title: "Course LMS", - description: "Course LMS Online REST API for Testing and Prototyping application. You can perform all major operations with your entities - create, delete and etc.", - }, + openapi: '3.0.0', + info: { + version: '1.0.0', + title: 'Course LMS', + description: + 'Course LMS Online REST API for Testing and Prototyping application. You can perform all major operations with your entities - create, delete and etc.', + }, servers: [ { url: getBaseUrl(process.env.NEXT_PUBLIC_BACK_API) || config.swaggerUrl, - description: "Development server", - } + description: 'Development server', + }, ], components: { securitySchemes: { @@ -85,28 +81,36 @@ const options = { type: 'http', scheme: 'bearer', bearerFormat: 'JWT', - } + }, }, responses: { UnauthorizedError: { - description: "Access token is missing or invalid" - } - } + description: 'Access token is missing or invalid', + }, + }, }, - security: [{ - bearerAuth: [] - }] + security: [ + { + bearerAuth: [], + }, + ], }, - apis: ["./src/routes/*.js"], + apis: ['./src/routes/*.js'], }; const specs = swaggerJsDoc(options); -app.use('/api-docs', function (req, res, next) { - swaggerUI.host = getBaseUrl(process.env.NEXT_PUBLIC_BACK_API) || req.get('host'); - next() - }, swaggerUI.serve, swaggerUI.setup(specs)) +app.use( + '/api-docs', + function (req, res, next) { + swaggerUI.host = + getBaseUrl(process.env.NEXT_PUBLIC_BACK_API) || req.get('host'); + next(); + }, + swaggerUI.serve, + swaggerUI.setup(specs), +); -app.use(cors({origin: true})); +app.use(cors({ origin: true })); require('./auth/auth'); app.use(bodyParser.json()); @@ -116,85 +120,148 @@ app.use('/api/file', fileRoutes); app.use('/api/pexels', pexelsRoutes); app.enable('trust proxy'); - -app.use('/api/users', passport.authenticate('jwt', {session: false}), usersRoutes); - -app.use('/api/roles', passport.authenticate('jwt', {session: false}), rolesRoutes); - -app.use('/api/permissions', passport.authenticate('jwt', {session: false}), permissionsRoutes); - -app.use('/api/courses', passport.authenticate('jwt', {session: false}), coursesRoutes); - -app.use('/api/course_sections', passport.authenticate('jwt', {session: false}), course_sectionsRoutes); - -app.use('/api/lessons', passport.authenticate('jwt', {session: false}), lessonsRoutes); - -app.use('/api/enrollments', passport.authenticate('jwt', {session: false}), enrollmentsRoutes); - -app.use('/api/lesson_progress', passport.authenticate('jwt', {session: false}), lesson_progressRoutes); - -app.use('/api/course_reviews', passport.authenticate('jwt', {session: false}), course_reviewsRoutes); - -app.use('/api/course_announcements', passport.authenticate('jwt', {session: false}), course_announcementsRoutes); - -app.use('/api/quizzes', passport.authenticate('jwt', {session: false}), quizzesRoutes); - -app.use('/api/quiz_questions', passport.authenticate('jwt', {session: false}), quiz_questionsRoutes); - -app.use('/api/quiz_options', passport.authenticate('jwt', {session: false}), quiz_optionsRoutes); - -app.use('/api/quiz_attempts', passport.authenticate('jwt', {session: false}), quiz_attemptsRoutes); - -app.use('/api/assignment_submissions', passport.authenticate('jwt', {session: false}), assignment_submissionsRoutes); - -app.use('/api/marketing_pages', passport.authenticate('jwt', {session: false}), marketing_pagesRoutes); - -app.use('/api/contact_messages', passport.authenticate('jwt', {session: false}), contact_messagesRoutes); - -app.use('/api/pricing_plans', passport.authenticate('jwt', {session: false}), pricing_plansRoutes); - -app.use('/api/plan_features', passport.authenticate('jwt', {session: false}), plan_featuresRoutes); - app.use( - '/api/openai', - passport.authenticate('jwt', { session: false }), - openaiRoutes, + '/api/roles', + passport.authenticate('jwt', { session: false }), + rolesRoutes, ); + app.use( - '/api/ai', - passport.authenticate('jwt', { session: false }), - openaiRoutes, + '/api/permissions', + passport.authenticate('jwt', { session: false }), + permissionsRoutes, +); + +app.use( + '/api/courses', + passport.authenticate('jwt', { session: false }), + coursesRoutes, +); + +app.use( + '/api/course_sections', + passport.authenticate('jwt', { session: false }), + course_sectionsRoutes, +); + +app.use( + '/api/lessons', + passport.authenticate('jwt', { session: false }), + lessonsRoutes, +); + +app.use( + '/api/enrollments', + passport.authenticate('jwt', { session: false }), + enrollmentsRoutes, +); + +app.use( + '/api/lesson_progress', + passport.authenticate('jwt', { session: false }), + lesson_progressRoutes, +); + +app.use( + '/api/course_reviews', + passport.authenticate('jwt', { session: false }), + course_reviewsRoutes, +); + +app.use( + '/api/course_announcements', + passport.authenticate('jwt', { session: false }), + course_announcementsRoutes, +); + +app.use( + '/api/quizzes', + passport.authenticate('jwt', { session: false }), + quizzesRoutes, +); + +app.use( + '/api/quiz_questions', + passport.authenticate('jwt', { session: false }), + quiz_questionsRoutes, +); + +app.use( + '/api/quiz_options', + passport.authenticate('jwt', { session: false }), + quiz_optionsRoutes, +); + +app.use( + '/api/quiz_attempts', + passport.authenticate('jwt', { session: false }), + quiz_attemptsRoutes, +); + +app.use( + '/api/assignment_submissions', + passport.authenticate('jwt', { session: false }), + assignment_submissionsRoutes, +); + +app.use( + '/api/marketing_pages', + passport.authenticate('jwt', { session: false }), + marketing_pagesRoutes, +); + +app.use( + '/api/contact_messages', + passport.authenticate('jwt', { session: false }), + contact_messagesRoutes, +); + +app.use( + '/api/pricing_plans', + passport.authenticate('jwt', { session: false }), + pricing_plansRoutes, +); + +app.use( + '/api/plan_features', + passport.authenticate('jwt', { session: false }), + plan_featuresRoutes, +); + +app.use( + '/api/users', + passport.authenticate('jwt', { session: false }), + usersRoutes, +); + +app.use( + '/api/openai', + passport.authenticate('jwt', { session: false }), + openaiRoutes, ); app.use( '/api/search', passport.authenticate('jwt', { session: false }), - searchRoutes); -app.use( - '/api/sql', - passport.authenticate('jwt', { session: false }), - sqlRoutes); - - -const publicDir = path.join( - __dirname, - '../public', + searchRoutes, ); +const publicDir = path.join(__dirname, '../public'); + if (fs.existsSync(publicDir)) { app.use('/', express.static(publicDir)); - app.get('*', function(request, response) { - response.sendFile( - path.resolve(publicDir, 'index.html'), - ); + app.get('*', function (request, response) { + response.sendFile(path.resolve(publicDir, 'index.html')); }); } const PORT = process.env.NODE_ENV === 'dev_stage' ? 3000 : 8080; +db.sequelize.sync().then(function () { app.listen(PORT, () => { console.log(`Listening on port ${PORT}`); }); +}); module.exports = app; diff --git a/backend/src/services/search.js b/backend/src/services/search.js index 50f390a..b842822 100644 --- a/backend/src/services/search.js +++ b/backend/src/services/search.js @@ -9,7 +9,6 @@ const Op = Sequelize.Op; * @param {object} currentUser */ async function checkPermissions(permission, currentUser) { - if (!currentUser) { throw new ValidationError('auth.unauthorized'); } @@ -36,401 +35,88 @@ async function checkPermissions(permission, currentUser) { } module.exports = class SearchService { - static async search(searchQuery, currentUser ) { + static async search(searchQuery, currentUser) { try { if (!searchQuery) { throw new ValidationError('iam.errors.searchQueryRequired'); } const tableColumns = { - - - + courses: [ + 'title', - - "users": [ - - "firstName", - - "lastName", - - "phoneNumber", - - "email", - - ], - - - - - - + 'slug', - - "courses": [ - - "title", - - "slug", - - "short_description", - - "description", - - "currency", - - ], - - - - + 'short_description', - - "course_sections": [ - - "title", - - ], - - - - + 'description', - - "lessons": [ - - "title", - - "slug", - - "content", - - "video_url", - - ], - - - - + 'currency', + ], - - "enrollments": [ - - "notes", - - ], - - - - + course_sections: ['title'], - - - - + lessons: ['title', 'slug', 'content', 'video_url'], - - "course_reviews": [ - - "title", - - "comment", - - ], - - - - + enrollments: ['notes'], - - "course_announcements": [ - - "title", - - "message", - - ], - - - - + course_reviews: ['title', 'comment'], - - "quizzes": [ - - "title", - - "instructions", - - ], - - - - + course_announcements: ['title', 'message'], - - "quiz_questions": [ - - "prompt", - - "explanation", - - ], - - - - + quizzes: ['title', 'instructions'], - - "quiz_options": [ - - "label", - - ], - - - - + quiz_questions: ['prompt', 'explanation'], - - - - + quiz_options: ['label'], - - "assignment_submissions": [ - - "submission_text", - - "instructor_feedback", - - ], - - - - + assignment_submissions: ['submission_text', 'instructor_feedback'], - - "marketing_pages": [ - - "title", - - "slug", - - "hero_headline", - - "hero_subheadline", - - "content", - - ], - - - - + marketing_pages: [ + 'title', - - "contact_messages": [ - - "name", - - "email", - - "subject", - - "message", - - ], - - - - + 'slug', - - "pricing_plans": [ - - "name", - - "description", - - "currency", - - ], - - - - + 'hero_headline', - - "plan_features": [ - - "name", - - "description", - - ], - - + 'hero_subheadline', + + 'content', + ], + + contact_messages: ['name', 'email', 'subject', 'message'], + + pricing_plans: ['name', 'description', 'currency'], + + plan_features: ['name', 'description'], + + users: ['firstName', 'lastName', 'phoneNumber', 'email'], }; const columnsInt = { - - - - - - - - - - - "courses": [ - - "price", - - ], - - - - - - "course_sections": [ - - "position", - - ], - - - - - - "lessons": [ - - "duration_minutes", - - "position", - - ], - - - - - - "enrollments": [ - - "progress_percent", - - ], - - - - - - "lesson_progress": [ - - "progress_percent", - - ], - - - - - - "course_reviews": [ - - "rating", - - ], - - - - - - - - - - "quizzes": [ - - "time_limit_minutes", - - "pass_percent", - - ], - - - - - - "quiz_questions": [ - - "points", - - "position", - - ], - - - - - - "quiz_options": [ - - "position", - - ], - - - - - - "quiz_attempts": [ - - "score_percent", - - ], - - - - - - "assignment_submissions": [ - - "grade_percent", - - ], - - - - - - - - - - - - - - "pricing_plans": [ - - "price_monthly", - - "price_yearly", - - "sort_order", - - ], - - - - - - "plan_features": [ - - "sort_order", - - ], - - + courses: ['price'], + + course_sections: ['position'], + + lessons: ['duration_minutes', 'position'], + + enrollments: ['progress_percent'], + + lesson_progress: ['progress_percent'], + + course_reviews: ['rating'], + + quizzes: ['time_limit_minutes', 'pass_percent'], + + quiz_questions: ['points', 'position'], + + quiz_options: ['position'], + + quiz_attempts: ['score_percent'], + + assignment_submissions: ['grade_percent'], + + pricing_plans: ['price_monthly', 'price_yearly', 'sort_order'], + + plan_features: ['sort_order'], }; let allFoundRecords = []; @@ -441,48 +127,63 @@ module.exports = class SearchService { const attributesIntToSearch = columnsInt[tableName] || []; const whereCondition = { [Op.or]: [ - ...attributesToSearch.map(attribute => ({ + ...attributesToSearch.map((attribute) => ({ [attribute]: { - [Op.iLike] : `%${searchQuery}%`, + [Op.iLike]: `%${searchQuery}%`, }, })), - ...attributesIntToSearch.map(attribute => ( + ...attributesIntToSearch.map((attribute) => Sequelize.where( - Sequelize.cast(Sequelize.col(`${tableName}.${attribute}`), 'varchar'), - { [Op.iLike]: `%${searchQuery}%` } - ) - )), + Sequelize.cast( + Sequelize.col(`${tableName}.${attribute}`), + 'varchar', + ), + { [Op.iLike]: `%${searchQuery}%` }, + ), + ), ], }; - - - const hasPermission = await checkPermissions(`READ_${tableName.toUpperCase()}`, currentUser); + const hasPermission = await checkPermissions( + `READ_${tableName.toUpperCase()}`, + currentUser, + ); if (!hasPermission) { continue; } const foundRecords = await db[tableName].findAll({ where: whereCondition, - attributes: [...tableColumns[tableName], 'id', ...attributesIntToSearch], + attributes: [ + ...tableColumns[tableName], + 'id', + ...attributesIntToSearch, + ], }); - + const modifiedRecords = foundRecords.map((record) => { const matchAttribute = []; - + for (const attribute of attributesToSearch) { - if (record[attribute]?.toLowerCase()?.includes(searchQuery.toLowerCase())) { + if ( + record[attribute] + ?.toLowerCase() + ?.includes(searchQuery.toLowerCase()) + ) { matchAttribute.push(attribute); } } for (const attribute of attributesIntToSearch) { const castedValue = String(record[attribute]); - if (castedValue && castedValue.toLowerCase().includes(searchQuery.toLowerCase())) { + if ( + castedValue && + castedValue.toLowerCase().includes(searchQuery.toLowerCase()) + ) { matchAttribute.push(attribute); } } - + return { ...record.get(), matchAttribute, @@ -499,4 +200,4 @@ module.exports = class SearchService { throw error; } } -} \ No newline at end of file +}; diff --git a/frontend/src/helpers/dataFormatter.js b/frontend/src/helpers/dataFormatter.js index 151c057..54ee21f 100644 --- a/frontend/src/helpers/dataFormatter.js +++ b/frontend/src/helpers/dataFormatter.js @@ -2,269 +2,230 @@ import dayjs from 'dayjs'; import _ from 'lodash'; export default { - filesFormatter(arr) { - if (!arr || !arr.length) return []; - return arr.map((item) => item); - }, - imageFormatter(arr) { - if (!arr || !arr.length) return [] - return arr.map(item => ({ - publicUrl: item.publicUrl || '' - })) - }, - oneImageFormatter(arr) { - if (!arr || !arr.length) return '' - return arr[0].publicUrl || '' - }, - dateFormatter(date) { - if (!date) return '' - return dayjs(date).format('YYYY-MM-DD') - }, - dateTimeFormatter(date) { - if (!date) return '' - return dayjs(date).format('YYYY-MM-DD HH:mm') - }, - booleanFormatter(val) { - return val ? 'Yes' : 'No' - }, - dataGridEditFormatter(obj) { - return _.transform(obj, (result, value, key) => { - if (_.isArray(value)) { - result[key] = _.map(value, 'id'); - } else if (_.isObject(value)) { - result[key] = value.id; - } else { - result[key] = value; - } - }); - }, - - - usersManyListFormatter(val) { - if (!val || !val.length) return [] - return val.map((item) => item.firstName) - }, - usersOneListFormatter(val) { - if (!val) return '' - return val.firstName - }, - usersManyListFormatterEdit(val) { - if (!val || !val.length) return [] - return val.map((item) => { - return {id: item.id, label: item.firstName} - }); - }, - usersOneListFormatterEdit(val) { - if (!val) return '' - return {label: val.firstName, id: val.id} - }, - - - - rolesManyListFormatter(val) { - if (!val || !val.length) return [] - return val.map((item) => item.name) - }, - rolesOneListFormatter(val) { - if (!val) return '' - return val.name - }, - rolesManyListFormatterEdit(val) { - if (!val || !val.length) return [] - return val.map((item) => { - return {id: item.id, label: item.name} - }); - }, - rolesOneListFormatterEdit(val) { - if (!val) return '' - return {label: val.name, id: val.id} - }, - - - - permissionsManyListFormatter(val) { - if (!val || !val.length) return [] - return val.map((item) => item.name) - }, - permissionsOneListFormatter(val) { - if (!val) return '' - return val.name - }, - permissionsManyListFormatterEdit(val) { - if (!val || !val.length) return [] - return val.map((item) => { - return {id: item.id, label: item.name} - }); - }, - permissionsOneListFormatterEdit(val) { - if (!val) return '' - return {label: val.name, id: val.id} - }, - - - - coursesManyListFormatter(val) { - if (!val || !val.length) return [] - return val.map((item) => item.title) - }, - coursesOneListFormatter(val) { - if (!val) return '' - return val.title - }, - coursesManyListFormatterEdit(val) { - if (!val || !val.length) return [] - return val.map((item) => { - return {id: item.id, label: item.title} - }); - }, - coursesOneListFormatterEdit(val) { - if (!val) return '' - return {label: val.title, id: val.id} - }, - - - - course_sectionsManyListFormatter(val) { - if (!val || !val.length) return [] - return val.map((item) => item.title) - }, - course_sectionsOneListFormatter(val) { - if (!val) return '' - return val.title - }, - course_sectionsManyListFormatterEdit(val) { - if (!val || !val.length) return [] - return val.map((item) => { - return {id: item.id, label: item.title} - }); - }, - course_sectionsOneListFormatterEdit(val) { - if (!val) return '' - return {label: val.title, id: val.id} - }, - - - - lessonsManyListFormatter(val) { - if (!val || !val.length) return [] - return val.map((item) => item.title) - }, - lessonsOneListFormatter(val) { - if (!val) return '' - return val.title - }, - lessonsManyListFormatterEdit(val) { - if (!val || !val.length) return [] - return val.map((item) => { - return {id: item.id, label: item.title} - }); - }, - lessonsOneListFormatterEdit(val) { - if (!val) return '' - return {label: val.title, id: val.id} - }, - - - - enrollmentsManyListFormatter(val) { - if (!val || !val.length) return [] - return val.map((item) => item.notes) - }, - enrollmentsOneListFormatter(val) { - if (!val) return '' - return val.notes - }, - enrollmentsManyListFormatterEdit(val) { - if (!val || !val.length) return [] - return val.map((item) => { - return {id: item.id, label: item.notes} - }); - }, - enrollmentsOneListFormatterEdit(val) { - if (!val) return '' - return {label: val.notes, id: val.id} - }, - - - - - - - - - - quizzesManyListFormatter(val) { - if (!val || !val.length) return [] - return val.map((item) => item.title) - }, - quizzesOneListFormatter(val) { - if (!val) return '' - return val.title - }, - quizzesManyListFormatterEdit(val) { - if (!val || !val.length) return [] - return val.map((item) => { - return {id: item.id, label: item.title} - }); - }, - quizzesOneListFormatterEdit(val) { - if (!val) return '' - return {label: val.title, id: val.id} - }, - - - - quiz_questionsManyListFormatter(val) { - if (!val || !val.length) return [] - return val.map((item) => item.prompt) - }, - quiz_questionsOneListFormatter(val) { - if (!val) return '' - return val.prompt - }, - quiz_questionsManyListFormatterEdit(val) { - if (!val || !val.length) return [] - return val.map((item) => { - return {id: item.id, label: item.prompt} - }); - }, - quiz_questionsOneListFormatterEdit(val) { - if (!val) return '' - return {label: val.prompt, id: val.id} - }, - - - - - - - - - - - - - - - - plan_featuresManyListFormatter(val) { - if (!val || !val.length) return [] - return val.map((item) => item.name) - }, - plan_featuresOneListFormatter(val) { - if (!val) return '' - return val.name - }, - plan_featuresManyListFormatterEdit(val) { - if (!val || !val.length) return [] - return val.map((item) => { - return {id: item.id, label: item.name} - }); - }, - plan_featuresOneListFormatterEdit(val) { - if (!val) return '' - return {label: val.name, id: val.id} - }, - - -} + filesFormatter(arr) { + if (!arr || !arr.length) return []; + return arr.map((item) => item); + }, + imageFormatter(arr) { + if (!arr || !arr.length) return []; + return arr.map((item) => ({ + publicUrl: item.publicUrl || '', + })); + }, + oneImageFormatter(arr) { + if (!arr || !arr.length) return ''; + return arr[0].publicUrl || ''; + }, + dateFormatter(date) { + if (!date) return ''; + return dayjs(date).format('YYYY-MM-DD'); + }, + dateTimeFormatter(date) { + if (!date) return ''; + return dayjs(date).format('YYYY-MM-DD HH:mm'); + }, + booleanFormatter(val) { + return val ? 'Yes' : 'No'; + }, + dataGridEditFormatter(obj) { + return _.transform(obj, (result, value, key) => { + if (_.isArray(value)) { + result[key] = _.map(value, 'id'); + } else if (_.isObject(value)) { + result[key] = value.id; + } else { + result[key] = value; + } + }); + }, + + rolesManyListFormatter(val) { + if (!val || !val.length) return []; + return val.map((item) => item.name); + }, + rolesOneListFormatter(val) { + if (!val) return ''; + return val.name; + }, + rolesManyListFormatterEdit(val) { + if (!val || !val.length) return []; + return val.map((item) => { + return { id: item.id, label: item.name }; + }); + }, + rolesOneListFormatterEdit(val) { + if (!val) return ''; + return { label: val.name, id: val.id }; + }, + + permissionsManyListFormatter(val) { + if (!val || !val.length) return []; + return val.map((item) => item.name); + }, + permissionsOneListFormatter(val) { + if (!val) return ''; + return val.name; + }, + permissionsManyListFormatterEdit(val) { + if (!val || !val.length) return []; + return val.map((item) => { + return { id: item.id, label: item.name }; + }); + }, + permissionsOneListFormatterEdit(val) { + if (!val) return ''; + return { label: val.name, id: val.id }; + }, + + coursesManyListFormatter(val) { + if (!val || !val.length) return []; + return val.map((item) => item.title); + }, + coursesOneListFormatter(val) { + if (!val) return ''; + return val.title; + }, + coursesManyListFormatterEdit(val) { + if (!val || !val.length) return []; + return val.map((item) => { + return { id: item.id, label: item.title }; + }); + }, + coursesOneListFormatterEdit(val) { + if (!val) return ''; + return { label: val.title, id: val.id }; + }, + + course_sectionsManyListFormatter(val) { + if (!val || !val.length) return []; + return val.map((item) => item.title); + }, + course_sectionsOneListFormatter(val) { + if (!val) return ''; + return val.title; + }, + course_sectionsManyListFormatterEdit(val) { + if (!val || !val.length) return []; + return val.map((item) => { + return { id: item.id, label: item.title }; + }); + }, + course_sectionsOneListFormatterEdit(val) { + if (!val) return ''; + return { label: val.title, id: val.id }; + }, + + lessonsManyListFormatter(val) { + if (!val || !val.length) return []; + return val.map((item) => item.title); + }, + lessonsOneListFormatter(val) { + if (!val) return ''; + return val.title; + }, + lessonsManyListFormatterEdit(val) { + if (!val || !val.length) return []; + return val.map((item) => { + return { id: item.id, label: item.title }; + }); + }, + lessonsOneListFormatterEdit(val) { + if (!val) return ''; + return { label: val.title, id: val.id }; + }, + + enrollmentsManyListFormatter(val) { + if (!val || !val.length) return []; + return val.map((item) => item.notes); + }, + enrollmentsOneListFormatter(val) { + if (!val) return ''; + return val.notes; + }, + enrollmentsManyListFormatterEdit(val) { + if (!val || !val.length) return []; + return val.map((item) => { + return { id: item.id, label: item.notes }; + }); + }, + enrollmentsOneListFormatterEdit(val) { + if (!val) return ''; + return { label: val.notes, id: val.id }; + }, + + quizzesManyListFormatter(val) { + if (!val || !val.length) return []; + return val.map((item) => item.title); + }, + quizzesOneListFormatter(val) { + if (!val) return ''; + return val.title; + }, + quizzesManyListFormatterEdit(val) { + if (!val || !val.length) return []; + return val.map((item) => { + return { id: item.id, label: item.title }; + }); + }, + quizzesOneListFormatterEdit(val) { + if (!val) return ''; + return { label: val.title, id: val.id }; + }, + + quiz_questionsManyListFormatter(val) { + if (!val || !val.length) return []; + return val.map((item) => item.prompt); + }, + quiz_questionsOneListFormatter(val) { + if (!val) return ''; + return val.prompt; + }, + quiz_questionsManyListFormatterEdit(val) { + if (!val || !val.length) return []; + return val.map((item) => { + return { id: item.id, label: item.prompt }; + }); + }, + quiz_questionsOneListFormatterEdit(val) { + if (!val) return ''; + return { label: val.prompt, id: val.id }; + }, + + plan_featuresManyListFormatter(val) { + if (!val || !val.length) return []; + return val.map((item) => item.name); + }, + plan_featuresOneListFormatter(val) { + if (!val) return ''; + return val.name; + }, + plan_featuresManyListFormatterEdit(val) { + if (!val || !val.length) return []; + return val.map((item) => { + return { id: item.id, label: item.name }; + }); + }, + plan_featuresOneListFormatterEdit(val) { + if (!val) return ''; + return { label: val.name, id: val.id }; + }, + + usersManyListFormatter(val) { + if (!val || !val.length) return []; + return val.map((item) => item.firstName); + }, + usersOneListFormatter(val) { + if (!val) return ''; + return val.firstName; + }, + usersManyListFormatterEdit(val) { + if (!val || !val.length) return []; + return val.map((item) => { + return { id: item.id, label: item.firstName }; + }); + }, + usersOneListFormatterEdit(val) { + if (!val) return ''; + return { label: val.firstName, id: val.id }; + }, +}; diff --git a/frontend/src/menuAside.ts b/frontend/src/menuAside.ts index b29ed3e..ab4de0c 100644 --- a/frontend/src/menuAside.ts +++ b/frontend/src/menuAside.ts @@ -1,5 +1,5 @@ import * as icon from '@mdi/js'; -import { MenuAsideItem } from './interfaces' +import { MenuAsideItem } from './interfaces'; const menuAside: MenuAsideItem[] = [ { @@ -7,22 +7,14 @@ const menuAside: MenuAsideItem[] = [ icon: icon.mdiViewDashboardOutline, label: 'Dashboard', }, - - { - href: '/users/users-list', - label: 'Users', - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - icon: icon.mdiAccountGroup ?? icon.mdiTable, - permissions: 'READ_USERS' - }, + { href: '/roles/roles-list', label: 'Roles', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore icon: icon.mdiShieldAccountVariantOutline ?? icon.mdiTable, - permissions: 'READ_ROLES' + permissions: 'READ_ROLES', }, { href: '/permissions/permissions-list', @@ -30,135 +22,191 @@ const menuAside: MenuAsideItem[] = [ // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore icon: icon.mdiShieldAccountOutline ?? icon.mdiTable, - permissions: 'READ_PERMISSIONS' + permissions: 'READ_PERMISSIONS', }, { href: '/courses/courses-list', label: 'Courses', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiSchool' in icon ? icon['mdiSchool' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_COURSES' + icon: + 'mdiSchool' in icon + ? icon['mdiSchool' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_COURSES', }, { href: '/course_sections/course_sections-list', label: 'Course sections', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiViewList' in icon ? icon['mdiViewList' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_COURSE_SECTIONS' + icon: + 'mdiViewList' in icon + ? icon['mdiViewList' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_COURSE_SECTIONS', }, { href: '/lessons/lessons-list', label: 'Lessons', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiPlayCircleOutline' in icon ? icon['mdiPlayCircleOutline' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_LESSONS' + icon: + 'mdiPlayCircleOutline' in icon + ? icon['mdiPlayCircleOutline' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_LESSONS', }, { href: '/enrollments/enrollments-list', label: 'Enrollments', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiAccountSchool' in icon ? icon['mdiAccountSchool' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_ENROLLMENTS' + icon: + 'mdiAccountSchool' in icon + ? icon['mdiAccountSchool' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_ENROLLMENTS', }, { href: '/lesson_progress/lesson_progress-list', label: 'Lesson progress', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiProgressCheck' in icon ? icon['mdiProgressCheck' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_LESSON_PROGRESS' + icon: + 'mdiProgressCheck' in icon + ? icon['mdiProgressCheck' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_LESSON_PROGRESS', }, { href: '/course_reviews/course_reviews-list', label: 'Course reviews', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiStarCircle' in icon ? icon['mdiStarCircle' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_COURSE_REVIEWS' + icon: + 'mdiStarCircle' in icon + ? icon['mdiStarCircle' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_COURSE_REVIEWS', }, { href: '/course_announcements/course_announcements-list', label: 'Course announcements', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiBullhorn' in icon ? icon['mdiBullhorn' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_COURSE_ANNOUNCEMENTS' + icon: + 'mdiBullhorn' in icon + ? icon['mdiBullhorn' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_COURSE_ANNOUNCEMENTS', }, { href: '/quizzes/quizzes-list', label: 'Quizzes', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiHelpCircleOutline' in icon ? icon['mdiHelpCircleOutline' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_QUIZZES' + icon: + 'mdiHelpCircleOutline' in icon + ? icon['mdiHelpCircleOutline' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_QUIZZES', }, { href: '/quiz_questions/quiz_questions-list', label: 'Quiz questions', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiOrderBoolAscendingVariant' in icon ? icon['mdiOrderBoolAscendingVariant' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_QUIZ_QUESTIONS' + icon: + 'mdiOrderBoolAscendingVariant' in icon + ? icon['mdiOrderBoolAscendingVariant' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_QUIZ_QUESTIONS', }, { href: '/quiz_options/quiz_options-list', label: 'Quiz options', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiCheckboxMarkedCircleOutline' in icon ? icon['mdiCheckboxMarkedCircleOutline' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_QUIZ_OPTIONS' + icon: + 'mdiCheckboxMarkedCircleOutline' in icon + ? icon['mdiCheckboxMarkedCircleOutline' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_QUIZ_OPTIONS', }, { href: '/quiz_attempts/quiz_attempts-list', label: 'Quiz attempts', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiClipboardTextOutline' in icon ? icon['mdiClipboardTextOutline' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_QUIZ_ATTEMPTS' + icon: + 'mdiClipboardTextOutline' in icon + ? icon['mdiClipboardTextOutline' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_QUIZ_ATTEMPTS', }, { href: '/assignment_submissions/assignment_submissions-list', label: 'Assignment submissions', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiFileUploadOutline' in icon ? icon['mdiFileUploadOutline' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_ASSIGNMENT_SUBMISSIONS' + icon: + 'mdiFileUploadOutline' in icon + ? icon['mdiFileUploadOutline' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_ASSIGNMENT_SUBMISSIONS', }, { href: '/marketing_pages/marketing_pages-list', label: 'Marketing pages', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiWeb' in icon ? icon['mdiWeb' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_MARKETING_PAGES' + icon: + 'mdiWeb' in icon + ? icon['mdiWeb' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_MARKETING_PAGES', }, { href: '/contact_messages/contact_messages-list', label: 'Contact messages', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiEmailOutline' in icon ? icon['mdiEmailOutline' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_CONTACT_MESSAGES' + icon: + 'mdiEmailOutline' in icon + ? icon['mdiEmailOutline' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_CONTACT_MESSAGES', }, { href: '/pricing_plans/pricing_plans-list', label: 'Pricing plans', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiCashMultiple' in icon ? icon['mdiCashMultiple' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_PRICING_PLANS' + icon: + 'mdiCashMultiple' in icon + ? icon['mdiCashMultiple' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_PRICING_PLANS', }, { href: '/plan_features/plan_features-list', label: 'Plan features', // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - icon: 'mdiChecklist' in icon ? icon['mdiChecklist' as keyof typeof icon] : icon.mdiTable ?? icon.mdiTable, - permissions: 'READ_PLAN_FEATURES' + icon: + 'mdiChecklist' in icon + ? icon['mdiChecklist' as keyof typeof icon] + : icon.mdiTable ?? icon.mdiTable, + permissions: 'READ_PLAN_FEATURES', + }, + { + href: '/users/users-list', + label: 'Users', + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + icon: icon.mdiAccountGroup ?? icon.mdiTable, + permissions: 'READ_USERS', }, { href: '/profile', @@ -166,14 +214,13 @@ const menuAside: MenuAsideItem[] = [ icon: icon.mdiAccountCircle, }, - { href: '/api-docs', target: '_blank', label: 'Swagger API', icon: icon.mdiFileCode, - permissions: 'READ_API_DOCS' + permissions: 'READ_API_DOCS', }, -] +]; -export default menuAside +export default menuAside; diff --git a/frontend/src/pages/dashboard.tsx b/frontend/src/pages/dashboard.tsx index d853a60..c7b9d3c 100644 --- a/frontend/src/pages/dashboard.tsx +++ b/frontend/src/pages/dashboard.tsx @@ -1,700 +1,903 @@ import * as icon from '@mdi/js'; -import Head from 'next/head' -import React from 'react' +import Head from 'next/head'; +import React from 'react'; import axios from 'axios'; -import type { ReactElement } from 'react' -import LayoutAuthenticated from '../layouts/Authenticated' -import SectionMain from '../components/SectionMain' -import SectionTitleLineWithButton from '../components/SectionTitleLineWithButton' -import BaseIcon from "../components/BaseIcon"; -import { getPageTitle } from '../config' -import Link from "next/link"; +import type { ReactElement } from 'react'; +import LayoutAuthenticated from '../layouts/Authenticated'; +import SectionMain from '../components/SectionMain'; +import SectionTitleLineWithButton from '../components/SectionTitleLineWithButton'; +import BaseIcon from '../components/BaseIcon'; +import { getPageTitle } from '../config'; +import Link from 'next/link'; +import { useTranslation } from 'next-i18next'; -import { hasPermission } from "../helpers/userPermissions"; +import { hasPermission } from '../helpers/userPermissions'; import { fetchWidgets } from '../stores/roles/rolesSlice'; import { WidgetCreator } from '../components/WidgetCreator/WidgetCreator'; import { SmartWidget } from '../components/SmartWidget/SmartWidget'; import { useAppDispatch, useAppSelector } from '../stores/hooks'; const Dashboard = () => { - const dispatch = useAppDispatch(); - const iconsColor = useAppSelector((state) => state.style.iconsColor); - const corners = useAppSelector((state) => state.style.corners); - const cardsStyle = useAppSelector((state) => state.style.cardsStyle); + const { t } = useTranslation('common'); + const dispatch = useAppDispatch(); + const iconsColor = useAppSelector((state) => state.style.iconsColor); + const corners = useAppSelector((state) => state.style.corners); + const cardsStyle = useAppSelector((state) => state.style.cardsStyle); - const loadingMessage = 'Loading...'; + const loadingMessage = t('pages.dashboard.loading', { + defaultValue: 'Loading...', + }); - - const [users, setUsers] = React.useState(loadingMessage); - const [roles, setRoles] = React.useState(loadingMessage); - const [permissions, setPermissions] = React.useState(loadingMessage); - const [courses, setCourses] = React.useState(loadingMessage); - const [course_sections, setCourse_sections] = React.useState(loadingMessage); - const [lessons, setLessons] = React.useState(loadingMessage); - const [enrollments, setEnrollments] = React.useState(loadingMessage); - const [lesson_progress, setLesson_progress] = React.useState(loadingMessage); - const [course_reviews, setCourse_reviews] = React.useState(loadingMessage); - const [course_announcements, setCourse_announcements] = React.useState(loadingMessage); - const [quizzes, setQuizzes] = React.useState(loadingMessage); - const [quiz_questions, setQuiz_questions] = React.useState(loadingMessage); - const [quiz_options, setQuiz_options] = React.useState(loadingMessage); - const [quiz_attempts, setQuiz_attempts] = React.useState(loadingMessage); - const [assignment_submissions, setAssignment_submissions] = React.useState(loadingMessage); - const [marketing_pages, setMarketing_pages] = React.useState(loadingMessage); - const [contact_messages, setContact_messages] = React.useState(loadingMessage); - const [pricing_plans, setPricing_plans] = React.useState(loadingMessage); - const [plan_features, setPlan_features] = React.useState(loadingMessage); + const [roles, setRoles] = React.useState(loadingMessage); + const [permissions, setPermissions] = React.useState(loadingMessage); + const [courses, setCourses] = React.useState(loadingMessage); + const [course_sections, setCourse_sections] = React.useState(loadingMessage); + const [lessons, setLessons] = React.useState(loadingMessage); + const [enrollments, setEnrollments] = React.useState(loadingMessage); + const [lesson_progress, setLesson_progress] = React.useState(loadingMessage); + const [course_reviews, setCourse_reviews] = React.useState(loadingMessage); + const [course_announcements, setCourse_announcements] = + React.useState(loadingMessage); + const [quizzes, setQuizzes] = React.useState(loadingMessage); + const [quiz_questions, setQuiz_questions] = React.useState(loadingMessage); + const [quiz_options, setQuiz_options] = React.useState(loadingMessage); + const [quiz_attempts, setQuiz_attempts] = React.useState(loadingMessage); + const [assignment_submissions, setAssignment_submissions] = + React.useState(loadingMessage); + const [marketing_pages, setMarketing_pages] = React.useState(loadingMessage); + const [contact_messages, setContact_messages] = + React.useState(loadingMessage); + const [pricing_plans, setPricing_plans] = React.useState(loadingMessage); + const [plan_features, setPlan_features] = React.useState(loadingMessage); + const [users, setUsers] = React.useState(loadingMessage); - - const [widgetsRole, setWidgetsRole] = React.useState({ - role: { value: '', label: '' }, + const [widgetsRole, setWidgetsRole] = React.useState({ + role: { value: '', label: '' }, + }); + const { currentUser } = useAppSelector((state) => state.auth); + const { isFetchingQuery } = useAppSelector((state) => state.openAi); + + const { rolesWidgets, loading } = useAppSelector((state) => state.roles); + + async function loadData() { + const entities = [ + 'roles', + 'permissions', + 'courses', + 'course_sections', + 'lessons', + 'enrollments', + 'lesson_progress', + 'course_reviews', + 'course_announcements', + 'quizzes', + 'quiz_questions', + 'quiz_options', + 'quiz_attempts', + 'assignment_submissions', + 'marketing_pages', + 'contact_messages', + 'pricing_plans', + 'plan_features', + 'users', + ]; + const fns = [ + setRoles, + setPermissions, + setCourses, + setCourse_sections, + setLessons, + setEnrollments, + setLesson_progress, + setCourse_reviews, + setCourse_announcements, + setQuizzes, + setQuiz_questions, + setQuiz_options, + setQuiz_attempts, + setAssignment_submissions, + setMarketing_pages, + setContact_messages, + setPricing_plans, + setPlan_features, + setUsers, + ]; + + const requests = entities.map((entity, index) => { + if (hasPermission(currentUser, `READ_${entity.toUpperCase()}`)) { + return axios.get(`/${entity.toLowerCase()}/count`); + } else { + fns[index](null); + return Promise.resolve({ data: { count: null } }); + } }); - const { currentUser } = useAppSelector((state) => state.auth); - const { isFetchingQuery } = useAppSelector((state) => state.openAi); - - const { rolesWidgets, loading } = useAppSelector((state) => state.roles); - - - async function loadData() { - const entities = ['users','roles','permissions','courses','course_sections','lessons','enrollments','lesson_progress','course_reviews','course_announcements','quizzes','quiz_questions','quiz_options','quiz_attempts','assignment_submissions','marketing_pages','contact_messages','pricing_plans','plan_features',]; - const fns = [setUsers,setRoles,setPermissions,setCourses,setCourse_sections,setLessons,setEnrollments,setLesson_progress,setCourse_reviews,setCourse_announcements,setQuizzes,setQuiz_questions,setQuiz_options,setQuiz_attempts,setAssignment_submissions,setMarketing_pages,setContact_messages,setPricing_plans,setPlan_features,]; - const requests = entities.map((entity, index) => { - - if(hasPermission(currentUser, `READ_${entity.toUpperCase()}`)) { - return axios.get(`/${entity.toLowerCase()}/count`); - } else { - fns[index](null); - return Promise.resolve({data: {count: null}}); - } - - }); + Promise.allSettled(requests).then((results) => { + results.forEach((result, i) => { + if (result.status === 'fulfilled') { + fns[i](result.value.data.count); + } else { + fns[i](result.reason.message); + } + }); + }); + } - Promise.allSettled(requests).then((results) => { - results.forEach((result, i) => { - if (result.status === 'fulfilled') { - fns[i](result.value.data.count); - } else { - fns[i](result.reason.message); - } - }); - }); - } - - async function getWidgets(roleId) { - await dispatch(fetchWidgets(roleId)); - } - React.useEffect(() => { - if (!currentUser) return; - loadData().then(); - setWidgetsRole({ role: { value: currentUser?.app_role?.id, label: currentUser?.app_role?.name } }); - }, [currentUser]); + async function getWidgets(roleId) { + await dispatch(fetchWidgets(roleId)); + } + React.useEffect(() => { + if (!currentUser) return; + loadData().then(); + setWidgetsRole({ + role: { + value: currentUser?.app_role?.id, + label: currentUser?.app_role?.name, + }, + }); + }, [currentUser]); + + React.useEffect(() => { + if (!currentUser || !widgetsRole?.role?.value) return; + getWidgets(widgetsRole?.role?.value || '').then(); + }, [widgetsRole?.role?.value]); - React.useEffect(() => { - if (!currentUser || !widgetsRole?.role?.value) return; - getWidgets(widgetsRole?.role?.value || '').then(); - }, [widgetsRole?.role?.value]); - return ( <> - {getPageTitle('Overview')} + {getPageTitle( + t('pages.dashboard.pageTitle', { defaultValue: 'Overview' }), + )} + icon={icon.mdiChartTimelineVariant} + title={t('pages.dashboard.overview', { defaultValue: 'Overview' })} + main + > {''} - - {hasPermission(currentUser, 'CREATE_ROLES') && } + /> + )} {!!rolesWidgets.length && - hasPermission(currentUser, 'CREATE_ROLES') && ( -

- {`${widgetsRole?.role?.label || 'Users'}'s widgets`} -

- )} + hasPermission(currentUser, 'CREATE_ROLES') && ( +

+ {`${widgetsRole?.role?.label || 'Users'}'s widgets`} +

+ )}
- {(isFetchingQuery || loading) && ( -
- {' '} - Loading widgets... -
- )} + {(isFetchingQuery || loading) && ( +
+ {' '} + {t('pages.dashboard.loadingWidgets', { + defaultValue: 'Loading widgets...', + })} +
+ )} - { rolesWidgets && - rolesWidgets.map((widget) => ( - + {rolesWidgets && + rolesWidgets.map((widget) => ( + ))}
{!!rolesWidgets.length &&
} - -
- - - {hasPermission(currentUser, 'READ_USERS') && -
-
-
-
- Users -
-
- {users} -
-
-
- -
+ +
+ {hasPermission(currentUser, 'READ_ROLES') && ( + +
+
+
+
+ Roles
-
- } - - {hasPermission(currentUser, 'READ_ROLES') && -
-
-
-
- Roles -
-
- {roles} -
-
-
- -
+
+ {roles}
+
+
+ +
- } - - {hasPermission(currentUser, 'READ_PERMISSIONS') && -
-
-
-
- Permissions -
-
- {permissions} -
-
-
- -
+
+ + )} + + {hasPermission(currentUser, 'READ_PERMISSIONS') && ( + +
+
+
+
+ Permissions
-
- } - - {hasPermission(currentUser, 'READ_COURSES') && -
-
-
-
- Courses -
-
- {courses} -
-
-
- -
+
+ {permissions}
+
+
+ +
- } - - {hasPermission(currentUser, 'READ_COURSE_SECTIONS') && -
-
-
-
- Course sections -
-
- {course_sections} -
-
-
- -
+
+ + )} + + {hasPermission(currentUser, 'READ_COURSES') && ( + +
+
+
+
+ Courses
-
- } - - {hasPermission(currentUser, 'READ_LESSONS') && -
-
-
-
- Lessons -
-
- {lessons} -
-
-
- -
+
+ {courses}
+
+
+ +
- } - - {hasPermission(currentUser, 'READ_ENROLLMENTS') && -
-
-
-
- Enrollments -
-
- {enrollments} -
-
-
- -
+
+ + )} + + {hasPermission(currentUser, 'READ_COURSE_SECTIONS') && ( + +
+
+
+
+ Course sections
-
- } - - {hasPermission(currentUser, 'READ_LESSON_PROGRESS') && -
-
-
-
- Lesson progress -
-
- {lesson_progress} -
-
-
- -
+
+ {course_sections}
+
+
+ +
- } - - {hasPermission(currentUser, 'READ_COURSE_REVIEWS') && -
-
-
-
- Course reviews -
-
- {course_reviews} -
-
-
- -
+
+ + )} + + {hasPermission(currentUser, 'READ_LESSONS') && ( + +
+
+
+
+ Lessons
-
- } - - {hasPermission(currentUser, 'READ_COURSE_ANNOUNCEMENTS') && -
-
-
-
- Course announcements -
-
- {course_announcements} -
-
-
- -
+
+ {lessons}
+
+
+ +
- } - - {hasPermission(currentUser, 'READ_QUIZZES') && -
-
-
-
- Quizzes -
-
- {quizzes} -
-
-
- -
+
+ + )} + + {hasPermission(currentUser, 'READ_ENROLLMENTS') && ( + +
+
+
+
+ Enrollments
-
- } - - {hasPermission(currentUser, 'READ_QUIZ_QUESTIONS') && -
-
-
-
- Quiz questions -
-
- {quiz_questions} -
-
-
- -
+
+ {enrollments}
+
+
+ +
- } - - {hasPermission(currentUser, 'READ_QUIZ_OPTIONS') && -
-
-
-
- Quiz options -
-
- {quiz_options} -
-
-
- -
+
+ + )} + + {hasPermission(currentUser, 'READ_LESSON_PROGRESS') && ( + +
+
+
+
+ Lesson progress
-
- } - - {hasPermission(currentUser, 'READ_QUIZ_ATTEMPTS') && -
-
-
-
- Quiz attempts -
-
- {quiz_attempts} -
-
-
- -
+
+ {lesson_progress}
+
+
+ +
- } - - {hasPermission(currentUser, 'READ_ASSIGNMENT_SUBMISSIONS') && -
-
-
-
- Assignment submissions -
-
- {assignment_submissions} -
-
-
- -
+
+ + )} + + {hasPermission(currentUser, 'READ_COURSE_REVIEWS') && ( + +
+
+
+
+ Course reviews
-
- } - - {hasPermission(currentUser, 'READ_MARKETING_PAGES') && -
-
-
-
- Marketing pages -
-
- {marketing_pages} -
-
-
- -
+
+ {course_reviews}
+
+
+ +
- } - - {hasPermission(currentUser, 'READ_CONTACT_MESSAGES') && -
-
-
-
- Contact messages -
-
- {contact_messages} -
-
-
- -
+
+ + )} + + {hasPermission(currentUser, 'READ_COURSE_ANNOUNCEMENTS') && ( + +
+
+
+
+ Course announcements
-
- } - - {hasPermission(currentUser, 'READ_PRICING_PLANS') && -
-
-
-
- Pricing plans -
-
- {pricing_plans} -
-
-
- -
+
+ {course_announcements}
+
+
+ +
- } - - {hasPermission(currentUser, 'READ_PLAN_FEATURES') && -
-
-
-
- Plan features -
-
- {plan_features} -
-
-
- -
+
+ + )} + + {hasPermission(currentUser, 'READ_QUIZZES') && ( + +
+
+
+
+ Quizzes
+
+ {quizzes} +
+
+
+ +
- } - - +
+ + )} + + {hasPermission(currentUser, 'READ_QUIZ_QUESTIONS') && ( + +
+
+
+
+ Quiz questions +
+
+ {quiz_questions} +
+
+
+ +
+
+
+ + )} + + {hasPermission(currentUser, 'READ_QUIZ_OPTIONS') && ( + +
+
+
+
+ Quiz options +
+
+ {quiz_options} +
+
+
+ +
+
+
+ + )} + + {hasPermission(currentUser, 'READ_QUIZ_ATTEMPTS') && ( + +
+
+
+
+ Quiz attempts +
+
+ {quiz_attempts} +
+
+
+ +
+
+
+ + )} + + {hasPermission(currentUser, 'READ_ASSIGNMENT_SUBMISSIONS') && ( + +
+
+
+
+ Assignment submissions +
+
+ {assignment_submissions} +
+
+
+ +
+
+
+ + )} + + {hasPermission(currentUser, 'READ_MARKETING_PAGES') && ( + +
+
+
+
+ Marketing pages +
+
+ {marketing_pages} +
+
+
+ +
+
+
+ + )} + + {hasPermission(currentUser, 'READ_CONTACT_MESSAGES') && ( + +
+
+
+
+ Contact messages +
+
+ {contact_messages} +
+
+
+ +
+
+
+ + )} + + {hasPermission(currentUser, 'READ_PRICING_PLANS') && ( + +
+
+
+
+ Pricing plans +
+
+ {pricing_plans} +
+
+
+ +
+
+
+ + )} + + {hasPermission(currentUser, 'READ_PLAN_FEATURES') && ( + +
+
+
+
+ Plan features +
+
+ {plan_features} +
+
+
+ +
+
+
+ + )} + + {hasPermission(currentUser, 'READ_USERS') && ( + +
+
+
+
+ Users +
+
+ {users} +
+
+
+ +
+
+
+ + )}
- ) -} + ); +}; Dashboard.getLayout = function getLayout(page: ReactElement) { - return {page} -} + return {page}; +}; -export default Dashboard +export default Dashboard; diff --git a/frontend/src/stores/store.ts b/frontend/src/stores/store.ts index 3569163..e9308bc 100644 --- a/frontend/src/stores/store.ts +++ b/frontend/src/stores/store.ts @@ -4,25 +4,25 @@ import mainReducer from './mainSlice'; import authSlice from './authSlice'; import openAiSlice from './openAiSlice'; -import usersSlice from "./users/usersSlice"; -import rolesSlice from "./roles/rolesSlice"; -import permissionsSlice from "./permissions/permissionsSlice"; -import coursesSlice from "./courses/coursesSlice"; -import course_sectionsSlice from "./course_sections/course_sectionsSlice"; -import lessonsSlice from "./lessons/lessonsSlice"; -import enrollmentsSlice from "./enrollments/enrollmentsSlice"; -import lesson_progressSlice from "./lesson_progress/lesson_progressSlice"; -import course_reviewsSlice from "./course_reviews/course_reviewsSlice"; -import course_announcementsSlice from "./course_announcements/course_announcementsSlice"; -import quizzesSlice from "./quizzes/quizzesSlice"; -import quiz_questionsSlice from "./quiz_questions/quiz_questionsSlice"; -import quiz_optionsSlice from "./quiz_options/quiz_optionsSlice"; -import quiz_attemptsSlice from "./quiz_attempts/quiz_attemptsSlice"; -import assignment_submissionsSlice from "./assignment_submissions/assignment_submissionsSlice"; -import marketing_pagesSlice from "./marketing_pages/marketing_pagesSlice"; -import contact_messagesSlice from "./contact_messages/contact_messagesSlice"; -import pricing_plansSlice from "./pricing_plans/pricing_plansSlice"; -import plan_featuresSlice from "./plan_features/plan_featuresSlice"; +import rolesSlice from './roles/rolesSlice'; +import permissionsSlice from './permissions/permissionsSlice'; +import coursesSlice from './courses/coursesSlice'; +import course_sectionsSlice from './course_sections/course_sectionsSlice'; +import lessonsSlice from './lessons/lessonsSlice'; +import enrollmentsSlice from './enrollments/enrollmentsSlice'; +import lesson_progressSlice from './lesson_progress/lesson_progressSlice'; +import course_reviewsSlice from './course_reviews/course_reviewsSlice'; +import course_announcementsSlice from './course_announcements/course_announcementsSlice'; +import quizzesSlice from './quizzes/quizzesSlice'; +import quiz_questionsSlice from './quiz_questions/quiz_questionsSlice'; +import quiz_optionsSlice from './quiz_options/quiz_optionsSlice'; +import quiz_attemptsSlice from './quiz_attempts/quiz_attemptsSlice'; +import assignment_submissionsSlice from './assignment_submissions/assignment_submissionsSlice'; +import marketing_pagesSlice from './marketing_pages/marketing_pagesSlice'; +import contact_messagesSlice from './contact_messages/contact_messagesSlice'; +import pricing_plansSlice from './pricing_plans/pricing_plansSlice'; +import plan_featuresSlice from './plan_features/plan_featuresSlice'; +import usersSlice from './users/usersSlice'; export const store = configureStore({ reducer: { @@ -31,29 +31,29 @@ export const store = configureStore({ auth: authSlice, openAi: openAiSlice, -users: usersSlice, -roles: rolesSlice, -permissions: permissionsSlice, -courses: coursesSlice, -course_sections: course_sectionsSlice, -lessons: lessonsSlice, -enrollments: enrollmentsSlice, -lesson_progress: lesson_progressSlice, -course_reviews: course_reviewsSlice, -course_announcements: course_announcementsSlice, -quizzes: quizzesSlice, -quiz_questions: quiz_questionsSlice, -quiz_options: quiz_optionsSlice, -quiz_attempts: quiz_attemptsSlice, -assignment_submissions: assignment_submissionsSlice, -marketing_pages: marketing_pagesSlice, -contact_messages: contact_messagesSlice, -pricing_plans: pricing_plansSlice, -plan_features: plan_featuresSlice, + roles: rolesSlice, + permissions: permissionsSlice, + courses: coursesSlice, + course_sections: course_sectionsSlice, + lessons: lessonsSlice, + enrollments: enrollmentsSlice, + lesson_progress: lesson_progressSlice, + course_reviews: course_reviewsSlice, + course_announcements: course_announcementsSlice, + quizzes: quizzesSlice, + quiz_questions: quiz_questionsSlice, + quiz_options: quiz_optionsSlice, + quiz_attempts: quiz_attemptsSlice, + assignment_submissions: assignment_submissionsSlice, + marketing_pages: marketing_pagesSlice, + contact_messages: contact_messagesSlice, + pricing_plans: pricing_plansSlice, + plan_features: plan_featuresSlice, + users: usersSlice, }, -}) +}); // Infer the `RootState` and `AppDispatch` types from the store itself -export type RootState = ReturnType +export type RootState = ReturnType; // Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState} -export type AppDispatch = typeof store.dispatch +export type AppDispatch = typeof store.dispatch;