Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ export default {
short_description: 'Short description',
description_tooltip:
'The editor is WYSIWYG and includes formatting tools whilst retaining the ability to write markdown shortcuts inline and output plain Markdown.',
ai_analysis_enable_label: 'AI Recording Analysis',
ai_analysis_enable_tooltip: 'Check this option to enable AI-powered analysis of user attention and satisfaction during the meeting',
attributes: 'Attributes',
new_course: 'New course',
new_questionnaire: 'New Questionnaire',
Expand Down
2 changes: 2 additions & 0 deletions src/locales/fr-FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ export default {
summary_tooltip:
'The editor is WYSIWYG and includes formatting tools whilst retaining the ability to write markdown shortcuts inline and output plain Markdown.',
short_description: 'Short description',
ai_analysis_enable_label: 'Analyse de l’enregistrement par IA',
ai_analysis_enable_tooltip: 'Cochez cette option pour activer l’analyse de l’attention et de la satisfaction des utilisateurs pendant la réunion',
description: 'Description',
description_tooltip:
'The editor is WYSIWYG and includes formatting tools whilst retaining the ability to write markdown shortcuts inline and output plain Markdown.',
Expand Down
2 changes: 2 additions & 0 deletions src/locales/pl-PL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ export default {
target_group: 'Grupa docelowa',
author_tutor: 'Autor / Nauczyciel',
short_description: 'Krótki opis',
ai_analysis_enable_label: 'Analiza nagrania AI',
ai_analysis_enable_tooltip: 'Zaznacz tę opcję aby włączyć analizę badania atencji oraz satystakcji użytkowników na spotkaniu',
summary: 'Podsumowanie',
summary_tooltip:
'Dany edytor WYSIWYG zawiera narzędzia do formatowania, zachowując jednocześnie możliwość pisania Markdown z klawiatury oraz wyświetlania zwykłego Markdown.',
Expand Down
28 changes: 16 additions & 12 deletions src/pages/Consultations/components/EffectivenessAnalysis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
createTableOrderObject,
EMOTION_POOL,
formatPercent,
getLabelColorByValue,
getLabelColorByValue, getRatingLabelColorByValue,
} from '@/utils/utils';
import { Link } from '@@/exports';
import {
Expand Down Expand Up @@ -79,18 +79,20 @@ const ValueTag = React.memo(
value,
suffix = '',
isRaw = false,
rating,
}: {
value: string | number;
suffix?: string;
isRaw?: boolean;
rating?: boolean;
}) => {
const displayValue = useMemo(() => {
if (isRaw) return formatPercent(value);
const num = typeof value === 'string' ? parseFloat(value) : value;
return isNaN(num) ? '0.00' : num.toFixed(2);
}, [value, isRaw]);

const color = useMemo(() => getLabelColorByValue(parseFloat(displayValue)), [displayValue]);
const color = useMemo(() => rating ? getRatingLabelColorByValue(parseFloat(displayValue)) : getLabelColorByValue(parseFloat(displayValue)), [displayValue]);

return (
<StyledValueTag $color={color}>
Expand All @@ -101,6 +103,15 @@ const ValueTag = React.memo(
},
);

const createEmotionColumn = (emoji: string, dataKey: string): ProColumns<RecommenderTerm> => ({
title: <EmojiHeader>{emoji}</EmojiHeader>,
dataIndex: `avg_emotions_${dataKey}` as keyof RecommenderTerm,
hideInSearch: true,
align: 'center',
width: 45,
render: (val) => `${formatPercent(val as string)}%`,
});

export const EffectivenessAnalysis = ({
modelType = 'consultation',
}: EffectivenessAnalysisProps) => {
Expand All @@ -117,14 +128,7 @@ export const EffectivenessAnalysis = ({
[modelType],
);

const createEmotionColumn = (emoji: string, dataKey: string): ProColumns<RecommenderTerm> => ({
title: <EmojiHeader>{emoji}</EmojiHeader>,
dataIndex: `avg_emotions_${dataKey}` as keyof RecommenderTerm,
hideInSearch: true,
align: 'center',
width: 45,
render: (val) => `${formatPercent(val as string)}%`,
});


const columns: ProColumns<RecommenderTerm>[] = useMemo(
() => [
Expand Down Expand Up @@ -156,7 +160,7 @@ export const EffectivenessAnalysis = ({
title: <FormattedMessage id="categories" />,
dataIndex: 'category_id',
hideInTable: true,
renderFormItem: ({ type, ...rest }) => <CategoryTree {...rest} />,
renderFormItem: ({ ...rest }) => <CategoryTree {...rest} />,
},
{
title: <FormattedMessage id="average_attention" />,
Expand All @@ -182,7 +186,7 @@ export const EffectivenessAnalysis = ({
dataIndex: 'rating',
hideInSearch: true,
width: 60,
render: (_, record) => <ValueTag value={record.rating ?? 0.0} />,
render: (_, record) => <ValueTag rating value={record.rating ?? 0.0} />,
},
{
title: <FormattedMessage id="recording_short" />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import type {
ChartPoint,
} from '@/pages/Consultations/components/types';
import { getAnalyticsChartFrames, getModelAnalytics } from '@/services/escola-lms/consultations';
import {ANALYSIS_COLORS, EmotionKey, formatExpirationTime, formatRating, getLabelColorByValue} from '@/utils/utils';
import {
ANALYSIS_COLORS, EmotionKey, formatRating, getLabelColorByValue,
getRatingLabelColorByValue
} from '@/utils/utils';
import { PageContainer } from '@ant-design/pro-components';
import { Card, Col, Select, Space, Typography, message } from 'antd';
import React, { useEffect, useMemo, useState } from 'react';
Expand Down Expand Up @@ -80,6 +83,10 @@ const EffectivenessAnalysisDetails = () => {
() => getLabelColorByValue(analysisMeta?.rating ? analysisMeta.rating : 0),
[analysisMeta?.rating],
);
const ratingColor = useMemo(
() => getRatingLabelColorByValue(analysisMeta?.rating ? analysisMeta.rating : 0),
[analysisMeta?.rating],
);

console.log(color, 'color');

Expand Down Expand Up @@ -189,7 +196,7 @@ const EffectivenessAnalysisDetails = () => {
<FormattedMessage id="engagement_rating" />
</SectionTitle>
<Space size="large">
<RatingValue color={color}>{formatRating(analysisMeta?.rating || 0)}</RatingValue>
<RatingValue color={ratingColor}>{formatRating(analysisMeta?.rating || 0)}</RatingValue>
<RatingDescription type="secondary">
<FormattedMessage
id="ai_analysis_average"
Expand Down
10 changes: 9 additions & 1 deletion src/pages/Consultations/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ProCard from '@ant-design/pro-card';
import ProForm, {
ProFormDatePicker,
ProFormDigit,
ProFormSelect,
ProFormSelect, ProFormSwitch,
ProFormText,
} from '@ant-design/pro-form';
import { Alert, Button, Col, Row, Spin } from 'antd';
Expand Down Expand Up @@ -357,6 +357,14 @@ const ConsultationForm = () => {
fieldProps={{ step: 1 }}
/>
</ProForm.Group>
<ProForm.Group>
<ProFormSwitch
name="analyze_enabled"
label={<FormattedMessage id="ai_analysis_enable_label" />}
tooltip={<FormattedMessage id="ai_analysis_enable_tooltip" />}
width="lg"
/>
</ProForm.Group>
<ProForm.Group>
<ProForm.Item
name="description"
Expand Down
10 changes: 9 additions & 1 deletion src/pages/Webinars/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { splitImagePath, tagsArrToIds } from '@/utils/utils';
import ProCard from '@ant-design/pro-card';
import ProForm, {
ProFormDateTimePicker,
ProFormSelect,
ProFormSelect, ProFormSwitch,
ProFormText,
ProFormTextArea,
} from '@ant-design/pro-form';
Expand Down Expand Up @@ -315,6 +315,14 @@ const WebinarForm = () => {
<UserSelect multiple />
</ProForm.Item>
</ProForm.Group>
<ProForm.Group>
<ProFormSwitch
name="analyze_enabled"
label={<FormattedMessage id="ai_analysis_enable_label" />}
tooltip={<FormattedMessage id="ai_analysis_enable_tooltip" />}
width="lg"
/>
</ProForm.Group>
<ProForm.Group>
<ProFormTextArea
name="short_desc"
Expand Down
6 changes: 6 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,12 @@ export const getLabelColorByValue = (val: number) => {
return ANALYSIS_COLORS.green;
};

export const getRatingLabelColorByValue = (val: number) => {
if (val < 3.5) return ANALYSIS_COLORS.red;
if (val < 7.0) return ANALYSIS_COLORS.orange;
return ANALYSIS_COLORS.green;
};

export enum EmotionKey {
SURPRISED = 'surprised',
DISGUSTED = 'disgusted',
Expand Down
Loading