File: oldvar.proc

package info (click to toggle)
wims 2%3A4.29a%2Bdfsg1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 185,704 kB
  • sloc: xml: 366,687; javascript: 120,570; ansic: 62,341; java: 62,170; sh: 7,744; perl: 3,937; yacc: 3,217; cpp: 1,915; lex: 1,805; makefile: 1,084; lisp: 914; pascal: 601; python: 520; php: 318; asm: 7
file content (202 lines) | stat: -rw-r--r-- 6,353 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
!! search old technical variable. variable without values are forget
!if $version_class>=5
  !exit
!endif
olddon=!record 0 of wimshome/s2/$wims_session/oldtechvar.don
!if $olddon=$empty or $subjob=$empty
  olddon=!sh cd $wims_home/log/classes/$tv_Sclass/.users/;\
grep -r user__ * | awk -F= '$$2!=""{print $$0}'
  olddon=!replace internal :!set user__ by , in $olddon
  olddon=!replace internal = by , in $olddon
  !if $olddon=$empty
    !writefile wimshome/s2/$wims_session/oldtechvar.don EMPTY
  !else
    !writefile wimshome/s2/$wims_session/oldtechvar.don $olddon
  !endif
!endif
!if EMPTY=$olddon
  !reset olddon
!endif
nb=!linecnt $olddon
!if $nb<=0
  error=nooldvar
  job=listvar
  !changeto $job.proc
  !exit
!endif

listclsuser=$empty
nuser=!recordcnt wimshome/log/classes/$wims_class/.userlist
!if $nuser>0
  !for k=1 to $nuser
    u=!record $k of wimshome/log/classes/$wims_class/.userlist
    listclsuser=!append item $(u[3]) to $listclsuser
  !next k
!endif
listlocalname=!item $tv_listlocal of $tv_listname

!! ------ description of used variables :
!! listforbname1 : contient les noms de variables non chargeables car affects galement  des participants extrieurs  la classe
!! listforbname2 : le nom est dj utilis comme une variable globale (non modifiable localement)
!! listforbname3 : nom de variable non exploitable ou liste des valeurs trop longue.
!! listnew : variable ajoutable en variable locale
!! listmodify : variable locale modifiable
!! listlogin_$name : contient la liste des logins contenant une valeur pour la variable name
!! listval_$name : liste des diffrentes valeurs trouves pour la variable name

!for k=1 to $nb
  l=!line $k of $olddon
  !distribute item $l into varuser,varname,varval
  name2=!text select 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ in $varname
  name2=!nospace $name2
  n=!charcnt $name2
  !if $n>$MAXcharname or $n<1
    listforbname3=!listunion $listforbname3 and $varname
  !else
    varname=$name2
    !if $varname notitemof $tv_listallname
      # eventualy a new vartech
      listnew=!listunion $listnew and $varname
      # precheck condition of localisation (no participant use it outside class)
      !if $varuser notitemof $listclsuser
        listforbname1=!listunion $listforbname1 and $varname
      !endif
    !else
      !if $varname isitemof $listlocalname
        listmodify=!listunion $listmodify and $varname
      !else
        listforbname2=!listunion $listforbname2 and $varname
      !endif
    !endif
  !endif
!next k
listnew=!listcomplement $listforbname1 in $listnew
!! check list of value for new techvar
!for k in $listnew
  newval=!sh grep $k $wims_home/s2/$wims_session/oldtechvar.don
  newval=!column 3 of $newval
  newval=!listuniq $newval
  nb=!itemcnt $newval
  !if $nb>$MAXnbvalue
    listnew=!listcomplement $k in $listnew
    listforbname3=!listunion $listforbname3 and $k
  !endif
!next k
!! check list of value for modify techvar
!for k in $listmodify
  newval=!sh grep $k $wims_home/s2/$wims_session/oldtechvar.don
  newval=!column 3 of $newval
  num=!positionof item $techvar in $tv_listname
  don=!record $num of wimshome/log/classes/$wims_class/.techvar
  oldval=!line 2 of $don
  val=!listuniq $newval,$oldval
  nb=!itemcnt $val
  !if $nb>$MAXnbvalue
    listmodify=!listcomplement $k in $listmodify
    listforbname3=!listunion $listforbname3 and $k
  !endif
!next k

!!debug olddon : $olddon\
!!listforbname1 : $listforbname1\
!!listforbname2 : $listforbname2\
!!listforbname3 : $listforbname3\
!!listnew : $listnew \
!!listmodify : $listmodify

!if $listnew$listforbname1$listforbname2$listmodify=$empty
  error=nooldvar
  job=listvar
  !changeto $job.proc
  !exit
!endif

!! --------------------------- le processus make est  reprendre avec les nouvelles variables.

!if $subjob=make
  nb=!itemcnt $tv_listlocal
  !if $nb>=$MAXtechvar
    error=toomanytechvar
    !reset subjob
    !exit
  !endif
  !if $techvar notitemof $listnew
    error=oldvar_badvar
    !reset subjob
    !exit
  !endif
  num=!replace internal / by _ in $wims_class
  !increase nb
  num=$(num)_$nb
  liste=!sh grep $techvar $wims_home/s2/$wims_session/oldtechvar.don
  !if $liste=$empty
    error=oldvar_nouser
    !reset subjob
    !exit
  !endif
  !! make the new technical variable
  listval=!column 3 of $liste
  listval=!listuniq $listval
  nbval=!itemcnt $listval
  !if $nbval>$MAXnbvalue
    error=badoldvaluesnb
    !reset subjob
    !exit
  !endif
  techvar=!lower $techvar
  !fileappend wimshome/log/classes/$wims_class/.techvar :$techvar\
$listval
  !fileappend wimshome/log/classes/$tv_Sclass/.indextechvar :$techvar,$wims_class,$[$nb]
  !! put value in participant file.
  nb=!linecnt $liste
  !for k=1 to $nb
    udon=!line $k of $liste
    !distribute item $udon into login,bb,val
    !setdef !set user_techvar_$num=$val in wimshome/log/classes/$tv_Sclass/.users/$login
    listlogin=!append item $login to $listlogin
  !next k
  !restart module=adm/class/techvar
!endif

!if $subjob=modify
  !if $techvar notitemof $listmodify
    error=oldvar_badvar
    !reset subjob
    !exit
  !endif
  liste=!sh grep $techvar $wims_home/s2/$wims_session/oldtechvar.don
  !if $liste=$empty
    error=oldvar_nouser
    !reset subjob
    !exit
  !endif
  nb=!linecnt $liste
  num0=!positionof item $techvar in $tv_listname
  num=$(tv_listtechvar[$num0;3])
  cls=!item $num0 of $tv_listcode
  !for k=1 to $nb
    udon=!line $k of $liste
    !distribute item $udon into login,bb,val
    !setdef !set user_techvar_$(cls)=$val in wimshome/log/classes/$tv_Sclass/.users/$login
    listlogin=!append item $login to $listlogin
  !next k
  !! modify list of values (if necessary) of technical variable
  listval=!column 3 of $liste
  listval=!listuniq $listval
  don=!record $num of wimshome/log/classes/$wims_class/.techvar
  oldval=!line 2 of $don
  new=!listcomplement $oldval in $listval
  !if $new!=$empty
    nb=!recordcnt wimshome/log/classes/$wims_class/.techvar
    output=$empty
    !for k=1 to $nb
      tmp=!record $k of wimshome/log/classes/$wims_class/.techvar
      !if $k=$num
        tmp=!replace line number 2 by $oldval,$new in $tmp
      !endif
      output=!append line :$tmp to $output
    !next k
    !filewrite wimshome/log/classes/$wims_class/.techvar $output
  !endif
  !restart module=adm/class/techvar&job=userlist
!endif