Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
14105 guerimand 1
!!
2
!! move a field of a .sheet$sheet or .exam$exam to another position
3
!! keep correct score dependancy
4
!! input parameter :
5
!! item 1 : word exam or word sheet (...)
6
!! item 2 : num of exam or sheet to be tranform
7
!! item 3 : the position where the field be inserted after (next are translated). if empty, the field is deleted if 0 the field is placed in first position
8
!! item 4 : the position of the source field 
9
!! wims_read_parm : name of record
10
 
11
!distribute item $wims_read_parm into type_,num_,target_,source_
14128 guerimand 12
!! line number containt score dependancy (not same for exam and sheet)
14105 guerimand 13
!if $type_=sheet
14
  li_=7
15
!else
14109 guerimand 16
  li_=4
14105 guerimand 17
!endif
18
ecnt_=!recordcnt wimshome/log/classes/$wims_class/$(type_)s/.$(type_)$num_
19
!for e_=1 to $ecnt_
20
  field_$e_=!record $e_ of wimshome/log/classes/$wims_class/$(type_)s/.$(type_)$num_
21
  field_$e_=!line 1 to 10 of $(field_$e_)\
22
\
23
\
24
\
25
\
26
\
27
\
28
 
29
!next e_
30
list_=!values v for v=1 to $ecnt_
31
list_=!replace item number $source_ by $empty in $list_
32
!if $target_!=$empty
33
  !if $target_=0
34
    list_=$source_,$list_
35
  !else
14113 guerimand 36
    !if $target_=$[$ecnt_+1]
37
      list_=$list_,$source_
38
    !else
14198 guerimand 39
      !if $target_!=$empty
40
        !if $target_<$source_
41
          list_=!replace item $target_ by $source_,$target_ in $list_
42
        !else
43
          list_=!replace item $target_ by $target_,$source_ in $list_
44
        !endif
45
      !endif
14113 guerimand 46
    !endif
14105 guerimand 47
  !endif
48
!endif
49
list_=!nonempty item $list_
50
mlist_=$empty
51
!for i_=1 to $ecnt_
52
  p_=!positionof item $i_ in $list_
53
  !if $p_=$empty
54
    p_=EMPTY
55
  !endif
56
  mlist_=!append item $p_ to $mlist_
57
!next i_
58
ecnt_=!itemcnt $list_
59
!writefile wimshome/log/classes/$wims_class/$(type_)s/.$type_$num_ $empty
60
!for e_=1 to $ecnt_
61
  !! ------- check for score dependancy
62
  sco_=!line $li_ of $(field_$(list_[$e_]))
63
  !if $sco_!=$empty
64
    nsco_=$empty
65
    sco_=!items2lines $sco_
66
    sco_=!replace internal : by , in $sco_
67
    sco_=!replace internal + by , in $sco_
68
    nbl_=!linecnt $sco_
69
    !for i_=1 to $nbl_
70
      nbi_=!itemcnt $(sco_[$i_;])
71
      nli_=$empty
72
      !for j_=1 to $nbi_-1
73
        !if $(mlist_[$(sco_[$i_;$j_])])!=EMPTY
74
          nli_=!append item $(mlist_[$(sco_[$i_;$j_])]) to $nli_
75
        !endif
76
      !next j_
77
      nli_=!nonempty item $nli_
78
      nli_=!replace internal , by + in $(nli_)
79
      !if $nli_!=$empty
80
        nli_=$nli_:$(sco_[$i_;$nbi_])
81
        nsco_=!append item $nli_ to $nsco_
82
      !endif
83
    !next i_
84
    field_$(list_[$e_])=!replace line number $li_ by $nsco_ in $(field_$(list_[$e_]))
85
  !endif
86
  !! save field
87
  !appendfile wimshome/log/classes/$wims_class/$(type_)s/.$type_$num_ :$(field_$(list_[$e_]))
88
!next e_