From 79e2430fb65fa4de1b19e126c0db97e6fba704a5 Mon Sep 17 00:00:00 2001 From: Epagris Date: Tue, 1 Oct 2024 16:19:42 +0200 Subject: [PATCH] - report query params added to LaTeX as a comment --- class/ReportBuilder.php | 18 +++++++++++++++++- interface.php | 9 ++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/class/ReportBuilder.php b/class/ReportBuilder.php index 94abbfd..a65218b 100644 --- a/class/ReportBuilder.php +++ b/class/ReportBuilder.php @@ -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; diff --git a/interface.php b/interface.php index 024a0e7..c95b451 100644 --- a/interface.php +++ b/interface.php @@ -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";