Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2d9c9f4
setup for analytics actions interaction
tmaog Apr 1, 2025
26fd610
feat: numberDisplay UI
tmaog Apr 8, 2025
3466079
feat: creation of open-close tool action and open - close node action
tmaog Apr 8, 2025
7b48854
setup
tmaog Apr 8, 2025
6fa0b4b
fix: error cases
tmaog Apr 9, 2025
372aa62
Merge branch 'WorkAdventureXPolyGloT-new-UI-gamified' into merge-bran…
tmaog Apr 9, 2025
46cd71f
Merge pull request #34 from polyglot-edu/merge-branch-error
tmaog Apr 9, 2025
7a3f0f5
feat: action creation for tools and pages interaction
tmaog Apr 10, 2025
eb4a931
Merge pull request #35 from polyglot-edu/WorkAdventureXPolyGloT-new-U…
tmaog Apr 10, 2025
4a233d5
name fix
tmaog Apr 10, 2025
7b36734
action fix
tmaog Apr 13, 2025
e35717a
Merge pull request #36 from polyglot-edu/WorkAdventureXPolyGloT-new-U…
tmaog Apr 13, 2025
352ffcf
integration submit action
tmaog Apr 15, 2025
36e6b36
bug fix register action api
tmaog Apr 15, 2025
7aaa7e6
submit action integrated missing truefalse bug
tmaog Apr 15, 2025
8b17270
playerId to uuid
tmaog Apr 16, 2025
98bdfea
Merge branch 'main' into WorkAdventureXPolyGloT-new-UI-gamified
tmaog Apr 16, 2025
ffeed62
Merge pull request #37 from polyglot-edu/WorkAdventureXPolyGloT-new-U…
tmaog Apr 16, 2025
ae6dcbd
action api errors managed
tmaog Apr 16, 2025
8ba36f8
Merge pull request #38 from polyglot-edu/WorkAdventureXPolyGloT-new-U…
tmaog Apr 16, 2025
8ef47b7
Update deploy-prod.yml
tmaog Apr 16, 2025
85867b3
update deploy
tmaog Apr 16, 2025
eead0e6
update deploy
tmaog Apr 16, 2025
186ac0d
update deploy
tmaog Apr 16, 2025
2bc282f
update deploy
tmaog Apr 16, 2025
7499b46
restore deploy prod
tmaog Apr 16, 2025
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
68 changes: 65 additions & 3 deletions src/components/ActivityTypes/closeEndedQuestion.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { CheckIcon, CloseIcon } from '@chakra-ui/icons';
import { Box, Button, Flex, Icon, Textarea, useToast } from '@chakra-ui/react';
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
import { PolyglotNodeValidation } from '../../types/polyglotElements';
import { registerAnalyticsAction } from '../../data/AnalyticsFunctions';
import { API } from '../../data/api';
import {
OpenCloseNodeAction,
Platform,
PolyglotNodeValidation,
SubmitAction,
ZoneId,
} from '../../types/polyglotElements';
import FlexText from '../CostumTypography/FlexText';
import HeadingSubtitle from '../CostumTypography/HeadingSubtitle';
import HeadingTitle from '../CostumTypography/HeadingTitle';
Expand All @@ -13,6 +21,10 @@ type CloseEndedToolProps = {
setSatisfiedConditions: Dispatch<SetStateAction<string[]>>;
showNextButton: boolean;
setShowNextButton: Dispatch<SetStateAction<boolean>>;
userId: string;
flowId: string;
lastAction: string;
setLastAction: Dispatch<SetStateAction<string>>;
};

type CloseEndedData = {
Expand All @@ -29,21 +41,50 @@ const CloseEndedTool = ({
setSatisfiedConditions,
showNextButton,
setShowNextButton,
userId,
lastAction,
setLastAction,
flowId,
}: CloseEndedToolProps) => {
const [disable, setDisable] = useState(false);
const [assessment, setAssessment] = useState<string>();
const data = actualActivity?.data as CloseEndedData;
const [inputValue, setInputValue] = useState('');

useEffect(() => {
if (actualActivity?.type != 'closeEndedQuestionNode') return;
if (!data) return;
setDisable(false);
setAssessment('');
//to move in validation button

if (!isOpen) return;
try {
if (userId && actualActivity?._id) {
if (lastAction == 'open_node') return;
setLastAction('open_node');

registerAnalyticsAction({
timestamp: new Date(),
userId: userId,
actionType: 'open_node',
zoneId: ZoneId.WebAppZone,
platform: Platform.WebApp,
action: {
flowId: flowId,
nodeId: actualActivity?._id,
activity: actualActivity.type,
},
} as OpenCloseNodeAction);
}
} catch (e) {
console.log(e);
}
}, [actualActivity]);

const toast = useToast();
if (!isOpen) return <></>;
console.log('close ended activity');

return (
<Box
width={'80%'}
Expand Down Expand Up @@ -130,7 +171,28 @@ const CloseEndedTool = ({
return 'undefined';
})
.filter((edge) => edge !== 'undefined') ?? [];
if (edgesId) setSatisfiedConditions(edgesId);
if (edgesId) {
setSatisfiedConditions(edgesId);
const result = actualActivity?.validation.find((edge) =>
edgesId.includes(edge.id)
)?.data.conditionKind as string;
console.log(result);
registerAnalyticsAction({
timestamp: new Date(),
userId: userId,
actionType: 'submit_answer',
zoneId: ZoneId.WebAppZone,
platform: Platform.WebApp,
action: {
//miss other values
flowId: flowId,
nodeId: actualActivity?._id,
exerciseType: actualActivity?.type,
answer: assessment,
result: result,
},
} as SubmitAction);
}
setShowNextButton(true);
}}
>
Expand Down
66 changes: 63 additions & 3 deletions src/components/ActivityTypes/multichoiceQuestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@ import {
useEffect,
useState,
} from 'react';
import { PolyglotNodeValidation } from '../../types/polyglotElements';
import { registerAnalyticsAction } from '../../data/AnalyticsFunctions';
import { API } from '../../data/api';
import {
OpenCloseNodeAction,
Platform,
PolyglotNodeValidation,
SubmitAction,
ZoneId,
} from '../../types/polyglotElements';
import FlexText from '../CostumTypography/FlexText';
import HeadingSubtitle from '../CostumTypography/HeadingSubtitle';
import HeadingTitle from '../CostumTypography/HeadingTitle';
Expand All @@ -27,6 +35,10 @@ type MultichoiceToolProps = {
setSatisfiedConditions: Dispatch<SetStateAction<string[]>>;
showNextButton: boolean;
setShowNextButton: Dispatch<SetStateAction<boolean>>;
userId: string;
flowId: string;
lastAction: string;
setLastAction: Dispatch<SetStateAction<string>>;
};

type MultichoiceQuestionData = {
Expand All @@ -42,6 +54,10 @@ const MultichoiceTool = ({
setSatisfiedConditions,
showNextButton,
setShowNextButton,
userId,
lastAction,
setLastAction,
flowId,
}: MultichoiceToolProps) => {
const [disable, setDisable] = useState(false);
const data = actualActivity?.data as MultichoiceQuestionData;
Expand All @@ -52,10 +68,34 @@ const MultichoiceTool = ({
}, []);

useEffect(() => {
if (actualActivity?.type != 'multipleChoiceQuestionNode') return;
if (!data) return;
setDisable(false);
setCheckBoxValue('');
//to move in validation button

try {
if (!isOpen) return;
if (userId && actualActivity?._id) {
if (lastAction == 'open_node') return;
setLastAction('open_node');

console.log('choiceAction');
registerAnalyticsAction({
timestamp: new Date(),
userId: userId,
actionType: 'open_node',
zoneId: ZoneId.WebAppZone,
platform: Platform.WebApp,
action: {
flowId: flowId,
nodeId: actualActivity._id,
activity: actualActivity.type,
},
} as OpenCloseNodeAction);
}
} catch (e) {
console.log(e);
}
}, [actualActivity]);

const toast = useToast();
Expand Down Expand Up @@ -141,7 +181,27 @@ const MultichoiceTool = ({
})
.filter((edge) => edge !== 'undefined') ?? [];
console.log(edgesId);
if (edgesId) setSatisfiedConditions(edgesId);
if (edgesId) {
setSatisfiedConditions(edgesId);
const result = actualActivity?.validation.find((edge) =>
edgesId.includes(edge.id)
)?.data.conditionKind as string;
console.log(result);
registerAnalyticsAction({
timestamp: new Date(),
userId: userId,
actionType: 'submit_answer',
zoneId: ZoneId.WebAppZone,
platform: Platform.WebApp,
action: {
flowId: flowId,
nodeId: actualActivity?._id,
exerciseType: actualActivity?.type,
answer: checkBoxValue,
result: result,
},
} as SubmitAction);
}
setShowNextButton(true);
}}
>
Expand Down
61 changes: 59 additions & 2 deletions src/components/ActivityTypes/openQuestion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,15 @@ import {
import { AxiosResponse } from 'axios';
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
import { API } from '../../data/api';
import { PolyglotNodeValidation } from '../../types/polyglotElements';
import {
OpenCloseNodeAction,
Platform,
PolyglotNodeValidation,
SubmitAction,
ZoneId,
} from '../../types/polyglotElements';

import { registerAnalyticsAction } from '../../data/AnalyticsFunctions';
import FlexText from '../CostumTypography/FlexText';
import HeadingSubtitle from '../CostumTypography/HeadingSubtitle';
import HeadingTitle from '../CostumTypography/HeadingTitle';
Expand All @@ -24,6 +32,10 @@ type OpenQuestionToolProps = {
setSatisfiedConditions: Dispatch<SetStateAction<string[]>>;
showNextButton: boolean;
setShowNextButton: Dispatch<SetStateAction<boolean>>;
userId: string;
flowId: string;
lastAction: string;
setLastAction: Dispatch<SetStateAction<string>>;
};

type OpenQuestionData = {
Expand All @@ -41,6 +53,10 @@ const OpenQuestionTool = ({
setSatisfiedConditions,
showNextButton,
setShowNextButton,
userId,
flowId,
lastAction,
setLastAction,
}: OpenQuestionToolProps) => {
const [isDisable, setDisable] = useState(false);
const [isLoading, setLoading] = useState(false);
Expand All @@ -49,11 +65,35 @@ const OpenQuestionTool = ({
const [inputValue, setInputValue] = useState('');

useEffect(() => {
if (!isOpen) return;
if (!data) return;
setDisable(false);
setAssessment('');
//to move in validation button

try {
if (userId && actualActivity?._id) {
if (lastAction == 'open_node') return;
setLastAction('open_node');

registerAnalyticsAction({
timestamp: new Date(),
userId: userId,
actionType: 'open_node',
zoneId: ZoneId.WebAppZone,
platform: Platform.WebApp,
action: {
flowId: flowId,
nodeId: actualActivity._id,
activity: actualActivity.type,
},
} as OpenCloseNodeAction);
}
} catch (e) {
console.log(e);
}
}, [actualActivity]);

const toast = useToast();
if (!isOpen) return <></>;
console.log('open question activity');
Expand Down Expand Up @@ -152,7 +192,24 @@ const OpenQuestionTool = ({
.filter((edge) => edge !== 'undefined') ?? [];
unlock(true);
setDisable(true);
if (edgesId) setSatisfiedConditions(edgesId);
if (edgesId) {
setSatisfiedConditions(edgesId);
registerAnalyticsAction({
timestamp: new Date(),
userId: userId,
actionType: 'submit_answer',
zoneId: ZoneId.WebAppZone,
platform: Platform.WebApp,
action: {
//miss other values
flowId: flowId,
nodeId: actualActivity?._id,
exerciseType: actualActivity?.type,
answer: assessment,
result: data.isAnswerCorrect.toString(),
},
} as SubmitAction);
}
setLoading(false);
setShowNextButton(true);
} catch (err) {
Expand Down
Loading
Loading