Rev 12200 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 12200 | Rev 16866 | ||
---|---|---|---|
Line 16... | Line 16... | ||
16 | */ |
16 | */ |
17 | 17 | ||
18 | /* This is an internal program, |
18 | /* This is an internal program, |
19 | * used to show statistics of frequentation, module by module. |
19 | * used to show statistics of frequentation, module by module. |
20 | */ |
20 | */ |
- | 21 | ||
- | 22 | /* TODO : lorsqu'on selectionne score et noscore il y a une double lecture |
|
- | 23 | des fichiers de log (une premiere lecture pour score et une autre pour noscore |
|
- | 24 | surement qu'une seule lecture serait possible A voir */ |
|
- | 25 | ||
21 | 26 | ||
22 | #include "../Lib/libwims.h" |
27 | #include "../Lib/libwims.h" |
23 | #include "../wimsdef.h" |
28 | #include "../wimsdef.h" |
24 | 29 | ||
25 | #define MAX_SCORE 512*1024 |
30 | #define MAX_SCORE 512*1024 |
Line 52... | Line 57... | ||
52 | hr=atoi(p+9); |
57 | hr=atoi(p+9); |
53 | if(sec<0 || min<0 || hr<0 || sec>59 || min>59 || hr>23) return -1; |
58 | if(sec<0 || min<0 || hr<0 || sec>59 || min>59 || hr>23) return -1; |
54 | return hr*3600+min*60+sec; |
59 | return hr*3600+min*60+sec; |
55 | } |
60 | } |
56 | 61 | ||
- | 62 | /* traitement d'une ligne des fichiers score/noscore d'un utilisateur |
|
- | 63 | les donnees des sheet sont stockees dans shdata |
|
- | 64 | les donnees des exam sont stockees dans examdata */ |
|
57 | static |
65 | static |
58 | void oneline(char *p, char *typ) |
66 | void oneline(char *p, char *typ) |
59 | { |
67 | { |
60 | int i, j, sh, ex, t; |
68 | int i, j, sh, ex, t; |
61 | char *data[64]; |
69 | char *data[64]; |
62 | statexodata *tab; |
70 | statexodata *tab; |
63 | char *pp, *pe; |
71 | char *pp, *pe; |
- | 72 | char *ltype; |
|
64 | for(i=0, pp=find_word_start(p); i<9 && *pp; pp=find_word_start(pe),i++) { |
73 | for(i=0, pp=find_word_start(p); i<9 && *pp; pp=find_word_start(pe),i++) { |
65 | pe=find_word_end(pp); if(*pe) *pe++=0; |
74 | pe=find_word_end(pp); if(*pe) *pe++=0; |
66 | data[i]=pp; |
75 | data[i]=pp; |
67 | } |
76 | } |
68 | if(i<6) return; |
77 | if(i<6) return; |
69 | sh=atoi(data[2]); ex=atoi(data[3]); |
78 | sh=atoi(data[2]); ex=atoi(data[3]); |
70 | if(sh<=0 || ex<=0 || ex>MAX_EXOS || strlen(data[1])>10) return; |
79 | if(sh<=0 || ex<=0 || ex>MAX_EXOS || strlen(data[1])>10) return; |
71 | if(data[0][0]=='E') { |
80 | if(data[0][0]=='E') { |
72 | tab=examdata; data[0]++; if(sh>MAX_EXAMS) return; |
81 | tab=examdata; data[0]++; if(sh>MAX_EXAMS) return; |
- | 82 | ltype="S"; |
|
73 | } |
83 | } |
74 | else { |
84 | else { |
75 | tab=shdata; if(sh>MAX_SHEETS) return; |
85 | tab=shdata; if(sh>MAX_SHEETS) return; |
- | 86 | ltype="noscore"; |
|
76 | } |
87 | } |
77 | tab+=(sh-1)*MAX_EXOS+(ex-1); |
88 | tab+=(sh-1)*MAX_EXOS+(ex-1); |
78 | t=str2time(data[0]); if(t==-1) return; |
89 | t=str2time(data[0]); if(t==-1) return; |
79 | if(strstr(data[4],"new")!=NULL) { |
90 | if(strstr(data[4],"new")!=NULL) { |
80 | if(strcmp(typ,"score")==0) |
91 | if(strcmp(typ,"score")==0) |
81 | for (j = 6; j < i; ++j) if (strcmp(data[j], |
92 | for (j = 6; j < i; ++j) if (strcmp(data[j],ltype)==0) return; |
82 | if(strcmp(typ,"noscore")==0) |
93 | if(strcmp(typ,"noscore")==0) { |
- | 94 | int test=0; |
|
83 | for (j = 7; j < i; ++j) if (strcmp(data[j], |
95 | for (j = 7; j < i; ++j) if (strcmp(data[j],ltype)==0) test=1; |
- | 96 | if (test==0) return; |
|
- | 97 | } |
|
84 | snprintf(tab->lastnew,12,"%s",data[1]); |
98 | snprintf(tab->lastnew,12,"%s",data[1]); |
85 | tab->newcnt++; tab->lasttime=t; |
99 | tab->newcnt++; tab->lasttime=t; |
86 | fcind++; |
100 | fcind++; |
87 | return; |
101 | return; |
88 | } |
102 | } |
89 | if(strcmp(data[4],"score")==0) { |
103 | if(strcmp(data[4],"score")==0) { |
90 | if(strcmp(tab->lastnew,data[1])!=0) return; |
104 | if(strcmp(tab->lastnew,data[1])!=0) return; |
91 | if(sccnt>=MAX_SCORE) return; |
105 | if(sccnt>=MAX_SCORE) return; |
92 | if(tab->lasttime==-1) return; |
106 | if(tab->lasttime==-1) return; |
93 | if(strcmp(typ,"score |
107 | if(strcmp(typ,"score")==0) |
94 | for (j = |
108 | for (j = 6; j < i; ++j) if (strcmp(data[j],ltype)==0) return; |
95 |
|
109 | if(strcmp(typ,"noscore")==0) { |
- | 110 | int test=0; |
|
- | 111 | for (j = 7; j < i; ++j) if (strcmp(data[j],ltype)==0) test=1; |
|
- | 112 | if (test==0) return; |
|
- | 113 | } |
|
96 | t-=tab->lasttime; tab->lasttime=-1; if(t<0) t+=24*3600; |
114 | t-=tab->lasttime; tab->lasttime=-1; if(t<0) t+=24*3600; |
97 | if(t<0) t=0; |
115 | if(t<0) t=0; |
98 | if(t>5*3600) t=5*3600; |
116 | if(t>5*3600) t=5*3600; |
99 | scores[sccnt].dure=t; scores[sccnt].next=-1; |
117 | scores[sccnt].dure=t; scores[sccnt].next=-1; |
100 | scores[sccnt].score=(double) atof(data[5])*100+0.5; |
118 | scores[sccnt].score=(double) atof(data[5])*100+0.5; |
Line 102... | Line 120... | ||
102 | else tab->firstscore=sccnt; |
120 | else tab->firstscore=sccnt; |
103 | tab->lastscore=sccnt; sccnt++; tab->scorecnt++; |
121 | tab->lastscore=sccnt; sccnt++; tab->scorecnt++; |
104 | } |
122 | } |
105 | } |
123 | } |
106 | 124 | ||
- | 125 | ||
- | 126 | /* traitement d'un fichier de log particulier |
|
- | 127 | typ prend deux valeurs score ou noscore */ |
|
107 | void onefile(char *fname, char *typ) |
128 | void onefile(char *fname, char *typ) |
108 | { |
129 | { |
109 | FILE *f; |
130 | FILE *f; |
110 | char *buf, *pp, *pe; |
131 | char *buf, *pp, *pe; |
111 | long int l; |
132 | long int l; |
Line 119... | Line 140... | ||
119 | oneline(pp,typ); |
140 | oneline(pp,typ); |
120 | } |
141 | } |
121 | free(buf); |
142 | free(buf); |
122 | if(fcind>0) filecnt++; |
143 | if(fcind>0) filecnt++; |
123 | } |
144 | } |
- | 145 | ||
- | 146 | ||
- | 147 | /* traitement de tous les fichiers d'un repertoire |
|
- | 148 | qui est soit /score soit /noscore */ |
|
124 | 149 | ||
125 | void onedir_ (char buf[MAX_LINELEN+1], char *typ) |
150 | void onedir_ (char buf[MAX_LINELEN+1], char *typ) |
126 | { |
151 | { |
127 | char buf2[MAX_LINELEN+1]; |
152 | char buf2[MAX_LINELEN+1]; |
128 | DIR *dir; |
153 | DIR *dir; |
129 | struct dirent *ff; |
154 | struct dirent *ff; |
130 | dir=opendir(buf); if(dir==NULL) return; |
155 | dir=opendir(buf); if(dir==NULL) return; |
131 | while((ff=readdir(dir))!=NULL) { |
156 | while((ff=readdir(dir))!=NULL) { |
- | 157 | /* les fichiers commençant par . sont ceux des eleves supprimes ; les fichiers avec |
|
- | 158 | une extension .exam .bin ne sont pas des fichiers de scores |
|
- | 159 | le decompte d'activite n'est pas fait sur supervisor */ |
|
132 | if( |
160 | if(strstr(ff->d_name,".")!=NULL || strcmp(ff->d_name,"supervisor")==0) continue; |
133 | snprintf(buf2,sizeof(buf2),"%s/%s",buf,ff->d_name); |
161 | snprintf(buf2,sizeof(buf2),"%s/%s",buf,ff->d_name); |
134 | onefile(buf2,typ); |
162 | onefile(buf2,typ); |
135 | } |
163 | } |
136 | closedir(dir); |
164 | closedir(dir); |
137 | } |
165 | } |
Line 142... | Line 170... | ||
142 | char *t1, *t2, types[256]; |
170 | char *t1, *t2, types[256]; |
143 | snprintf(types,sizeof(types),"%s",sdata); |
171 | snprintf(types,sizeof(types),"%s",sdata); |
144 | for(t1=find_word_start(types); *t1; t1=find_word_start(t2)) { |
172 | for(t1=find_word_start(types); *t1; t1=find_word_start(t2)) { |
145 | t2=find_word_end(t1); if(*t2) *t2++=0; |
173 | t2=find_word_end(t1); if(*t2) *t2++=0; |
146 | snprintf(buf,sizeof(buf),"%s/%s/score",dirbase,dirname); |
174 | snprintf(buf,sizeof(buf),"%s/%s/score",dirbase,dirname); |
147 | onedir_(buf,t1); |
175 | onedir_(buf,t1); |
148 | snprintf(buf,sizeof(buf),"%s/%s/noscore",dirbase,dirname); |
176 | snprintf(buf,sizeof(buf),"%s/%s/noscore",dirbase,dirname); |
149 | onedir_(buf,t1); |
177 | onedir_(buf,t1); |
150 | } |
178 | } |
151 | } |
179 | } |
- | 180 | ||
- | 181 | /* traitement des donnees seulement pour un utilisateur |
|
- | 182 | appel de la fonction onefile pour chaque fichier */ |
|
152 | 183 | ||
153 | void oneuser(char *dirname, char fname[64]) |
184 | void oneuser(char *dirname, char fname[64]) |
154 | { |
185 | { |
155 | char buf[MAX_LINELEN+1], buf2[MAX_LINELEN+1]; |
186 | char buf[MAX_LINELEN+1], buf2[MAX_LINELEN+1]; |
156 | char *t1, *t2, types[256]; |
187 | char *t1, *t2, types[256]; |
Line 159... | Line 190... | ||
159 | t2=find_word_end(t1); if(*t2) *t2++=0; |
190 | t2=find_word_end(t1); if(*t2) *t2++=0; |
160 | snprintf(buf,sizeof(buf),"%s/%s/score/%s",dirbase,dirname,fname); |
191 | snprintf(buf,sizeof(buf),"%s/%s/score/%s",dirbase,dirname,fname); |
161 | onefile(buf,t1); |
192 | onefile(buf,t1); |
162 | snprintf(buf2,sizeof(buf),"%s/%s/noscore/%s",dirbase,dirname,fname); |
193 | snprintf(buf2,sizeof(buf),"%s/%s/noscore/%s",dirbase,dirname,fname); |
163 | onefile(buf2,t1); |
194 | onefile(buf2,t1); |
164 | } |
195 | } |
165 | } |
196 | } |
166 | 197 | ||
- | 198 | /* traitement de plusieurs utilisateurs (appel de oneuser |
|
- | 199 | pour chacun d'entre eux */ |
|
167 | void multiuser(char *dirname, char *user) |
200 | void multiuser(char *dirname, char *user) |
168 | { |
201 | { |
169 | char buf[MAX_LINELEN+1]; |
202 | char buf[MAX_LINELEN+1]; |
170 | char *u1, *u2; |
203 | char *u1, *u2; |
171 | snprintf(buf,sizeof(buf),"%s",user); |
204 | snprintf(buf,sizeof(buf),"%s",user); |
172 | for(u1=find_word_start(buf); *u1; u1=find_word_start(u2)) { |
205 | for(u1=find_word_start(buf); *u1; u1=find_word_start(u2)) { |
173 | u2=find_word_end(u1); if(*u2) *u2++=0; |
206 | u2=find_word_end(u1); if(*u2) *u2++=0; |
174 | oneuser(dirname, u1); |
207 | oneuser(dirname, u1); |
175 | } |
208 | } |
176 | } |
209 | } |
177 | 210 | ||
- | 211 | /* fonction de generation des statistiques en utilisant les donnees |
|
- | 212 | recoltees dans les fichiers de log avec oneuser onefile etc... |
|
- | 213 | ne realise les statistiques que sur une feuille ou exam |
|
- | 214 | en meme temps */ |
|
178 | void stati(statexodata *dat) |
215 | void stati(statexodata *dat) |
179 | { |
216 | { |
180 | int i,j; |
217 | int i,j; |
181 | double s,d; |
218 | double s,d; |
182 | scsum=scavg=scdeviat=dursum=duravg=durdeviat=cid=0; |
219 | scsum=scavg=scdeviat=dursum=duravg=durdeviat=cid=0; |
Line 262... | Line 299... | ||
262 | scmin,durmin,scmax,durmax, |
299 | scmin,durmin,scmax,durmax, |
263 | scdeviat, durdeviat, |
300 | scdeviat, durdeviat, |
264 | cid); |
301 | cid); |
265 | } |
302 | } |
266 | 303 | ||
- | 304 | ||
- | 305 | /* ecriture de la sortie */ |
|
267 | void output(void) |
306 | void output(void) |
268 | { |
307 | { |
269 | int i; |
308 | int i; |
270 | for(i=0;i<MAX_SHEETS*MAX_EXOS;i++) { outsheetexo(i, 0);} |
309 | for(i=0;i<MAX_SHEETS*MAX_EXOS;i++) { outsheetexo(i, 0);} |
271 | for(i=0;i<MAX_EXAMS*MAX_EXOS;i++) { outexamexo(i);} |
310 | for(i=0;i<MAX_EXAMS*MAX_EXOS;i++) { outexamexo(i);} |