This commit is contained in:
Wiesner András 2025-10-14 17:55:25 +02:00
parent b78339c19f
commit f94fade56c
4 changed files with 27 additions and 3 deletions

View File

@ -430,8 +430,12 @@ class Game extends AutoStoring
// obfuscate image filename // obfuscate image filename
if ($a["image_data"] !== "") { if ($a["image_data"] !== "") {
$a["image_data"] = $this->obfuscateAttachedImage($a["image_data"]); if (in_array("codeimage", $flags)) {
$a["image_type"] = "url"; $a["image_type"] = "code";
} else {
$a["image_data"] = $this->obfuscateAttachedImage($a["image_data"]);
$a["image_type"] = "url";
}
} }
// generate the task // generate the task

View File

@ -10,6 +10,7 @@ class PicturedTask extends Task
function __construct(string $type, array &$a = null) function __construct(string $type, array &$a = null)
{ {
parent::__construct($type, $a); parent::__construct($type, $a);
$this->image_data = $a["image_data"] ?? ($a["image_url"] ?? ""); $this->image_data = $a["image_data"] ?? ($a["image_url"] ?? "");
$this->image_type = $a["image_type"] ?? "none"; $this->image_type = $a["image_type"] ?? "none";
} }

View File

@ -283,11 +283,27 @@ class PicturedTask extends Task {
} }
break; break;
case "html": case "html":
case "code":
{ {
this.img = document.createElement("section"); this.img = document.createElement("section");
this.img.classList.add("question-image"); this.img.classList.add("question-image");
this.img.innerHTML = data;
if (this.img_type === "html") {
this.img.innerHTML = data;
} else if (this.img_type === "code") {
let pre = document.createElement("pre");
let code = document.createElement("code");
pre.append(code);
code.innerHTML = data;
hljs.highlightElement(pre);
this.img.innerHTML = `<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/base16/google-light.min.css"/>`;
this.img.style.textAlign = "left";
this.img.append(pre);
}
} }
break; break;
} }

View File

@ -37,6 +37,9 @@ if ($testid === "") {
<script type="text/javascript" src="https://nturley.github.io/netlistsvg/elk.bundled.js"></script> <script type="text/javascript" src="https://nturley.github.io/netlistsvg/elk.bundled.js"></script>
<script type="text/javascript" src="https://nturley.github.io/netlistsvg/built/netlistsvg.bundle.js"></script> <script type="text/javascript" src="https://nturley.github.io/netlistsvg/built/netlistsvg.bundle.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.43.3/ace.min.js" integrity="sha512-BHJlu9vUXVrcxhRwbBdNv3uTsbscp8pp3LJ5z/sw9nBJUegkNlkcZnvODRgynJWhXMCsVUGZlFuzTrr5I2X3sQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.43.3/ace.min.js" integrity="sha512-BHJlu9vUXVrcxhRwbBdNv3uTsbscp8pp3LJ5z/sw9nBJUegkNlkcZnvODRgynJWhXMCsVUGZlFuzTrr5I2X3sQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/styles/base16/google-light.min.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.11.1/languages/verilog.min.js"></script>
</head> </head>
<body> <body>
<section id="test_display"> <section id="test_display">