summaryrefslogtreecommitdiffstats
path: root/mkballots.sh
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2016-11-02 12:29:45 -0600
committerH. Peter Anvin <hpa@zytor.com>2016-11-02 12:29:45 -0600
commit9b81fd55d4b38bea3fbac9c819f5739db5a3e199 (patch)
tree2680842f7887674c2edddc10107f50f45bc3e5bc /mkballots.sh
parent924811b3823e666bfb2a7a9cd6482ef2b7d6ca48 (diff)
downloadballot-9b81fd55d4b38bea3fbac9c819f5739db5a3e199.tar.gz
ballot-9b81fd55d4b38bea3fbac9c819f5739db5a3e199.tar.xz
ballot-9b81fd55d4b38bea3fbac9c819f5739db5a3e199.zip
Add support for individually numbered score sheets
Allow generation of multiple individually numbered score sheets. For some reason this is really slow; it would be good to figure out if there is a way to speed this up in tikz. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'mkballots.sh')
-rwxr-xr-xmkballots.sh20
1 files changed, 15 insertions, 5 deletions
diff --git a/mkballots.sh b/mkballots.sh
index 3f2155a..bee2836 100755
--- a/mkballots.sh
+++ b/mkballots.sh
@@ -2,26 +2,36 @@
export PATH=$(realpath -s $(dirname "$0"))/bin:"$PATH"
if [ -z "$1" -o -z "$2" ]; then
set +x
- echo "Usage: $0 prefix numballots [batches]" 1>&2
+ echo "Usage: $0 prefix numballots [batches [scoresheets]]" 1>&2
exit 1
fi
nbatch="${3:-1}"
perbatch="${2:-100}"
+scoresheets="${4:-1}"
prefix="$1"
proj="${proj:-tab2016}"
+shuf='shuf --random-source=/dev/urandom'
if [ -z "$proj" ]; then
proj=tab2016
fi
sdaps="sdaps $proj"
rm -rf "$proj"
-sed -e "s:%%CANDIDATES%%:shuf --random-source=/dev/urandom < '$proj'.cand:e" \
- -e 'T' -e 's/^\(.*\)$/\\choiceline{\1}/mg' "$proj".tex > "$proj".pp.tex
+sed -e "s:%%CANDIDATES%%:$shuf < '$proj'.cand:e" \
+ -e 'T' -e 's/^\(.*\)$/\\choiceline{\1}/mg' \
+ "$proj".tex > "$proj".pp.tex
$sdaps setup_tex "$proj".pp.tex
rm "$proj".pp.tex
+# Produce a tiebreakers file for csvconv.pl so we can reproduce the output
+seq 1 $(wc -l < "$proj".cand) | $shuf | tr '\n' ',' | \
+ sed -e 's/,$/\n/' > "$proj"/tiebreakers.csv
+# Generate score sheets (one PDF with blank ID, one with individual numbers)
scoresheet.pl "$proj" > "$proj"/scoresheet.tex
+genids.pl "$prefix"/MT $scoresheets 1 > "$proj"/scoresheet.ids
+scoresheet.pl "$proj" "$proj"/scoresheet.ids > "$proj"/scoresheets.tex
cd "$proj"
-pdflatex scoresheet.tex ; pdflatex scoresheet.tex
+pdflatex scoresheet.tex && pdflatex scoresheet.tex
pdfmerge questionnaire.pdf scoresheet.pdf chkalign.pdf
+pdflatex scoresheets.tex && pdflatex scoresheets.tex
cd ..
bdigits=$(echo -n $((nbatch)) | wc -c)
start=1
@@ -33,4 +43,4 @@ for (( batch=1 ; batch <= nbatch ; batch++ )); do
start=$((start + perbatch))
done
# Make a backup copy of the project directory
-tar cvvfJ "$proj".sdaps.tar.xz "$proj"
+tar cvvfJ "$proj".sdaps.tar.xz "$proj" "$proj".tex "$proj".cand