From 36a05ea37673294bea9108738b77455bb7a6a7d0 Mon Sep 17 00:00:00 2001 From: Jonas Date: Thu, 18 Jul 2024 18:06:57 +0200 Subject: [PATCH 1/5] feat: Assignment Intelligence --- src/components/WithNavigation.tsx | 4 + src/lang/de.json | 3 +- src/pages/learning/LearningAssignmentPage.tsx | 110 +++++++++++++++++ src/pages/learning/LearningPage.tsx | 116 ++++++++++++++++++ src/pages/learning/LearningTopicPage.tsx | 56 +++++++++ src/routing/NavigatorLazy.tsx | 25 ++++ 6 files changed, 313 insertions(+), 1 deletion(-) create mode 100644 src/pages/learning/LearningAssignmentPage.tsx create mode 100644 src/pages/learning/LearningPage.tsx create mode 100644 src/pages/learning/LearningTopicPage.tsx diff --git a/src/components/WithNavigation.tsx b/src/components/WithNavigation.tsx index 645c2e0e7..4d85e4fe5 100644 --- a/src/components/WithNavigation.tsx +++ b/src/components/WithNavigation.tsx @@ -79,6 +79,10 @@ const WithNavigation: React.FC = ({ label: t('navigation.label.forPupils'), icon: ({ isActive }) => , }, + 'learning': { + label: t('navigation.label.learning'), + icon: LFKnowledgeIcon + } }; return ( diff --git a/src/lang/de.json b/src/lang/de.json index 3853978c9..7f24a17e4 100644 --- a/src/lang/de.json +++ b/src/lang/de.json @@ -2057,7 +2057,8 @@ "appointments": "Termine", "chat": "Chat", "forStudents": "Wissens-Center", - "forPupils": "Wissens-Center" + "forPupils": "Wissens-Center", + "learning": "Lernen" } }, "screening": { diff --git a/src/pages/learning/LearningAssignmentPage.tsx b/src/pages/learning/LearningAssignmentPage.tsx new file mode 100644 index 000000000..db1cf2909 --- /dev/null +++ b/src/pages/learning/LearningAssignmentPage.tsx @@ -0,0 +1,110 @@ +import { useNavigate, useParams } from "react-router-dom"; +import WithNavigation from "../../components/WithNavigation"; +import { useQuery } from "@apollo/client"; +import CenterLoadingSpinner from "../../components/CenterLoadingSpinner"; +import { Button, HStack, Heading, Text, TextArea, VStack } from "native-base"; +import { useTranslation } from "react-i18next"; +import { Pressable } from "react-native"; +import HSection from "../../widgets/HSection"; +import { gql } from "../../gql"; +import { Learning_Note } from "../../gql/graphql"; +import useApollo from "../../hooks/useApollo"; +import { useState } from "react"; + +type Note = Pick; + +function NotesUI({ notes, assignmentId, refetch }: { notes: Note[], assignmentId: number, refetch: () => void }) { + const [text, setText] = useState(''); + const { client } = useApollo(); + + async function ask() { + await client.mutate({ + mutation: gql(` + mutation Ask($assignmentId: Int!, $text: String!) { + learningNoteCreate(note: { + assignmentId: $assignmentId + type: question + text: $text + }) { id } + } + `), + variables: { text, assignmentId } + }); + + refetch(); + } + + async function addAnswer() { + await client.mutate({ + mutation: gql(` + mutation AddAnswer($assignmentId: Int!, $text: String!) { + learningNoteCreate(note: { + assignmentId: $assignmentId + type: answer + text: $text + }) { id } + } + `), + variables: { text, assignmentId } + }); + + refetch(); + } + + return + {notes.map(note => )} + +