Enhance transformation exercise formatting and improve choice option generation in VocabLessonView
- Added formatting for transformation exercises to display prompts as "Übersetze 'X' ins Bisaya", improving clarity for users. - Updated the buildChoiceOptions method to exclude the prompt from the choice options, ensuring a more relevant selection for multiple choice questions. - Enhanced console logging to provide better insights into the prompt and answer during choice option creation, aiding in debugging and user feedback.
This commit is contained in:
@@ -541,6 +541,14 @@ export default {
|
||||
if (!qData) return exercise.title;
|
||||
|
||||
if (qData.question) return qData.question;
|
||||
|
||||
// Für Transformation-Übungen: Formatiere als "Übersetze 'X' ins Bisaya"
|
||||
if (qData.type === 'transformation' && qData.text) {
|
||||
const sourceLang = qData.sourceLanguage || 'Deutsch';
|
||||
const targetLang = qData.targetLanguage || 'Bisaya';
|
||||
return `Übersetze "${qData.text}" ins ${targetLang}`;
|
||||
}
|
||||
|
||||
if (qData.text) return qData.text;
|
||||
return exercise.title;
|
||||
},
|
||||
@@ -769,18 +777,31 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
buildChoiceOptions(correctAnswer, allVocabs) {
|
||||
buildChoiceOptions(correctAnswer, allVocabs, excludePrompt = null) {
|
||||
const options = new Set([correctAnswer]);
|
||||
// Normalisiere alle Werte für den Vergleich (trim + lowercase)
|
||||
const normalizedExcludeSet = new Set();
|
||||
normalizedExcludeSet.add(this.normalizeVocab(correctAnswer));
|
||||
// Wichtig: Der Prompt (die Frage) darf nicht in den Optionen erscheinen
|
||||
if (excludePrompt) {
|
||||
normalizedExcludeSet.add(this.normalizeVocab(excludePrompt));
|
||||
}
|
||||
|
||||
// Füge 3 Distraktoren hinzu
|
||||
let attempts = 0;
|
||||
const maxAttempts = 50; // Verhindere Endlosschleife
|
||||
const maxAttempts = 100; // Erhöht, da wir mehr Filter haben
|
||||
|
||||
while (options.size < 4 && allVocabs.length > 1 && attempts < maxAttempts) {
|
||||
attempts++;
|
||||
const randomVocab = allVocabs[Math.floor(Math.random() * allVocabs.length)];
|
||||
const distractor = this.vocabTrainerDirection === 'L2R' ? randomVocab.reference : randomVocab.learning;
|
||||
if (distractor !== correctAnswer) {
|
||||
options.add(distractor);
|
||||
|
||||
// Prüfe: Distraktor darf nicht gleich correctAnswer oder excludePrompt sein (mit Normalisierung)
|
||||
if (distractor && distractor.trim()) {
|
||||
const normalizedDistractor = this.normalizeVocab(distractor);
|
||||
if (!normalizedExcludeSet.has(normalizedDistractor) && !options.has(distractor)) {
|
||||
options.add(distractor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -789,8 +810,9 @@ export default {
|
||||
const genericOptions = ['Option A', 'Option B', 'Option C', 'Option D'];
|
||||
let index = 0;
|
||||
while (options.size < 4 && index < genericOptions.length) {
|
||||
if (!options.has(genericOptions[index])) {
|
||||
options.add(genericOptions[index]);
|
||||
const option = genericOptions[index];
|
||||
if (!excludeSet.has(option)) {
|
||||
options.add(option);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
@@ -836,8 +858,15 @@ export default {
|
||||
// Erstelle Choice-Optionen für Multiple Choice
|
||||
if (this.vocabTrainerMode === 'multiple_choice') {
|
||||
console.log('[VocabLessonView] Erstelle Choice-Optionen...');
|
||||
this.vocabTrainerChoiceOptions = this.buildChoiceOptions(this.currentVocabQuestion.answer, this.vocabTrainerPool);
|
||||
console.log('[VocabLessonView] Choice-Optionen erstellt:', this.vocabTrainerChoiceOptions.length);
|
||||
console.log('[VocabLessonView] Prompt:', this.currentVocabQuestion.prompt);
|
||||
console.log('[VocabLessonView] Answer:', this.currentVocabQuestion.answer);
|
||||
// Wichtig: Der Prompt (die Frage) darf nicht in den Optionen erscheinen
|
||||
this.vocabTrainerChoiceOptions = this.buildChoiceOptions(
|
||||
this.currentVocabQuestion.answer,
|
||||
this.vocabTrainerPool,
|
||||
this.currentVocabQuestion.prompt // Exkludiere den Prompt
|
||||
);
|
||||
console.log('[VocabLessonView] Choice-Optionen erstellt:', this.vocabTrainerChoiceOptions);
|
||||
}
|
||||
|
||||
// Fokussiere Eingabefeld im Typing-Modus
|
||||
|
||||
Reference in New Issue
Block a user