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
5 changes: 3 additions & 2 deletions src/components/Card/PlanLessonCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type FlowCardProps = {
px?: SpaceProps['px'];
id: number;
isSelected: boolean;
suggestedType: string;
setSelectedNode: (id: number) => void;
updateNodeAt: (id: number, updatedNode: PlanLessonNode) => void;
};
Expand All @@ -45,13 +46,13 @@ const PlanLessonCard = ({
setSelectedNode,
isSelected,
updateNodeAt,
suggestedType,
}: FlowCardProps) => {
const [specificData, setSpecificData] = useState<SpecificData>({
solutions_number: 1,
distractors_number: 1,
easily_discardable_distractors_number: 1,
});

const planNodeSuggestedType = planNode.type;

useEffect(() => {
Expand Down Expand Up @@ -79,7 +80,7 @@ const PlanLessonCard = ({
<strong>Topic:</strong> {planNode.topic}
</Text>
<Text fontSize="sm">
<strong>Type:</strong> {planNode.type}
<strong>Suggested Type:</strong> {suggestedType}
</Text>
<Text fontSize="sm">
<strong>Details:</strong> {planNode.details}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Modals/AIToolModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ const AIToolModal = ({
break;
case 'short answer question':
adaptedData = {
question: dataGen.assignment,
question: dataGen.assignment + ' ' + dataGen.plus,
correctAnswers: dataGen.solutions,
};
break;
Expand Down
28 changes: 16 additions & 12 deletions src/components/Modals/CreateAILPModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const dataFactory: Record<string, (values: AIExerciseGenerated) => any> = {
possibleAnswer: values.solutions[0],
}),
closeEndedQuestionNode: (values) => ({
question: values.assignment,
question: values.assignment + ' ' + values.plus,
correctAnswers: values.solutions,
isAnswerCorrect: [],
}),
Expand Down Expand Up @@ -539,7 +539,7 @@ const CreateAILPModal = ({ isOpen, onClose, action }: ModaTemplateProps) => {
if (!learningOutcome || !eduLevel) {
throw new Error('Missing learningOutcome or eduLevel');
}
API.planLesson({
await API.planLesson({
topics: selectedTopic,
learning_outcome: learningOutcome,
language: analysedMaterial.language,
Expand Down Expand Up @@ -717,16 +717,20 @@ const CreateAILPModal = ({ isOpen, onClose, action }: ModaTemplateProps) => {
<ModalBody hidden={!screen3}>
<FormControl label="Nodes">
<Box display="flex" flexDirection="column">
{AINodes?.nodes.map((node, id) => (
<PlanLessonCard
planNode={node}
key={id}
id={id}
setSelectedNode={handleToggleNode}
isSelected={selectedNodeIds.includes(id)}
updateNodeAt={updateNodeAt}
/>
))}
{AINodes?.nodes.map((node, id) => {
const suggestedType = node.type;
return (
<PlanLessonCard
planNode={node}
key={id}
id={id}
setSelectedNode={handleToggleNode}
isSelected={selectedNodeIds.includes(id)}
updateNodeAt={updateNodeAt}
suggestedType={suggestedType}
/>
);
})}
</Box>
</FormControl>
<Button
Expand Down
2 changes: 1 addition & 1 deletion src/components/Properties/Edges/EdgeProperties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const config = [
'CreateKeywordsListNode',
'MemoriseKeywordsListNode',
'PromptEngineeringNode',
'ProblemSolvingNode',
'ProblemSolvingNode',
],
},
{
Expand Down
2 changes: 2 additions & 0 deletions src/pages/flows/[id]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { APIV2 } from '../../../data/api';
import useStore from '../../../store';
import { PolyglotFlow } from '../../../types/polyglotElements';
import auth0 from '../../../utils/auth0';
import { clearFlowCaches } from '../../../utils/cache';

type FlowIndexProps = {
accessToken: string | undefined;
Expand Down Expand Up @@ -66,6 +67,7 @@ const FlowIndex = ({ accessToken }: FlowIndexProps) => {
});
if (returnPath) router.push(returnPath);
storeState.updateFlowInfo(response.data);
clearFlowCaches(response.data._id);
} else {
outputToast &&
toast({
Expand Down
8 changes: 8 additions & 0 deletions src/utils/cache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function clearFlowCaches(flowId: string) {
try {
localStorage.removeItem('flow');
localStorage.removeItem('rescue-' + flowId);
} catch (error) {
console.warn('Failed to clear flow caches', error);
}
}
1 change: 1 addition & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const configUnconditionalEdge = [
'lessonTextNode',
'WatchVideoNode',
'ReadMaterialNode',
'ScanningNode',
'MindMapNode',
'SummaryNode',
'ProblemSolvingNode',
Expand Down
Loading