Subversion Repositories wimsdev

Rev

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