Rev 15708 | Rev 15852 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 15708 | Rev 15847 | ||
---|---|---|---|
Line 43... | Line 43... | ||
43 | rscore data is created (table of structures). |
43 | rscore data is created (table of structures). |
44 | according to the value of wims_sheet or wims_exo |
44 | according to the value of wims_sheet or wims_exo |
45 | */ |
45 | */ |
46 | int getscoreuser(char *classe, char *user) |
46 | int getscoreuser(char *classe, char *user) |
47 | { |
47 | { |
48 | int i |
48 | int i, osh, sh; |
49 | double s; |
- | |
50 | char *nowuser, *nowsheet, *nowexo, *nowscore; |
49 | char *nowuser, *nowsheet, *nowexo, *nowscore; |
51 | char *pp; |
50 | char *pp; |
52 | if(user==NULL || *user==0) { |
51 | if(user==NULL || *user==0) { |
53 | user=getvar("wims_user"); |
52 | user=getvar("wims_user"); |
54 | if(user==NULL || *user==0) return -1; |
53 | if(user==NULL || *user==0) return -1; |
Line 79... | Line 78... | ||
79 | } |
78 | } |
80 | /* 3 is here the length of "OK " */ |
79 | /* 3 is here the length of "OK " */ |
81 | pp=scorebuf+sizeof(int)+3; rscore=(struct scoreresult *) pp; |
80 | pp=scorebuf+sizeof(int)+3; rscore=(struct scoreresult *) pp; |
82 | scorecnt=(i-sizeof(int)-3)/sizeof(scoreresult); |
81 | scorecnt=(i-sizeof(int)-3)/sizeof(scoreresult); |
83 | if(scorecnt>MAX_CLASSEXOS) module_error("too_many_exercises"); |
82 | if(scorecnt>MAX_CLASSEXOS) module_error("too_many_exercises"); |
- | 83 | osh=-1; |
|
84 |
|
84 | for(i=totsheets=0;i<scorecnt;i++) { |
85 | sh= |
85 | sh=rscore[i].sh; |
- | 86 | /* MAX_SHEETS doit être inférieur à 255 donc on n'atteint pas l'examen */ |
|
86 | if( |
87 | if (sh >= MAX_SHEETS) break; |
87 |
|
88 | while(osh<sh) |
88 |
|
89 | {++osh; scoresum[osh]=shexocnt[osh]=0; sheetstart[osh]=i;} |
89 |
|
90 | scoresum[sh]+=rscore[i].require*rscore[i].weight*rscore[i].active; |
- | 91 | shexocnt[sh]++; |
|
90 | } |
92 | } |
91 | if(osh>0) scoresum[osh-1]=s; |
- | |
92 | totsheets=osh; |
93 | totsheets=osh+1; |
93 | for(j=0;j<totsheets-1;j++) shexocnt[j]=sheetstart[j+1]-sheetstart[j]; |
- | |
94 | shexocnt[totsheets-1]=i-sheetstart[totsheets-1]; |
- | |
- | 94 | ||
95 | examstart=i; examcnt=scorecnt-examstart; |
95 | examstart=i; examcnt=scorecnt-examstart; |
96 | mystrncpy(rscore_class,classe,sizeof(rscore_class)); |
96 | mystrncpy(rscore_class,classe,sizeof(rscore_class)); |
97 | mystrncpy(rscore_user,user,sizeof(rscore_user)); |
97 | mystrncpy(rscore_user,user,sizeof(rscore_user)); |
98 | return 0; |
98 | return 0; |
99 | } |
99 | } |
100 | /* work : exo */ |
100 | /* work : exo */ |
Line 182... | Line 182... | ||
182 | _scoreparm(p); |
182 | _scoreparm(p); |
183 | if(*score_class==0 || *score_user==0) return; |
183 | if(*score_class==0 || *score_user==0) return; |
184 | if(getscoreuser(score_class,score_user)<0) return; |
184 | if(getscoreuser(score_class,score_user)<0) return; |
185 | /* 2^8 no_sheet + no_exo_in_the_sheet so limit no_exo to 2^8 */ |
185 | /* 2^8 no_sheet + no_exo_in_the_sheet so limit no_exo to 2^8 */ |
186 | for(i=osh=0,p1=p;i<scorecnt && p1-p<MAX_LINELEN-32;i++) { |
186 | for(i=osh=0,p1=p;i<scorecnt && p1-p<MAX_LINELEN-32;i++) { |
187 | sh= |
187 | sh=rscore[i].sh+1; if(sh<1 || sh>MAX_SHEETS) break; |
188 | if(score_sheet!=0) { |
188 | if(score_sheet!=0) { |
189 | if(sh<score_sheet) continue; |
189 | if(sh<score_sheet) continue; |
190 | if(sh>score_sheet || sh>MAX_SHEETS) break; |
190 | if(sh>score_sheet || sh>MAX_SHEETS) break; |
191 | } |
191 | } |
192 | ex= |
192 | ex=rscore[i].exo+1; |
193 | if(score_exo!=0 && ex!=score_exo) continue; |
193 | if(score_exo!=0 && ex!=score_exo) continue; |
194 | if(osh!=0 && sh!=osh) *p1++='\n'; |
194 | if(osh!=0 && sh!=osh) *p1++='\n'; |
195 | switch(dtype) { |
195 | switch(dtype) { |
196 | case sr_require: {d=rscore[i].require; break;} |
196 | case sr_require: {d=rscore[i].require; break;} |
197 | case sr_weight: {d=rscore[i].weight; break;} |
197 | case sr_weight: {d=rscore[i].weight; break;} |
Line 316... | Line 316... | ||
316 | if(rscore[j].mean>=1) { |
316 | if(rscore[j].mean>=1) { |
317 | double dt=rscore[j].score; |
317 | double dt=rscore[j].score; |
318 | float db=rscore[j].best; |
318 | float db=rscore[j].best; |
319 | float dl=rscore[j].level; |
319 | float dl=rscore[j].level; |
320 | if(rscore[j].mean<2) {dt=dt/2; db=db/2; dl=dl/2;} |
320 | if(rscore[j].mean<2) {dt=dt/2; db=db/2; dl=dl/2;} |
321 | d=dt*rscore[j].weight; |
321 | d=dt*rscore[j].weight*rscore[j].active; |
322 | /* quality */ |
322 | /* quality; barycenter with coefficients d */ |
323 | mean+=rscore[j].mean*d; |
323 | mean+=rscore[j].mean*d; |
324 | /* cumulative score */ |
324 | /* cumulative score */ |
325 | tot+=d; |
325 | tot+=d; |
326 | /* best */ |
326 | /* best */ |
327 | totb+=db*rscore[j].weight; |
327 | totb+=db*rscore[j].weight*rscore[j].active; |
328 | /* level */ |
328 | /* level */ |
329 | totl+=dl*rscore[j].weight; |
329 | totl+=dl*rscore[j].weight*rscore[j].active; |
330 | totw+=rscore[j].weight; |
330 | totw+=rscore[j].weight*rscore[j].active; |
331 | } |
331 | } |
332 | } |
332 | } |
333 | if(tot>0) {d=mean/tot;} else d=0; |
333 | if(tot>0) {d=mean/tot;} else d=0; |
334 | /* cumulative score */ |
334 | /* cumulative score */ |
335 | p1=moneyprint(p1,rint(100*tot/scoresum[i])); *p1++=' '; |
335 | p1=moneyprint(p1,rint(100*tot/scoresum[i])); *p1++=' '; |
Line 657... | Line 657... | ||
657 | s=getvar("exotrymax"); |
657 | s=getvar("exotrymax"); |
658 | if(s==NULL || *s==0) return 0; |
658 | if(s==NULL || *s==0) return 0; |
659 | getscoreuser(classe,user); |
659 | getscoreuser(classe,user); |
660 | char *p=getvar("wims_scorereg"); |
660 | char *p=getvar("wims_scorereg"); |
661 | for(i=0;i<scorecnt;i++) { |
661 | for(i=0;i<scorecnt;i++) { |
662 | sh= |
662 | sh=rscore[i].sh+1; |
663 | if (she!=sh) continue; |
663 | if (she!=sh) continue; |
664 | ex= |
664 | ex=rscore[i].exo+1; |
665 | if(exo!=ex) continue; |
665 | if(exo!=ex) continue; |
666 | if(cmd_type==cmd_new || cmd_type==cmd_renew) |
666 | if(cmd_type==cmd_new || cmd_type==cmd_renew) |
667 | if(rscore[i].new >= atoi(s)) { |
667 | if(rscore[i].new >= atoi(s)) { |
668 | if(strcmp(p,"suspend")!=0) setvar("wims_scorereg","exotrymax"); |
668 | if(strcmp(p,"suspend")!=0) setvar("wims_scorereg","exotrymax"); |
669 | return 1; |
669 | return 1; |
Line 684... | Line 684... | ||
684 | if(strcmp(user,"supervisor")==0) return NULL; |
684 | if(strcmp(user,"supervisor")==0) return NULL; |
685 | s=getvar("seedrepeat"); |
685 | s=getvar("seedrepeat"); |
686 | if(s==NULL || *s==0 || atoi(s)<=0) return NULL; |
686 | if(s==NULL || *s==0 || atoi(s)<=0) return NULL; |
687 | getscoreuser(classe,user); |
687 | getscoreuser(classe,user); |
688 | for(i=0;i<scorecnt;i++) { |
688 | for(i=0;i<scorecnt;i++) { |
689 | sh= |
689 | sh=rscore[i].sh+1; |
690 | if (she!=sh) continue; |
690 | if (she!=sh) continue; |
691 | ex= |
691 | ex=rscore[i].exo+1; |
692 | if(exo!=ex) continue; |
692 | if(exo!=ex) continue; |
693 | if(atoi(rscore[i].seedlast)==0) { |
693 | if(atoi(rscore[i].seedlast)==0) { |
694 | char *seed=getvar("wims_seed"); |
694 | char *seed=getvar("wims_seed"); |
695 | return seed; |
695 | return seed; |
696 | } |
696 | } |