From: paul Date: Tue, 13 Oct 2015 01:38:11 +0000 (+0000) Subject: enable attendance modification from course list X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=c89909a0589793b2cbad5b143f4698a6ec16c048;p=lobster enable attendance modification from course list svn path=/trunk/; revision=74 --- diff --git a/actions/update_course.sh b/actions/update_course.sh index e98892e..a5ba8ce 100755 --- a/actions/update_course.sh +++ b/actions/update_course.sh @@ -1,6 +1,6 @@ #!/bin/zsh -# Copyright 2014 Paul Hänsch +# Copyright 2014, 2015 Paul Hänsch # # This file is part of Confetti. # @@ -22,6 +22,7 @@ cgi_post course="${_POST[course]}" tempfile="temp/$course" coursefile="ical/$course" +attfile="$_DATA/mappings/attendance" # DURATION: uid="${_POST[UID]}" @@ -91,6 +92,21 @@ case "${_POST[action]}" in echo -n "Location: ?p=courses&edit=$course\n\n" ;; update) + attendance=() + for att in attendance attendance{0..100}; do + [ -n "${_POST[$att]}" ] && attendance+=("${_POST[$att]}") + done + sed -rn 's:^'$course'\t(.+)$:\1:p' "$attfile" |while read card; do + touch "$_DATA/vcard/$card" + done + sed -i -r '/^'$course'\t(.+)$/d' "$attfile" + for each in $attendance; do + echo "$course\t$each" + done >>"$attfile" + sed -rn 's:^'$course'\t(.+)$:\1:p' "$attfile" |while read card; do + touch "$_DATA/vcard/$card" + done + echo "END:VEVENT\r" >>"$tempfile" echo "END:VCALENDAR\r" >>"$tempfile" mv "$tempfile" "$coursefile"