Rev 11062 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10133 | bpr | 1 | # mkuserlist |
4626 | obado | 2 | # Constructs .userlist file in specified class (wims_class by default) |
10133 | bpr | 3 | # constructs .usernextlist and .userprevlist |
4 | # also constructs .userlist_external if needed |
||
4626 | obado | 5 | |
20 | reyssat | 6 | uclass=$wims_read_parm |
7 | !default uclass=$wims_class |
||
4626 | obado | 8 | |
11060 | obado | 9 | # What's the point of $wims_prefix ? |
20 | reyssat | 10 | !if user notwordof $wims_prefix |
11060 | obado | 11 | wims_prefix=$wims_prefix user |
20 | reyssat | 12 | !endif |
4626 | obado | 13 | |
20 | reyssat | 14 | :mkstart |
15 | supclass=!defof class_superclass in wimshome/log/classes/$uclass/.def |
||
16 | reset class_lvl |
||
4626 | obado | 17 | |
20 | reyssat | 18 | !if $supclass!=$empty and $supclass!=$uclass |
11060 | obado | 19 | supertype=!defof class_type in wimshome/log/classes/$supclass/.def |
20 | typename=!defof class_typename in wimshome/log/classes/$uclass/.def |
||
13211 | bpr | 21 | !!case of program can occur in case of intercourse |
22 | !if $typename iswordof level |
||
11060 | obado | 23 | !exit |
20 | reyssat | 24 | !endif |
11060 | obado | 25 | !if $typename issametext course |
26 | class_parent=!defof class_parent in wimshome/log/classes/$uclass/.def |
||
27 | !if $class_parent!=$empty |
||
28 | i=!defof class_ocourses in wimshome/log/classes/$class_parent/.def |
||
29 | i=!makelist $wims_superclass/x for x in $i |
||
30 | !if $uclass isitemof $i |
||
31 | uclass=$class_parent |
||
32 | !goto mkstart |
||
33 | !endif |
||
13211 | bpr | 34 | tn=!defof class_typename in wimshome/log/classes/$class_parent/.def |
35 | !if $tn=program |
||
36 | clist=$class_parent |
||
37 | !endif |
||
11060 | obado | 38 | !endif |
13211 | bpr | 39 | clist=!listuniq $clist,$uclass |
20 | reyssat | 40 | !else |
11060 | obado | 41 | !if / isin $uclass |
42 | class_lvl=!translate internal / to , in $uclass |
||
43 | class_lvl=$(class_lvl[1])/$(class_lvl[2]) |
||
44 | !if $class_lvl=$uclass |
||
45 | class_lvl= |
||
13211 | bpr | 46 | clist=!listuniq $supclass,$clist,$uclass |
11060 | obado | 47 | !else |
13211 | bpr | 48 | clist=!listuniq $supclass,$clist,$class_lvl,$uclass |
11060 | obado | 49 | !endif |
50 | !else |
||
51 | clist=!listuniq $supclass,$uclass |
||
52 | !endif |
||
20 | reyssat | 53 | !endif |
54 | !else |
||
11060 | obado | 55 | typename=class |
56 | clist=$uclass |
||
57 | supclass=$uclass |
||
20 | reyssat | 58 | !endif |
59 | |||
60 | mul_userdir=wimshome/log/classes/$supclass/.users |
||
61 | mul_userdir2=$wims_home/log/classes/$supclass/.users |
||
4626 | obado | 62 | |
11038 | obado | 63 | pack_size = 500 |
64 | |||
65 | ## On range la liste des utilisateurs par paquets de $pack_size (userlist_0, userlist_1, etc...) |
||
20 | reyssat | 66 | start=0 |
11038 | obado | 67 | userlist_$start=!sh cd $mul_userdir2; ls 2>/dev/null | head -$pack_size |
20 | reyssat | 68 | userlist_$start=!words2items $(userlist_$start) |
4626 | obado | 69 | |
20 | reyssat | 70 | userlist_lastcnt=!itemcnt $(userlist_$start) |
4626 | obado | 71 | |
11060 | obado | 72 | !while $userlist_lastcnt>$[$pack_size-1] |
11038 | obado | 73 | !advance start |
11060 | obado | 74 | userlist_$start=!sh cd $mul_userdir2; ls 2>/dev/null | tail -n +$[$start*$pack_size+1] | head -$pack_size |
11038 | obado | 75 | userlist_$start=!words2items $(userlist_$start) |
76 | userlist_lastcnt=!itemcnt $(userlist_$start) |
||
20 | reyssat | 77 | !endwhile |
78 | |||
10133 | bpr | 79 | ## On supprime une eventuelle liste temporaire "userlist*.raw" dans chaque classe |
80 | ## just junk |
||
20 | reyssat | 81 | !for c in $clist |
11060 | obado | 82 | !sh rm -f $wims_home/log/classes/$c/.userlist.raw 2>/dev/null\ |
11062 | obado | 83 | rm -f $wims_home/log/classes/$c/.userlist_external.raw 2>/dev/null |
1605 | bpr | 84 | !next |
4626 | obado | 85 | |
11038 | obado | 86 | ## On parcourt nos paquets de $pack_size users |
20 | reyssat | 87 | !for N=0 to $start |
11060 | obado | 88 | !for u in $(userlist_$N) |
89 | !reset user_firstname, user_lastname, user_supervisable,\ |
||
90 | user_class, user_participate, user_exists, user_external_auth |
||
91 | !readdef $mul_userdir/$u |
||
5295 | bpr | 92 | |
11060 | obado | 93 | !!TODO better to make a special list for user_supervisable who participates |
94 | !!(suppress to add supervisor who are registered as participant to appear in userlist) |
||
95 | !if $user_exists=yes and $user_supervisable!=yes |
||
96 | userline=:$user_lastname,$user_firstname,$u |
||
97 | !reset userline_external |
||
98 | !if $user_external_auth!=$empty |
||
99 | userline_external=$user_external_auth:$u |
||
100 | !endif |
||
101 | !if $typename=course |
||
102 | !readdef wimshome/log/classes/$uclass/.users/$u |
||
103 | !if $user_class!=$empty |
||
104 | !appendfile wimshome/log/classes/$uclass/.userlist.raw $userline,$user_class |
||
105 | !if $userline_external!=$empty |
||
106 | !appendfile wimshome/log/classes/$uclass/.userlist_external.raw $userline_external |
||
107 | !endif |
||
108 | !endif |
||
109 | !else |
||
110 | !if $supclass=$uclass or $uclass isitemof $user_participate |
||
111 | !appendfile wimshome/log/classes/$uclass/.userlist.raw $userline |
||
112 | !if $userline_external!=$empty |
||
113 | !appendfile wimshome/log/classes/$uclass/.userlist_external.raw $userline_external |
||
114 | !endif |
||
115 | !endif |
||
116 | ### do it for the $supclass ? could be done many times if not in a group ? |
||
117 | !if $supclass!=$uclass |
||
118 | !appendfile wimshome/log/classes/$supclass/.userlist.raw $userline |
||
119 | !if $userline_external!=$empty |
||
120 | !appendfile wimshome/log/classes/$supclass/.userlist_external.raw $userline_external |
||
121 | !endif |
||
122 | !if $class_lvl!=$empty and $class_lvl/ isin $user_participate |
||
123 | ## do it for the intermediaire class ? could be done many times |
||
124 | !appendfile wimshome/log/classes/$class_lvl/.userlist.raw $userline |
||
125 | !if $userline_external!=$empty |
||
126 | !appendfile wimshome/log/classes/$class_lvl/.userlist_external.raw $userline_external |
||
127 | !endif |
||
128 | !endif |
||
129 | !endif |
||
130 | !endif |
||
20 | reyssat | 131 | !endif |
11060 | obado | 132 | !next u |
20 | reyssat | 133 | !next N |
134 | |||
135 | basedir=$wims_home/log/classes |
||
6868 | bpr | 136 | basedir2=wimshome/log/classes |
10133 | bpr | 137 | |
20 | reyssat | 138 | !for c in $clist |
11061 | obado | 139 | !sh sort -f $basedir/$c/.userlist.raw >$basedir/$c/.userlist 2>/dev/null\ |
140 | rm -f $basedir/$c/.userlist.raw 2>/dev/null\ |
||
141 | sort -f $basedir/$c/.userlist_external.raw > $basedir/$c/.userlist_external 2>/dev/null\ |
||
142 | rm -f $basedir/$c/.userlist_external.raw 2>/dev/null |
||
10133 | bpr | 143 | !next |
13211 | bpr | 144 | |
10133 | bpr | 145 | ## Now the files .userlist and .userlist_external are created in the classes of $clist, |
146 | ## so in the sup classes of $uclass. Do we need to do that (it is done many times for |
||
147 | ## the portal ... |
||
148 | |||
149 | ## do now the .usernextlist and .userprevlist only in the class $uclass |
||
150 | ## in fact, there is only one class in $uclass. Leave the loop for the moment |
||
151 | !for c in $uclass |
||
11062 | obado | 152 | !sh rm -f $basedir/$c/.usernextlist.raw 2>/dev/null\ |
153 | rm -f $basedir/$c/.userprevlist.raw 2>/dev/null |
||
10133 | bpr | 154 | !set nbuser_=!recordcnt $basedir2/$c/.userlist |
155 | !if $nbuser_=0 |
||
156 | !break |
||
157 | !endif |
||
11062 | obado | 158 | record_start = 1 |
159 | remaining = $nbuser_ - 1 |
||
160 | ## On parcourt nos users par paquets de $pack_size |
||
161 | !while $remaining > 0 |
||
162 | nb_processing = $[min($remaining, $pack_size)] |
||
163 | record_end = $[$record_start+$nb_processing] |
||
164 | list_n=!record $record_start to $record_end of $basedir2/$c/.userlist |
||
165 | list_n=!column 3 of $list_n |
||
166 | nextuser=!makelist $$(list_n[x]), $$(list_n[x+1]); for x=1 to $nb_processing |
||
167 | nextuser=!nospace $nextuser |
||
168 | nextuser=!replace internal ;, by ; in $nextuser |
||
169 | |||
170 | prevuser=!nospace $(nextuser[;2,1]) |
||
171 | |||
172 | prevuser=!rows2lines $prevuser |
||
173 | prevuser=!replace internal , by : in $prevuser |
||
174 | nextuser=!rows2lines $nextuser |
||
175 | nextuser=!replace internal , by : in $nextuser |
||
176 | |||
177 | !appendfile $basedir2/$c/.usernextlist.raw $nextuser |
||
178 | !appendfile $basedir2/$c/.userprevlist.raw $prevuser |
||
179 | record_start = $record_start + $nb_processing |
||
180 | remaining = $remaining - $nb_processing |
||
181 | !endwhile |
||
182 | first_user = !record 1 of $basedir2/$c/.userlist |
||
183 | first_user = !item 3 of $first_user |
||
184 | last_user = !record -1 of $basedir2/$c/.userlist |
||
185 | last_user = !item 3 of $last_user |
||
186 | !appendfile $basedir2/$c/.usernextlist.raw $last_user:$first_user |
||
187 | !appendfile $basedir2/$c/.userprevlist.raw $first_user:$last_user |
||
6868 | bpr | 188 | !sh mv $basedir/$c/.usernextlist.raw $basedir/$c/.usernextlist\ |
11062 | obado | 189 | mv $basedir/$c/.userprevlist.raw $basedir/$c/.userprevlist |
20 | reyssat | 190 | !next c |