Subversion Repositories wimsdev

Rev

Rev 10714 | 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
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
7
    olddon=!sh cd $wims_home/log/classes/$tv_Sclass/.users/;\
8
grep -r user__ * | awk -F= '$$2!=""{print $$0}'
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
10714 bpr 14
      !writefile wimshome/s2/$wims_session/oldtechvar.don $olddon
9979 guerimand 15
    !endif
16
!endif
17
!if EMPTY=$olddon
18
    !reset olddon
19
!endif
20
nb=!linecnt $olddon
21
!if $nb<=0
22
    error=nooldvar
23
    job=listvar
24
    !changeto $job.proc
25
    !exit
26
!endif
27
 
28
listclsuser=$empty
29
nuser=!recordcnt wimshome/log/classes/$wims_class/.userlist
30
!if $nuser>0
31
    !for k=1 to $nuser
10714 bpr 32
      u=!record $k of wimshome/log/classes/$wims_class/.userlist
33
      listclsuser=!append item $(u[3]) to $listclsuser
9979 guerimand 34
    !next k
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
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
10714 bpr 54
      listforbname3=!listunion $listforbname3 and $varname
9979 guerimand 55
    !else
10714 bpr 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
64
      !else
65
          !if $varname isitemof $listlocalname
66
            listmodify=!listunion $listmodify and $varname
67
          !else
68
            listforbname2=!listunion $listforbname2 and $varname
69
          !endif
70
      !endif
9979 guerimand 71
    !endif
72
!next k
73
listnew=!listcomplement $listforbname1 in $listnew
74
!! check list of value for new techvar
75
!for k in $listnew
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
10714 bpr 81
      listnew=!listcomplement $k in $listnew
82
      listforbname3=!listunion $listforbname3 and $k
9979 guerimand 83
    !endif
84
!next k
85
!! check list of value for modify techvar
86
!for k in $listmodify
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
10714 bpr 95
      listmodify=!listcomplement $k in $listmodify
96
      listforbname3=!listunion $listforbname3 and $k
9979 guerimand 97
    !endif
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
108
    error=nooldvar
109
    job=listvar
110
    !changeto $job.proc
111
    !exit
112
!endif
113
 
10714 bpr 114
!! --------------------------- le processus make est à reprendre avec les nouvelles variables.
9979 guerimand 115
 
116
!if $subjob=make
10714 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
10549 guerimand 137
!! make the new technical variable
10714 bpr 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
10820 guerimand 146
   techvar=!lower $techvar
10714 bpr 147
   !fileappend wimshome/log/classes/$wims_class/.techvar :$techvar\
10549 guerimand 148
$listval
149
    !fileappend wimshome/log/classes/$tv_Sclass/.indextechvar :$techvar,$wims_class,$[$nb]
150
!! put value in participant file.
9979 guerimand 151
    nb=!linecnt $liste
152
    !for k=1 to $nb
10714 bpr 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
9979 guerimand 157
    !next k
158
    !restart module=adm/class/techvar
159
!endif
160
 
161
!if $subjob=modify
162
    !if $techvar notitemof $listmodify
10714 bpr 163
      error=oldvar_badvar
164
      !reset subjob
165
      !exit
9979 guerimand 166
    !endif
167
    liste=!sh grep $techvar $wims_home/s2/$wims_session/oldtechvar.don
168
    !if $liste=$empty
10714 bpr 169
       error=oldvar_nouser
170
      !reset subjob
171
      !exit
9979 guerimand 172
    !endif
173
    nb=!linecnt $liste
10702 guerimand 174
    num0=!positionof item $techvar in $tv_listname
175
    num=$(tv_listtechvar[$num0;3])
176
    cls=!item $num0 of $tv_listcode
9979 guerimand 177
    !for k=1 to $nb
10714 bpr 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
9979 guerimand 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
10714 bpr 190
      nb=!recordcnt wimshome/log/classes/$wims_class/.techvar
191
      output=$empty
192
      !for k=1 to $nb
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
198
      !next k
9979 guerimand 199
        !filewrite wimshome/log/classes/$wims_class/.techvar $output
200
    !endif
201
    !restart module=adm/class/techvar&job=userlist
202
!endif