Skip to content

Commit 174622b

Browse files
fix(tutor): graphic and text issues (#66)
* fix(tutor): graphic and text issues * wip * wip * adds space at the end
1 parent e0ea4ec commit 174622b

File tree

10 files changed

+218
-77
lines changed

10 files changed

+218
-77
lines changed

src/components/dropdowns/BaseDropdown.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ defineProps<{
141141
}
142142
143143
.dropdown-content {
144-
height: 25rem;
144+
height: auto;
145145
overflow-y: auto;
146146
}
147147
.dropdown-trigger {
Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import { ref, computed } from 'vue';
33
import ChevronDown from '@/components/icons/ChevronDown.vue';
4+
import BaseDropdown from '@/components/dropdowns/BaseDropdown.vue';
45
56
// TODO: add info that default values will be used if not written down
67
// TODO: make files required:w
@@ -18,6 +19,8 @@ interface Props {
1819
action: () => void;
1920
actionText?: string;
2021
addedFilesTitles: string[];
22+
storedLanguage: string;
23+
selectLang: (string) => void;
2124
}
2225
2326
const props = defineProps<Props>();
@@ -90,7 +93,7 @@ const appendNewInputFile = () => {
9093
</script>
9194

9295
<template>
93-
<div id="target-1" class="wrapper" :class="{ disabled }">
96+
<div id="target-1" class="wrapper">
9497
<h1 class="title is-4">1 - {{ $t('tutor.firstStep.title') }}</h1>
9598
<p class="subtitle is-6">{{ $t('tutor.firstStep.description') }}</p>
9699

@@ -138,7 +141,7 @@ const appendNewInputFile = () => {
138141
</h2>
139142
<p class="subtitle is-6">{{ $t('tutor.firstStep.cursusDescriptionDescription') }}</p>
140143

141-
<div class="is-flex is-flex-wrap-wrap descriptions">
144+
<div class="is-flex is-flex-wrap-wrap is-justify-content-space-between descriptions">
142145
<div class="description">
143146
<label for="cursus-title">{{ $t('tutor.firstStep.cursusTitleLabel') }}</label>
144147
<input
@@ -174,6 +177,32 @@ const appendNewInputFile = () => {
174177
:placeholder="$t('tutor.firstStep.cursusDurationPlaceholder')"
175178
/>
176179
</div>
180+
<div class="description">
181+
<label for="cursus-lang">{{ $t('tutor.firstStep.syllabusLanguage') }}</label>
182+
<BaseDropdown v-slot="slotProps" :isUp="isUp" :title="storedLanguage">
183+
<ClickableText
184+
class="dropdown-item"
185+
:text="$t('removeSelection')"
186+
:action="
187+
() => {
188+
slotProps.toggleVisibility();
189+
}
190+
"
191+
/>
192+
<a
193+
:key="lang"
194+
@click="
195+
selectLang(lang);
196+
slotProps.toggleVisibility();
197+
"
198+
v-for="lang in ['fr', 'en']"
199+
class="dropdown-item"
200+
:class="storedLanguage === lang && 'is-active'"
201+
>
202+
{{ $t(`${lang}`) }}
203+
</a>
204+
</BaseDropdown>
205+
</div>
177206
</div>
178207

179208
<label for="cursus-description" class="mt-4">
@@ -183,7 +212,6 @@ const appendNewInputFile = () => {
183212
id="cursus-description"
184213
class="textarea mt-1"
185214
:placeholder="$t('tutor.firstStep.cursusDescriptionPlaceholder')"
186-
rows="5"
187215
:value="description"
188216
@input="emit('update:description', ($event.target as HTMLTextAreaElement).value)"
189217
/>
@@ -203,16 +231,16 @@ const appendNewInputFile = () => {
203231
}
204232
.wrapper {
205233
padding: 5% 0;
206-
height: 80%;
207-
width: 80%;
234+
width: 100%;
208235
display: flex;
209236
flex-direction: column;
210237
transition: all 1s;
211238
margin: 0 auto;
212239
}
213240
214241
.description {
215-
width: 32%;
242+
max-height: 2.5rem;
243+
width: 24%;
216244
}
217245
218246
.wrapper.disabled {
@@ -222,5 +250,6 @@ const appendNewInputFile = () => {
222250
223251
.descriptions {
224252
gap: 0.5rem;
253+
margin-bottom: 1rem;
225254
}
226255
</style>

src/components/tutor/SecondStep.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ defineProps<{
8484
.wrapper {
8585
display: flex;
8686
flex-direction: column;
87-
width: 80%;
87+
width: 100%;
8888
8989
flex-grow: 0;
9090
flex-basis: 0;
91-
height: 90%;
91+
height: 100%;
9292
transition: all 0.5s;
9393
margin: auto;
9494
overflow: hidden;

src/components/tutor/SummariesStep.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ref } from 'vue';
1010
const props = defineProps<{
1111
summaries: [string];
1212
files: File;
13-
updateSummary: () => void;
13+
updateSummary: (index: number, content: string) => void;
1414
action: () => void;
1515
actionText?: string;
1616
disabled: boolean;
@@ -114,9 +114,8 @@ const handleTextEdit = (event, index) => {
114114
}
115115
.summaries-section {
116116
margin: auto;
117-
height: 80%;
118117
padding: 5% 0;
119-
width: 80%;
118+
width: 100%;
120119
}
121120
.summaries-section.disabled {
122121
height: 10%;

src/components/tutor/ThirdStep.vue

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,29 @@ const handleTextEdit = (event, index) => {
4343
</span>
4444
{{ isEditable ? $t('save') : $t('edit') }}
4545
</button>
46-
47-
<p
48-
:contenteditable="isEditable"
49-
:class="{ editable: isEditable }"
50-
id="syllabus"
51-
class="syllabus content"
52-
v-if="syllabus?.content"
53-
v-html="marked.parse(syllabus?.content)"
54-
@blur="handleTextEdit($event, index)"
55-
@click="isEditable = true"
56-
/>
46+
<div class="editable-syllabus-wrapper">
47+
<p
48+
:contenteditable="isEditable"
49+
:class="{ editable: isEditable }"
50+
id="syllabus"
51+
class="syllabus content"
52+
v-if="syllabus?.content"
53+
v-html="marked.parse(syllabus?.content)"
54+
@blur="handleTextEdit($event, index)"
55+
@click="isEditable = true"
56+
/>
57+
</div>
5758
</div>
5859

5960
<textarea class="textarea" v-if="enableFeedback" v-model="feedback"></textarea>
6061

61-
<div class="is-flex is-justify-content-end mt-4">
62+
<div class="is-flex is-justify-content-end mt-4 pb-6">
6263
<button class="button" @click="toggleFeedback">
6364
{{
6465
enableFeedback ? $t('tutor.thirdStep.sendFeedback') : $t('tutor.thirdStep.giveFeedback')
6566
}}
6667
</button>
67-
<button class="button is-primary ml-2" @click="action()">download</button>
68+
<button class="button is-primary ml-2" @click="action()">{{ $t('download') }}</button>
6869
</div>
6970
</div>
7071
</template>
@@ -75,15 +76,14 @@ const handleTextEdit = (event, index) => {
7576
padding-right: 1rem;
7677
}
7778
.wrapper {
78-
overflow: scroll;
7979
display: flex;
8080
height: 100%;
8181
flex-direction: column;
8282
flex-grow: 0;
8383
flex-basis: 0;
8484
transition: flex-grow 0.3s;
8585
padding: 5% 0;
86-
width: 80%;
86+
width: 100%;
8787
margin: auto;
8888
}
8989
@@ -106,6 +106,12 @@ details:not([open]) {
106106
background-color: var(--neutral-10);
107107
cursor: text;
108108
}
109+
110+
.editable-syllabus-wrapper {
111+
height: 70vh;
112+
overflow-y: scroll;
113+
margin-bottom: 8px;
114+
}
109115
.editable {
110116
border: 2px solid var(--primary);
111117
background-color: var(--neutral-0);

src/localisation/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ export const en = {
319319
},
320320
textLengthFeedback: 'Please add more text to improve search results.',
321321
tutor: {
322+
syllabusSteps: 'Syllabus steps:',
322323
BIG_FILE: 'File size exceeds 5 MB.',
323324
BAD_EXTENSION: 'File type not supported. Only PDF, TXT, and DOCX files are allowed.',
324325
retry: {
@@ -347,6 +348,7 @@ export const en = {
347348
'WeLearn has extracted the following summaries from your uploaded documents. You can review them before proceeding to the next step.'
348349
},
349350
firstStep: {
351+
syllabusLanguage: 'Syllabus language',
350352
acceptedFiles: 'Accepted file types: PDF, TXT, DOCX',
351353
searchError: 'No results were found for the provided document.',
352354
title: 'Add documents',

src/localisation/fr.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ export const fr = {
324324
},
325325
textLengthFeedback: 'Veuillez ajouter davantage de texte pour lancer la recherche.',
326326
tutor: {
327+
syllabusSteps: 'Étapes du syllabus :',
327328
BIG_FILE: 'La taille du fichier dépasse 5 Mo.',
328329
BAD_EXTENSION:
329330
'Type de fichier non pris en charge. Seuls les fichiers PDF, TXT et DOCX sont acceptés.',
@@ -354,6 +355,7 @@ export const fr = {
354355
'WeLearn a extrait les points clés de vos documents importés pour générer le syllabus.'
355356
},
356357
firstStep: {
358+
syllabusLanguage: 'Langue du syllabus',
357359
acceptedFiles: 'Types de fichiers acceptés : PDF, TXT, DOCX',
358360
searchError: 'Aucun résultat trouvé pour le document fourni.',
359361
title: 'Ajoutez des documents',

src/stores/tutor.ts

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,21 @@ export const useTutorStore = defineStore('tutor', () => {
8383
};
8484
};
8585

86-
// const summaries = ref<[string]>([
87-
// "Global warming, a subset of climate change, refers to the long-term rise in the average temperature of the Earth's climate system, primarily caused by human activities such as fossil fuel burning, deforestation, and certain agricultural and industrial practices that release greenhouse gases. These gases trap heat in the lower atmosphere, leading to various environmental impacts like desert expansion, increased frequency of heat waves and wildfires, accelerated Arctic warming, glacier retreat, and sea ice decline. Climate change also affects biodiversity, forcing species to relocate or face extinction, and poses significant threats to human societies, including increased flooding, extreme heat, food and water scarcity, disease, economic loss, and potential human migration and conflict. Even with efforts to minimize future warming, some effects will persist for centuries, including ocean heating, acidification, and sea-level rise. The Paris Agreement aims to limit global warming to well below 2°C, but current pledges still project a rise of about 2.8°C by the end of the century. There is widespread support for climate action, with most countries aiming to stop emitting carbon dioxide. Strategies include phasing out fossil fuels, conserving energy, switching to clean energy sources, and removing carbon from the atmosphere through methods like reforestation and carbon-storing farming practices.",
88-
// "The article discusses the XL-Sum dataset, a large-scale multilingual abstractive summarization dataset containing 1 million professionally annotated article-summary pairs from BBC, covering 44 languages. The dataset is designed to address the lack of high-quality datasets for low-resource languages in abstractive summarization. XL-Sum introduces the first publicly available summarization dataset for many languages and achieves competitive results in both multilingual and low-resource summarization tasks. The dataset is created using a custom crawler and a set of heuristics to extract high-quality summaries from BBC articles. Evaluations show that the summaries are highly abstractive, concise, and of high quality, with minimal redundancy. The mT5 model fine-tuned on XL-Sum achieves state-of-the-art results, demonstrating the dataset's effectiveness in abstractive summarization across multiple languages."
89-
// ]);
90-
9186
const summaries = ref<[string]>([]);
9287

93-
const updateSummary = (index, content) => {
88+
const updateSummary = (index: number, content: string) => {
9489
summaries.value[index] = content;
9590
};
9691

9792
const updateSyllabus = (index, content) => {
9893
syllabi.value[index] = content;
9994
};
10095

96+
const syllabusLanguage: Ref<string> = ref(i18n.global.locale.value);
97+
const selectSyllabusLanguage = (lang: string) => {
98+
syllabusLanguage.value = lang;
99+
};
100+
101101
const getFilesContent = async (arg: File[]) => {
102102
isLoading.value = true;
103103
shouldRetryAction.value = false;
@@ -108,17 +108,24 @@ export const useTutorStore = defineStore('tutor', () => {
108108
}
109109
});
110110
try {
111-
const resp = await postAxios('/tutor/files/content', formData, {
112-
headers: { 'content-type': 'multipart/form-data' }
113-
});
111+
const resp = await postAxios(
112+
`/tutor/files/content?lang=${syllabusLanguage.value}`,
113+
formData,
114+
{
115+
headers: { 'content-type': 'multipart/form-data' }
116+
}
117+
);
114118
if (resp.status === 204) {
115119
shouldRetryAction.value = true;
116120
throw new Error('retry getFilesContent');
117121
} else {
118-
const red_summaries = resp.data.extracts.reduce((acc, curr) => {
119-
acc = [...acc, curr.summary];
120-
return acc;
121-
}, []);
122+
const red_summaries = resp.data.extracts.reduce(
123+
(acc: string[], curr: { summary: string }) => {
124+
acc = [...acc, curr.summary];
125+
return acc;
126+
},
127+
[]
128+
);
122129
summaries.value = red_summaries;
123130
goNext();
124131
isLoading.value = false;
@@ -224,7 +231,7 @@ export const useTutorStore = defineStore('tutor', () => {
224231
isLoading.value = true;
225232
try {
226233
console.log(selectedSources.value.length);
227-
const resp = await postAxios(`/tutor/syllabus?lang=${i18n.global.locale.value}`, {
234+
const resp = await postAxios(`/tutor/syllabus?lang=${syllabusLanguage.value}`, {
228235
...tutorSearch.value,
229236
documents: selectedSources.value,
230237
...(courseTitle.value && { course_title: courseTitle.value }),
@@ -301,6 +308,8 @@ export const useTutorStore = defineStore('tutor', () => {
301308
};
302309

303310
return {
311+
syllabusLanguage,
312+
selectSyllabusLanguage,
304313
step,
305314
goBack,
306315
goNext,

src/views/TutorPage.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
<script setup lang="ts">
22
import { computed } from 'vue';
3-
import CursusInfo from '@/components/tutor/FirstStep.vue';
3+
import CursusInfo from '@/components/tutor/CursusInfo.vue';
44
import SummariesStep from '@/components/tutor/SummariesStep.vue';
55
import SourcesList from '@/components/tutor/SecondStep.vue';
66
import EditableSyllabus from '@/components/tutor/ThirdStep.vue';
77
import StepsIndicator from '@/components/tutor/StepsIndicator.vue';
88
import ModalWrapper from '@/components/ModalWrapper.vue';
99
import ErrorComponent from '@/components/ErrorComponent.vue';
1010
import ErrorDocumentIcon from '@/components/icons/ErrorDocumentIcon.vue';
11-
// import CheckIcon from '@/components/icons/CheckIcon.vue';
1211
import { useTutorStore } from '@/stores/tutor';
1312
1413
const store = useTutorStore();
@@ -26,7 +25,7 @@ const getI18nText = computed(() => {
2625
};
2726
});
2827
29-
const stepToAction: Record<0 | 1 | 2 | 3, () => Promise<void>> = {
28+
const stepToAction: Record<0 | 1 | 2 | 3 | 4, () => Promise<void>> = {
3029
1: store.handleSummaryFiles,
3130
2: store.retrieveTutorSearch,
3231
3: store.handleCreateSyllabus,
@@ -36,7 +35,9 @@ const stepToAction: Record<0 | 1 | 2 | 3, () => Promise<void>> = {
3635
<template>
3736
<div class="content-centered-wrapper">
3837
<div class="is-flex is-justify-content-center is-align-items-center">
39-
<p class="subtitle has-text-weight-bold is-5 mr-4 my-auto">Syllabus steps:</p>
38+
<p class="subtitle has-text-weight-bold is-5 mr-4 my-auto">
39+
{{ $t('tutor.syllabusSteps') }}
40+
</p>
4041

4142
<StepsIndicator
4243
:step="store.step"
@@ -47,7 +48,7 @@ const stepToAction: Record<0 | 1 | 2 | 3, () => Promise<void>> = {
4748
</div>
4849
<ErrorComponent v-if="store.reloadError" />
4950

50-
<ModalWrapper v-if="store.isLoading" :isOpen="store.isLoading" :onClose="() => {}">
51+
<ModalWrapper v-if="store.isLoading" :isOpen="store.isLoading" :onClose="store.stopAction">
5152
<div v-if="store.shouldRetryAction" class="box">
5253
<div
5354
class="is-flex is-flex-direction-column is-align-items-center is-justify-content-center"
@@ -87,6 +88,8 @@ const stepToAction: Record<0 | 1 | 2 | 3, () => Promise<void>> = {
8788
</ModalWrapper>
8889
<div class="layout-flex">
8990
<CursusInfo
91+
:selectLang="store.selectSyllabusLanguage"
92+
:storedLanguage="store.syllabusLanguage"
9093
:searchError="store.hasSearchError"
9194
:fileError="store.fileError"
9295
v-model:courseTitle="store.courseTitle"

0 commit comments

Comments
 (0)