The WeBWorK script and the SCORM adapter are the last real uses of jQuery on an HTML page, and Runestone no longer needs it

Aperta
#3,302 5 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Refactoring
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript

Direzione di ricerca

Read js/src/pretext-webwork.js and js/ptx_scorm_events.js, focusing on handleWW, WWshowCorrect, and installWeBWorKAjaxIntercept; compare the documented Runestone event handling at the referenced commit. Replace the page's jQuery request and event hooks with the described native events, preserve the SCORM check-only behavior, then rebuild js/dist/pretext-webwork.js and js/dist/ptx_scorm_events.js. Done means PreTeXt's page scripts no longer rely on page jQuery while iframe jQuery calls still work.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

What happens

Two scripts depend on the jQuery that every HTML page loads at xsl/pretext-html.xsl, line 14892, where the comment says it is "Required by the WeBWorK integration scripts and by Runestone". Line numbers at ac611425.

js/src/pretext-webwork.js:

  • line 153, in handleWW, sends the problem form with $.post(url, ..., "json") (the call closes at line 489);
  • line 337, also in handleWW, fires $("body").trigger('runestone_ww_check', data) after a check, and line 497, in WWshowCorrect, fires $("body").trigger("runestone_show_correct", {...}).

Lines 471-472 and 560 call iframe.contentWindow.jQuery, the copy the WeBWorK server loads inside the problem iframe, and are not affected.

js/ptx_scorm_events.js, in installWeBWorKAjaxIntercept (lines 1724-1816, SCORM packages only), registers jQuery's global ajaxSend and ajaxComplete handlers to catch the check submissions made by that $.post, and retries at load when window.jQuery is not yet defined. The comment at line 1715 says jQuery "is loaded by the Runestone bundle asynchronously", which is no longer the case.

Runestone no longer needs the page's jQuery. In RunestoneInteractive/rs at 31fbb2b7 (2026-11-03), bases/rsptx/interactives/runestone/webwork/js/webwork.js lines 213-247 take the payload from either a jQuery event's extra argument or a native event's detail, and register with addEventListener when window.jQuery is absent; no component source there imports jQuery, and the webpack configuration lists it only as an external a page may provide. SageCell bundles its own copy.

Once this and #3301 are done, nothing of PreTeXt's own references the page's jQuery.

Suggested change

  • $.post becomes fetch with method: "POST", the same URL-encoded body, and response.json(); the callback body is unchanged.
  • The two trigger calls become document.body.dispatchEvent(new CustomEvent("runestone_ww_check", { detail: data })), and likewise for runestone_show_correct. Runestone's handler reads detail when no extra argument arrives.
  • The SCORM intercept listens for a native event instead of jQuery's AJAX events: pretext-webwork.js dispatches one event, say pretext_ww_response, carrying the action and the parsed response in detail after every successful fetch, and installWeBWorKAjaxIntercept becomes a plain addEventListener for it, keeping its check-only filter. The load retry and the stale comment go.
  • Rebuild js/dist (pretext-webwork.js and ptx_scorm_events.js).

Environment: commit ac611425 (2026-11-03); Runestone at 31fbb2b7 (2026-11-03).

Claude Fable 5.1, acting as a coding assistant for Rob Beezer

Lingua principale
XSLT
Stelle
466
Fork
251
Merge medio
4m
PR unite (30g)
13

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di PreTeXtBook/pretext

Tutte le issue di PreTeXtBook/pretext

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.