Skip to content

Commit

Permalink
Export test solutions
Browse files Browse the repository at this point in the history
  • Loading branch information
paul019 committed May 27, 2024
1 parent 8e64483 commit 8fb6578
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 6 deletions.
64 changes: 64 additions & 0 deletions assets/latex/qualification_test_solutions.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
\documentclass[parskip=full]{article}

% Import packages
\usepackage[ngerman]{babel}
\usepackage[hidelinks]{hyperref}
\usepackage{multicol}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{amsthm}
\usepackage{mathrsfs}
\usepackage{graphicx}

% Set layout params
\usepackage[a4paper,left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\setlength\parindent{0pt}
\pagestyle{empty}

\newcommand{\dd}[1]{\text{d}{#1}}

\newcommand{\mainTitle}[1]{
\begin{center}
\Huge
\textbf{#1}

\vspace*{0.2cm}

\Large
Lösungen zum Qualifikations-Test

\normalsize
\end{center}
}

\newcommand{\testTitle}[1]{
\hrulefill

\begin{center}
\Large
\textbf{#1}
\end{center}
}

% Arguments:
% 1. Index
% 2. Latex
% 3. Name
\newcommand{\integral}[3]{
\hrulefill

\textbf{#1. Aufgabe} \textit{#3}

\begin{align*}
#2
\end{align*}
}


\begin{document}
% \mainTitle{Heidelberg Integration Bee 2024}

% \integral{1}{\int{x}}{Vereinfachen!}
% \integral{1}{\int{x}}{Vereinfachen!}

% PLACEHOLDER
\end{document}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:integration_bee_helper/extensions/list_extension.dart';
import 'package:integration_bee_helper/models/agenda_item_model/agenda_item_knockout.dart';
import 'package:integration_bee_helper/models/agenda_item_model/agenda_item_live_competition.dart';
import 'package:integration_bee_helper/models/agenda_item_model/agenda_item_model_competition.dart';
Expand All @@ -16,6 +17,7 @@ part 'knockout_round_cards.dart';
part 'qualification_round_sheets.dart';
part 'tests.dart';
part 'integrals_list.dart';
part 'tests_solutions.dart';

class ExportDocumentsService {
Future<void> exportDocuments(BuildContext context) async {
Expand Down Expand Up @@ -58,6 +60,12 @@ class ExportDocumentsService {
allIntegrals: allIntegrals,
));

futures.add(_generateTestsSolutions(
context,
tests: agendaItems.whereType<AgendaItemModelTest>().toList(),
allIntegrals: allIntegrals,
));

futures.add(_generateIntegralsList(
context,
agendaItems:
Expand All @@ -72,4 +80,8 @@ class ExportDocumentsService {
zipFileName: 'integration_bee_documents.zip',
);
}

String _transformTitle(String title) {
return title.replaceAll('#', '\\#');
}
}
13 changes: 7 additions & 6 deletions lib/services/export_documents_service/integrals_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ extension GenerateIntegralsList on ExportDocumentsService {
commands.add(
'\\integral{${integral.code}}{${integral.latexProblemAndSolution.transformed}}',
);
if (integral.name != '') {
if (integral.name != '' || integral.youtubeVideoId != '') {
final parts = [
integral.name,
integral.youtubeVideoId != '' ? 'mit Video' : '',
].deleteEmptyEntries();

commands.add(
'\\integralName{${integral.name}}',
'\\integralName{${parts.join(' -- ')}}',
);
}
}
Expand Down Expand Up @@ -73,8 +78,4 @@ extension GenerateIntegralsList on ExportDocumentsService {

return file;
}

String _transformTitle(String title) {
return title.replaceAll('#', '\\#');
}
}
45 changes: 45 additions & 0 deletions lib/services/export_documents_service/tests_solutions.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
part of 'export_documents_service.dart';

extension GenerateTestsSolutions on ExportDocumentsService {
Future<TextFile?> _generateTestsSolutions(
BuildContext context, {
String eventName = 'Heidelberg Integration Bee 2024', //TODO
required List<AgendaItemModelTest> tests,
required List<IntegralModel> allIntegrals,
}) async {
if(tests.isEmpty) {
return null;
}

final List<String> commands = [
'\\mainTitle{$eventName}',
];

for (var test in tests) {
if (tests.length > 1) {
commands.add(
'\\testTitle{${_transformTitle(test.title)}}',
);
}

// Regular integrals:
for (var (i, integralCode) in test.integralsCodes.indexed) {
final integral = allIntegrals.firstWhere(
(integral) => integral.code == integralCode,
);
commands.add(
'\\integral{${i + 1}}{${integral.latexProblemAndSolution.transformed}}{${integral.name}}',
);
}
}

var file = await TextFile.fromAsset(
context,
assetFileName: 'latex/qualification_test_solutions.tex',
displayFileName: 'DOPPELSEITIG_SW_qualifikations_test_loesung.tex',
);
file = file.makeReplacement(newText: commands.join('\n'));

return file;
}
}
4 changes: 4 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ flutter:
- assets/sound/
- assets/latex/knockout_round_cards.tex
- assets/latex/qualification_round_sheets.tex
- assets/latex/integrals_list.tex
- assets/latex/qualification_test_solutions.tex
- assets/latex/qualification_test.tex


# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
Expand Down

0 comments on commit 8fb6578

Please sign in to comment.