- 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.
function genTeX(): string
{
$tex = "\\begin{quiz}{" . $this->title . "}{" . $this->getMaxFillingCount() . "}\n";
$tex = "\\begin{quiz}{" . $this->title . "}{" . $this->getNumberOfSubmissions() . "}\n";
foreach ($this->challenges as $challenge) {
$tex .= $challenge->genTeX();
}
@ -181,11 +181,13 @@ class Report
{
private string $title;
private array $sections;
private array $comments;
function __construct(string $title)
{
$this->title = $title;
$this->sections = [];
$this->comments = [];
}
@ -195,13 +197,27 @@ class Report
$this->sections[] = $section;
}
function addComment(string $comment): void
{
$this->comments[] = $comment;
}
// Generate TeX representation.
function genTeX(): string
{
$tex = "";
// generate content
foreach ($this->sections as $section) {
$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::escape($tex);
return $tex;

View File

@ -572,6 +572,13 @@ function generate_report_by_groups(ReqHandler &$rh, array $params): string
$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
$report->saveTeX($buildDir);
@ -596,7 +603,7 @@ function generate_report_by_groups(ReqHandler &$rh, array $params): string
foreach ($files as $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->close();
$contentType = "application/zip";