Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
9979 guerimand 1
!! search old technical variable. variable without values are forget
10714 bpr 2
!if $version_class>=5
3
  !exit
4
!endif
9979 guerimand 5
olddon=!record 0 of wimshome/s2/$wims_session/oldtechvar.don
6
!if $olddon=$empty or $subjob=$empty
12488 bpr 7
  olddon=!sh cd $wims_home/log/classes/$tv_Sclass/.users/;\
9979 guerimand 8
grep -r user__ * | awk -F= '$$2!=""{print $$0}'
12488 bpr 9
  olddon=!replace internal :!set user__ by , in $olddon
10
  olddon=!replace internal = by , in $olddon
11
  !if $olddon=$empty
12
    !writefile wimshome/s2/$wims_session/oldtechvar.don EMPTY
13
  !else
14
    !writefile wimshome/s2/$wims_session/oldtechvar.don $olddon
15
  !endif
9979 guerimand 16
!endif
17
!if EMPTY=$olddon
12488 bpr 18
  !reset olddon
9979 guerimand 19
!endif
20
nb=!linecnt $olddon
21
!if $nb<=0
12488 bpr 22
  error=nooldvar
23
  job=listvar
24
  !changeto $job.proc
25
  !exit
9979 guerimand 26
!endif
27
 
28
listclsuser=$empty
29
nuser=!recordcnt wimshome/log/classes/$wims_class/.userlist
30
!if $nuser>0
12488 bpr 31
  !for k=1 to $nuser
32
    u=!record $k of wimshome/log/classes/$wims_class/.userlist
33
    listclsuser=!append item $(u[3]) to $listclsuser
34
  !next k
9979 guerimand 35
!endif
36
listlocalname=!item $tv_listlocal of $tv_listname
37
 
10714 bpr 38
!! ------ description of used variables :
39
!! listforbname1 : contient les noms de variables non chargeables car affectés également à des participants extérieurs à la classe
40
!! listforbname2 : le nom est déjà utilisé comme une variable globale (non modifiable localement)
9979 guerimand 41
!! listforbname3 : nom de variable non exploitable ou liste des valeurs trop longue.
42
!! listnew : variable ajoutable en variable locale
43
!! listmodify : variable locale modifiable
44
!! listlogin_$name : contient la liste des logins contenant une valeur pour la variable name
10714 bpr 45
!! listval_$name : liste des différentes valeurs trouvées pour la variable name
9979 guerimand 46
 
47
!for k=1 to $nb
12488 bpr 48
  l=!line $k of $olddon
49
  !distribute item $l into varuser,varname,varval
50
  name2=!text select 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ in $varname
51
  name2=!nospace $name2
52
  n=!charcnt $name2
53
  !if $n>$MAXcharname or $n<1
54
    listforbname3=!listunion $listforbname3 and $varname
55
  !else
56
    varname=$name2
57
    !if $varname notitemof $tv_listallname
58
      # eventualy a new vartech
59
      listnew=!listunion $listnew and $varname
60
      # precheck condition of localisation (no participant use it outside class)
61
      !if $varuser notitemof $listclsuser
62
        listforbname1=!listunion $listforbname1 and $varname
63
      !endif
9979 guerimand 64
    !else
12488 bpr 65
      !if $varname isitemof $listlocalname
66
        listmodify=!listunion $listmodify and $varname
10714 bpr 67
      !else
12488 bpr 68
        listforbname2=!listunion $listforbname2 and $varname
10714 bpr 69
      !endif
9979 guerimand 70
    !endif
12488 bpr 71
  !endif
9979 guerimand 72
!next k
73
listnew=!listcomplement $listforbname1 in $listnew
74
!! check list of value for new techvar
75
!for k in $listnew
12488 bpr 76
  newval=!sh grep $k $wims_home/s2/$wims_session/oldtechvar.don
77
  newval=!column 3 of $newval
78
  newval=!listuniq $newval
79
  nb=!itemcnt $newval
80
  !if $nb>$MAXnbvalue
81
    listnew=!listcomplement $k in $listnew
82
    listforbname3=!listunion $listforbname3 and $k
83
  !endif
9979 guerimand 84
!next k
85
!! check list of value for modify techvar
86
!for k in $listmodify
12488 bpr 87
  newval=!sh grep $k $wims_home/s2/$wims_session/oldtechvar.don
88
  newval=!column 3 of $newval
89
  num=!positionof item $techvar in $tv_listname
90
  don=!record $num of wimshome/log/classes/$wims_class/.techvar
91
  oldval=!line 2 of $don
92
  val=!listuniq $newval,$oldval
93
  nb=!itemcnt $val
94
  !if $nb>$MAXnbvalue
95
    listmodify=!listcomplement $k in $listmodify
96
    listforbname3=!listunion $listforbname3 and $k
97
  !endif
9979 guerimand 98
!next k
99
 
100
!!debug olddon : $olddon\
101
!!listforbname1 : $listforbname1\
102
!!listforbname2 : $listforbname2\
103
!!listforbname3 : $listforbname3\
104
!!listnew : $listnew \
105
!!listmodify : $listmodify
106
 
107
!if $listnew$listforbname1$listforbname2$listmodify=$empty
12488 bpr 108
  error=nooldvar
109
  job=listvar
110
  !changeto $job.proc
111
  !exit
9979 guerimand 112
!endif
113
 
10714 bpr 114
!! --------------------------- le processus make est à reprendre avec les nouvelles variables.
9979 guerimand 115
 
116
!if $subjob=make
12488 bpr 117
  nb=!itemcnt $tv_listlocal
118
  !if $nb>=$MAXtechvar
119
    error=toomanytechvar
120
    !reset subjob
121
    !exit
122
  !endif
123
  !if $techvar notitemof $listnew
124
    error=oldvar_badvar
125
    !reset subjob
126
    !exit
127
  !endif
128
  num=!replace internal / by _ in $wims_class
129
  !increase nb
130
  num=$(num)_$nb
131
  liste=!sh grep $techvar $wims_home/s2/$wims_session/oldtechvar.don
132
  !if $liste=$empty
133
    error=oldvar_nouser
134
    !reset subjob
135
    !exit
136
  !endif
137
  !! make the new technical variable
138
  listval=!column 3 of $liste
139
  listval=!listuniq $listval
140
  nbval=!itemcnt $listval
141
  !if $nbval>$MAXnbvalue
142
    error=badoldvaluesnb
143
    !reset subjob
144
    !exit
145
  !endif
146
  techvar=!lower $techvar
147
  !fileappend wimshome/log/classes/$wims_class/.techvar :$techvar\
10549 guerimand 148
$listval
12488 bpr 149
  !fileappend wimshome/log/classes/$tv_Sclass/.indextechvar :$techvar,$wims_class,$[$nb]
150
  !! put value in participant file.
151
  nb=!linecnt $liste
152
  !for k=1 to $nb
153
    udon=!line $k of $liste
154
    !distribute item $udon into login,bb,val
155
    !setdef !set user_techvar_$num=$val in wimshome/log/classes/$tv_Sclass/.users/$login
156
    listlogin=!append item $login to $listlogin
157
  !next k
158
  !restart module=adm/class/techvar
9979 guerimand 159
!endif
160
 
161
!if $subjob=modify
12488 bpr 162
  !if $techvar notitemof $listmodify
163
    error=oldvar_badvar
164
    !reset subjob
165
    !exit
166
  !endif
167
  liste=!sh grep $techvar $wims_home/s2/$wims_session/oldtechvar.don
168
  !if $liste=$empty
169
    error=oldvar_nouser
170
    !reset subjob
171
    !exit
172
  !endif
173
  nb=!linecnt $liste
174
  num0=!positionof item $techvar in $tv_listname
175
  num=$(tv_listtechvar[$num0;3])
176
  cls=!item $num0 of $tv_listcode
177
  !for k=1 to $nb
178
    udon=!line $k of $liste
179
    !distribute item $udon into login,bb,val
180
    !setdef !set user_techvar_$(cls)=$val in wimshome/log/classes/$tv_Sclass/.users/$login
181
    listlogin=!append item $login to $listlogin
182
  !next k
183
  !! modify list of values (if necessary) of technical variable
184
  listval=!column 3 of $liste
185
  listval=!listuniq $listval
186
  don=!record $num of wimshome/log/classes/$wims_class/.techvar
187
  oldval=!line 2 of $don
188
  new=!listcomplement $oldval in $listval
189
  !if $new!=$empty
190
    nb=!recordcnt wimshome/log/classes/$wims_class/.techvar
191
    output=$empty
9979 guerimand 192
    !for k=1 to $nb
12488 bpr 193
      tmp=!record $k of wimshome/log/classes/$wims_class/.techvar
194
      !if $k=$num
195
        tmp=!replace line number 2 by $oldval,$new in $tmp
196
      !endif
197
      output=!append line :$tmp to $output
9979 guerimand 198
    !next k
12488 bpr 199
    !filewrite wimshome/log/classes/$wims_class/.techvar $output
200
  !endif
201
  !restart module=adm/class/techvar&job=userlist
9979 guerimand 202
!endif