Subversion Repositories wimsdev

Rev

Rev 17206 | Rev 17327 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23 reyssat 1
# Variable calculations should be done in this file.
2
# It is read and interpreted by wims for all valid calls to the module.
2368 bpr 3
!read adm/class/classlang names.phtml
13046 bpr 4
!! number of lines in a record of a sheet
15763 guerimand 5
!set sheetrecordlimit=11
13046 bpr 6
 
10339 bpr 7
!if $job!=$empty and $job notwordof text modify
12701 bpr 8
  job1=$job
9
  !!for the icon and the title
10339 bpr 10
  !if $job=getsource
11
    job1=sheetsource
12
  !endif
13
  !if $job=prep_putsource
14
    job1=putsource
15
  !endif
10512 bpr 16
  !default name_$(job1)=$(wims_name_$job1)
17
  wims_ariane=!append line sheetadmin,1,cmd=resume to $wims_ariane
18
  !if $(name_$(job1))!=$empty or
19
    wims_ariane=!append line "$(name_$(job1))",8, to $wims_ariane
20
  !endif
10339 bpr 21
!else
22
  !set wims_ariane=!append line sheetadmin,8 to $wims_ariane
23
!endif
24
!set wims_ariane_self=no
25
 
9670 guerimand 26
scnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheets
27
!if $sheet>$scnt
12312 bpr 28
  wims_infoshow=yes
29
  !setdef wims_infoshow=$wims_infoshow in wimshome/sessions/$wims_session/var.stat
9670 guerimand 30
!endif
9655 guerimand 31
!if $cmd=resume
12312 bpr 32
  !bound infoshow within yes,no default $wims_infoshow
33
  wims_infoshow=$infoshow
34
  !setdef wims_infoshow=$wims_infoshow in wimshome/sessions/$wims_session/var.stat
9655 guerimand 35
!endif
36
 
11965 guerimand 37
tmp=!defof MAX_SHEETS\
11967 guerimand 38
MAX_REQUIRE\
39
DF_SEVERITY\
40
MIN_WEIGHT\
16729 guerimand 41
MAX_WEIGHT\
42
MAX_EXOS in wimshome/public_html/bases/sys/define.conf
43
!distribute line $tmp into max_sheets,require_limit,df_severity,min_weight,max_weight,max_exos
23 reyssat 44
title_limit=80
45
desc_limit=4000
46
etitle_limit=100
47
edesc_limit=400
12316 bpr 48
 
8255 bpr 49
require_limit=$[$require_limit/10]
10305 guerimand 50
wims_prefix=class user tmp n sharing sharable techvar
23 reyssat 51
srcname=wimshome/$wims_sesdir/home_sheet.src
52
wims_helper=chapter=3
53
 
1533 guerimand 54
!readproc tabletheme
23 reyssat 55
!if $wims_user!=supervisor
12312 bpr 56
  error=not_supervisor
57
  !exit
23 reyssat 58
!endif
1980 guerimand 59
!if $job=chseries
12312 bpr 60
  !changeto chseries.proc
1980 guerimand 61
!endif
11633 bpr 62
!readproc adm/levelname.phtml
1980 guerimand 63
!readproc adm/search_engine/names.$lang
64
!readproc adm/search_engine/mklist_form.proc
23 reyssat 65
 
66
today=!char 1 to 8 of $wims_now
67
thisyear=!char 1 to 4 of $today
68
 
7290 bpr 69
!if $class_expiration=$empty
12312 bpr 70
  !defread wimshome/log/classes/$wims_class/.def
71
  !if $wims_superclass!=$empty
72
    class_expiration=!defof class_expiration in wimshome/log/classes/$wims_superclass/.def
73
  !endif
23 reyssat 74
!endif
1533 guerimand 75
 
23 reyssat 76
!if $class_expiration=$empty
12312 bpr 77
  error=bad_class
78
  !exit
23 reyssat 79
!endif
80
 
81
sharers=
82
sharing1=!defof sharable_sheet in wimshome/log/classes/$wims_class/neighbors
83
!for c in $sharing1
12312 bpr 84
  d=!defof sharing_sheet in wimshome/log/classes/$c/neighbors
85
  !if $d issametext $wims_class
86
    sharers=!append item $c to $sharers
87
  !endif
23 reyssat 88
!next c
11967 guerimand 89
 
12089 guerimand 90
!if $save!=$empty
12312 bpr 91
  jquery_defined=!defof jquery_defined in themes/$wims_theme/header.phtml
17311 guerimand 92
  expmon=!char 6 to 7 of $expdate
93
  expday=!char 9 to 10 of $expdate
94
  expyear=!char 1 to 4 of $expdate
12312 bpr 95
  !if $expday>=1 and $expday<=31 and $expmon>=1 and $expmon<=12 \
14335 bpr 96
      and $expyear>=$thisyear and $expyear<=$thisyear+1 \
97
      and $expyear$expmon$expday>$today \
98
      and $expyear$expmon$expday<=$class_expiration \
99
      and N notin $expmon$expday$expyear
12312 bpr 100
    expiration=$expyear$expmon$expday
101
    expdate=$expiration
102
  !else
103
    !if $expyear$expmon$expday>$class_expiration
104
      !readproc adm/date.phtml $class_expiration
105
      error=toolate
106
    !else
107
      expiration=$class_expiration
108
      expdate=$expiration
109
    !endif
110
  !endif
23 reyssat 111
!endif
12089 guerimand 112
 
8255 bpr 113
!if $sheet>$max_sheets
12312 bpr 114
  error=bad_maxsheet
115
  !exit
3062 bpr 116
!endif
117
 
118
!if $sheet<1
12312 bpr 119
  error=bad_sheet
120
  !exit
23 reyssat 121
!endif
122
# menu preparation
123
!if $job!=$empty and $job iswordof \
14335 bpr 124
    prep_activate prep_erase prep_expire prep_putsource prep_modify
12312 bpr 125
  data=!record $sheet of wimshome/log/classes/$wims_class/sheets/.sheets
15763 guerimand 126
  !distribute lines $data into active,expire,title,desc,bla,comment,attribut,exodescshow,formal_hidden_condition,indivtechvar
12387 bpr 127
  !if $modif!=$empty
128
    exo=!record $modif of wimshome/log/classes/$wims_class/sheets/.sheet$sheet
129
    !distribute lines $exo into D_,p_
130
    !read getparm $p_ exotrymax
131
  !endif
12312 bpr 132
  error=$job
7801 bpr 133
  !if $expire < $today
134
    test_expire=$expire,$today
135
  !endif
15859 guerimand 136
  !if $indivtechvar!=$empty and ($job=prep_modify or $job=prep_activate)
15763 guerimand 137
    !readproc adm/vfilter/listvarfilter.proc
138
    nb=!positionof item $indivtechvar in $tv_listcode
139
    !if $nb!=$empty
140
      don=!line $nb of $tv_listtechvar
141
      !distribute item $don into name,classid,number
142
      don=!record $number of wimshome/log/classes/$classid/.techvar
143
      listval=!line 2 of $don
15910 guerimand 144
      nbtechvalue=!itemcnt $listval
15763 guerimand 145
    !else
146
      !reset indivtechvar
147
    !endif
148
  !endif
15859 guerimand 149
  !if $job=prep_activate
16729 guerimand 150
     nb=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$sheet
151
     !if $nb>$max_exos
152
       error=toomanyexo
153
       !reset job
154
       !exit
155
     !endif
15859 guerimand 156
     !read adm/sheet/checkdepindiv
157
     !if $sheet isitemof $sheet_dependancy and $sheet isitemof $sheet_indivtechvar
158
        error=depindiv
159
        !reset job
160
     !endif
161
  !endif
12312 bpr 162
  !exit
23 reyssat 163
!endif
164
scnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheets
165
!if $job=erase and $sheet<=$scnt and $sheet>=1
12312 bpr 166
  test=
167
  !for s=$sheet to $scnt
168
    l=!record $s of wimshome/log/classes/$wims_class/sheets/.sheets
169
    l=!line 1 of $l
170
    !if $l>0
171
     test=notclean
172
    !endif
173
  !next s
174
  !if $test=$empty
175
    update_field=0
176
    !read proc/update.docindex
177
    !read update.sheet
23 reyssat 178
  !endif
16728 guerimand 179
  !read adm/sheet/writeweights
12312 bpr 180
  !restart module=home
23 reyssat 181
!endif
182
 
9679 guerimand 183
!if $job=duplicate
12312 bpr 184
  !changeto $job.proc
9679 guerimand 185
!endif
186
 
23 reyssat 187
!if $job=expire
12312 bpr 188
  !distribute item 1,2 into update_field,update_content
189
  !read update.sheet
190
  job=
23 reyssat 191
!endif
192
 
193
!if $job=hide
12312 bpr 194
  !distribute item 1,3 into update_field,update_content
195
  !read update.sheet
196
  job=
23 reyssat 197
!endif
198
 
8093 bpr 199
!if $job=reactivate
12312 bpr 200
  !distribute item 1,1 into update_field,update_content
201
  !read update.sheet
202
  job=
23 reyssat 203
!endif
204
 
205
!if $job=deactivate
12312 bpr 206
  !read var.proc.deactivate
23 reyssat 207
!else
12312 bpr 208
  confirmed=!replace word share by $ in $confirmed
209
  confirmed=!singlespace $confirmed
23 reyssat 210
!endif
211
 
212
activetest=!record $sheet of wimshome/log/classes/$wims_class/sheets/.sheets
213
a_=!line 1 of $activetest
214
a_=!trim $a_
215
expp=!line 2 of $activetest
216
!default expiration=$expp
7801 bpr 217
 
218
!if $expiration>$class_expiration or $test_expire!=$empty
12312 bpr 219
  expiration=$class_expiration
23 reyssat 220
!endif
7801 bpr 221
 
23 reyssat 222
ecnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$sheet
15767 guerimand 223
wims_listexo=!values v for v=1 to $ecnt
224
!setdef wims_listexo=$wims_listexo in wimshome/sessions/$wims_session/var.stat
1513 guerimand 225
activetest=!replace line number 3 by $ecnt in $activetest
23 reyssat 226
 
227
!if $job=putsource and $a_=0
12312 bpr 228
  source=!trim $source
229
  !writefile $srcname $source
230
  putcnt=!recordcnt $srcname
231
  !for i=1 to $putcnt
232
    s_=!record $i of $srcname
233
    n_=!linecnt $s_
234
    bad_source=$i
13046 bpr 235
    !if $n_>=5 and $n_<=$sheetrecordlimit
12312 bpr 236
      !distribute lines $s_ into di,pa,re,we,ti,de
237
      !for k in re,we,di,pa,ti,de
238
        $k=!trim $($k)
239
        w$k=!wordcnt $($k)
240
      !next k
241
      !if NaN isin $[$re]$[$we] or $[$wre*$wwe*$wdi]!=1 or $wpa>1 or $ti=$empty or\
14335 bpr 242
          .. isin $di or $re<0 or $we<0 or ($re>0 and $we=0)
12312 bpr 243
         error=bad_source
17206 guerimand 244
         ssource=$source
12312 bpr 245
        !exit
246
      !endif
247
      ti=!char 1 to $etitle_limit of $ti
248
      de=!char 1 to $edesc_limit of $de
249
      source_$i=$s_
250
      last=$i
251
    !else
13046 bpr 252
      # last record may be empty
12312 bpr 253
      !if $i!=$putcnt
254
        error=bad_source
17206 guerimand 255
        ssource=$source
12312 bpr 256
        !exit
257
      !endif
258
    !endif
259
  !next i
260
  !for i=1 to $last
261
    !appendfile wimshome/log/classes/$wims_class/sheets/.sheet$sheet :$(source_$i)
262
  !next i
17206 guerimand 263
  !reset ssource
23 reyssat 264
!endif
265
 
266
!if $activetest!=$empty
12312 bpr 267
  sheet_exist=yes
268
  !default expiration=!line 2 of $activetest
269
  activetest=!line 1 of $activetest
270
  exocnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$sheet
23 reyssat 271
!else
12312 bpr 272
  sheet_exist=no
273
  activetest=-1
274
  exocnt=0
275
  !default expiration=$class_expiration
23 reyssat 276
!endif
277
 
278
!if $job=getsource and $sheet_exist=yes
13640 obado 279
  !writefile $srcname
12312 bpr 280
  !for i=1 to $exocnt
281
    l=!record $i of wimshome/log/classes/$wims_class/sheets/.sheet$sheet
13640 obado 282
    # replace eventual html entities so it will not insert \n in textarea
283
    l=!replace internal &#13;&#10; by $ $ in $l
12312 bpr 284
    !appendfile $srcname $$:$l
285
  !next i
13640 obado 286
  !appendfile $srcname
12312 bpr 287
  !exit
23 reyssat 288
!endif
289
 
10062 guerimand 290
!readproc adm/vfilter/listvarfilter.proc
23 reyssat 291
!if $allow=yes
12312 bpr 292
  !if $tv_listname=$empty
293
    !bound allowtype within all,none,select default all
294
  !else
295
    !bound allowtype within all,none,select,techvar default all
296
  !endif
12994 guerimand 297
  !read adm/scorerestriction get
12312 bpr 298
  IPlist=$_output
299
  IPlist=!translate ,;\
23 reyssat 300
* to $    $ in $IPlist
12312 bpr 301
  IPlist=!trim $IPlist
302
  !if $allowtype=select and $IPlist=$empty and $save!=$empty
303
    allowtype=all
304
  !endif
305
  !if $allowtype=all
306
    allow_parm=
307
  !endif
308
  !if $allowtype=none
309
    allow_parm=none
310
  !endif
311
  !if $allowtype=select
312
    allow_parm=$IPlist
313
  !endif
10305 guerimand 314
 
12312 bpr 315
  !if $allowtype=techvar
316
    !readproc adm/vfilter/shexselect.proc $sheet
317
  !endif
10305 guerimand 318
!endif
11810 guerimand 319
 
11967 guerimand 320
!! --------------- get/save severity parameters
321
rec=!record 0 of wimshome/log/classes/$wims_class/sheets/.severity
322
!if $save!=$empty
12312 bpr 323
  !distribute word $df_severity into t1,t2,t3
324
  !bound weight between $min_weight and $max_weight default $t1
325
  !bound formulaA between integer 0 and 6 default $t2
326
  !bound formulaB between integer 0 and 2 default $t3
327
  nb=!linecnt $rec
13059 guerimand 328
  !! define maxscore default =10 (not general variable maybe we should ?)
329
  !if $nb=0
13060 bpr 330
    rec=10
13059 guerimand 331
  !endif
12312 bpr 332
  new=$weight $formulaA $formulaB
13058 guerimand 333
  !if $sheet>$nb-1
12312 bpr 334
    !for k=$nb+1 to $sheet+1
14335 bpr 335
      rec=!append line $df_severity to $rec
13058 guerimand 336
    !next k
12312 bpr 337
  !endif
338
  rec=!replace line number $[$sheet+1] by $new in $rec
339
  !writefile wimshome/log/classes/$wims_class/sheets/.severity $rec
11967 guerimand 340
!endif
341
rec=!line $[$sheet+1] of $rec
342
!distribute word $rec into s_weight,s_formulaA,s_formulaB
343
!default weight=$s_weight
344
!default formulaA=$s_formulaA
345
!default formulaB=$s_formulaB
346
 
10062 guerimand 347
!! ---- save modification of allow parameters
10305 guerimand 348
!if $save!=$empty
10062 guerimand 349
  !if $sharers!=$empty and $allowshare=1
16798 guerimand 350
    !if $allowtype=techvar
16801 guerimand 351
      !readproc adm/vfilter/validtechvar.proc $allowtechvar\
16798 guerimand 352
$sharers
353
      !if $output=1
354
        setclass=!items2words $wims_class,$sharers
355
      !else
356
        error=badallowshare
357
        allowshare=0
358
        setclass=$wims_class
359
      !endif
16801 guerimand 360
    !else
361
      setclass=!items2words $wims_class,$sharers
16798 guerimand 362
    !endif
10062 guerimand 363
  !else
12312 bpr 364
    setclass=$wims_class
10062 guerimand 365
  !endif
366
  !if $allow_parm=$empty
12312 bpr 367
    !sh for c in $setclass; do rm -f $wims_home/log/classes/$$c/.$sheet; done
10062 guerimand 368
  !else
16777 guerimand 369
    setclass=!words2items $setclass
12312 bpr 370
    !for c in $setclass
371
      !writefile wimshome/log/classes/$c/.$sheet $allow_parm
372
    !next c
10062 guerimand 373
  !endif
374
  wims_class_log=sheet $sheet allow $allowtype $allowshare by $wims_realuser
10305 guerimand 375
!endif
10062 guerimand 376
!! ---- end of saving
23 reyssat 377
 
10062 guerimand 378
!if $allow=$empty or $save!=$empty
379
!! --- read saving configuration for allow parameters initial time and after saving
12312 bpr 380
  !readproc adm/vfilter/shexread.proc $sheet
11810 guerimand 381
!! to distribute IPlist content into variable
12312 bpr 382
  !read adm/scorerestriction put\
11810 guerimand 383
$IPlist
10062 guerimand 384
!endif
10244 guerimand 385
old_allowtype=$allowtype
386
old_allowtechvar=$allowtechvar
10062 guerimand 387
!reset allow,save
388
!! --- end of reading
23 reyssat 389
 
390
expmon=!char 5,6 of $expiration
391
expday=!char 7,8 of $expiration
392
expyear=!char 1,2,3,4 of $expiration
393
 
394
!if $job!=text
13640 obado 395
  # remove \n from textareas
12312 bpr 396
  mod_desc=!replace internal $\
13640 obado 397
$ by $ $ in $mod_desc
12312 bpr 398
  mod_comment=!replace internal $\
13640 obado 399
$ by $ $ in $mod_comment
12312 bpr 400
  !if $title_save$desc_save=$empty
401
    rec=!record $sheet of wimshome/log/classes/$wims_class/sheets/.sheets
13831 bpr 402
    !distribute lines $rec into bidon,bidon,title_save,desc_save,prpage_save,\
15763 guerimand 403
      comment_save,attribut_save,exodescshow_save,formal_hidden_condition_save,\
404
      indivtechvar_save
15860 guerimand 405
      !bound indivtechvar_save within $empty,$tv_listlocalcode default $empty
12312 bpr 406
  !endif
407
  title=$title_save
408
  desc=$desc_save
409
  prpage=$prpage_save
410
  comment=$comment_save
13825 bpr 411
  exodescshow=$exodescshow_save
14441 guerimand 412
  !readproc adm/vfilter/convertformat.proc human\
413
$formal_hidden_condition_save
414
  hidden_condition=$output_convertformat
15763 guerimand 415
  indivtechvar=$indivtechvar_save
23 reyssat 416
!else
12312 bpr 417
  !if $title=$empty
418
    error=no_title
419
    !exit
420
  !endif
12801 obado 421
  title=!singlespace $title
422
  title=!char 1 to $title_limit of $title
423
  title=!replace internal : by &#58; in $title
424
 
12312 bpr 425
  desc=!replace internal $\
13640 obado 426
$ by $ $ in $desc
12801 obado 427
  desc=!singlespace $desc
428
  desc=!char 1 to $desc_limit of $desc
429
  desc=!replace internal : by &#58; in $desc
430
 
12312 bpr 431
  comment=!replace internal $\
13640 obado 432
$ by $ $ in $comment
12312 bpr 433
  comment=!singlespace $comment
12801 obado 434
 
16919 guerimand 435
  !! --- manage of personalized presentation of sheet page
436
  !if $prpage isitemof no,yes or $prpage=$empty
437
    !bound prpage within yes,no default no
438
  !else
439
    !! old gestion of prpage with doc link
440
    !! deprecated but keep for background compatibility
441
    prpage=!word 1 of $prpage
442
    prpage=!char 1 to 100 of $prpage
443
    !if .. isin $prpage or / notin $prpage
444
      prpage=no
12312 bpr 445
    !endif
16919 guerimand 446
    !if $prpage!=no
447
      test=!fileexists wimshome/log/classes/$wims_class/doc/$prpage.def
448
      !if $test!=yes
449
        prpage=no
450
      !endif
451
    !endif
12312 bpr 452
  !endif
16919 guerimand 453
 
14441 guerimand 454
  !if $hidden_condition!=$empty
455
    !readproc adm/vfilter/convertformat.proc formal\
456
$hidden_condition
457
    formal_hidden_condition=$output_convertformat
16195 guerimand 458
    !if $output_error!=$empty
459
      error=badtechvarname $output_error
460
    !endif
461
    !readproc adm/vfilter/convertformat.proc human\
462
$formal_hidden_condition
463
    hidden_condition=$output_convertformat
14441 guerimand 464
  !else
465
    formal_hidden_condition=$empty
466
  !endif
15763 guerimand 467
  !! indivtechvar is not modifiable when sheet is activated.
468
  !if $activetest>0
469
    rec=!record $sheet of wimshome/log/classes/$wims_class/sheets/.sheets
470
    indivtechvar=!item 10 of $rec
471
  !endif
15860 guerimand 472
  !bound indivtechvar within $empty,$tv_listlocalcode default $empty
12312 bpr 473
  !if $sheet_exist=yes
474
    !distribute lines 2\
23 reyssat 475
$expiration into update_field,update_content
12312 bpr 476
    !read update.sheet
12801 obado 477
 
12312 bpr 478
    !distribute lines 3\
23 reyssat 479
$title into update_field,update_content
12312 bpr 480
    !read update.sheet
12801 obado 481
 
12312 bpr 482
    !distribute lines 4\
23 reyssat 483
$desc into update_field,update_content
12312 bpr 484
    !read update.sheet
12801 obado 485
 
12312 bpr 486
    !distribute lines 5\
23 reyssat 487
$prpage into update_field,update_content
12312 bpr 488
    !read update.sheet
12801 obado 489
 
12312 bpr 490
    !distribute lines 6\
1969 guerimand 491
$comment into update_field,update_content
12312 bpr 492
    !read update.sheet
13825 bpr 493
 
494
    !distribute lines 7\
495
$attribut into update_field,update_content
496
    !read update.sheet
14646 bpr 497
 
13825 bpr 498
    !distribute lines 8\
499
$exodescshow into update_field,update_content
500
    !read update.sheet
14646 bpr 501
 
14441 guerimand 502
    !distribute lines 9\
503
$formal_hidden_condition into update_field,update_content
504
    !read update.sheet
505
 
15763 guerimand 506
    !if $activetest=0
507
      !distribute lines 10\
508
$indivtechvar into update_field,update_content
509
    !read update.sheet
510
 
511
    !endif
512
 
12312 bpr 513
  !else
514
    !appendfile wimshome/log/classes/$wims_class/sheets/.sheets :0\
23 reyssat 515
$expiration\
516
$title\
517
$desc\
1969 guerimand 518
$prpage\
13825 bpr 519
$comment\
520
$attribut\
14441 guerimand 521
$exodescshow\
15763 guerimand 522
$formal_hidden_condition\
15859 guerimand 523
$empty
524
    indivtechvar=$empty
12312 bpr 525
    sheet_exist=yes
526
    activetest=0
527
    sheet=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheets
528
    !writefile wimshome/log/classes/$wims_class/sheets/.sheet$sheet
14242 obado 529
    message=$name_createok
12312 bpr 530
  !endif
531
  title_save=$title
532
  desc_save=$desc
533
  prpage_save=$prpage
534
  comment_save=$comment
13825 bpr 535
  attribut_save=$attribut
536
  exodescshow_save=$exodescshow
14441 guerimand 537
  formal_hidden_condition_save=$formal_hidden_condition
15763 guerimand 538
  indivtechvar_save=$indivtechvar
23 reyssat 539
!endif
540
 
16919 guerimand 541
!if $job=prpage and $prpage_save=yes
542
  test=!fileexists wimshome/sessions/$wims_session/user-deposit
543
  !if $test=yes
544
    msg2wims_primitives=if ifval for while\
545
      reload fold ref link docform form resource calcform embed\
546
      exercise tool doc example help adm tooltip href slib\
547
      def define comment draw canvasdraw audio glossary
548
      !sh rm -f $wims_home/$wims_sesdir/sheet$(sheet).def;\
549
          $wims_home/bin/msg2wims $wims_home/$wims_sesdir/user-deposit $wims_home/$wims_sesdir/sheet$(sheet).def;\
550
          if [ -e $wims_home/$wims_sesdir/sheet$(sheet).def ]; then\
551
            mv $wims_home/$wims_sesdir/sheet$(sheet).def $wims_home/log/classes/$wims_class/sheets/sheet$(sheet).def;\
552
            mv $wims_home/$wims_sesdir/user-deposit $wims_home/log/classes/$wims_class/sheets/sheet$(sheet).src;\
553
          else\
554
            rm -f $wims_home/$wims_sesdir/user-deposit;\
555
          fi;
556
  !endif
557
!endif
558
 
23 reyssat 559
!if $job=activate and $[$activetest]=0
15859 guerimand 560
  !read adm/sheet/checkdepindiv
561
  !if $sheet isitemof $sheet_dependancy and $sheet isitemof $sheet_indivtechvar
562
    error=depindiv
563
    !reset job
564
    !exit
565
  !endif
15857 guerimand 566
  !read adm/sheet/writeweights
12312 bpr 567
  !if $test_expire!=$empty
568
    !distribute items 2,$expiration into update_field,update_content
7801 bpr 569
    !read update.sheet
570
    !reset test_expire
12312 bpr 571
  !endif
572
  !distribute item 1,1 into update_field,update_content
573
  !read update.sheet
574
  activetest=1
575
  wims_class_log=activate sheet $sheet by $wims_realuser
23 reyssat 576
!endif
577
 
13208 obado 578
!! only delete or move items when sheet has not been activated
579
!if $activetest=0
580
  # delete an item
581
  !if $job=delete and $delete>0 and $delete<=$exocnt
14105 guerimand 582
    !read adm/sheet/sheetexam.shift sheet,$sheet,,$delete
13208 obado 583
    delete=
584
    exocnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheet$sheet
585
  !endif
23 reyssat 586
 
14104 guerimand 587
  # move to specific position
14113 guerimand 588
  !if $job=moveto and $movetarget>=1 and $movetarget<=$[$exocnt+1] and $movesource!=$movetarget and $movesource>=1 and $movesource<=$exocnt
14105 guerimand 589
    !read adm/sheet/sheetexam.shift sheet,$sheet,$movetarget,$movesource
14104 guerimand 590
  !endif
591
 
15763 guerimand 592
  # change individualisation of sheet with a technical variable
15860 guerimand 593
  !if $job=indiv and $indivtechvar!=0 and $indivtechvar!=$empty
15763 guerimand 594
    !read indiv.proc
595
  !endif
16022 bpr 596
 
13432 bpr 597
!endif
598
 
23 reyssat 599
# modify an item
600
!if $job=modify and $modif>0 and $modif<=$exocnt
12312 bpr 601
  !if $activetest=0
602
    exo=!record $modif of wimshome/log/classes/$wims_class/sheets/.sheet$sheet
603
    !distribute lines $exo into D_,p_
13315 bpr 604
    ####
12312 bpr 605
    iniparm=$p_
12387 bpr 606
    !read getparm $iniparm exo random qnum exotrymax
12312 bpr 607
    exocnt_=!itemcnt $get_exo
13315 bpr 608
    #### common with addmodule
12387 bpr 609
    iniparm2=!replace internal & by $\
610
$ in $iniparm
611
    iniparm2_cnt=!linecnt $iniparm2
612
    new_iniparm=
613
    equal==
12312 bpr 614
    !if $get_random=0
615
      !for i=1 to $get_qnum
16037 bpr 616
        update_order=!append item $(update_ex$i) to $update_order
12312 bpr 617
      !next
618
      get_exo=$(get_exo[$update_order])
619
      !for v in $get_exo
13760 bpr 620
        new_iniparm=!append line exo=$v to $new_iniparm
12312 bpr 621
      !next
622
      !for u=1 to $iniparm2_cnt
623
        l=!line $u of $iniparm2
624
        !if exo$equal notin $l
13760 bpr 625
          new_iniparm=!append line $l to $new_iniparm
12312 bpr 626
        !endif
627
      !next
13760 bpr 628
      new_iniparm=!replace internal $\
629
$ by & in $new_iniparm
12312 bpr 630
      new_iniparm=!nospace $new_iniparm
631
      p_=$new_iniparm
7354 bpr 632
    !endif
12387 bpr 633
    !if $get_exotrymax!=$mod_exotrymax
634
      tmp=!nospace $mod_exotrymax
635
      !if exotrymax isin $p_
13315 bpr 636
        !if $tmp!=$empty
637
          p_=!replace internal exotrymax=$get_exotrymax by exotrymax=$tmp in $p_
638
        !else
639
          p_=!replace internal exotrymax=$get_exotrymax by in $p_
640
        !endif
12400 bpr 641
      !else
12387 bpr 642
        !if $tmp!=$empty
12400 bpr 643
          p_=$p_&exotrymax=$tmp
12387 bpr 644
          !reset mod_exotrymax
645
        !endif
646
      !endif
647
      p_=!nospace $p_
12400 bpr 648
      p_=!replace internal && by & in $p_
12387 bpr 649
      !reset tmp
650
    !endif
651
 
13315 bpr 652
    #####
15910 guerimand 653
    mod_indiv=!listintersection $mod_indiv and $listval
654
    !bound mod_weight between $min_weight and $max_weight default 1
12312 bpr 655
    !bound mod_require between 0 and $[10*$require_limit] default 0
15910 guerimand 656
    !if $mod_indiv!=$empty
16022 bpr 657
      nbvalue=!itemcnt $listval
15910 guerimand 658
      !distribute item $max_weight,$[10*$require_limit],$min_weight,0 into limitM_weight,limitM_require,limitm_weight,limitm_require
659
      !for type in weight,require
660
        tmp=$(mod_$type)
661
        !for k=1 to $nbvalue
662
          !bound $type$k between $(limitm_$type) and $(limitM_$type) default $tmp
663
          !if $($type$k)!=$tmp
664
            mod_$type=$(mod_$type);$(listval[$k]),$($type$k)
665
          !endif
666
        !next k
16022 bpr 667
      !next type
15910 guerimand 668
    !endif
12312 bpr 669
    mod_title=!singlespace $mod_title
670
    mod_desc=!singlespace $mod_desc
671
    mod_comment=!singlespace $mod_comment
672
    mod_title=!char 1 to $etitle_limit of $mod_title
673
    mod_desc=!char 1 to $edesc_limit of $mod_desc
674
    mod_comment=!char 1 to $edesc_limit of $mod_comment
4528 bpr 675
  !endif
12312 bpr 676
  !if $mod_feedback notsametext $empty
14646 bpr 677
    !reset mod_feedback_tmp
678
    tmpcnt=!itemcnt $(mod_feedback[;1])
679
    !for t_=1 to $tmpcnt
680
      mod_feedback_=$(mod_feedback[$t_;])
681
      mod_feedback_lim=$(mod_feedback_[2])
682
      mod_feedback_lim2=$(mod_feedback_[3])
683
      !bound mod_feedback_lim between 0 and 11 default 10
684
      !bound mod_feedback_lim2 between 0  and $mod_feedback_lim default 0
685
      mod_feedback_=!nospace $(mod_feedback_[1])
686
      mod_feedback_test=!replace = by _ in $mod_feedback_
687
      !if cmd_new notin $mod_feedback_test
688
        mod_feedback_=!nospace $mod_feedback_&cmd=new
689
      !endif
690
      !if adm/doc isin $mod_feedback_ and job_read notin $mod_feedback_test
691
        mod_feedback_=$mod_feedback_&job=read
692
      !endif
693
      mod_feedback_tmp=!append line $mod_feedback_,$mod_feedback_lim,$mod_feedback_lim2 to $mod_feedback_tmp
694
    !next
695
    mod_feedback=!lines2rows $mod_feedback_tmp
4528 bpr 696
  !endif
7290 bpr 697
 
12312 bpr 698
  exo=$modif
699
  !if $activetest=0
700
    update_content=$D_\
23 reyssat 701
$p_\
702
$mod_require\
703
$mod_weight\
704
$mod_title\
705
$mod_desc\
1969 guerimand 706
$mod_dep\
4528 bpr 707
$mod_comment\
12316 bpr 708
$mod_feedback\
15763 guerimand 709
$mod_attribut\
710
$mod_indiv
12312 bpr 711
    update_field=0
712
    !read adm/class/update.exo
4864 bpr 713
 !else
12312 bpr 714
    !distribute lines 5\
7290 bpr 715
$mod_title into update_field,update_content
12312 bpr 716
    !read adm/class/update.exo
717
    !distribute lines 6\
7290 bpr 718
$mod_desc into update_field,update_content
12312 bpr 719
    !read adm/class/update.exo
720
    !distribute lines 8\
7290 bpr 721
$mod_comment into update_field,update_content
12312 bpr 722
    !read adm/class/update.exo
723
    !distribute lines 9\
7290 bpr 724
$mod_feedback into update_field,update_content
12312 bpr 725
    !read adm/class/update.exo
12316 bpr 726
    !distribute lines 10\
727
$mod_attribut into update_field,update_content
728
    !read adm/class/update.exo
12312 bpr 729
  !endif
7290 bpr 730
 
12316 bpr 731
  !distribute items $ into mod_title,mod_desc,mod_weight,mod_require,mod_dep,\
15763 guerimand 732
    mod_comment,mod_feedback,mod_attribut,mod_indiv
23 reyssat 733
!endif
734
 
735
!if $[$activetest]=0
12312 bpr 736
  erasable=yes
737
  scnt=!recordcnt wimshome/log/classes/$wims_class/sheets/.sheets
738
  !for s=$sheet+1 to $scnt
739
    l=!record $s of wimshome/log/classes/$wims_class/sheets/.sheets
740
    l=!line 1 of $l
741
    !if $l>0
742
      erasable=no
743
    !endif
744
  !next s
23 reyssat 745
!endif
746
 
3245 guerimand 747
!if $back=1 and $error=$empty
12312 bpr 748
  !restart module=home
7020 bpr 749
!endif