Skip to content

Commit

Permalink
Add list of submissions to the report
Browse files Browse the repository at this point in the history
  • Loading branch information
FinnLidbetter committed May 30, 2024
1 parent 5e83e6c commit 29f58da
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 13 deletions.
3 changes: 3 additions & 0 deletions crifx/contest_objects/judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ def is_same(self, other_judge):
or self.primary_name == other_judge.primary_name
)

def __str__(self):
return f"{self.primary_name}"


UNKNOWN_JUDGE = Judge("UNKNOWN", None)
19 changes: 16 additions & 3 deletions crifx/problemset_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,17 @@ def _set_judges_by_name(self, alias_groups: list[AliasGroup]):
)
for git_user in git_users_by_name.values()
}
for alias_group in alias_groups:
if (
alias_group.git_name is not None
and alias_group.git_name not in self.judges_by_name
):
# The user has a git name but no commits in the repository yet.
self.judges_by_name[alias_group.git_name] = Judge(
alias_group.identifier,
GitUser(alias_group.git_name, "unknown email", b"", b""),
*alias_group.aliases,
)
for alias_group in gitless:
if alias_group.identifier in git_users_by_name:
logging.warning(
Expand All @@ -85,6 +96,7 @@ def _set_judges_by_name(self, alias_groups: list[AliasGroup]):
self.judges_by_name[alias_group.identifier] = Judge(
alias_group.identifier, None, *alias_group.aliases
)
logging.debug("Identified judges: %s", str(self.judges_by_name))

def parse_problemset(self) -> ProblemSet:
"""Parse a ProblemSet."""
Expand Down Expand Up @@ -210,14 +222,15 @@ def _parse_submissions_dir(
for line_number, line in enumerate(submission_lines):
author_match = re.search(CRIFX_AUTHOR_PATTERN, line)
if author_match is not None:
author_name_override = author_match.group(1)
logging.debug(
"Found author override for file %s on line %d",
"Found author override for file %s on line %d. Override name is '%s'",
submission_path,
line_number + 1,
author_name_override,
)
author_name_override = author_match.group(1)
break
lines_of_code = len(submission_file.readlines())
lines_of_code = len(submission_lines)
file_bytes = os.stat(submission_path).st_size
except (FileExistsError, FileNotFoundError, PermissionError):
logging.warning(
Expand Down
27 changes: 23 additions & 4 deletions crifx/report_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,28 @@ def _write_problem_details(self, problem: Problem):
assert self.doc is not None
self.doc.append(Command(r"newpage"))
with self.doc.create(Section(problem.name)):
with self.doc.create(Subsection("Submissions")):
with self.doc.create(Subsection("Accepted")):
with self.doc.create(Itemize()) as itemize:
for submission in problem.ac_submissions:
itemize.add_item(
f"{submission.filename} by {submission.author}. "
f"{submission.lines_of_code} lines of code."
)
with self.doc.create(Subsection("Wrong Answer")):
with self.doc.create(Itemize()) as itemize:
for submission in problem.wa_submissions:
itemize.add_item(
f"{submission.filename} by {submission.author}. "
f"{submission.lines_of_code} lines of code."
)
with self.doc.create(Subsection("Time Limit Exceeded")):
with self.doc.create(Itemize()) as itemize:
for submission in problem.tle_submissions:
itemize.add_item(
f"{submission.filename} by {submission.author}. "
f"{submission.lines_of_code} lines of code."
)
with self.doc.create(Subsection("Problemtools verifyproblem output")):
if problem.review_status.run_problemtools:
self.doc.append("null")
Expand All @@ -390,10 +412,7 @@ def _write_problem_details(self, problem: Problem):
)
with self.doc.create(Subsection("Test Cases")):
self.doc.append(
"Test case descriptions are rendered below if they exist. "
f"Otherwise, the first {INPUT_FILE_LINES_MAX} lines of input "
f"are rendered if they each have at most {INPUT_FILE_WIDTH_MAX} "
"characters."
"Test case descriptions are rendered below if .desc files exist."
)
with self.doc.create(Itemize()) as itemize:
for test_case in problem.test_cases:
Expand Down
54 changes: 48 additions & 6 deletions examples/example_problemset/.crifx/crifx-report.tex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
\usepackage{datetime2}%
\usepackage{listings}%
\title{CRIFX Contest Preparation Status Report}%
\date{Compiled \today~at \DTMcurrenttime\DTMcurrentzone~for commit fc2980d2}%
\date{Compiled \today~at \DTMcurrenttime\DTMcurrentzone~for commit 5e83e6cd}%
%
\begin{document}%
\normalsize%
Expand All @@ -28,7 +28,7 @@ \section{Submissions summary}%
\hline%
addtwonumbers&\cellcolor{red}1/3&\cellcolor{red}1/2&0&0&1&1&0&0&0\\%
\hline%
helloworld&\cellcolor{red}1/3&\cellcolor{green}2/2&0&1&1&2&1&0&5\\%
helloworld&\cellcolor{red}2/3&\cellcolor{green}2/2&0&1&1&2&1&0&5\\%
\hline%
\end{tabular}

Expand All @@ -50,9 +50,9 @@ \section{How can I help?}%
\label{sec:HowcanIhelp?}%
\begin{enumerate}%
\item%
addtwonumbers needs at least 2 more AC submissions from people other than Finn Lidbetter.%
addtwonumbers needs at least 2 more AC submissions from people other than Jane Doe.%
\item%
helloworld needs at least 2 more AC submissions from people other than Finn Lidbetter.%
helloworld needs at least one more AC submission from someone other than Finn Lidbetter and Homer Simpson.%
\item%
addtwonumbers needs at least one more AC submission from any of the following language groups: c/c++ or java/kotlin.%
\item%
Expand All @@ -77,27 +77,69 @@ \section{How can I help?}%
\newpage%
\section{addtwonumbers}%
\label{sec:addtwonumbers}%
\subsection{Submissions}%
\label{subsec:Submissions}%
\subsection{Accepted}%
\label{subsec:Accepted}%
\begin{itemize}%
\item%
add\_two\_jd.py by Jane Doe. 12 lines of code.%
\end{itemize}

%
\subsection{Wrong Answer}%
\label{subsec:WrongAnswer}%

%
\subsection{Time Limit Exceeded}%
\label{subsec:TimeLimitExceeded}%

%
\subsection{Problemtools verifyproblem output}%
\label{subsec:Problemtoolsverifyproblemoutput}%
Including problemtools verifyproblem output is disabled for this problem. It can be enabled in the crifx{-}problem{-}status.toml file for this problem.

%
\subsection{Test Cases}%
\label{subsec:TestCases}%
Test case descriptions are rendered below if they exist. Otherwise, the first 10 lines of input are rendered if they each have at most 90 characters.%
Test case descriptions are rendered below if .desc files exist.%

%
\newpage%
\section{helloworld}%
\label{sec:helloworld}%
\subsection{Submissions}%
\label{subsec:Submissions}%
\subsection{Accepted}%
\label{subsec:Accepted}%
\begin{itemize}%
\item%
hello.py by Homer Simpson. 12 lines of code.%
\item%
hello\_finn.java by Finn Lidbetter. 9 lines of code.%
\end{itemize}

%
\subsection{Wrong Answer}%
\label{subsec:WrongAnswer}%
\begin{itemize}%
\item%
lowercase\_only.py by Finn Lidbetter. 9 lines of code.%
\end{itemize}

%
\subsection{Time Limit Exceeded}%
\label{subsec:TimeLimitExceeded}%

%
\subsection{Problemtools verifyproblem output}%
\label{subsec:Problemtoolsverifyproblemoutput}%
null

%
\subsection{Test Cases}%
\label{subsec:TestCases}%
Test case descriptions are rendered below if they exist. Otherwise, the first 10 lines of input are rendered if they each have at most 90 characters.%
Test case descriptions are rendered below if .desc files exist.%
\begin{itemize}%
\item%
sample{-}1%
Expand Down
Binary file modified examples/example_problemset/crifx-report.pdf
Binary file not shown.

0 comments on commit 29f58da

Please sign in to comment.