Subversion Repositories wimsdev

Rev

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