\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{advalguebung}[2024/11/18 Template Übungen Uni Trier - Algorithmik]

\newcommand{\semester}{WS 2024/25}

\newif\ifstandaloneaktiv
\standaloneaktivfalse
\newif\ifunbewertetaktiv
\unbewertetaktivfalse
\newif\iftutoriumaktiv
\tutoriumaktivfalse
\DeclareOption{einzelaufgabe}{%
  \standaloneaktivtrue%
}
\DeclareOption{tutorium}{%
  \tutoriumaktivtrue%
}
\DeclareOption{unbewertet}{%
  \unbewertetaktivtrue%
}
\DeclareOption{moritz}{%
}
\DeclareOption*{%
  \PassOptionsToClass{\CurrentOption}{scrartcl}%
}

\ProcessOptions\relax


\LoadClass[12pt,DIV=13]{scrartcl}

\ifstandaloneaktiv
  \usepackage[inline,solutions]{uebunghcw}%also requires anhang.sty
  \clearnames
  \addname{\jobname}
\else
  \usepackage[subpreambles,sort]{standalone}
  \usepackage[inline,autosolutions]{uebunghcw}%also requires anhang.sty
  \iftutoriumaktiv
    \renewcommand{\punkte}[1]{}%suppress output of point-values for tutorial sheets
  \fi
  \iftutoriumaktiv
    \renewcommand{\punkte}[1]{}%suppress output of point-values for ungraded sheets
  \fi

  \AtBeginDocument{
    \heading{\exerciseNum.\ \iftutoriumaktiv Pr\"asenz\"u\else\"U\fi bungsblatt zur Vorlesung\\ \vspace{0.15cm}
      Algorithmen für geographische Informationssysteme\\ \vspace{0.2cm}
      (\semester)}
    \iftutoriumaktiv
    \footer{Diese Aufgaben werden eventuell gemeinsam in den \"Ubungen am \deadlineDate~\ gel\"ost.
Sie brauchen Sie nicht vorher zu l\"osen und auch nicht abzugeben.}
    \fi
  }
  \newcommand{\adsaufgabe}[2][]{%
    \def\PARTS{#1}%
    \input{../../allgemein/uebungen/aufgaben/ads-#2.tex}
  }
\fi


\setkomafont{sectioning}{\normalfont\normalcolor\bfseries}
\usepackage{graphicx}
\usepackage{amsmath,amsfonts}
\usepackage{hyperref,url}
\usepackage{enumerate}

\usepackage{tikz}
\usetikzlibrary{positioning,shapes,calc}

\usepackage[german, ruled, vlined, longend]{algorithm2e}
\SetKw{KwDownTo}{downto}
\SetKw{KwAnd}{and}
\SetKw{KwOr}{or}
\DontPrintSemicolon

\usepackage{mathtools}
\newcommand{\enquote}[1]{``{#1}''}
\def\Oh{\ensuremath{\mathcal{O}}}
\newcommand{\setN}{\mathbb{N}}
\newcommand{\setZ}{\mathbb{Z}}
\newcommand{\setQ}{\mathbb{Q}}
\newcommand{\setR}{\mathbb{R}}
\newcommand{\defeq}{:=}
\newcommand{\eqdef}{=:}
\DeclarePairedDelimiter\norm{\lVert}{\rVert}
\DeclarePairedDelimiter\ceils{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}
\newcommand{\mathcomm}[1]{\triangleright~\text{#1}}%
\DeclarePairedDelimiter{\set}{\{}{\}}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}

\ifluatex
\else
\def\ttdefault{cmvtt}
\fi

% for including subpartable tasks
\usepackage{ifthen}
\newcommand\storelabel[2]{\expandafter\xdef\csname label#1\endcsname{#2}}
\newcommand\getlabel[1]{\csname label#1\endcsname}

\newenvironment{teilaufgabepartial}{%
\ifthenelse{\value{nooparts} > 1}{\begin{teilaufgabe}}{}%
}{
\ifthenelse{\value{nooparts} > 1}{\end{teilaufgabe}}{}%
}

\newcommand{\printPart}[2]{\ifthenelse{\equal{#1}{\string 1}}{\ifthenelse{\value{nooparts} > 1}{\item}{} #2}{}}

\newcommand{\checkfor}[1]{%
  \ifcsname#1\endcsname%
    \foreach \val [count=\i] in \PARTS {%
      \storelabel{part-\i}{\val}%
      \addtocounter{nooparts}{\val}%
    }%
  \else%
    \foreach \i in {1,...,\value{parts}} {% parts counter defined in the subfile
      \storelabel{part-\i}{1}%
      \addtocounter{nooparts}{1}%
    }%
  \fi%
}

\makeatletter
\newcommand*\ifcounter[1]{%
  \ifcsname c@#1\endcsname
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
}
\makeatother


\newcommand{\algo}[1]{\mbox{\textsc{#1}}}
\newcommand{\javacode}[1]{\begin{itemize}\item \texttt{#1}\end{itemize}}
