diff --git a/front/app/_editor/course/[courseid]/lecture/[lectureid]/edit/page.tsx b/front/app/_editor/course/[courseid]/activity/[activityid]/edit/page.tsx similarity index 58% rename from front/app/_editor/course/[courseid]/lecture/[lectureid]/edit/page.tsx rename to front/app/_editor/course/[courseid]/activity/[activityid]/edit/page.tsx index 6dde926d..778ec4f0 100644 --- a/front/app/_editor/course/[courseid]/lecture/[lectureid]/edit/page.tsx +++ b/front/app/_editor/course/[courseid]/activity/[activityid]/edit/page.tsx @@ -4,7 +4,7 @@ import { default as React, useEffect, useRef } from "react"; import { useRouter } from "next/navigation"; -import { getLecture } from "@services/courses/lectures"; +import { getActivity } from "@services/courses/activities"; import AuthProvider from "@components/Security/AuthProvider"; import EditorWrapper from "@components/Editor/EditorWrapper"; import useSWR, { mutate } from "swr"; @@ -12,21 +12,21 @@ import { getAPIUrl } from "@services/config/config"; import { swrFetcher } from "@services/utils/requests"; -function EditLecture(params: any) { +function EditActivity(params: any) { const router = useRouter(); - const lectureid = params.params.lectureid; + const activityid = params.params.activityid; const courseid = params.params.courseid; const { data: courseInfo, error: error_course } = useSWR(`${getAPIUrl()}courses/meta/course_${courseid}`, swrFetcher); - const { data: lecture, error: error_lecture } = useSWR(`${getAPIUrl()}lectures/lecture_${lectureid}`, swrFetcher); + const { data: activity, error: error_activity } = useSWR(`${getAPIUrl()}activities/activity_${activityid}`, swrFetcher); return ( - {!courseInfo || !lecture ?
Loading...
: } + {!courseInfo || !activity ?
Loading...
: }
); } -export default EditLecture; +export default EditActivity; diff --git a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/lecture/[lectureid]/page.tsx b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx similarity index 69% rename from front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/lecture/[lectureid]/page.tsx rename to front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx index 868205a3..937cfd27 100644 --- a/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/lecture/[lectureid]/page.tsx +++ b/front/app/_orgs/[orgslug]/(withmenu)/course/[courseid]/activity/[activityid]/page.tsx @@ -3,61 +3,61 @@ import { useRouter } from "next/navigation"; import Link from "next/link"; import React, { useMemo } from "react"; import Layout from "@components/UI/Layout"; -import { getLecture } from "@services/courses/lectures"; +import { getActivity } from "@services/courses/activities"; import { getAPIUrl, getBackendUrl, getUriWithOrg } from "@services/config/config"; -import Canva from "@components/LectureViews/DynamicCanva/DynamicCanva"; -import styled from "styled-components"; +import Canva from "@components/ActivityViews/DynamicCanva/DynamicCanva"; +import styled from "styled-components"; import { getCourse } from "@services/courses/courses"; -import VideoLecture from "@components/LectureViews/Video/Video"; +import VideoActivity from "@components/ActivityViews/Video/Video"; import useSWR, { mutate } from "swr"; import { Check } from "lucide-react"; -import { maskLectureAsComplete } from "@services/courses/activity"; +import { maskActivityAsComplete } from "@services/courses/activity"; import { swrFetcher } from "@services/utils/requests"; -function LecturePage(params: any) { - const lectureid = params.params.lectureid; +function ActivityPage(params: any) { + const activityid = params.params.activityid; const courseid = params.params.courseid; const orgslug = params.params.orgslug; const { data: course, error: error_course } = useSWR(`${getAPIUrl()}courses/meta/course_${courseid}`, swrFetcher); - const { data: lecture, error: error_lecture } = useSWR(`${getAPIUrl()}lectures/lecture_${lectureid}`, swrFetcher); + const { data: activity, error: error_activity } = useSWR(`${getAPIUrl()}activities/activity_${activityid}`, swrFetcher); - console.log(course, lecture); + console.log(course, activity); - async function markLectureAsCompleteFront() { - const activity = await maskLectureAsComplete("" + lectureid, courseid, lecture.lecture_id.replace("lecture_", "")); - mutate(`${getAPIUrl()}lectures/lecture_${lectureid}`); + async function markActivityAsCompleteFront() { + const activity = await maskActivityAsComplete("" + activityid, courseid, activity.activity_id.replace("activity_", "")); + mutate(`${getAPIUrl()}activities/activity_${activityid}`); mutate(`${getAPIUrl()}courses/meta/course_${courseid}`); } return ( <> {error_course &&

Failed to load

} - {!course || !lecture ? ( + {!course || !activity ? (
Loading...
) : ( - - - + + + - - + +

Course

{course.course.name}

-
-
+ + {course.chapters.map((chapter: any) => { return ( <>
- {chapter.lectures.map((lecture: any) => { + {chapter.activities.map((activity: any) => { return ( <> - - + + {" "} ); @@ -69,15 +69,15 @@ function LecturePage(params: any) { })} - {lecture ? ( + {activity ? ( - {lecture.type == "dynamic" && } + {activity.type == "dynamic" && } {/* todo : use apis & streams instead of this */} - {lecture.type == "video" && } + {activity.type == "video" && } - {course.activity.lectures_marked_complete && - course.activity.lectures_marked_complete.includes("lecture_" + lectureid) && + {course.activity.activities_marked_complete && + course.activity.activities_marked_complete.includes("activity_" + activityid) && course.activity.status == "ongoing" ? ( ) : ( - {newChapterModal && } - {newLectureModal && ( - + {newActivityModal && ( + )}
@@ -271,7 +271,7 @@ function CourseEdit(params: any) { { {course.chapters.map((chapter: any) => { return ( <> - {chapter.lectures.map((lecture: any) => { + {chapter.activities.map((activity: any) => { return ( <> - + {" "} @@ -92,12 +92,12 @@ const CourseIdPage = (params: any) => { return ( <>

Chapter : {chapter.name}

- {chapter.lectures.map((lecture: any) => { + {chapter.activities.map((activity: any) => { return ( <>

- Lecture {lecture.name} - + Activity {activity.name} + {" "}

diff --git a/front/app/_orgs/[orgslug]/(withmenu)/activity/page.tsx b/front/app/_orgs/[orgslug]/(withmenu)/progress/page.tsx similarity index 100% rename from front/app/_orgs/[orgslug]/(withmenu)/activity/page.tsx rename to front/app/_orgs/[orgslug]/(withmenu)/progress/page.tsx diff --git a/front/components/LectureViews/DynamicCanva/DynamicCanva.tsx b/front/components/ActivityViews/DynamicCanva/DynamicCanva.tsx similarity index 91% rename from front/components/LectureViews/DynamicCanva/DynamicCanva.tsx rename to front/components/ActivityViews/DynamicCanva/DynamicCanva.tsx index f3fc0a78..59cc3497 100644 --- a/front/components/LectureViews/DynamicCanva/DynamicCanva.tsx +++ b/front/components/ActivityViews/DynamicCanva/DynamicCanva.tsx @@ -13,7 +13,7 @@ import PDFBlock from "@components/Editor/Extensions/PDF/PDFBlock"; interface Editor { content: string; - lecture: any; + activity: any; //course: any; } @@ -32,19 +32,19 @@ function Canva(props: Editor) { }), ImageBlock.configure({ editable: isEditable, - lecture: props.lecture, + activity: props.activity, }), VideoBlock.configure({ editable: true, - lecture: props.lecture, + activity: props.activity, }), MathEquationBlock.configure({ editable: false, - lecture: props.lecture, + activity: props.activity, }), PDFBlock.configure({ editable: true, - lecture: props.lecture, + activity: props.activity, }), Youtube.configure({ controls: true, diff --git a/front/components/LectureViews/Video/Video.tsx b/front/components/ActivityViews/Video/Video.tsx similarity index 77% rename from front/components/LectureViews/Video/Video.tsx rename to front/components/ActivityViews/Video/Video.tsx index c8398f13..00fe9799 100644 --- a/front/components/LectureViews/Video/Video.tsx +++ b/front/components/ActivityViews/Video/Video.tsx @@ -2,10 +2,10 @@ import { getBackendUrl } from "@services/config/config"; import React from "react"; import styled from "styled-components"; -function VideoLecture({ lecture, course }: { lecture: any; course: any }) { +function VideoActivity({ activity, course }: { activity: any; course: any }) { function getChapterName() { let chapterName = ""; - let chapterId = lecture.chapter_id; + let chapterId = activity.chapter_id; course.chapters.forEach((chapter: any) => { if (chapter.chapter_id === chapterId) { chapterName = chapter.name; @@ -15,21 +15,21 @@ function VideoLecture({ lecture, course }: { lecture: any; course: any }) { } return ( - +

Chapter : {getChapterName()}

- {lecture.name} + {activity.name}
- + -
+ ); } -export default VideoLecture; +export default VideoActivity; -const VideoLectureLayout = styled.div` +const VideoActivityLayout = styled.div` display: flex; flex-direction: column; margin-top: 10px; diff --git a/front/components/Drags/Lecture.tsx b/front/components/Drags/Activity.tsx similarity index 63% rename from front/components/Drags/Lecture.tsx rename to front/components/Drags/Activity.tsx index ffb805df..3202099b 100644 --- a/front/components/Drags/Lecture.tsx +++ b/front/components/Drags/Activity.tsx @@ -5,31 +5,31 @@ import { EyeOpenIcon, Pencil2Icon } from '@radix-ui/react-icons' import styled from "styled-components"; import { getUriWithOrg } from "@services/config/config"; -function Lecture(props: any) { +function Activity(props: any) { return ( - + {(provided) => ( - -

{props.lecture.name}

+ +

{props.activity.name}

    -
+ )}
); } -export const LectureWrapper = styled.div` +export const ActivityWrapper = styled.div` padding: 2px; padding-left: 17px; list-style: none; @@ -44,4 +44,4 @@ export const LectureWrapper = styled.div` } `; -export default Lecture; +export default Activity; diff --git a/front/components/Drags/Chapter.tsx b/front/components/Drags/Chapter.tsx index 344456c0..f4253593 100644 --- a/front/components/Drags/Chapter.tsx +++ b/front/components/Drags/Chapter.tsx @@ -1,7 +1,7 @@ import React from "react"; import styled from "styled-components"; import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd"; -import Lecture, { LectureWrapper } from "./Lecture"; +import Activity, { ActivityWrapper } from "./Activity"; function Chapter(props: any) { return ( @@ -18,10 +18,10 @@ function Chapter(props: any) { {props.info.list.chapter.name}{" "} - + {(provided) => ( - - {props.info.list.lectures.map((lecture: any, index: any) => ( - + + {props.info.list.activities.map((activity: any, index: any) => ( + ))} {provided.placeholder} - + )} @@ -66,7 +66,7 @@ const ChapterWrapper = styled.div` } `; -const LecturesList = styled.div` +const ActivitiesList = styled.div` padding: 10px; `; diff --git a/front/components/Drags/data.ts b/front/components/Drags/data.ts index 35e558ea..6be1c453 100644 --- a/front/components/Drags/data.ts +++ b/front/components/Drags/data.ts @@ -1,15 +1,15 @@ export const initialData = { - lectures: { - "lecture-1": { id: "lecture-1", content: "First lecture" }, - "lecture-2": { id: "lecture-2", content: "Second lecture" }, - "lecture-3": { id: "lecture-3", content: "Third lecture" }, - "lecture-4": { id: "lecture-4", content: "Fourth lecture" }, - "lecture-5": { id: "lecture-5", content: "Fifth lecture" }, + activities: { + "activity-1": { id: "activity-1", content: "First activity" }, + "activity-2": { id: "activity-2", content: "Second activity" }, + "activity-3": { id: "activity-3", content: "Third activity" }, + "activity-4": { id: "activity-4", content: "Fourth activity" }, + "activity-5": { id: "activity-5", content: "Fifth activity" }, }, chapters: { - "chapter-1": { id: "chapter-1", name: "Chapter 1", lectureIds: ["lecture-1", "lecture-2", "lecture-3"] }, - "chapter-2": { id: "chapter-2", name: "Chapter 2", lectureIds: ["lecture-4"] }, - "chapter-3": { id: "chapter-3", name: "Chapter 3", lectureIds: ["lecture-5"] }, + "chapter-1": { id: "chapter-1", name: "Chapter 1", activityIds: ["activity-1", "activity-2", "activity-3"] }, + "chapter-2": { id: "chapter-2", name: "Chapter 2", activityIds: ["activity-4"] }, + "chapter-3": { id: "chapter-3", name: "Chapter 3", activityIds: ["activity-5"] }, }, chapterOrder: ["chapter-1", "chapter-2", "chapter-3"], diff --git a/front/components/Editor/Editor.tsx b/front/components/Editor/Editor.tsx index e8945cdc..2cecf098 100644 --- a/front/components/Editor/Editor.tsx +++ b/front/components/Editor/Editor.tsx @@ -28,7 +28,7 @@ interface Editor { content: string; ydoc: any; provider: any; - lecture: any; + activity: any; course: any; setContent: (content: string) => void; } @@ -52,23 +52,23 @@ function Editor(props: Editor) { }), ImageBlock.configure({ editable: true, - lecture: props.lecture, + activity: props.activity, }), VideoBlock.configure({ editable: true, - lecture: props.lecture, + activity: props.activity, }), MathEquationBlock.configure({ editable: true, - lecture: props.lecture, + activity: props.activity, }), PDFBlock.configure({ editable: true, - lecture: props.lecture, + activity: props.activity, }), QuizBlock.configure({ editable: true, - lecture: props.lecture, + activity: props.activity, }), Youtube.configure({ controls: true, @@ -112,7 +112,7 @@ function Editor(props: Editor) { {" "} - {props.course.course.name} {props.lecture.name}{" "} + {props.course.course.name} {props.activity.name}{" "} props.setContent(editor.getJSON())}> Save diff --git a/front/components/Editor/EditorWrapper.tsx b/front/components/Editor/EditorWrapper.tsx index cfdfcd77..359e09a3 100644 --- a/front/components/Editor/EditorWrapper.tsx +++ b/front/components/Editor/EditorWrapper.tsx @@ -2,11 +2,11 @@ import { default as React, } from "react"; import * as Y from "yjs"; import { WebrtcProvider } from "y-webrtc"; import Editor from "./Editor"; -import { updateLecture } from "../../services/courses/lectures"; +import { updateActivity } from "@services/courses/activities"; interface EditorWrapperProps { content: string; - lecture: any; + activity: any; course:any } @@ -18,16 +18,16 @@ function EditorWrapper(props: EditorWrapperProps) : JSX.Element { const [isLoading, setIsLoading] = React.useState(true); function createRTCProvider() { - // const provider = new WebrtcProvider(props.lecture.lecture_id, ydoc); + // const provider = new WebrtcProvider(props.activity.activity_id, ydoc); // setYdocState(ydoc); // setProviderState(provider); setIsLoading(false); } async function setContent(content: any) { - let lecture = props.lecture; - lecture.content = content; - const res = await updateLecture(lecture, lecture.lecture_id); + let activity = props.activity; + activity.content = content; + const res = await updateActivity(activity, activity.activity_id); alert(JSON.stringify(res)); } @@ -35,7 +35,7 @@ function EditorWrapper(props: EditorWrapperProps) : JSX.Element { createRTCProvider(); return
Loading...
; } else { - return ; + return ; } } diff --git a/front/components/Editor/Extensions/Image/ImageBlockComponent.tsx b/front/components/Editor/Extensions/Image/ImageBlockComponent.tsx index c3088977..ce53bc9c 100644 --- a/front/components/Editor/Extensions/Image/ImageBlockComponent.tsx +++ b/front/components/Editor/Extensions/Image/ImageBlockComponent.tsx @@ -17,7 +17,7 @@ function ImageBlockComponent(props: any) { const handleSubmit = async (e: any) => { e.preventDefault(); setIsLoading(true); - let object = await uploadNewImageFile(image, props.extension.options.lecture.lecture_id); + let object = await uploadNewImageFile(image, props.extension.options.activity.activity_id); setIsLoading(false); setblockObject(object); props.updateAttributes({ @@ -41,7 +41,7 @@ function ImageBlockComponent(props: any) { {blockObject && ( { e.preventDefault(); setIsLoading(true); - let object = await uploadNewPDFFile(pdf, props.extension.options.lecture.lecture_id); + let object = await uploadNewPDFFile(pdf, props.extension.options.activity.activity_id); setIsLoading(false); setblockObject(object); props.updateAttributes({ @@ -41,7 +41,7 @@ function PDFBlockComponent(props: any) { {blockObject && (