Skip to content

Refactor question button from template to TypeScript component#95

Draft
Copilot wants to merge 9 commits intomasterfrom
copilot/add-question-feature-in-editor
Draft

Refactor question button from template to TypeScript component#95
Copilot wants to merge 9 commits intomasterfrom
copilot/add-question-feature-in-editor

Conversation

Copy link

Copilot AI commented Feb 12, 2026

The question/help button was implemented as inline HTML and JavaScript in the Jinja2 template, mixing presentation with business logic and violating established component patterns.

Changes

AssignmentInterface (frontend/components/assignment_interface.ts)

  • Added question form observables: questionTitle, questionContent, includeCode
  • Added showQuestionModal() and submitQuestion() methods
  • Makes functionality available to all assignment interface subclasses

BlockPyInterface (frontend/components/blockpy/blockpy_interface.ts)

  • Inlined question button template following existing pattern (same approach as reader.ts)
  • Uses Knockout.js data-bind for event handling

Template cleanup (templates/blockpy/editor.html)

  • Removed 191 lines of inline HTML and JavaScript
  • Template now only contains structural markup

Before/After

Before:

<!-- In template -->
<button onclick="showQuestionModal()">Ask Question</button>
<script>
function showQuestionModal() { ... }
function submitQuestion() { 
    const title = $('#question-title').val();
    // 70+ lines of jQuery...
}
</script>

After:

// In AssignmentInterface
questionTitle: ko.Observable<string>;

showQuestionModal() {
    $('#question-modal').modal('show');
}

submitQuestion() {
    const title = this.questionTitle();
    // Type-safe, testable code
}

// In BlockPyInterface  
const TEMPLATE = `<button data-bind="click: showQuestionModal">...</button>`;
ko.components.register("blockpy", { viewModel: BlockPyInterface, template: TEMPLATE });

This aligns with the component architecture used throughout the codebase and enables proper separation of concerns, type safety, and reusability.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 7 commits February 12, 2026 15:45
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
…, remove unused import

Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Copilot AI changed the title [WIP] Add question feature in BlockPy Server editor Add Q&A system for student questions in editor interface Feb 12, 2026
Copilot AI requested a review from acbart February 12, 2026 15:56
Co-authored-by: acbart <897227+acbart@users.noreply.github.com>
Copilot AI changed the title Add Q&A system for student questions in editor interface Refactor question button from template to TypeScript component Feb 12, 2026
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.

2 participants