Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds utility scripts #115

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ canvaslms.pdf: ${SRC_DIR}/cli/submissions.tex
canvaslms.pdf: ${SRC_DIR}/cli/grade.tex
canvaslms.pdf: ${SRC_DIR}/cli/results.tex
canvaslms.pdf: ${SRC_DIR}/grades/grades.tex
canvaslms.pdf: ${SRC_DIR}/cli/utils.tex

${SRC_DIR}/%.tex: ${SRC_DIR}/%.nw
${MAKE} -C $(dir $@) $(notdir $@)
Expand Down
1 change: 1 addition & 0 deletions doc/canvaslms.tex
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ \part{The command-line interface}
\input{../src/canvaslms/cli/grade.tex}
\input{../src/canvaslms/cli/results.tex}
\input{../src/canvaslms/grades/grades.tex}
\input{../src/canvaslms/cli/utils.tex}


\printbibliography
Expand Down
6 changes: 6 additions & 0 deletions src/canvaslms/cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ login.py
login.tex
results.py
results.tex
utils.tex
OLIstats
afstats
lsgroup
pfstats

5 changes: 5 additions & 0 deletions src/canvaslms/cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ MODULES+= submissions.py submissions.tex
MODULES+= grade.py grade.tex
MODULES+= results.py results.tex

MODULES+= utils.tex
MODULES+= afstats pfstats
MODULES+= lsgroup
MODULES+= OLIstats

.PHONY: all
all: ${MODULES}

Expand Down
157 changes: 157 additions & 0 deletions src/canvaslms/cli/utils.nw
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
\chapter{Some utitlity scripts}

\section{Grade statistics}

We have different scripts for assignments with P/F and A-F grading scales.
For these scripts, we simply count how many have each certain grade.
We also output how many have not been graded yet, and how many have not
submitted anything.

\subsection{Statistics for P/F grading scale}

<<pfstats>>=
#!/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
@

\subsection{Statistics for A-F grading scale}

<<afstats>>=
#!/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
@

\subsection{Results statistics for OLI tests}

We want to see how many students have taken the OLI tests.
We can't tell if they've passed or failed them without additional information.
If they have submitted them, we consider them done.
<<OLIstats>>=
#!/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
@


\section{List user's group memberships}

When we grade someone and report their result to Canvas, we want to check if
they're in the same group as someone else.
If so, we can't report a grade without reporting for the other student too.
<<lsgroup>>=
#!/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
@