\ProvidesPackage{agd-rubric}

% Copyright (C) 2013 Andrew Gainer-Dewar <andrew.gainer.dewar@gmail.com>
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.2 of this license or (at your option) any later
% version. The latest version of this license is in:
% http://www.latex-project.org/lppl.txt
% and version 1.2 or later is part of all distributions of
% LaTeX version 1999/12/01 or later.j

\usepackage{csquotes}

\usepackage{hyperref}

\usepackage[margin=1in,letterpaper]{geometry}

\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}

\usepackage{microtype}
\usepackage{booktabs}
\usepackage{forloop}
\usepackage{calc}

\tightlists

\newcounter{totalcolnum}
\newcounter{colnum}
\newlength{\colwidth}
\newlength{\firstcolwidth}
\setlength{\firstcolwidth}{3.5cm}

% Set up \therubric to access parameters of \rubric
\newcommand{\therubric}[1]{\csname rubric@#1\endcsname}

\newcommand{\rubriccourse}[1]{\gdef\rubric@course{#1}}
\newcommand{\rubricterm}[1]{\gdef\rubric@term{#1}}
\newcommand{\rubricthing}[1]{\gdef\rubric@thing{#1}}
\newcommand{\rubrictopprompt}[1]{\gdef\rubric@topprompt{#1}}

\setlength{\droptitle}{-5eX}
\renewcommand*{\@maketitle}{
  \newpage
  \null
  \vspace{\droptitle}
  \begin{center}
    \textsc{\textbf{\large \therubric{topprompt}:}} \hrulefill \\[\baselineskip]
%    \textbf{\Huge ABET assessment rubric: \therubric{thing}} \\[\baselineskip]
    \textbf{\Large ABET assessment rubric: \therubric{thing}} \\[\baselineskip]
    \textsc{\normalsize \therubric{course} (\therubric{term})}
  \end{center}
}

\newenvironment{rubrictable}[1]{
  \setcounter{totalcolnum}{#1}
  \setlength{\colwidth}{\textwidth - \firstcolwidth*\real{2}}
  \setlength{\colwidth}{\colwidth / \real{\value{totalcolnum}}}
  \begin{center}
    \begin{tabular}{p{\firstcolwidth} | *{\value{totalcolnum}}{p{\colwidth}}}
      \toprule
      \forloop{colnum}{1}{\value{colnum} < \value{totalcolnum}}{
%      %\forloop{colnum}{0}{\value{colnum} < \value{totalcolnum}}{
%        & \textbf{\Large \arabic{colnum}}
        &  %\textbf{\Large \arabic{colnum}}
      } \\ %\midrule
    }
    {
      \bottomrule
    \end{tabular}
  \end{center}
}

\newcommand{\rubriccat}[2]{
  \textbf{\Large #1} #2 \\[2eX]
}

\newcommand{\rubricdesc}[2]{& \textbf{#1} {\raggedright #2}}
