Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
20 reyssat 1
 
2
transfer_test=0
3
!distribute words $wims_read_parm into transfer_user, transfer_cmd, transfer_other
4594 czzmrn 4
!if ($wims_supertype!=4 and $wims_supertype!=2) or $wims_user!=supervisor
20 reyssat 5
 !exit
6
!endif
7
tr_list=
8
tr_typename=!defof class_typename in wimshome/log/classes/$wims_class/.def
9
tr_l1=!defof user_participate in \
10
	wimshome/log/classes/$wims_superclass/.users/$transfer_user
4594 czzmrn 11
!if $wims_supertype=4 
20 reyssat 12
!if $tr_typename=course
13
 tr_program=!defof sharing_exam in wimshome/log/classes/$wims_class/neighbors
14
 tr_class=!defof user_class in wimshome/log/classes/$wims_class/.users/$transfer_user
15
 !if $tr_class=$empty
16
  tr_parent=!defof class_parent in wimshome/log/classes/$wims_class/.def
17
  !if $tr_parent!=$empty and $tr_parent isitemof $tr_l1
18
   tr_class=$tr_parent
19
  !endif
20
 !else
21
  tr_class=$wims_superclass/$tr_class
22
 !endif
23
 !if $tr_program!=$empty and $tr_class!=$empty
24
  tr_l2=!record 0 of wimshome/log/classes/$tr_program/courses
25
  tr_l3=!record 0 of wimshome/log/classes/$tr_program/icourses
26
  tr_l2=!append line $tr_l3 to $tr_l2
27
  tr_l2=!column 1 of $tr_l2
28
  tr_l2=!nonempty items $tr_l2
29
  tr_l2=!makelist $wims_superclass/x for x in $tr_l2
30
  tr_l2=!listcomplement $wims_class in $tr_l2
31
  tr_list=
32
  !for c_ in $tr_l2
33
   tr_test1=!defof user_class in \
34
	wimshome/log/classes/$c_/.users/$transfer_user
35
   tr_test2=!defof sharing_exam in wimshome/log/classes/$c_/neighbors
36
   !if $wims_superclass/$tr_test1=$tr_class or \
37
	$tr_test2=$tr_program
38
    tr_list=!append item $c_ to $tr_list
39
   !endif
40
  !next c_
41
 !endif
42
!else
43
 !if $wims_class notitemof $tr_l1
44
  !exit
45
 !endif
46
 tr_l1=!listcomplement $wims_class in $tr_l1
47
 !for c_ in $tr_l1
48
  tr_l2=!defof class_ocourses in wimshome/log/classes/$c_/.def
49
  tr_l3=!defof user_courses in wimshome/log/classes/$c_/.users/$transfer_user
50
  tr_l2=!append item $tr_l3 to $tr_l2
51
  tr_l2=!nonempty items $tr_l2
52
  !if $tr_l2!=$empty
53
   tr_l2=!makelist $wims_superclass/x for x in $tr_l2
54
   tr_list=!append item $tr_l2 to $tr_list
55
  !endif
56
 !next c_
57
!endif
4594 czzmrn 58
!else
59
!! same for wims_supertype=2 build a tr_list analogue to the one above: 
60
!! suitable classes to look into for activity by $transfer_user
61
!if  $wims_supertype=2 and $tr_typename=class
62
 tr_sharing=!defof sharing_exam in wimshome/log/classes/$wims_class/neighbors
63
 tr_sharable=!defof sharable_exam in wimshome/log/classes/$wims_class/neighbors
64
 !! is user_class really used?
65
 tr_class=!defof user_class in wimshome/log/classes/$wims_class/.users/$transfer_user
66
 !if $tr_class=$empty
67
  !! case 1 --> $wims_class is not "giving" (tr_sharable=$empty, i.e.
68
  !!   $tr_sharing!=$empty), need to check whether it is sharing from
69
  !!   (tr_sharing!=$empty) and need to find classes sharing from the
70
  !!   same class 
71
  !if $tr_sharing!=$empty
72
   tr_list=$tr_sharing
73
   !! altri candidati
74
   tr_l2=!defof sharable_exam in wimshome/log/classes/$tr_sharing/neighbors
75
   tr_l2=!listcomplement $wims_class in $tr_l2	 
76
   !! controllo che queste effettivamente siano in sharing 
77
   !for c_ in $tr_l2
78
    tr_test=!defof sharing_exam in wimshome/log/classes/$c_/neighbors
79
    !if $tr_test=$tr_sharing
80
     tr_list=!append item $c_ to $tr_list
81
    !endif
82
   !next c_
83
  !else
84
   !! case 2 --> $wims_class is giving resources to other classes
85
   !! (tr_sharable!=$empty) suitable class are in the ones in
86
   !! $wims_superclass/.subclasses that have $wims_class in sharing_exams
87
   !if $tr_sharable!=$empty
88
    tr_list=
89
    cnt_class=!recordcnt wimshome/log/classes/$wims_superclass/.subclasses
90
    !for i = 1 to $cnt_class
91
     cl=!record $i of wimshome/log/classes/.index
92
     cl_test=$(cl[1])
93
     cl_sharing=!defof sharing_exam in wimshome/log/classes/$cl_test/neighbors
94
     !if $cl_sharing=$wims_class
95
      tr_list=!append item $cl_test to $tr_list 
96
     !endif
97
    !next
98
   !endif
99
  !endif
100
 !else
101
  tr_class=$wims_superclass/$tr_class
102
 !endif
103
!endif
104
!endif
20 reyssat 105
 
106
!if $tr_list!=$empty
107
 tr_l1=!makelist x/score for x in $tr_list
108
 tr_l2=!makelist x/noscore for x in $tr_list
109
 tr_l1=!items2words $tr_l1
110
 tr_l2=!items2words $tr_l2
111
 tr_score=!sh cd $wims_home/log/classes\
112
	find $tr_l1 -name $transfer_user -o -name $transfer_user.exam | sed 's!/score/.*$$!!'
113
 tr_noscore=!sh cd $wims_home/log/classes\
114
	find $tr_l2 -name $transfer_user | sed 's!/noscore/.*$$!!'
115
 tr_score=!words2items $tr_score
116
 tr_noscore=!words2items $tr_noscore
117
 tr_list=!listunion $tr_score and $tr_noscore
118
 tr_list=!nonempty items $tr_list
119
!endif
120
 
121
transfer_test=!itemcnt $tr_list
122
!if $transfer_test<1 or $transfer_cmd=test or\
123
	$transfer_other notitemof $tr_list
124
 !exit
125
!endif
126
 
4594 czzmrn 127
!if $wims_supertype=4
20 reyssat 128
!default tr_program=!defof sharing_exam in wimshome/log/classes/$transfer_other/neighbors
129
!if $tr_typename!=course
130
 tr_l1=!defof class_ocourses in wimshome/log/classes/$wims_class/.def
131
 tr_l2=!defof user_courses in wimshome/log/classes/$wims_class/.users/$transfer_user
132
 tr_l1=!append item $tr_l2 to $tr_l1
133
 tr_l1=!nonempty items $tr_l1
134
 tr_l1=!makelist $wims_superclass/x for x in $tr_l1
135
 !for c in $tr_l1
136
  tr_pr=!defof sharing_exam in wimshome/log/classes/$c/neighbors
137
  !if $tr_pr=$tr_program
138
   tr_this=$c
139
   !break
140
  !endif
141
 !next c
142
 !if $tr_this=$empty
143
  error=no_reccourse
144
  !exit
145
 !endif
146
!else
147
 tr_this=$wims_class
148
!endif
4594 czzmrn 149
!endif
20 reyssat 150
 
4594 czzmrn 151
!if $wims_supertype=2 and $tr_typename=class
152
 !if $transfer_other isitemof $tr_list
153
  tr_this=$wims_class
154
 !endif
155
!endif
156
 
20 reyssat 157
tr_c1=log/classes/$transfer_other
158
tr_c2=log/classes/$tr_this
159
!if $transfer_cmd=replace
160
 mline=cp $tr_c1/score/$transfer_user $tr_c2/score
161
!else
162
 mline=cat $tr_c1/score/$transfer_user $tr_c2/score/$transfer_user 2>/dev/null >$wims_sesdir/transfer\
163
  sort <$wims_sesdir/transfer >$tr_c2/score/$transfer_user
164
!endif
165
 
166
!sh cd $wims_home\
167
 if [ -f $tr_c1/score/$transfer_user ]; then\
168
  $mline\
169
 fi\
170
 if [ -f $tr_c1/noscore/$transfer_user ]; then\
171
  cat $tr_c1/noscore/$transfer_user $tr_c2/noscore/$transfer_user 2>/dev/null >$wims_sesdir/transfer\
172
  sort <$wims_sesdir/transfer >$tr_c2/noscore/$transfer_user\
173
 fi\
174
 if [ -f $tr_c1/score/$transfer_user.exam ]; then\
175
  cat $tr_c1/score/$transfer_user.exam >>$tr_c2/score/$transfer_user.exam\
176
 fi\
177
 if [ -d $tr_c1/examlog/$transfer_user ]; then\
178
  mkdir -p $tr_c2/examlog\
179
  mv -f $tr_c1/examlog/$transfer_user $tr_c2/examlog\
180
 fi\
181
 if [ -d $tr_c1/exolog/$transfer_user ]; then\
182
  mkdir -p $tr_c2/exolog\
183
  mv -f $tr_c1/exolog/$transfer_user $tr_c2/exolog\
184
 fi\
185
 cd $tr_c1\
186
 rm -f noscore/$transfer_user score/$transfer_user score/$transfer_user.* 2>/dev/null
187