Skip to content

feat: interactive quiz and pedagogical shortcuts (Je n'ai pas compris button) - #283

Open
IlhamELBOUAZOULI wants to merge 2 commits into
Open-TutorAi:mainfrom
IlhamELBOUAZOULI:feature/interactive-quiz-and-pedagogical-shortcuts
Open

feat: interactive quiz and pedagogical shortcuts (Je n'ai pas compris button)#283
IlhamELBOUAZOULI wants to merge 2 commits into
Open-TutorAi:mainfrom
IlhamELBOUAZOULI:feature/interactive-quiz-and-pedagogical-shortcuts

Conversation

@IlhamELBOUAZOULI

@IlhamELBOUAZOULI IlhamELBOUAZOULI commented Jul 3, 2026

Copy link
Copy Markdown

Adds an interactive MCQ quiz modal and a "I didn't understand" pedagogical
shortcut button to the student chat interface, improving the learning experience
with immediate feedback and adaptive re-explanation.

Added

  • InteractiveQuiz.svelte: new interactive quiz modal component with:
    • Click-to-answer MCQ interface
    • Immediate correct/incorrect feedback (✅/❌) after each answer
    • Explanation displayed after each question
    • Concept re-explanation when the student answers incorrectly
    • Final results screen with score and question recap
    • "Retry" option to redo the quiz
  • "I didn't understand" button in PedagogicalShortcuts.svelte: re-explains
    the current concept in 3 different ways:
    • A simple analogy from everyday life
    • A concrete step-by-step example
    • A visual text table or diagram

Changed

  • PedagogicalShortcuts.svelte: "Multiple Choice" button now opens the
    interactive quiz modal instead of sending a plain text prompt to the chat
  • MessageInput.svelte: integrated InteractiveQuiz component
  • ui/src/lib/components/student/tutor/Chat.svelte: updated to support
    new pedagogical shortcuts
  • ui/src/lib/components/student/pages/Chat.svelte: updated chat page
  • ai/providers/proxy.py: increased TIMEOUT_DEFAULT from 30s to 120s
    to support LLM generation time

Fixed

  • Proxy timeout too short (30s) causing 502 errors during LLM quiz generation

Screenshots

Quiz - Multiple Choice Question
An interactive quiz modal displays an MCQ with 4 clickable options (A, B, C, D)
22

Quiz - Réponse correcte avec feedback
When the student selects the correct answer, it turns green ✅ with immediate explanation
image

Quiz - Incorrect Answer with Re-explanation
In case of a wrong answer, it turns red ❌, the correct answer is highlighted, and a re-explanation is displayed
image

Quiz - Final Results Screen
Once the quiz is completed, the student views their final score, percentage, and detailed summary
image

"I didn't understand" Button
Re-explains the concept using an analogy, a concrete example, and a visual table
image
image

- Add InteractiveQuiz.svelte: interactive MCQ modal with click-to-answer,
  correct/incorrect feedback with explanation, retry and final score screen
- Update PedagogicalShortcuts.svelte: Multiple Choice opens interactive quiz
- Add 'Je n ai pas compris' button: re-explains with analogy, example, table
- Fix proxy timeout: TIMEOUT_DEFAULT 30s to 120s in ai/providers/proxy.py
@pr-elhajji

Copy link
Copy Markdown
Contributor

thk you for your contribution.
please respect opentutorai style.

@pr-elhajji

Copy link
Copy Markdown
Contributor

Hi, thk for contuning dev.
just the design style is note aligned with opentutorai style

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the student chat experience by adding an interactive quiz flow and a new “I didn’t understand” pedagogical shortcut, while also increasing backend proxy timeouts to better accommodate longer LLM generations.

Changes:

  • Adds an interactive MCQ quiz modal experience and passes recent chat context into shortcuts for quiz generation.
  • Introduces a new “Je n’ai pas compris” shortcut that triggers multi-angle re-explanations.
  • Increases default proxy timeout to reduce 502s during longer generations.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
ui/src/lib/components/student/tutor/Chat.svelte Adjusts assistant message initialization (placeholder message state).
ui/src/lib/components/student/pages/Chat.svelte Tweaks layout/RightBar behavior and styling; introduces a new (currently unused) local state var.
ui/src/lib/components/chat/Shortcuts/PedagogicalShortcuts.svelte Reworks pedagogical shortcuts UI, adds “Je n’ai pas compris”, and implements an inline quiz modal + generation flow.
ui/src/lib/components/chat/Shortcuts/InteractiveQuiz.svelte Adds a standalone interactive quiz component with streaming JSON parsing.
ui/src/lib/components/chat/Messages/ContentRenderer.svelte Adds quiz JSON detection and attempts to render a QuizWidget instead of Markdown.
ui/src/lib/components/chat/MessageInput.svelte Passes recent conversation context into PedagogicalShortcuts for better quiz generation prompts.
ai/providers/proxy.py Increases TIMEOUT_DEFAULT to 120s to support longer generations.

Comment on lines 6 to 8
import Markdown from './Markdown.svelte';
import QuizWidget from './QuizWidget.svelte';
import { chatId, mobile, showArtifacts, showControls, showOverview } from '$lib/stores';
Comment on lines +669 to +677
<PedagogicalShortcuts on:submit={handleShortcut} conversationContext={
history?.messages
? Object.values(history.messages)
.filter(m => m?.role && m?.content)
.slice(-8)
.map(m => (m.role === 'user' ? 'Etudiant: ' : 'IA: ') + (typeof m.content === 'string' ? m.content : m.content?.[0]?.text || ''))
.join('\n')
: ''
} />
Comment on lines +16 to +17
type Phase = 'idle' | 'loading' | 'quiz' | 'results';
let phase: Phase = 'idle';
Comment on lines +73 to +88
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value, { stream: true });
// Parser les lignes JSON du stream Ollama
for (const line of chunk.split('\n')) {
if (!line.trim()) continue;
try {
const parsed = JSON.parse(line);
if (parsed?.message?.content) {
fullText += parsed.message.content;
}
if (parsed?.done) break;
} catch {}
}
}
Comment on lines 8 to 11
let chatData = {};
let isRightBarVisible = false;
let sidebarOpen = true;

Comment on lines +1 to +18
<!--
InteractiveQuiz.svelte
Emplacement: ui/src/lib/components/chat/Shortcuts/InteractiveQuiz.svelte
-->
<script lang="ts">
import { createEventDispatcher, getContext } from 'svelte';
import { get } from 'svelte/store';
import { models, settings, user } from '$lib/stores';
import { generateChatCompletion } from '$lib/apis/ollama';

const dispatch = createEventDispatcher();
const i18n: any = getContext('i18n');

export let conversationContext: string = '';

type Phase = 'idle' | 'loading' | 'quiz' | 'results';
let phase: Phase = 'idle';
let questions: Question[] = [];
Comment on lines +173 to +175
<button type="button" on:click={didntUnderstand} class="nav-button confused-theme">
🤔 Je n'ai pas compris
</button>
@Oumaima-elkhoummassi

Oumaima-elkhoummassi commented Jul 7, 2026

Copy link
Copy Markdown

Hi @IlhamELBOUAZOULI
Documentation review — no documentation file found in docs/ for this PR.

Per the project rule, documentation must be submitted in docs/ in the same Pull Request as the code .

For this feature (interactive quiz modal + "I didn't understand" shortcut), this means at minimum:

  • A technical doc: how InteractiveQuiz.svelte and the re-explanation logic work, what triggers the 3 different explanation formats (analogy / step-by-step / table), and why proxy.py's TIMEOUT_DEFAULT was raised to 120s
  • A user guide: how a student takes the quiz, what the retry option does, how the "I didn't understand" button works from their point of view

Could you add these before this is ready for review?

@IlhamELBOUAZOULI

Copy link
Copy Markdown
Author

Hi @Oumaima-elkhoummassi,

Thank you for the review!

The documentation has been added in the second commit of this PR (docs: add technical and user documentation + update quiz white theme). Here is what was included in docs/:

  • docs/interactive-quiz-technical.md — Technical documentation covering:

    • Architecture and file structure
    • InteractiveQuiz.svelte component (props, phases, events, LLM streaming logic)
    • PedagogicalShortcuts.svelte modifications (including the "Je n'ai pas compris" button and its 3-format re-explanation prompt)
    • Data flow diagram (student click → Ollama → JSON parsing → quiz UI)
    • Explanation of the TIMEOUT_DEFAULT fix (30s → 120s) in ai/providers/proxy.py
  • docs/interactive-quiz-user-guide.md — User guide covering:

    • Step-by-step guide for taking the interactive quiz
    • Explanation of correct/incorrect feedback behavior
    • How the "Je n'ai pas compris" button works from the student's perspective
    • Score guide, retry option, troubleshooting, and FAQ

You can view the files here:

Please let me know if anything needs to be adjusted or expanded. Ready for re-review!

Best regards,
Ilham

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants