Rev 10132 | Blame | Compare with Previous | Last modification | View Log | RSS feed
!! putCSV is at very early draft state. Do not use it yet (WIP).
!if $wims_class=$empty
error=unauthorized (no class defined)
!exit
!endif
t=!exec ftype $wims_home/$wims_sesdir/user-deposit
!if $t=$empty
error=empty
!exit
!endif
!if $t=binary
error=binary
!exit
!endif
!sh cd $wims_home/$wims_sesdir\
grep . user-deposit | awk '{print ":"$$0}' | tr ' "' ', ' >user_deposit\
rm -f user-deposit >/dev/null
file=$wims_sesdir/user_deposit
n=!recordcnt wimshome/$file
!if $n<=0
error=empty
!exit
!endif
loglist=
!for i=1 to $n
l=!record $i of wimshome/$file
!if $gotlogin!=$empty
ltest=!item $gotlogin of $l
ll=!wordcnt $ltest
!if $ll=1 and # notin $ltest
dep_$ltest=$l
loglist=!append item $ltest to $loglist
!endif
!else
!if $i>3
error=no_login
!exit
!endif
!if login isitemof $l
l=!lower $l
types=!nospace $l
gotlogin=!positionof item login in $l
gotlogin=!item 1 of $gotlogin
!endif
!endif
!next i
!if $gotlogin=$empty
error=no_login
!exit
!endif
remark=
!if sheet isin $types or exam isin $types or average isin $types
remark=$remark noauto
!endif
prop=no
!if noauto iswordof $remark or manual isin $types
remark=$remark noprop
!else
!if firstname isitemof $types and lastname isitemof $types
prop=yes
!read adm/class/userremain.proc
!endif
!endif
!if manual isin $types
manual=yes
!endif
replacelist=$types
types=!replace , by ,up_ in up_$types
gotcnt=!itemcnt $loglist
propcnt=0
gradecnt=0
!reset missing erased bad added change
processed=yes
!for l in $loglist
!reset up_firstname,up_lastname,up_email,up_password,up_comments,up_regnum
!distribute items $(dep_$l) into $types
exist=!defof user_exists in wimshome/log/classes/$wims_class/.users/$l
!if $exist=yes
!if $prop=yes
!read adm/class/adduser $l
!endif
!else
exist2=!defof user_exists in wimshome/log/classes/$wims_class/.users/.$l
!if $exist2=yes
erased=!append item $i to $erased
!else
missing=!append item $l to $missing
!if $up_firstname!=$empty and $up_lastname!=$empty and $up_password!=$empty
!if $prop=yes
!if $userremain>0
!read adm/class/adduser $l
!if $l notwordof $bad
added=!append item $l to $added
!else
userremain=$[$userremain-1]
!endif
!else
remark=$remark full
!endif
!endif
!endif
!endif
!endif
!next l
missing=!listcomplement $added in $missing
!if $change!=$empty
!read adm/class/mkuserlist
!read adm/class/stat
wims_class_log=spreadsheet userinfo
!endif
!if $manual=yes
fn=wimshome/log/classes/$wims_class/.grades
fu=wimshome/log/classes/$wims_class/.userlist
l=!record 1 of $fn
t=!line 2 of $l
n=!itemcnt $t
n=$[$n-2]
!if $n<1
error=no_manual
!exit
!endif
otypes=nn
!for i=1 to $n
otypes=$otypes,o_$i
!next i
first=$l
cnt=!recordcnt $fn
!for u=2 to $cnt
l=!record $u of $fn
uu=!item 1 of $l
orig_$uu=!item 2 to -1 of $l
!next u
!writefile $fn :$first
cnt=!recordcnt $fu
!for i=1 to $cnt
l_=!record $i of $fu
u=!item 3 of $l_
!distribute items $(dep_$u) into $types
!distribute items $(orig_$u) into $otypes
t_=!defof user_firstname user_lastname in wimshome/log/classes/$wims_class/.users/$u
!for i=1 to $n
l_=$[$(up_manual$i)]
!if NaN isin $l_ or Inf isin $l_ or $l_<0 or $l_>100000 or $(up_manual$i)=$empty
l_=
!endif
!default l_=$(o_$i)
t_=!append item $l_ to $t_
!next i
!appendfile $fn :$u,$t_
!next u
wims_class_log=spreadsheet grades
!endif