\chapter{Some utitlity scripts}% ===> this file was generated automatically by noweave --- better not edit it

\section{Grade statistics}

\nwfilename{utils.nw}\nwbegincode{1}\sublabel{NW487MPY-2O6i44-1}\nwmargintag{{\nwtagstyle{}\subpageref{NW487MPY-2O6i44-1}}}\moddef{pfstats~{\nwtagstyle{}\subpageref{NW487MPY-2O6i44-1}}}\endmoddef\nwstartdeflinemarkup\nwenddeflinemarkup
#!/bin/bash

COURSE="$1"
ASSIGNMENT="$2"
shift 2

results=$(mktemp)
canvaslms submissions -c $COURSE -a "$ASSIGNMENT" $@ | cut -f 4- > $results

function get_results() \{
  cat $results
\}

function print_stats() \{
  total=$(get_results | wc -l)
  echo "Total:     $total (100%)"
  Ps=$(get_results | grep ^P | wc -l)
  echo "P:         $Ps ($(((100 * $Ps / $total)))%)"
  Fxs=$(get_results | grep ^Fx | wc -l)
  echo "Fx:        $Fxs ($(((100 * $Fxs / $total)))%)"
  Fs=$(get_results | grep ^F[^x] | wc -l)
  echo "F:         $Fs ($(((100 * $Fs / $total)))%)"
  remaining=$(get_results | egrep "^[^PF].*[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}" | wc -l)
  echo "Remaining: $remaining ($(((100 * $remaining / $total)))%)"
  nothing=$(get_results | grep "^[^a-fA-F0-9]*$" | wc -l)
  echo "Nothing:   $nothing ($(((100 * $nothing / $total)))%)"
\}

print_stats
\nwnotused{pfstats}\nwendcode{}\nwbegincode{2}\sublabel{NW487MPY-3UhZF0-1}\nwmargintag{{\nwtagstyle{}\subpageref{NW487MPY-3UhZF0-1}}}\moddef{afstats~{\nwtagstyle{}\subpageref{NW487MPY-3UhZF0-1}}}\endmoddef\nwstartdeflinemarkup\nwenddeflinemarkup
#!/bin/bash

COURSE="$1"
ASSIGNMENT="$2"
shift 2

results=$(mktemp)
canvaslms submissions -c $COURSE -a "$ASSIGNMENT" $@ | cut -f 4- > $results

function get_results() \{
  cat $results
\}

function print_stats() \{
  total=$(get_results | wc -l)
  echo "Total:     $total (100%)"
  As=$(get_results | grep ^A | wc -l)
  echo "A:         $As ($(((100 * $As / $total)))%)"
  Bs=$(get_results | grep ^B | wc -l)
  echo "B:         $Bs ($(((100 * $Bs / $total)))%)"
  Cs=$(get_results | grep ^C | wc -l)
  echo "C:         $Cs ($(((100 * $Cs / $total)))%)"
  Ds=$(get_results | grep ^D | wc -l)
  echo "D:         $Ds ($(((100 * $Ds / $total)))%)"
  Es=$(get_results | grep ^E | wc -l)
  echo "E:         $Es ($(((100 * $Es / $total)))%)"
  Fxs=$(get_results | grep ^Fx | wc -l)
  echo "Fx:        $Fxs ($(((100 * $Fxs / $total)))%)"
  Fs=$(get_results | grep ^F[^x] | wc -l)
  echo "F:         $Fs ($(((100 * $Fs / $total)))%)"
  remaining=$(get_results | egrep "^[^A-F].*[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}" | wc -l)
  echo "Remaining: $remaining ($(((100 * $remaining / $total)))%)"
  nothing=$(get_results | grep "^[^a-fA-F0-9]*$" | wc -l)
  echo "Nothing:   $nothing ($(((100 * $nothing / $total)))%)"
\}

print_stats
\nwnotused{afstats}\nwendcode{}\nwbegindocs{3}\nwdocspar

\section{List user's group memberships}

\nwenddocs{}\nwbegincode{4}\sublabel{NW487MPY-9HYCI-1}\nwmargintag{{\nwtagstyle{}\subpageref{NW487MPY-9HYCI-1}}}\moddef{lsgroup~{\nwtagstyle{}\subpageref{NW487MPY-9HYCI-1}}}\endmoddef\nwstartdeflinemarkup\nwenddeflinemarkup
#!/bin/bash

course="$1"
user="$2"

users="/tmp/users-$course.csv"

if test "$#" -lt 2; then
  echo "$0 course user [group prefix]"
  exit 1
fi

group_prefix="$3"
if test -z "$group_prefix"; then
  group_prefix=".*"
fi

test -e "$users" || \\
  canvaslms users -sc "$course" -G "$group_prefix" | cut -f 2- > "$users"

groups="$(egrep "$group_prefix" "$users" | egrep "$user" | cut -f 1)"
if test -z "$groups"; then
  echo "User $user is in no group"
  exit 1
else
  IFS=$'\\n'
  for group in $groups; do
    egrep "^$group" "$users"
  done
fi
\nwnotused{lsgroup}\nwendcode{}\nwbegindocs{5}\nwdocspar

\section{Results statistics for OLI tests}

\nwenddocs{}

\nwixlogsorted{c}{{afstats}{NW487MPY-3UhZF0-1}{\nwixd{NW487MPY-3UhZF0-1}}}%
\nwixlogsorted{c}{{lsgroup}{NW487MPY-9HYCI-1}{\nwixd{NW487MPY-9HYCI-1}}}%
\nwixlogsorted{c}{{OLIstats}{NW487MPY-3WsRZx-1}{\nwixd{NW487MPY-3WsRZx-1}}}%
\nwixlogsorted{c}{{pfstats}{NW487MPY-2O6i44-1}{\nwixd{NW487MPY-2O6i44-1}}}%
\nwbegincode{6}\sublabel{NW487MPY-3WsRZx-1}\nwmargintag{{\nwtagstyle{}\subpageref{NW487MPY-3WsRZx-1}}}\moddef{OLIstats~{\nwtagstyle{}\subpageref{NW487MPY-3WsRZx-1}}}\endmoddef\nwstartdeflinemarkup\nwenddeflinemarkup
#!/bin/bash

COURSE="$1"
ASSIGNMENT="$2"
shift 2

results=$(mktemp)
canvaslms submissions -c $COURSE -a "Test:.*$ASSIGNMENT" $@ | \\
  cut -f 4- > $results

function get_results() \{
  cat $results
\}

function print_stats() \{
  total=$(get_results | wc -l)
  echo "Total:     $total (100%)"
  year=$(date +%Y)
  done=$(get_results | grep $year- | wc -l)
  echo "done:      $done ($(((100 * $done / $total)))%)"
  nothing=$(get_results | grep "^[^a-fA-F0-9]*$" | wc -l)
  echo "Nothing:   $nothing ($(((100 * $nothing / $total)))%)"
\}

print_stats

\nwnotused{OLIstats}\nwendcode{}
