Subversion Repositories wimsdev

Rev

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