Subversion Repositories wimsdev

Rev

Rev 18085 | Rev 18088 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18085 Rev 18087
Line 366... Line 366...
366
 
366
 
367
/* Returns the status of a sheet, or -1 if error */
367
/* Returns the status of a sheet, or -1 if error */
368
int getsheetstatus(char *classe, int sheet)
368
int getsheetstatus(char *classe, int sheet)
369
{
369
{
370
  char *p, *st, buf[MAX_LINELEN+1], namebuf[MAX_FNAME+1];
370
  char *p, *st, buf[MAX_LINELEN+1], namebuf[MAX_FNAME+1];
371
  int i,j,res;
371
  int i,j,res,lnb;
372
  char *p1,buf2[MAX_LINELEN],buf4[MAX_LINELEN];
372
  char *p1,buf1[MAX_LINELEN],buf2[MAX_LINELEN];
373
  char buf5[MAX_LINELEN],buf6[MAX_LINELEN];
373
  char buf3[MAX_LINELEN],buf4[MAX_LINELEN];
374
 
-
 
375
  if(isexam || score_isexam) st="exam"; else st="sheet";
374
  if(isexam || score_isexam) {st="exam"; lnb=8;} else {st="sheet";lnb=9;};
376
  mkfname(namebuf,"%s/%s/%ss/.%ss",class_base,classe,st,st);
375
  mkfname(namebuf,"%s/%s/%ss/.%ss",class_base,classe,st,st);
377
  direct_datafile=1;datafile_fnd_record(namebuf,sheet,buf);direct_datafile=0;
376
  direct_datafile=1;datafile_fnd_record(namebuf,sheet,buf);direct_datafile=0;
378
  p=find_word_start(buf); if(*p==0) return -1;
377
  p=find_word_start(buf); if(*p==0) return -1;
379
  i=*p-'0'; if(i>5 || i<0) i=-1;
378
  i=*p-'0'; if(i>5 || i<0) i=-1;
380
  if((isexam || score_isexam) && i==0) {
379
  if((isexam || score_isexam) && i==0) {
381
    p=getvar("wims_user"); if(p!=NULL && strcmp(p,"supervisor")==0) i=1;
380
    p=getvar("wims_user"); if(p!=NULL && strcmp(p,"supervisor")==0) i=1;
382
  }
381
  }
383
  res=i;
382
  res=i;
384
  if (res == 0 || res > 2)
383
  if (res == 0 || res > 2)
385
    goto ret;
384
    goto ret;
386
  if (strcmp(score_user,"supervisor")==0 || score_user[0]==0)
385
  if (strcmp(score_user,"supervisor")==0 || score_user[0]==0)
387
    goto ret;
386
    goto ret;
388
  mkfname(namebuf,"%s/%s/%ss/.%ss",class_base,classe,st,st);
-
 
389
  direct_datafile=1;datafile_fnd_record(namebuf,sheet,buf);direct_datafile=0;
-
 
390
  fnd_line(buf,9,buf2);
387
  fnd_line(buf,lnb,buf1);
391
  rows2lines(buf2);
388
  rows2lines(buf1);
392
  mkfname(namebuf,"%s/%s/.users/%s",class_base,classe,score_user);
389
  mkfname(namebuf,"%s/%s/.users/%s",class_base,classe,score_user);
393
  for(i=1;;++i){
390
  for(i=1;;++i){
394
    fnd_line(buf2,i,buf);
391
    fnd_line(buf1,i,buf);
395
    if(*buf==0) break;
392
    if(*buf==0) break;
396
    for (j=1;;++j){
393
    for (j=1;;++j){
397
            fnd_item(buf,j,buf4);
394
            fnd_item(buf,j,buf2);
398
            if (buf4[0]==0) {res = 3; goto ret;}
395
            if (buf2[0]==0) {res = 3; goto ret;}
399
            p1=strchr(buf4,'=');
396
            p1=strchr(buf2,'=');
400
            if(p1==NULL) break;
397
            if(p1==NULL) break;
401
            *p1=0;
398
            *p1=0;
402
            snprintf(buf5,sizeof(buf5),"%s_%s","user_techvar",buf4);
399
            snprintf(buf3,sizeof(buf3),"%s_%s","user_techvar",buf2);
403
            getdef(namebuf,buf5,buf6);
400
            getdef(namebuf,buf3,buf4);
404
            if(strcmp(buf6,p1+1)) break;
401
            if(strcmp(buf4,p1+1)) break;
405
          }
402
          }
406
  }
403
  }
407
  ret:
404
  ret:
408
  return res;
405
  return res;
409
}
406
}
Line 531... Line 528...
531
/* get status of a sheet in a class: can be 0, 1, 2 or 3
528
/* get status of a sheet in a class: can be 0, 1, 2 or 3
532
  (in preparation, active, perime or hidden) */
529
  (in preparation, active, perime or hidden) */
533
void calc_getsheetstatus(char *p)
530
void calc_getsheetstatus(char *p)
534
{
531
{
535
  _scoreparm(p);
532
  _scoreparm(p);
536
  if(*score_class==0 || score_sheet==0) {
533
  if(*score_class==0 || (score_sheet==0 && score_isexam==0)) {
537
    *p=0; return;
534
    *p=0; return;
538
  }
535
  }
539
  snprintf(p,20,"%d",getsheetstatus(score_class, score_sheet));
536
  snprintf(p,20,"%d",getsheetstatus(score_class, score_sheet?score_sheet:score_isexam));
540
}
537
}
541
 
538
 
542
/* whether there are too much tries for the exo return yes or no */
539
/* whether there are too much tries for the exo return yes or no */
543
void calc_getscoremaxexotry(char *p)
540
void calc_getscoremaxexotry(char *p)
544
{
541
{