\documentclass[a4paper, 11pt, dvipsnames]{exam}
\usepackage[dvipsnames]{xcolor}

\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{tikz}
\usetikzlibrary{cd}
\usepackage{cancel}
\usepackage{multicol}
\usepackage[margin=1.5cm]{geometry} 
\addtolength{\topmargin}{0.5cm}
\addtolength{\textheight}{-2cm}
\usepackage{parskip}
\usepackage{multicol}
\usepackage{hyperref}
\usepackage[polish,english]{babel}
\usepackage{csquotes}
\usepackage{titlesec}

\titlelabel{\thetitle. }



\renewcommand\qedsymbol{QED}
\newtheorem{thm}{Theorem}[subsection]
\newtheorem{lm}[thm]{Lemma}
\newtheorem{fact}[thm]{Fact}
\newtheorem{rk}[thm]{Remark}
\theoremstyle{definition}
\newtheorem{df}[thm]{Definition}
\renewcommand{\thethm}{%
  \ifnum\value{subsection}=0 
    \thesection% "no section"
  \else
    \thesubsection% at least within a section
  \fi%
  .\arabic{thm}}

\newcommand{\dom}{\textrm{dom}}
\newcommand{\rng}{\textrm{rng}}
\newcommand{\cf}{\textrm{cf}}
\newcommand{\Lim}{\textrm{Lim}}
\newcommand{\N}{\mathbb{N}}
\newcommand{\NN}{\mathcal{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\let\C\relax
\newcommand{\C}{\mathbb{C}}
\newcommand{\s}{\mathfrak{s}}
\newcommand{\p}{\mathfrak{p}}
\newcommand{\A}{\mathcal{A}}
\newcommand{\M}{\mathcal{M}}
\newcommand{\E}{\mathbb{E}}
\newcommand{\omom}{[\omega]^\omega}
\renewcommand{\P}{\mathbb{P}}
\newcommand{\st}{\mathrm{St}}
\DeclareMathOperator{\cl}{cl}
% \let\int\relax
% \DeclareMathOperator{\int}{int}
\DeclareMathOperator{\tg}{tg}
\DeclareMathOperator{\cov}{cov}
\DeclareMathOperator{\Clop}{Clop}
\DeclareMathOperator{\Cov}{Cov}
\DeclareMathOperator{\Var}{Var}
\DeclareMathOperator{\Corr}{Corr}
\DeclareMathOperator{\sgn}{sgn}
\DeclareMathOperator{\card}{card}
\DeclareMathOperator{\supp}{supp}
\DeclareMathOperator{\diam}{diam}
\DeclareMathOperator{\interior}{int}
\DeclareMathOperator{\conv}{conv}
\DeclareMathOperator{\id}{id}
\DeclareMathOperator{\im}{im}


\newcommand{\cone}[1]{\ensuremath{\langle #1 \rangle}}
\newcommand{\m}[1]{\equiv_{#1}}
\definecolor{darkorange}{RGB}{255, 140, 0}
\newcommand{\pom}[1]{{\colour{darkorange}#1}}
\newcommand{\nieb}[1]{{\colour{cyan}#1}}

\newcommand{\sol}{\begin{solution}}
\newcommand{\esol}{\end{solution}}
\newcommand{\que}{\question}

\newcommand{\maketytul}[1]{ \hrule \begin{center} \b{\LARGE #1} \end{center} \vspace{0.3cm} \hrule \vspace{0.3cm}}

\let\zad\que
\let\epsilon\varepsilon
\let\phi\varphi
\let\emptyset\varnothing
\let\le\leqslant
\let\leq\le
\let\ge\geqslant
\let\geq\ge
\let\bd\partial
\let\colour \color
\let \b \textbf
\let \i \textit
\let \varangle \sphericalangle
\let \Varangle \sphericalangle
\newcommand{\xautor}{BRAK NAZWISKA}
\newcommand{\autor}[1]{\lhead{\emph{#1}}
\renewcommand{\xautor}{#1}}

\chead{\emph{Ćwiczenia z probabilistycznych modeli grafowych}}
\rhead{\emph{ {2024/25, PWr}}}
\cfoot{\b {-- \thepage \ -- }}

\pointname{p}
\boxedpoints
\pointsinmargin
\marginpointname{p.}

\hqword{Zadanie:}
\hpword{Punkty:}
\htword{ $\Sigma$ \ }
\hsword{Wynik:}

\usepackage{qrcode}

\setlength\fillinlinelength{1.5cm}
            % \definecolor{wsk}{RGB}{210, 210, 210}
          \definecolor{wsk}{RGB}{130, 130, 130}




\newcommand{\wsk}[1]{{\colour{wsk}#1}}
\renewcommand{\solutiontitle}{\noindent\textbf{Rozwiązanie:}\enspace}
\renewcommand{\questionlabel}{\b {\large{ \thequestion.}}}

\newcommand{\indeks}{310250}
\newcommand{\imie}{Imię}
\newcommand{\nazwisko}{Nazwisko}
\newcommand{\tytul}{Tytuł kartkówki}
\newcommand{\data}{0000-00-00}
\newcommand{\przedmiot}{Przedmiot}
\newcommand{\pracafile}{kart1a}

\newcommand{\nrindeksu}[1]{
\renewcommand{\indeks}{#1}
}

\newcommand{\praca}[4]{
\renewcommand{\imie}{#3}
\renewcommand{\nazwisko}{#4}
\renewcommand{\indeks}{#2}
\renewcommand{\pracafile}{#1}
\input{\pracafile}
}

\newcommand{\kartkowka}[3]{
\renewcommand{\przedmiot}{#1}
\renewcommand{\tytul}{#2}
\renewcommand{\data}{#3}
}


\newcommand{\kodqr}{
\qrcode[height=2.2cm, level=H]{\indeks,\imie,\nazwisko,\przedmiot,\data,\nazwagrupy,\thepage}
}

\newcommand{\symbolgrupy}{}
\newcommand{\nazwagrupy}{}
\newcommand{\grupa}[2]{
\renewcommand{\symbolgrupy}{#1}
\renewcommand{\nazwagrupy}{#2}
}

\rfoot{\symbolgrupy}

\newcommand{\naglowekpracy}{
\fullwidth{
\maketytul{\tytul}
\addpoints
\begin{flushright}
\setlength{\fboxsep}{5pt}
\fbox{\begin{tabular}{@{}c@{}}
    \b{\Large \ \imie \ \nazwisko \ }  \\
    \indeks
\end{tabular}}
\setlength{\fboxsep}{3pt}
\hfill 
\gradetable[h] \quad
\kodqr
\end{flushright}
}
}

\newcommand{\naglowekkartki}{
\newpage
\fullwidth{
\maketytul{\tytul}
\begin{flushright}
\setlength{\fboxsep}{5pt}
\fbox{\begin{tabular}{@{}c@{}}
    \b{\Large \ \imie \ \nazwisko \ }  \\
    \indeks
\end{tabular}}
\setlength{\fboxsep}{3pt}
\hfill 
\kodqr
\end{flushright}
}
}

\newcommand{\naglowekpowitalny}{
\newpage
\fullwidth{
\maketytul{\tytul}
\begin{flushright}
\begin{tabular}{@{}l@{}}
    Czas trwania kartkówki: \b{15 minut}. \\
    Nie odwracaj kartki bez zgody prowadzącego. \\
    Powodzenia!
\end{tabular}
\hfill
\setlength{\fboxsep}{5pt}
\fbox{\begin{tabular}{@{}c@{}}
    \b{\Large \ \imie \ \nazwisko \ }  \\
    \indeks
\end{tabular}}
\setlength{\fboxsep}{3pt}
\kodqr
\end{flushright}
}
}

\newcommand{\naglowekpusty}{
\newpage
\fullwidth{
\maketytul{\tytul}
\begin{flushright}
\hfill
\setlength{\fboxsep}{5pt}
\fbox{\begin{tabular}{@{}c@{}}
    \b{\Large \ \imie \ \nazwisko \ }  \\
    \indeks
\end{tabular}}
\setlength{\fboxsep}{3pt}
\kodqr
\end{flushright}
}
}

\newcommand{\zadanie}[2]{\newpage \section*{Zadanie #1/#2} \rhead{Zadanie #1/#2}}
\usepackage{colortbl}
\usepackage[table]{xcolor} % tylko do kolorowania tabel, standardowo dozwolone

% Proste kolory
\definecolor{lightred}{RGB}{255, 200, 200}
\definecolor{lightgreen}{RGB}{200, 255, 200}
\definecolor{lightorange}{RGB}{255, 230, 200}
% Kolorowanie TAK/NIE
\newcommand{\kolorTakNie}[1]{%
  \ifnum#1>0%
    \cellcolor{lightgreen}TAK%
  \else%
    \cellcolor{lightred}NIE%
  \fi%

}

% Kolorowanie dla liczby zadań względem progu
\newcommand{\kolorProg}[2]{%
  \ifnum#1<#2
    \cellcolor{lightred}#1%
  \else
    \cellcolor{lightgreen}#1%
  \fi
}

% Kolorowanie punktów 
\newcommand{\kolorPunkty}[1]{%
  \ifnum#1<1
    \cellcolor{lightred}#1%
  \else
    \cellcolor{lightgreen}#1%
  \fi
}

\newcommand{\poleOceny}{\hspace{4cm}}

% Rozszerzona tabela samooceny
\newcommand{\tabelasamooceny}[9]{%

\ 
  \vspace*{1cm} 
\begin{center}
\textit{\huge Probabilistyczne modele grafowe 2024/25  \\  
\vspace{0.5cm}  
Zadanie domowe} \\  
\vspace{2cm}  

\textbf{\Huge \xautor} \\ 
\vspace{0.5cm}  
\textbf{\Huge \indeks} \\
\vspace{2.5cm}  


\end{center}
  
  \renewcommand{\arraystretch}{1.7}
  \begin{center}
  \begin{tabular}{|p{8cm}|c|c|}
    \hline
    \textbf{Kryterium} & \textbf{Samoocena} & \textbf{Ocena prowadzącego} \\
    \hline
    Liczba rozwiązanych zadań (min. 7) & \kolorProg{#1}{7} & \poleOceny \\
    \hline
    Zadania z zakresu listy 1 (min. 2) & \kolorProg{#2}{2} & \poleOceny \\
    \hline
    Zadania z zakresu  listy 2 (min. 1) & \kolorProg{#3}{1} & \poleOceny \\
    \hline
    Zadania z zakresu  listy 3 (min. 2) & \kolorProg{#4}{2} & \poleOceny \\
    \hline
    Zadania ułożone w kolejności tematów? & \kolorTakNie{#5} & \poleOceny \\
    \hline
    Treść zadania przed każdym rozwiązaniem? & \kolorTakNie{#6} & \poleOceny \\
    \hline
    Poprawność rozwiązań (0–33) & \kolorPunkty{#7} / 33 & \poleOceny \\
    \hline
    Forma prezentacji (0–33) & \kolorPunkty{#8} / 33 & \poleOceny \\
    \hline
    Dobór zadań (0–33) & \kolorPunkty{#9} / 33 & \poleOceny \\

    
    \hline
    
  \end{tabular}
  \end{center}
}

