Skip to content

feat(teacher-tools): implement AI generation for lesson planning, revisions, and summarization - #279

Open
ZakariaElamrani wants to merge 1 commit into
Open-TutorAi:mainfrom
ZakariaElamrani:feat/teacher-pedagogical-tools
Open

feat(teacher-tools): implement AI generation for lesson planning, revisions, and summarization#279
ZakariaElamrani wants to merge 1 commit into
Open-TutorAi:mainfrom
ZakariaElamrani:feat/teacher-pedagogical-tools

Conversation

@ZakariaElamrani

Copy link
Copy Markdown

Description

  • This PR introduces three new core AI-generative tools for the teacher workspace: Lesson Planning (Scénarios pédagogiques), Revision Sheets (Fiches de révision), and Document Summarization (Résumés de documents). It includes both the Svelte dynamic interfaces and the FastAPI backend logic required to orchestrate LLMs and save the generated ContentResources.

Added

  • Add Svelte interfaces for pedagogical planning (curriculum), revision sheets (revisions), and document transcripts (transcripts).
  • Add FastAPI backend routes (teacher_content) to proxy LLM requests and orchestrate content generation.
  • Add ContentResource database models and repositories to persistently save generated pedagogical assets.

Changed

  • Implement dynamic full-width UI layouts that automatically expand once AI generation is completed to give more reading space.
  • Implement inline Markdown editing functionality (textarea toggle) allowing teachers to manually modify the generated AI content.

Deprecated

  • None

Removed

  • None

Fixed

  • Fix internal 500 server errors (and subsequent CORS issues) by removing the hardcoded subject field dependency when saving revision sheets.

Security

  • None

Breaking Changes

  • None

Additional Information

  • This PR focuses strictly on the 3 core generative features and their immediate backend persistence layers.

Screenshots

1. Curriculum Planning
Capture d’écran du 2026-07-02 10-47-17

Capture d’écran du 2026-07-02 10-46-14 Capture d’écran du 2026-07-02 10-46-25 Capture d’écran du 2026-07-02 10-46-40

2. Revision Sheets
Capture d’écran du 2026-07-02 10-47-54

Capture d’écran du 2026-07-02 10-57-10

3. Document Summarization

Capture d’écran du 2026-07-02 10-53-59 Capture d’écran du 2026-07-02 10-54-05 Capture d’écran du 2026-07-02 10-55-45 Capture d’écran du 2026-07-02 10-55-52

- Add Svelte interfaces for pedagogical planning, revision sheets, and document transcripts
- Implement inline Markdown editing with dynamic full-width layouts
- Add FastAPI backend to orchestrate LLMs and save ContentResources
@Oumaima-elkhoummassi

Oumaima-elkhoummassi commented Jul 3, 2026

Copy link
Copy Markdown

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

Your PR description follows the right format (Added/Changed/Fixed sections)— that part is good. But the project rule requires that documentation is submitted with your code in the same Pull Request.

For three features with a visible UI (curriculum planning, revision sheets, document summarization), this means at minimum:

  • A technical doc: API endpoints for teacher_content routes, ContentResource data model, how the LLM orchestration works
  • A user guide: step-by-step instructions for a teacher (how to generate a lesson plan, how to edit AI content inline, how to save a revision sheet)

Could you add these in docs/ before this is ready for review?
Also, a PR checklist (target branch, testing done, code review) is missing
— could you add that too?

@ayman-sabir

Copy link
Copy Markdown

📋 Backend Review — Request Changes 🔴

Thanks for this — the three teacher tools are a nice idea, and the LLM wiring is actually done the right way (model resolution through ProvidersService.resolve_provider() + build_llm_body() + proxy_json(), with a default-model fallback). That part should survive the rework. But there are several blockers that stop it from merging:

🔴 Must fix (breaks build/runtime):

  1. The app won't start. teacher_content.py:8 imports from ai.retrieval.vector_store import VectorStore, but that module doesn't exist (ai/retrieval/ has only service.py + knowledge/). Since app.py:168 includes this router, the import raises ModuleNotFoundError at startup and the whole test suite errors at collection. Add the real module or drop the vector/RAG code from this PR.
  2. CI lint fails — 73 trailing-whitespace lines (49 in the router). Run black . --exclude ".venv/|/venv/|ui/".
  3. No tests for ~760 lines of new backend.

🔴 Security:
4. Path traversal on uploados.path.join(teacher_dir, file.filename) (:85) uses the raw client filename, so ../../… escapes the upload dir and open(..., "wb") can overwrite arbitrary files. Store under a server-generated UUID name (like the assignments/files domains) and enforce MAX_UPLOAD_SIZE_MB.
5. No authorization — no role gate and no ownership checks anywhere. Any authenticated user (incl. students) can call these teacher tools, and GET /classroom/{id}/rag returns any classroom's documents to any caller. Add _require_teacher and per-classroom/resource ownership checks.

🟠 Architecture / data:
6. No service layer — the 617-line router holds all prompt-building, LLM calls, ORM, commits, and file I/O, with the model-resolution block copy-pasted across four endpoints. Please move this into learning/<domain>/service.py, and relocate the repository into the domain package extending BaseRepository.
7. Data layer: models use Integer PKs (convention is String(36) UUID) and teacher_id/created_by are Integer FKs to users.id, which is String(36) — a type mismatch that only limps on SQLite. Add to_dict() and module docstrings too.

🟡 Also: French → English throughout, replace print() (:550-551) with logging, remove the duplicate import BaseModel (:222), and ResourceResponse.created_at is typed str over a datetime value.

@pr-elhajji

Copy link
Copy Markdown
Contributor

Hi, thk for contuning dev.
just the design style is note aligned with opentutorai style (and also is hardcoded)

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 adds a new “teacher content” feature slice that lets teachers generate and edit AI-produced pedagogical assets (annual curriculum planning, revision sheets, and document transcript summaries) from the Svelte teacher workspace, backed by new FastAPI endpoints and persistence models (ContentResource / QuestionItem).

Changes:

  • Added three new teacher UI pages for curriculum planning, revision sheet generation, and transcript/document summarization (with inline Markdown preview/edit flows).
  • Added a new frontend API client module ($lib/apis/teacher-content) and a new backend router (/api/v1/teacher/content/*) to orchestrate LLM calls and save generated content.
  • Added new SQLAlchemy models and a repository for storing teacher-generated content resources and question items.

Reviewed changes

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

Show a summary per file
File Description
ui/src/routes/teacher/content/transcripts/+page.svelte New UI flow to extract document text and generate an AI summary with preview/edit/copy.
ui/src/routes/teacher/content/revisions/+page.svelte New UI flow to generate revision sheets from teacher-provided “frequent errors”.
ui/src/routes/teacher/content/curriculum/+page.svelte New UI flow to upload a syllabus and generate a week-by-week curriculum timeline plus scenario generation modal.
ui/src/lib/apis/teacher-content/index.ts New TS API client for teacher content endpoints (generation + question bank + extraction).
gateway/http/routers/teacher_content.py New FastAPI router implementing upload/indexing, LLM generation, extraction, and question bank endpoints.
gateway/http/app.py Registers the new teacher_content router with the application.
data/repositories/content_resource_repository.py New repository for CRUD operations over ContentResource and QuestionItem.
data/models/content_resources.py New ORM models for persisted teacher content resources and question items.
data/models/init.py Registers the new ORM models for metadata/table creation.

Comment on lines +85 to +87
file_path = os.path.join(teacher_dir, file.filename)
with open(file_path, "wb") as buffer:
shutil.copyfileobj(file.file, buffer)
Comment on lines +430 to +434
repo = ContentResourceRepository(db)
resources = repo.get_by_classroom(classroom_id)

# Filtrer uniquement les RAG documents
rag_docs = [r for r in resources if r.resource_type == ResourceType.RAG_DOCUMENT]
Comment on lines +199 to +201

results = [repo.db.query(QuestionItem).filter(QuestionItem.id == qid).first() for qid in question_ids]
results = [r for r in results if r is not None]
tags=q.tags,
created_by=user.id
)
question = repo.add_question(question)
}
vector_store.index_question(question.id, q.question_text, metadata)

return content
Comment on lines +56 to +60
const response = await generateRevisionSheet(token, {
classroom_id: 1, // Mock
frequent_errors: frequentErrors,
model_id: selectedModel
});
Comment on lines +93 to +97
const response = await generateTranscriptSummary(token, {
classroom_id: 1, // Mock classroom ID for now
transcription: transcriptionText,
model_id: selectedModel
});
>
<input
type="file"
accept=".pdf,.txt,.docx"
<p class="text-sm font-medium text-gray-900 dark:text-white">
{$i18n.t('Cliquez ou glissez-déposez le document')}
</p>
<p class="text-xs text-gray-500 mt-1">PDF, TXT, DOCX</p>
Comment on lines +138 to +142
export interface RevisionSheetResponse {
resource_id: number;
content: string;
}

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.

5 participants