feat(blockly): complete Blockly module — secure sandbox, AI exercise generation, score sync - #288
Draft
baaki-hicham wants to merge 5 commits into
Draft
feat(blockly): complete Blockly module — secure sandbox, AI exercise generation, score sync#288baaki-hicham wants to merge 5 commits into
baaki-hicham wants to merge 5 commits into
Conversation
Backend: - Sandbox Python isole (subprocess + timeout 5s) - Router FastAPI (execute, submit, generate/stream, workspace) - Schemas Pydantic avec validation stricte - Generateur LLM Ollama (qwen2.5:0.5b) Frontend: - Interface Svelte complete (carte exercice + editeur) - Integration Blockly (toolbox dynamique par niveau) - Progression automatique (beginner > intermediate > advanced) - Feedback IA en temps reel (SSE streaming) Tests: - 10 tests unitaires sandbox - 9 tests progression de niveau - 17 tests endpoints API - 10 tests integration flux complets - Total: 46/46 passed US-B01 a US-B07: Toutes implementees
…ss with Piston sandbox, fix streaming and monochrome palette
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR delivers the complete Blockly module for Open TutorAI, combining two contributions:
Problem
The original implementation had several critical issues:
85.0/api/blocklysubprocessinstead of Docker sandboxstream=Falsefor OllamaNoneemerald,teal,purple)bg-gradient-to-r)/api/blocklyinstead ofTUTOR_API_BASE_URL)Solution
Backend
Sandbox (Fix #4)
Each student submission now runs in an isolated Piston Docker container:
Student → FastAPI (8080) → Piston (2000) → Docker container → Result
Score synchronization (Fix Update files from open webui to Open Tutor-ai #1)
Exercises generated by Ollama are now saved in DB (
blockly_exercisestable).On submission, test cases are retrieved from DB using
assignment_id+student_id(ownership check).No test cases can be manipulated from the frontend.
Real streaming (Fix #5)
Ollama now uses
stream=Falsefor exercise generation (reliability) with chunked yielding for SSE.Feedback uses
stream=Truetoken by token.Frontend
Blockly v12 editor (Fix #10)
injectfromblockly/coreafterUpdate()with initialization flag instead oftick()aloneblockly/msg/enbefore inject{ t: (s) => _i18n?.t?.(s) ?? s }Design (Fix #7, #8)
gray-*paletteblue-600)New Files
Backend
learning/blockly/router.pylearning/blockly/service.pylearning/blockly/sandbox.pylearning/blockly/models.pyBlocklyExercise,BlocklySubmission,BlocklyWorkspacemodelslearning/blockly/schemas.pyai/llm/blockly_generator.pydevops/docker/docker-compose.piston.ymlFrontend
ui/src/routes/student/blockly/new/+page.svelteui/src/lib/apis/blockly/index.tsAPI Endpoints
/api/v1/blockly/execute/api/v1/blockly/test/api/v1/blockly/submit/api/v1/blockly/generate/stream/api/v1/blockly/workspace/save/api/v1/blockly/workspace/{id}How to Test Locally
1. Start Piston sandbox
2. Start Ollama
3. Start backend
source .venv/bin/activate uvicorn main:app --reload --port 80804. Run tests
5. Open student page
http://localhost:5173/student/blockly/new
Dependencies
privileged: truesupport (required for Piston containers)qwen2.5:0.5bmodel🚧 Work in progress
Functional features:
Known limitations to fix before review: