Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ declare global {
taskSettings?: any,
initBlocklySubTask?: () => void,
instructionsPostProcessing?: (() => void)[],
MathJax: any,
}
}

Expand Down
12 changes: 11 additions & 1 deletion frontend/submission/task_platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function getTaskDataFromTaskSettings(taskSettings: any) {
return taskData;
}

export function getServerTaskFromTaskData(taskData: any, task: TaskServer = null) {
export function getServerTaskFromTaskData(taskData: any, task: TaskServer = null): Task {
if (taskData.data) {
taskData.gridInfos.allowClientExecution = true;
}
Expand All @@ -136,6 +136,16 @@ export function getServerTaskFromTaskData(taskData: any, task: TaskServer = null
if (window.PEMTaskMetaData.supportedLanguages) {
taskData.supportedLanguages = window.PEMTaskMetaData.supportedLanguages.join(',');
}
if (window.PEMTaskMetaData.useLatex) {
taskData.useLatex = !!window.PEMTaskMetaData.useLatex;
}
}

if (task.useLatex) {
taskData.gridInfos.importModules = [
...(taskData.gridInfos.importModules ?? []),
'mathjax',
];
}

return {
Expand Down
4 changes: 4 additions & 0 deletions frontend/task/instructions/instructions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@
.task-instructions-video.is-not-shown {
cursor: pointer;
}

.mjx-chtml {
font-size: 100% !important;
}
21 changes: 21 additions & 0 deletions frontend/task/libs/import_modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,27 @@ export function loadFonts(theme: string, task: Task|null) {
}
}

let mathJaxConfigured = false;
export function loadMathJax() {
if (mathJaxConfigured) {
return;
}

window.MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]},
messageStyle: "none",
});
window.MathJax.Hub.processSectionDelay = 0;

window.instructionsPostProcessing = [
...(window.instructionsPostProcessing ?? []),
() => {
window.MathJax.Hub.Queue(['Typeset', window.MathJax.Hub]);
},
];
mathJaxConfigured = true;
}

export function getJsLibLoaded() {
return jsLibLoaded;
}
Expand Down
6 changes: 4 additions & 2 deletions frontend/task/libs/quickalgo_library_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {appSelect} from '../../hooks';
import {quickAlgoLibraries} from './quick_algo_libraries_model';
import log from 'loglevel';
import {extractLevelSpecific, extractVariantSpecific} from '../utils';
import {call, put, select} from 'typed-redux-saga';
import {importModules, importPlatformModules, loadFonts} from './import_modules';
import {call, put} from 'typed-redux-saga';
import {importModules, importPlatformModules, loadFonts, loadMathJax} from './import_modules';
import {SmartContractLib} from './smart_contract/smart_contract_lib';
import {DefaultQuickalgoLibrary} from './default_quickalgo_library';
import {PrinterLib} from './printer/printer_lib';
Expand Down Expand Up @@ -81,6 +81,8 @@ export function* createQuickalgoLibrary(platformAlreadyChanged: boolean = false)
yield* call(importModules, levelGridInfos.importModules, window.modulesPath);
}
}

yield* call(loadMathJax);
yield* call(loadFonts, state.options.theme, currentTask);

// Reset fully local strings when creating a new context to avoid keeping strings from an other language
Expand Down
1 change: 1 addition & 0 deletions frontend/task/task_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export interface TaskNormalized {
author: string,
showLimits: boolean,
userTests: boolean,
useLatex: boolean,
isEvaluable: boolean,
scriptAnimation: string,
hasSubtasks: boolean,
Expand Down