- report query params added to LaTeX as a comment

This commit is contained in:
Wiesner András 2024-10-01 16:19:42 +02:00
parent 9e209df51f
commit 79e2430fb6
2 changed files with 25 additions and 2 deletions

View File

@ -168,7 +168,7 @@ class ReportSection
// Generate TeX representation of this report. // Generate TeX representation of this report.
function genTeX(): string function genTeX(): string
{ {
$tex = "\\begin{quiz}{" . $this->title . "}{" . $this->getMaxFillingCount() . "}\n"; $tex = "\\begin{quiz}{" . $this->title . "}{" . $this->getNumberOfSubmissions() . "}\n";
foreach ($this->challenges as $challenge) { foreach ($this->challenges as $challenge) {
$tex .= $challenge->genTeX(); $tex .= $challenge->genTeX();
} }
@ -181,11 +181,13 @@ class Report
{ {
private string $title; private string $title;
private array $sections; private array $sections;
private array $comments;
function __construct(string $title) function __construct(string $title)
{ {
$this->title = $title; $this->title = $title;
$this->sections = []; $this->sections = [];
$this->comments = [];
} }
@ -195,13 +197,27 @@ class Report
$this->sections[] = $section; $this->sections[] = $section;
} }
function addComment(string $comment): void
{
$this->comments[] = $comment;
}
// Generate TeX representation. // Generate TeX representation.
function genTeX(): string function genTeX(): string
{ {
$tex = ""; $tex = "";
// generate content
foreach ($this->sections as $section) { foreach ($this->sections as $section) {
$tex .= $section->genTeX() . "\n\n"; $tex .= $section->genTeX() . "\n\n";
} }
// add comments if any
if ($this->comments != []) {
$tex .= "\\clearpage\n\small\n\\noindent ";
$tex .= join("\\\\\n", $this->comments);
}
// escape LaTeX control characters
$tex = TeXUtils::processCodeInserts($tex); $tex = TeXUtils::processCodeInserts($tex);
$tex = TeXUtils::escape($tex); $tex = TeXUtils::escape($tex);
return $tex; return $tex;

View File

@ -572,6 +572,13 @@ function generate_report_by_groups(ReqHandler &$rh, array $params): string
$report->addSection($section); $report->addSection($section);
} }
// add comments
$report->addComment("gameid: ${gameid}");
$groupsJoined = join(", ", $groups);
$report->addComment("groups: ${groupsJoined}");
$report->addComment("filter: ${filter}");
$report->addComment("best_only: ${params["best_only"]}");
// generate latex // generate latex
$report->saveTeX($buildDir); $report->saveTeX($buildDir);
@ -596,7 +603,7 @@ function generate_report_by_groups(ReqHandler &$rh, array $params): string
foreach ($files as $file) { foreach ($files as $file) {
$zip->addFile($file, basename($file)); $zip->addFile($file, basename($file));
} }
$zip->addFromString("request.txt", "gameid: ${gameid}\ngroups: " . join(", ", $groups) . "\nfilter: ${filter}\nouttype: ${outtype}\n"); $zip->addFromString("request.txt", "gameid: ${gameid}\ngroups: " . $groupsJoined . "\nfilter: ${filter}\nouttype: ${outtype}\nbest_only: ${params["best_only"]}");
$zip->addFromString("request.url", $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]); $zip->addFromString("request.url", $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"]);
$zip->close(); $zip->close();
$contentType = "application/zip"; $contentType = "application/zip";