Subversion Repositories wimsdev

Rev

Rev 15698 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2691 czzmrn 1
 
2
# This line prevents clashes of users with same login.
3
adduser_replace=nopass
4
wims_priv_cryptpass=allow
5
wims_deposit=!word 1 of $wims_deposit
6
!if $wims_deposit=$empty
12467 bpr 7
  !exit
2691 czzmrn 8
!endif
9
 
10
!if / isin $wims_deposit or .. isin $wims_deposit
12467 bpr 11
  error=bad_filename
12
  !exit
2691 czzmrn 13
!endif
14
 
15
d=!translate . to $ $ in $wims_deposit
16
d=!word -1 of $d
17
!if $d notwordof csv tsv txt
12467 bpr 18
  error=bad_filename
19
  !exit
2691 czzmrn 20
!endif
21
 
22
sdir=$wims_home/$wims_sesdir
23
t=!exec ftype $sdir/user-deposit
24
!if $t=$empty
12467 bpr 25
  !exit
2691 czzmrn 26
!endif
27
!if $t=binary
12467 bpr 28
  error=binary_upload
29
  !exit
2691 czzmrn 30
!endif
31
 
32
!sh grep . $sdir/user-deposit | awk '{print ":"$$0}' | tr '	"' ', ' >$sdir/user_deposit
33
file=wimshome/$wims_sesdir/user_deposit
34
 
5151 bpr 35
!read csv/gotlogin $file,login
36
 
37
!if $gotlogin=$empty
12467 bpr 38
  !read adm/class/initclass $wims_class,auth
39
  !if $auth_method notitemof $auth_method_list
40
    error=no_login
41
    !exit
42
  !else
43
    !read csv/gotlogin $file,external_auth
44
    !if $(gotexternal_auth)=$empty
45
      error=no_login_external_auth
46
      !exit
47
    !else
48
      extern=yes
49
    !endif
50
  !endif
2691 czzmrn 51
!endif
52
 
53
remark=
54
!if sheet isin $types or exam isin $types or average isin $types
12467 bpr 55
  remark=$remark noauto
2691 czzmrn 56
!endif
57
 
58
prop=no
11563 bpr 59
!if noauto iswordof $remark
12467 bpr 60
  !!or manual isin $types prop are changed now.
61
  remark=$remark noprop
2691 czzmrn 62
!else
12467 bpr 63
  !! pourquoi cette condition ???
64
  !if firstname isitemof $types and lastname isitemof $types
65
    prop=yes
66
  !endif
67
  !read adm/class/userremain.proc
2691 czzmrn 68
!endif
69
 
70
!if manual isin $types
12467 bpr 71
  manual=yes
2691 czzmrn 72
!endif
73
 
74
replacelist=$types
75
types=!replace , by ,up_ in up_$types
76
types_cnt=!itemcnt $types
77
gotcnt=!itemcnt $loglist
78
propcnt=0
79
gradecnt=0
3714 bpr 80
!reset missing erased bad added change badlogin
2691 czzmrn 81
processed=yes
5151 bpr 82
!! on parcourt la liste des lignes des bons logins
83
!for i = 1 to $gotcnt
84
  l=$(loglist[$i])
85
  l__=$(logtest[$i])
10372 bpr 86
  !reset up_firstname,up_lastname,up_email,up_password,up_comments,up_regnum,up_photourl,\
87
    up_vars,up_participate,up_external_auth,up_supervise,up_supervisable
5151 bpr 88
  !! fill in the fields ...
2691 czzmrn 89
  !distribute items $(dep_$l__) into $types
90
  !for m = 1 to $types_cnt
91
    typ=$(types[$m])
92
    !if Aup_var_ isin A$typ
93
      typ1=!replace internal up_var_ by  in $typ
10708 guerimand 94
      !if $typ1 isitemof $tv_listlocalname
13361 bpr 95
        up_vars=!append line $typ1=$($typ) to $up_vars
10708 guerimand 96
      !endif
2691 czzmrn 97
    !endif
10020 guerimand 98
  !next m
2691 czzmrn 99
  up_vars=!lines2rows $up_vars
5151 bpr 100
  !if $extern=yes
5775 bpr 101
    up_external_auth=!lowercase $l
5659 bpr 102
    l=!lookup $l in wimshome/$sclassdir/.userlist_external
5151 bpr 103
    !if $l=$empty
8057 bpr 104
      l=!lookup $l in wimshome/$sclassdir/.teacherlist_external
5151 bpr 105
    !endif
106
    !if $l=$empty
12467 bpr 107
      !if $idp_method=ldap
108
        !!define login_method
8057 bpr 109
        !read adm/class/initldap
12467 bpr 110
      !endif
5151 bpr 111
      !read adm/class/hashlogin $up_external_auth,$wims_class,$login_method
112
      l=$login
113
      !default up_password=!randint 1999999,3000000
114
    !endif
115
  !endif extern=yes
116
 
12467 bpr 117
  !! $l is now the login in all cases
2691 czzmrn 118
  exist=!defof user_exists in wimshome/$userdir/$l
119
  existsup=$exist
5151 bpr 120
  !if $existsup=yes
12467 bpr 121
    lfname=!defof user_lastname,user_firstname,user_external_auth in wimshome/$userdir/$l
122
    !default up_firstname=$(lfname[2])
123
    !default up_lastname=$(lfname[1])
124
    !default up_external_auth=$(lfname[3])
125
    !if $up_firstname!=$empty and $up_lastname!=$empty
126
      prop=yes
127
    !endif
5151 bpr 128
  !else
12467 bpr 129
    !!FIXME
5151 bpr 130
    !if $idp_method isitemof $idp_method_list and ($up_firstname=$empty or $up_lastname=$empty)
15049 obado 131
      !! I am not sure of what we must do : priority to the idp or to the modification of the teacher ?
5660 bpr 132
      !distribute item $up_firstname, $up_lastname into up_firstname_ , $up_lastname_
5151 bpr 133
      !read adm/class/idp_$idp_method $up_external_auth
5660 bpr 134
      !if $up_lastname_!=$empty
5151 bpr 135
        up_lastname=$up_lastname_
136
      !endif
137
      !if $up_firstname_!=$empty
138
        up_firstname=$up_firstname_
139
      !endif
140
      !if $up_firstname!=$empty and $up_lastname!=$empty
13361 bpr 141
        prop=yes
5151 bpr 142
      !endif
143
    !endif
8057 bpr 144
  !endif
2691 czzmrn 145
  !if $wims_superclass!=$empty and $wims_superclass!=$wims_class
12467 bpr 146
    participate=!defof user_participate in wimshome/$userdir/$l
147
    !if $wims_class notitemof $participate
148
      !if $wims_typename=course
149
        tmp=!defof class_parent in wimshome/log/classes/$wims_class/.def
150
        !if $(tmp)!=$empty and $tmp notitemof $participate
11563 bpr 151
          exist=
12467 bpr 152
        !endif
153
        !reset tmp
154
      !else
155
        exist=
11563 bpr 156
      !endif
157
    !endif
2691 czzmrn 158
  !endif
159
  !if $exist=yes
5151 bpr 160
    !if $prop=yes
12467 bpr 161
      !read adm/class/adduser $l
5151 bpr 162
    !endif
2691 czzmrn 163
  !else
12467 bpr 164
    exist2=!defof user_exists in wimshome/$userdir/.$l
165
    !if $exist2=yes
166
      erased=!append item $l to $erased
167
    !else
168
      missing=!append item $l to $missing
169
      !! ici aussi on a besoin d'avoir le nom et prenom
170
      !if $existsup=yes or ($up_firstname!=$empty and $up_lastname!=$empty and $up_password!=$empty)
171
        !if $prop=yes
172
          !if $userremain>0
173
            !read adm/class/adduser $l
174
            !if $l notitemof $bad
175
              added=!append item $l to $added
176
	            userremain=$[$userremain-1]
177
            !endif  l notitemof bad
178
          !else
179
            remark=$remark full
180
          !endif userremain
181
        !endif prop=yes
2691 czzmrn 182
      !else
12467 bpr 183
        !if $up_password=$empty
13761 bpr 184
          pass_missing=yes
12467 bpr 185
        !endif
186
      !endif firstname ... non empty
187
    !endif exist2=yes
5151 bpr 188
  !endif exist=yes
2691 czzmrn 189
!next l
190
!if $change!=$empty
12467 bpr 191
  !read adm/class/mkuserlist
192
  !if $classtype isin 24
193
    !read adm/gateway/mkteacherlist
194
  !endif
195
  !read adm/class/stat
196
  wims_class_log=spreadsheet userinfo by $wims_realuser
2691 czzmrn 197
!endif
198
missing=!listcomplement $added in $missing
199
change=!listcomplement $added in $change
4445 bpr 200
added=!listcomplement $missing in $added
2691 czzmrn 201
 
202
!if $manual=yes
12467 bpr 203
  fn=wimshome/log/classes/$wims_class/.grades
204
  fu=wimshome/log/classes/$wims_class/.userlist
205
  l=!record 1 of $fn
206
  t=!line 2 of $l
207
  n=!itemcnt $t
208
  n=$[$n-2]
209
  !if $n<1
210
    error=no_manual
211
    !exit
212
  !endif
213
  otypes=nn
2691 czzmrn 214
  !for i=1 to $n
12467 bpr 215
    otypes=$otypes,o_$i
2691 czzmrn 216
  !next i
12467 bpr 217
  first=$l
218
  cnt=!recordcnt $fn
14341 guerimand 219
  list_grades=$empty
12467 bpr 220
  !for u=2 to $cnt
221
    l=!record $u of $fn
222
    uu=!item 1 of $l
14341 guerimand 223
    list_grades=!append item $uu to $list_grades
12467 bpr 224
    orig_$uu=!item 2 to -1 of $l
225
  !next u
226
  !writefile $fn :$first
227
  cnt=!recordcnt $fu
14341 guerimand 228
  list_user=$empty
229
  joker=--
18602 bpr 230
  tmp1=!replace internal up_manual by in $types
231
  tmp2=!replace internal o_ by in $otypes
232
  list_mod=!listintersect $tmp1 and $tmp2
233
  !for ii=1 to $cnt
234
    l_=!record $ii of $fu
12467 bpr 235
    u=!item 3 of $l_
14341 guerimand 236
    list_user=!append item $u to $list_user
15698 bpr 237
    !distribute items $(dep_$u) into $types
12467 bpr 238
    !distribute items $(orig_$u) into $otypes
239
    t_=!defof user_firstname user_lastname in wimshome/$userdir/$u
240
    !for i=1 to $n
18602 bpr 241
      !if $i isitemof $list_mod
242
        !if $(up_manual$i)=$empty
243
          l_=!item $i+1 of $(orig_$u)
244
        !else
245
          l_=$[$(up_manual$i)]
246
        !endif
247
        !if NaN isin $l_ or Inf isin $l_ or $l_<0 or $l_>100000 or $l_=$empty
248
          l_=$joker
249
        !endif
250
      !else
251
        l_=!item $i+1 of $(orig_$u)
12467 bpr 252
      !endif
253
      !default l_=$(o_$i)
14341 guerimand 254
      !default l_=$joker
12467 bpr 255
      t_=!append item $l_ to $t_
256
    !next i
14341 guerimand 257
    t_=!replace internal $joker by $empty in $t_
12467 bpr 258
    !appendfile $fn :$u,$t_
18602 bpr 259
  !next ii
14341 guerimand 260
  list_deleted=!listcomplement $list_user in $list_grades
261
  !if $list_deleted!=$empty
262
    nbdel=!itemcnt $list_deleted
263
    !for k=1 to $nbdel
264
      !appendfile $fn :$(list_deleted[$k]),$(orig_$(list_deleted[$k]))
265
    !next k
266
  !endif
12467 bpr 267
  wims_class_log=spreadsheet grades by $wims_realuser
2691 czzmrn 268
!endif