File: transfer

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 (186 lines) | stat: -rw-r--r-- 6,915 bytes parent folder | download | duplicates (3)
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

transfer_test=0
!distribute words $wims_read_parm into transfer_user, transfer_cmd, transfer_other
!if ($wims_supertype!=4 and $wims_supertype!=2) or $wims_user!=supervisor
  !exit
!endif
tr_list=
tr_typename=!defof class_typename in wimshome/log/classes/$wims_class/.def
tr_l1=!defof user_participate in \
  wimshome/log/classes/$wims_superclass/.users/$transfer_user
!if $wims_supertype=4
  !if $tr_typename=course
    tr_program=!defof sharing_exam in wimshome/log/classes/$wims_class/neighbors
    tr_class=!defof user_class in wimshome/log/classes/$wims_class/.users/$transfer_user
    !if $tr_class=$empty
      tr_parent=!defof class_parent in wimshome/log/classes/$wims_class/.def
      !if $tr_parent!=$empty and $tr_parent isitemof $tr_l1
        tr_class=$tr_parent
      !endif
    !else
      tr_class=$wims_superclass/$tr_class
    !endif
    !if $tr_program!=$empty and $tr_class!=$empty
      tr_l2=!record 0 of wimshome/log/classes/$tr_program/courses
      tr_l3=!record 0 of wimshome/log/classes/$tr_program/icourses
      tr_l2=!append line $tr_l3 to $tr_l2
      tr_l2=!column 1 of $tr_l2
      tr_l2=!nonempty items $tr_l2
      tr_l2=!makelist $wims_superclass/x for x in $tr_l2
      tr_l2=!listcomplement $wims_class in $tr_l2
      tr_list=
      !for c_ in $tr_l2
        tr_test1=!defof user_class in \
          wimshome/log/classes/$c_/.users/$transfer_user
        tr_test2=!defof sharing_exam in wimshome/log/classes/$c_/neighbors
        !if $wims_superclass/$tr_test1=$tr_class or \
            $tr_test2=$tr_program
          tr_list=!append item $c_ to $tr_list
        !endif
      !next c_
    !endif
  !else
    !if $wims_class notitemof $tr_l1
      !exit
    !endif
    tr_l1=!listcomplement $wims_class in $tr_l1
    !for c_ in $tr_l1
      tr_l2=!defof class_ocourses in wimshome/log/classes/$c_/.def
      tr_l3=!defof user_courses in wimshome/log/classes/$c_/.users/$transfer_user
      tr_l2=!append item $tr_l3 to $tr_l2
      tr_l2=!nonempty items $tr_l2
      !if $tr_l2!=$empty
        tr_l2=!makelist $wims_superclass/x for x in $tr_l2
        tr_list=!append item $tr_l2 to $tr_list
      !endif
    !next c_
  !endif
!else
  !! same for wims_supertype=2 build a tr_list analogue to the one above:
  !! suitable classes to look into for activity by $transfer_user
  !if  $wims_supertype=2 and $tr_typename=class
    tr_sharing=!defof sharing_exam in wimshome/log/classes/$wims_class/neighbors
    tr_sharable=!defof sharable_exam in wimshome/log/classes/$wims_class/neighbors
    !! is user_class really used?
    tr_class=!defof user_class in wimshome/log/classes/$wims_class/.users/$transfer_user
    !if $tr_class=$empty
      !! case 1 --> $wims_class is not "giving" (tr_sharable=$empty, i.e.
      !!   $tr_sharing!=$empty), need to check whether it is sharing from
      !!   (tr_sharing!=$empty) and need to find classes sharing from the
      !!   same class
      !if $tr_sharing!=$empty
        tr_list=$tr_sharing
        !! altri candidati
        tr_l2=!defof sharable_exam in wimshome/log/classes/$tr_sharing/neighbors
        tr_l2=!listcomplement $wims_class in $tr_l2
        !! controllo che queste effettivamente siano in sharing
        !for c_ in $tr_l2
          tr_test=!defof sharing_exam in wimshome/log/classes/$c_/neighbors
          !if $tr_test=$tr_sharing
            tr_list=!append item $c_ to $tr_list
          !endif
        !next c_
      !else
        !! case 2 --> $wims_class is giving resources to other classes
        !! (tr_sharable!=$empty) suitable class are in the ones in
        !! $wims_superclass/.subclasses that have $wims_class in sharing_exams
        !if $tr_sharable!=$empty
          tr_list=
          cnt_class=!recordcnt wimshome/log/classes/$wims_superclass/.subclasses
          !for i = 1 to $cnt_class
            cl=!record $i of wimshome/log/classes/.index
            cl_test=$(cl[1])
            cl_sharing=!defof sharing_exam in wimshome/log/classes/$cl_test/neighbors
            !if $cl_sharing=$wims_class
              tr_list=!append item $cl_test to $tr_list
            !endif
          !next
        !endif
      !endif
    !else
      tr_class=$wims_superclass/$tr_class
    !endif
  !endif
!endif

!if $tr_list!=$empty
  tr_l1=!makelist x/score for x in $tr_list
  tr_l2=!makelist x/noscore for x in $tr_list
  tr_l1=!items2words $tr_l1
  tr_l2=!items2words $tr_l2
  tr_score=!sh cd $wims_home/log/classes\
    find $tr_l1 -name $transfer_user -o -name $transfer_user.exam | sed 's!/score/.*$$!!'
  tr_noscore=!sh cd $wims_home/log/classes\
    find $tr_l2 -name $transfer_user | sed 's!/noscore/.*$$!!'
  tr_score=!words2items $tr_score
  tr_noscore=!words2items $tr_noscore
  tr_list=!listunion $tr_score and $tr_noscore
  tr_list=!nonempty items $tr_list
!endif

transfer_test=!itemcnt $tr_list
!if $transfer_test<1 or $transfer_cmd=test or\
  $transfer_other notitemof $tr_list
  !exit
!endif

!if $wims_supertype=4
  !default tr_program=!defof sharing_exam in wimshome/log/classes/$transfer_other/neighbors
  !if $tr_typename!=course
    tr_l1=!defof class_ocourses in wimshome/log/classes/$wims_class/.def
    tr_l2=!defof user_courses in wimshome/log/classes/$wims_class/.users/$transfer_user
    tr_l1=!append item $tr_l2 to $tr_l1
    tr_l1=!nonempty items $tr_l1
    tr_l1=!makelist $wims_superclass/x for x in $tr_l1
    !for c in $tr_l1
      tr_pr=!defof sharing_exam in wimshome/log/classes/$c/neighbors
      !if $tr_pr=$tr_program
        tr_this=$c
        !break
      !endif
    !next c
    !if $tr_this=$empty
      error=no_reccourse
      !exit
    !endif
  !else
    tr_this=$wims_class
  !endif
!endif

!if $wims_supertype=2 and $tr_typename=class
  !if $transfer_other isitemof $tr_list
    tr_this=$wims_class
  !endif
!endif

tr_c1=log/classes/$transfer_other
tr_c2=log/classes/$tr_this
!if $transfer_cmd=replace
  mline=cp $tr_c1/score/$transfer_user $tr_c2/score
!else
  mline=cat $tr_c1/score/$transfer_user $tr_c2/score/$transfer_user 2>/dev/null >$wims_sesdir/transfer\
    sort <$wims_sesdir/transfer >$tr_c2/score/$transfer_user
!endif

!sh cd $wims_home\
 if [ -f $tr_c1/score/$transfer_user ]; then\
   $mline\
  fi\
  if [ -f $tr_c1/noscore/$transfer_user ]; then\
   cat $tr_c1/noscore/$transfer_user $tr_c2/noscore/$transfer_user 2>/dev/null >$wims_sesdir/transfer\
   sort <$wims_sesdir/transfer >$tr_c2/noscore/$transfer_user\
  fi\
  if [ -f $tr_c1/score/$transfer_user.exam ]; then\
   cat $tr_c1/score/$transfer_user.exam >>$tr_c2/score/$transfer_user.exam\
  fi\
  if [ -d $tr_c1/examlog/$transfer_user ]; then\
   mkdir -p $tr_c2/examlog\
   mv -f $tr_c1/examlog/$transfer_user $tr_c2/examlog\
  fi\
  if [ -d $tr_c1/exolog/$transfer_user ]; then\
    mkdir -p $tr_c2/exolog\
    mv -f $tr_c1/exolog/$transfer_user $tr_c2/exolog\
  fi\
  cd $tr_c1\
  rm -f noscore/$transfer_user score/$transfer_user score/$transfer_user.* 2>/dev/null