\input regression-test.tex
\DocumentMetadata{}
\documentclass{ltx-talk}
\NewDocumentCommand\lecture{O{}mm}{\TYPE{LECTURE KEPT}}
\usepackage[ignorenonframetext]{osglecture-modes-ltxtalk}
\ExplSyntaxOn
\cs_new_protected:Npn \test_keep_end:
  { \END \osglecture_modes_scan: }
\osglecture_modes_declare_allowed_command:nn { END } { test_keep_end: }
\ExplSyntaxOff

\DeclareLectureMode{withSolution}
\DeclareLectureMode{withGrading}
\DeclareLectureMode[parents={withSolution,withGrading}]{examboth}
\SetLectureModes{examboth}

\NewDocumentEnvironment{Aufgabe}{}{\TYPE{AUFGABE BEGIN}}{\TYPE{AUFGABE END}}
\DeclareLectureKeepEnvironment{Aufgabe}

\NewDocumentEnvironment{Musterloesung}{}{\TYPE{MUSTERLOESUNG BEGIN}}{\TYPE{MUSTERLOESUNG END}}
\DeclareLectureKeepEnvironment[mode=withSolution]{Musterloesung}

\NewDocumentEnvironment{Bewertung}{}{\TYPE{BEWERTUNG BEGIN}}{\TYPE{BEWERTUNG END}}
\DeclareLectureKeepEnvironment[mode=withGrading]{Bewertung}

\begin{document}
\START
\lecture{Introduction}{intro}
\section{Sec}
\begin{Aufgabe}
  \TYPE{AUFGABE CONTENT}
\end{Aufgabe}
\begin{Musterloesung}
  \TYPE{MUSTERLOESUNG CONTENT}
\end{Musterloesung}
\begin{Bewertung}
  \TYPE{BEWERTUNG CONTENT}
\end{Bewertung}
\begin{unregisteredenv}
  \TYPE{SHOULD NOT APPEAR}
\end{unregisteredenv}
\END
\end{document}
