qcm

Faire des qcm simplement - retour accueil

git clone git://bebou.netlib.re/qcm
Log | Files | Refs |

commit 1823e0f320220a63d217f1d269f8baa5c7be42a1
Auteurice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Wed,  6 Nov 2024 18:21:10 +0100

Premier commit

Usage :

qcm
qcm -u http://monsite.com
qcm -n 6
qcm -l /var/log/httpd/logs

Elles sont toutes composables

Diffstat:
A.gitignore | 2++
Amakefile | 7+++++++
Aqcm.sh | 51+++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,2 @@ +.*.sw? +qcm diff --git a/makefile b/makefile @@ -0,0 +1,7 @@ +PREFIX = /usr/local + +all: qcm + +install: + mkdir -p "${DESTDIR}${PREFIX}/bin" + cp qcm "${DESTDIR}${PREFIX}/bin" diff --git a/qcm.sh b/qcm.sh @@ -0,0 +1,51 @@ +#! /bin/sh + +while getopts "l:u:n:" opt; do + case $opt in + ( l | u | n) [ ! -z $OPTARG ] && eval "$opt='$OPTARG'" ;; + esac +done + +url="${u:-http://bebou.netlib.re}" +nbq="${n:-4}" +logs="$l" + +playout() { + <<-. cat + url : $url/$id + answers : $answers + + $dat + + total : $tot + . +} + +tmpd=$(mktemp -d XXX) +id=$(basename "$tmpd") + +trap "rm -rf $tmpd;exit" INT TERM +trap "kill 0" EXIT + +possibleanswers="ABCDEFGHIJQLMNOPQRSTUVWXYZ" +answers=$(echo "$possibleanswers" | sed -E "s/(.{$nbq}).*/\1/") + +tail -fn0 ${logs:-/var/log/nginx/access.log} | + stdbuf -o0 grep -E "GET /$id/[$answers]" >> $tmpd/in & + +while :;do + dat=$(< $tmpd/in sort -u -k1,1 | cut -d ' ' -f7 | cut -d'/' -f3 | sort | uniq -c | sort -rn) + tot=$(echo "$dat" | awk '{print $1}' | paste -s -d+ | bc) + clear + playout + sleep 0.2 +done + +#POUR LES QR CODE +# +#for a in A B C D;do +# qrencode -s1 -lL -m2 -t UTF8 -o $tmpd/$a "$url/$a" +#done +#qr=$(paste $tmpd/A $tmpd/B;paste $tmpd/C $tmpd/D) +#echo "$dat\n\n$tot\n\n$qr" +