Просмотр исходного кода

Merge pull request #2106 from visuddhinanda/agile

课程模式discussion wbw显示学生discussion
visuddhinanda 1 год назад
Родитель
Сommit
4e511848eb

+ 7 - 0
dashboard/src/components/api/Comment.ts

@@ -67,11 +67,18 @@ export interface IDiscussionCountRequest {
   course_id?: string | null;
   sentences: string[][];
 }
+
+export interface IDiscussionCountWbw {
+  book_id: number;
+  paragraph: number;
+  wid: number;
+}
 export interface IDiscussionCountData {
   id: string;
   res_id: string;
   type: string;
   editor_uid: string;
+  wbw?: IDiscussionCountWbw;
 }
 export interface IDiscussionCountResponse {
   ok: boolean;

+ 15 - 0
dashboard/src/components/discussion/DiscussionButton.tsx

@@ -7,6 +7,7 @@ import { TResType } from "./DiscussionListCard";
 import { useAppSelector } from "../../hooks";
 import { currentUser } from "../../reducers/current-user";
 import { discussionList } from "../../reducers/discussion-count";
+import { IDiscussionCountWbw } from "../api/Comment";
 
 interface IWidget {
   initCount?: number;
@@ -15,6 +16,7 @@ interface IWidget {
   hideCount?: boolean;
   hideInZero?: boolean;
   onlyMe?: boolean;
+  wbw?: IDiscussionCountWbw;
 }
 const DiscussionButton = ({
   initCount = 0,
@@ -23,12 +25,22 @@ const DiscussionButton = ({
   hideCount = false,
   hideInZero = false,
   onlyMe = false,
+  wbw,
 }: IWidget) => {
   const user = useAppSelector(currentUser);
   const discussions = useAppSelector(discussionList);
 
   const all = discussions?.filter((value) => value.res_id === resId);
   const my = all?.filter((value) => value.editor_uid === user?.id);
+  const withStudent = discussions?.filter(
+    (value) =>
+      value.wbw?.book_id === wbw?.book_id &&
+      value.wbw?.paragraph === wbw?.paragraph &&
+      value.wbw?.wid.toString() === wbw?.wid.toString()
+  );
+
+  console.debug("DiscussionButton", discussions, wbw, withStudent);
+
   let currCount = initCount;
   if (onlyMe) {
     if (my) {
@@ -42,6 +54,9 @@ const DiscussionButton = ({
     } else {
       currCount = 0;
     }
+    if (withStudent) {
+      currCount += withStudent.length;
+    }
   }
 
   let myCount = false;

+ 11 - 1
dashboard/src/components/template/Nissaya/NissayaMeaning.tsx

@@ -10,7 +10,17 @@ export interface IMeaning {
 }
 
 export const nissayaBase = (item: string, endings: string[]): IMeaning => {
-  let word = item.trim().replaceAll("။", "");
+  let word = item
+    .trim()
+    .replaceAll("။", "")
+    .replaceAll("[}", "")
+    .replaceAll("]", "")
+    .replaceAll("(", "")
+    .replaceAll(")", "")
+    .replaceAll("၊", "")
+    .replaceAll(",", "")
+    .replaceAll(".", "");
+
   let end: string[] = [];
   for (let loop = 0; loop < 3; loop++) {
     for (let i = 0; i < word.length; i++) {

+ 5 - 1
dashboard/src/components/template/Wbw/WbwPali.tsx

@@ -406,7 +406,11 @@ const WbwPaliWidget = ({
           <NoteIcon />
           <BookMarkIcon />
           <RelationIcon />
-          <WbwPaliDiscussionIcon data={data} studio={studio} />
+          <WbwPaliDiscussionIcon
+            data={data}
+            studio={studio}
+            channelId={channelId}
+          />
         </Space>
       </div>
     );

+ 17 - 1
dashboard/src/components/template/Wbw/WbwPaliDiscussionIcon.tsx

@@ -1,6 +1,8 @@
 import { useAppSelector } from "../../../hooks";
 import { courseUser } from "../../../reducers/course-user";
+import { courseInfo } from "../../../reducers/current-course";
 import { currentUser } from "../../../reducers/current-user";
+import { IDiscussionCountWbw } from "../../api/Comment";
 import { IStudio } from "../../auth/Studio";
 import DiscussionButton from "../../discussion/DiscussionButton";
 import { IWbw } from "./WbwWord";
@@ -8,11 +10,14 @@ import { IWbw } from "./WbwWord";
 interface IWidget {
   data: IWbw;
   studio?: IStudio;
+  channelId?: string;
 }
-const WbwPaliDiscussionIcon = ({ data, studio }: IWidget) => {
+const WbwPaliDiscussionIcon = ({ data, studio, channelId }: IWidget) => {
   const userInCourse = useAppSelector(courseUser);
   const currUser = useAppSelector(currentUser);
+  const course = useAppSelector(courseInfo);
 
+  let wbw: IDiscussionCountWbw | undefined;
   let onlyMe = false;
   if (userInCourse) {
     if (userInCourse.role === "student") {
@@ -23,6 +28,16 @@ const WbwPaliDiscussionIcon = ({ data, studio }: IWidget) => {
         //其他channel 只显示自己的
         onlyMe = true;
       }
+    } else {
+      if (course) {
+        if (course.channelId === channelId) {
+          wbw = {
+            book_id: data.book,
+            paragraph: data.para,
+            wid: data.sn[0],
+          };
+        }
+      }
     }
   }
 
@@ -34,6 +49,7 @@ const WbwPaliDiscussionIcon = ({ data, studio }: IWidget) => {
       onlyMe={onlyMe}
       resId={data.uid}
       resType="wbw"
+      wbw={wbw}
     />
   );
 };

+ 1 - 0
dashboard/src/locales/en-US/buttons.ts

@@ -92,6 +92,7 @@ const items = {
   "buttons.forgot.password": "forgot password",
   "buttons.select.channel": "Select Channel",
   "buttons.set.display.mode": "Display Mode",
+  "buttons.manage": "Manage",
 };
 
 export default items;

+ 1 - 0
dashboard/src/locales/zh-Hans/buttons.ts

@@ -92,6 +92,7 @@ const items = {
   "buttons.forgot.password": "忘记密码",
   "buttons.select.channel": "选择版本风格",
   "buttons.set.display.mode": "显示模式",
+  "buttons.manage": "管理",
 };
 
 export default items;

+ 1 - 1
dashboard/src/pages/studio/course/list.tsx

@@ -136,7 +136,7 @@ const Widget = () => {
         >
           {intl.formatMessage({
             //编辑
-            id: "buttons.edit",
+            id: "buttons.manage",
           })}
         </Link>
       );