Faire des qcm simplement - retour accueil
git clone git://bebou.netlib.re/qcm
Log | Files | Refs | README |
commit 55e944dc88139bcad243fd08b2eded5c4862309b parent dd37deddbe1ad2f3d5842fd3a87150a07fd33727 Auteurice: Arthur Pons <arthur.pons@unistra.fr> Date: Tue, 12 Nov 2024 18:53:28 +0100 Ajout de l'option -e pour un mode "examen" Diffstat:
M | qcm.sh | | | 34 | ++++++++++++++++++++++++---------- |
1 file changed, 24 insertions(+), 10 deletions(-)
diff --git a/qcm.sh b/qcm.sh @@ -44,14 +44,18 @@ gplot() gnuplot -e " calcandshow() { - local plotcmd; plotcmd="$1" + local plotcmd hide; plotcmd="$1";hide="$2" if [ -z "$uniqueanswers" ];then tot=0 else - groupedanswers=$(echo "$uniqueanswers" | - grep -Eo "/$id/[^ ]+ " | cut -d'/' -f3- | # PARSAGE DE LOG - sed 's,%\([0-9A-F][0-9A-F]\),\\\\\x\1,g' | xargs printf "%b\n" | - grep -v "^$" | - sort | uniq -c | sort -rn | $plotcmd ) + if [ -n "$hide" ];then + groupedanswers= + else + groupedanswers=$(echo "$uniqueanswers" | + grep -Eo "/$id/[^ ]+ " | cut -d'/' -f3- | # PARSAGE DE LOG + sed 's,%\([0-9A-F][0-9A-F]\),\\\\\x\1,g' | xargs printf "%b\n" | + grep -v "^$" | + sort | uniq -c | sort -rn | $plotcmd ) + fi tot=$(echo "$uniqueanswers" | wc -l) fi @@ -92,16 +96,25 @@ demander() { tail -fn0 "$logs" | stdbuf -oL grep -E "$pattern" > $tmpd/notif & # PARSAGE DE LOG tail2pid=$! - calcandshow "$plotcmd" + calcandshow "$plotcmd" "$hide" cat $tmpd/notif | while read newanswer ;do uniqueanswers=$(< $tmpd/in sort $uopt -k1,1) - [ "$olduniqueanswers" != "$uniqueanswers" ] && calcandshow "$plotcmd" + [ "$olduniqueanswers" != "$uniqueanswers" ] && calcandshow "$plotcmd" "$hide" olduniqueanswers="$uniqueanswers" done & disppid=$! read _ < /dev/tty - kill $disppid $tail1pid $tail2pid; rm $tmpd/in + kill $disppid $tail1pid $tail2pid + + if [ -n "$hide" ];then + uniqueanswers=$(< $tmpd/in sort $uopt -k1,1) + calcandshow "$plotcmd" + read _ < /dev/tty + uniqueanswers=;groupedanswers=;tot=0 + fi + + rm $tmpd/in } nbq=4 @@ -111,11 +124,12 @@ plotcmd="cat" url="http://bebou.netlib.re" logs="/var/log/nginx/access.log" -while getopts "hgl:u:" opt; do +while getopts "hegl:u:" opt; do case $opt in ( l | u ) [ ! -z $OPTARG ] && eval "$opt='$OPTARG'" ;; ( g ) command -v gnuplot && plotcmd="gplot" ;; ( h ) usage; exit ;; + ( e ) hide="yes";; ( * ) echo "Option inconnue, voir l'aide en lançant qcm -h";exit 1;; esac done