\documentclass[a4paper,fontsize=12pt,listof=totoc,toc=sectionentrywithdots]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{lmodern}
\usepackage[onehalfspacing]{setspace}

\usepackage{mathtools}
\usepackage{amsxtra,amssymb,amsthm,amstext,amsfonts}
\usepackage{esint} % for circle integrals

\setcounter{secnumdepth}{5} % numbered paragraphs
\usepackage[hyphens]{url}
\usepackage[]{hyperref}
\usepackage{fancyhdr}

\usepackage[extendedchars]{grffile}

\usepackage{xcolor}
\usepackage{float}

% header and footer
\newcommand{\Assignment}{class name - assignment no. X} % title, for both title and header
\newcommand{\Task}[1]{ \section*{#1.)} \addcontentsline{toc}{section}{Task #1} \label{sec:task_#1}}
\newcommand{\Subtask}[1]{ \subsection*{#1)} \addcontentsline{toc}{subsection}{#1 )}}
\newcommand{\Authorname}{your name here} % your name here

\setlength{\headheight}{15.2pt}
\pagestyle{fancy}
\fancyhf{}

\fancyhead[R]{\Authorname}
\fancyhead[L]{\Assignment}
\fancyfoot[C]{\thepage}

\title{\Assignment}
\author{\Authorname}
\date{\today}
\begin{document}
\maketitle
\tableofcontents

\Task{1}
\Subtask{a}
example

\end{document}
