Rev 11060 | 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 |
||
21 | |||
22 | !if $typename iswordof level program |
||
23 | !exit |
||
20 | reyssat | 24 | !endif |
11060 | obado | 25 | |
26 | !if $typename issametext course |
||
27 | class_parent=!defof class_parent in wimshome/log/classes/$uclass/.def |
||
28 | !if $class_parent!=$empty |
||
29 | i=!defof class_ocourses in wimshome/log/classes/$class_parent/.def |
||
30 | i=!makelist $wims_superclass/x for x in $i |
||
31 | !if $uclass isitemof $i |
||
32 | uclass=$class_parent |
||
33 | !goto mkstart |
||
34 | !endif |
||
35 | !endif |
||
36 | clist=$uclass |
||
20 | reyssat | 37 | !else |
11060 | obado | 38 | !if / isin $uclass |
39 | class_lvl=!translate internal / to , in $uclass |
||
40 | class_lvl=$(class_lvl[1])/$(class_lvl[2]) |
||
41 | !if $class_lvl=$uclass |
||
42 | class_lvl= |
||
43 | clist=$supclass,$uclass |
||
44 | !else |
||
45 | clist=$supclass,$class_lvl,$uclass |
||
46 | !endif |
||
47 | !else |
||
48 | clist=!listuniq $supclass,$uclass |
||
49 | !endif |
||
20 | reyssat | 50 | !endif |
51 | !else |
||
11060 | obado | 52 | typename=class |
53 | clist=$uclass |
||
54 | supclass=$uclass |
||
20 | reyssat | 55 | !endif |
56 | |||
57 | mul_userdir=wimshome/log/classes/$supclass/.users |
||
58 | mul_userdir2=$wims_home/log/classes/$supclass/.users |
||
4626 | obado | 59 | |
11038 | obado | 60 | pack_size = 500 |
61 | |||
62 | ## On range la liste des utilisateurs par paquets de $pack_size (userlist_0, userlist_1, etc...) |
||
20 | reyssat | 63 | start=0 |
11038 | obado | 64 | userlist_$start=!sh cd $mul_userdir2; ls 2>/dev/null | head -$pack_size |
20 | reyssat | 65 | userlist_$start=!words2items $(userlist_$start) |
4626 | obado | 66 | |
20 | reyssat | 67 | userlist_lastcnt=!itemcnt $(userlist_$start) |
4626 | obado | 68 | |
11060 | obado | 69 | !while $userlist_lastcnt>$[$pack_size-1] |
11038 | obado | 70 | !advance start |
11060 | obado | 71 | |
72 | userlist_$start=!sh cd $mul_userdir2; ls 2>/dev/null | tail -n +$[$start*$pack_size+1] | head -$pack_size |
||
11038 | obado | 73 | userlist_$start=!words2items $(userlist_$start) |
74 | userlist_lastcnt=!itemcnt $(userlist_$start) |
||
20 | reyssat | 75 | !endwhile |
76 | |||
10133 | bpr | 77 | ## On supprime une eventuelle liste temporaire "userlist*.raw" dans chaque classe |
78 | ## just junk |
||
20 | reyssat | 79 | !for c in $clist |
11060 | obado | 80 | !sh rm -f $wims_home/log/classes/$c/.userlist.raw 2>/dev/null\ |
81 | rm -f $wims_home/log/classes/$c/.userlist_external.raw 2>/dev/null |
||
1605 | bpr | 82 | !next |
4626 | obado | 83 | |
11038 | obado | 84 | ## On parcourt nos paquets de $pack_size users |
20 | reyssat | 85 | !for N=0 to $start |
11060 | obado | 86 | !for u in $(userlist_$N) |
87 | !reset user_firstname, user_lastname, user_supervisable,\ |
||
88 | user_class, user_participate, user_exists, user_external_auth |
||
89 | !readdef $mul_userdir/$u |
||
5295 | bpr | 90 | |
11060 | obado | 91 | !!TODO better to make a special list for user_supervisable who participates |
92 | !!(suppress to add supervisor who are registered as participant to appear in userlist) |
||
93 | !if $user_exists=yes and $user_supervisable!=yes |
||
94 | userline=:$user_lastname,$user_firstname,$u |
||
95 | !reset userline_external |
||
96 | !if $user_external_auth!=$empty |
||
97 | userline_external=$user_external_auth:$u |
||
98 | !endif |
||
99 | !if $typename=course |
||
100 | !readdef wimshome/log/classes/$uclass/.users/$u |
||
101 | !if $user_class!=$empty |
||
102 | !appendfile wimshome/log/classes/$uclass/.userlist.raw $userline,$user_class |
||
103 | !if $userline_external!=$empty |
||
104 | !appendfile wimshome/log/classes/$uclass/.userlist_external.raw $userline_external |
||
105 | !endif |
||
106 | !endif |
||
107 | !else |
||
108 | !if $supclass=$uclass or $uclass isitemof $user_participate |
||
109 | !appendfile wimshome/log/classes/$uclass/.userlist.raw $userline |
||
110 | !if $userline_external!=$empty |
||
111 | !appendfile wimshome/log/classes/$uclass/.userlist_external.raw $userline_external |
||
112 | !endif |
||
113 | !endif |
||
114 | ### do it for the $supclass ? could be done many times if not in a group ? |
||
115 | !if $supclass!=$uclass |
||
116 | !appendfile wimshome/log/classes/$supclass/.userlist.raw $userline |
||
117 | !if $userline_external!=$empty |
||
118 | !appendfile wimshome/log/classes/$supclass/.userlist_external.raw $userline_external |
||
119 | !endif |
||
120 | !if $class_lvl!=$empty and $class_lvl/ isin $user_participate |
||
121 | ## do it for the intermediaire class ? could be done many times |
||
122 | !appendfile wimshome/log/classes/$class_lvl/.userlist.raw $userline |
||
123 | !if $userline_external!=$empty |
||
124 | !appendfile wimshome/log/classes/$class_lvl/.userlist_external.raw $userline_external |
||
125 | !endif |
||
126 | !endif |
||
127 | !endif |
||
128 | !endif |
||
20 | reyssat | 129 | !endif |
11060 | obado | 130 | !next u |
20 | reyssat | 131 | !next N |
132 | |||
133 | basedir=$wims_home/log/classes |
||
6868 | bpr | 134 | basedir2=wimshome/log/classes |
10133 | bpr | 135 | |
20 | reyssat | 136 | !for c in $clist |
11061 | obado | 137 | !sh sort -f $basedir/$c/.userlist.raw >$basedir/$c/.userlist 2>/dev/null\ |
138 | rm -f $basedir/$c/.userlist.raw 2>/dev/null\ |
||
139 | sort -f $basedir/$c/.userlist_external.raw > $basedir/$c/.userlist_external 2>/dev/null\ |
||
140 | rm -f $basedir/$c/.userlist_external.raw 2>/dev/null |
||
10133 | bpr | 141 | !next |
142 | ## Now the files .userlist and .userlist_external are created in the classes of $clist, |
||
143 | ## so in the sup classes of $uclass. Do we need to do that (it is done many times for |
||
144 | ## the portal ... |
||
145 | |||
146 | ## do now the .usernextlist and .userprevlist only in the class $uclass |
||
147 | ## in fact, there is only one class in $uclass. Leave the loop for the moment |
||
148 | !for c in $uclass |
||
6868 | bpr | 149 | rm -f $basedir/$c/.usernextlist.raw 2>/dev/null\ |
150 | rm -f $basedir/$c/.userprevlist.raw 2>/dev/null |
||
10133 | bpr | 151 | !set nbuser_=!recordcnt $basedir2/$c/.userlist |
152 | !if $nbuser_=0 |
||
153 | !break |
||
154 | !endif |
||
155 | !set list_1=!record 1 to -1 of $basedir2/$c/.userlist |
||
156 | !set list_1=!column 3 of $list_1 |
||
157 | !set nextuser=!makelist $$(list_1[x]), $$(list_1[x+1]); for x=1 to $nbuser_-1 |
||
158 | !set nextuser=!nospace $nextuser$(list_1[$nbuser_]),$(list_1[1]) |
||
159 | !set nextuser=!replace internal ;, by ; in $nextuser |
||
160 | !set prevuser=!nospace $(nextuser[;2,1]) |
||
161 | !set prevuser=!rows2lines $prevuser |
||
162 | !set prevuser=!replace internal , by : in $prevuser |
||
163 | !set nextuser=!rows2lines $nextuser |
||
164 | !set nextuser=!replace internal , by : in $nextuser |
||
165 | !writefile $basedir2/$c/.usernextlist.raw $nextuser |
||
166 | !writefile $basedir2/$c/.userprevlist.raw $prevuser |
||
6868 | bpr | 167 | !sh mv $basedir/$c/.usernextlist.raw $basedir/$c/.usernextlist\ |
11060 | obado | 168 | mv $basedir/$c/.userprevlist.raw $basedir/$c/.userprevlist |
20 | reyssat | 169 | !next c |
170 | |||
10132 | bpr | 171 | !exit |
20 | reyssat | 172 | !read adm/class/stat |