Subversion Repositories wimsdev

Rev

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

Rev 18056 Rev 18081
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;
371
  int i,j,res;
-
 
372
  char *p1,buf2[MAX_LINELEN],buf4[MAX_LINELEN];
-
 
373
  char buf5[MAX_LINELEN],buf6[MAX_LINELEN];
372
 
374
 
373
  if(isexam || score_isexam) st="exam"; else st="sheet";
375
  if(isexam || score_isexam) st="exam"; else st="sheet";
374
  mkfname(namebuf,"%s/%s/%ss/.%ss",class_base,classe,st,st);
376
  mkfname(namebuf,"%s/%s/%ss/.%ss",class_base,classe,st,st);
375
  direct_datafile=1;datafile_fnd_record(namebuf,sheet,buf);direct_datafile=0;
377
  direct_datafile=1;datafile_fnd_record(namebuf,sheet,buf);direct_datafile=0;
376
  p=find_word_start(buf); if(*p==0) return -1;
378
  p=find_word_start(buf); if(*p==0) return -1;
377
  i=*p-'0'; if(i>5 || i<0) i=-1;
379
  i=*p-'0'; if(i>5 || i<0) i=-1;
378
  if((isexam || score_isexam) && i==0) {
380
  if((isexam || score_isexam) && i==0) {
379
    p=getvar("wims_user"); if(p!=NULL && strcmp(p,"supervisor")==0) i=1;
381
    p=getvar("wims_user"); if(p!=NULL && strcmp(p,"supervisor")==0) i=1;
380
  }
382
  }
-
 
383
  res=i;
-
 
384
  if (res == 0 || res > 2)
-
 
385
    goto ret;
-
 
386
  if (strcmp(score_user,"supervisor")==0 || score_user[0]==0)
-
 
387
    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);
-
 
391
  rows2lines(buf2);
-
 
392
  mkfname(namebuf,"%s/%s/.users/%s",class_base,class,score_user);
-
 
393
  for(i=1;;++i){
-
 
394
    fnd_line(buf2,i,buf);
-
 
395
    if(*buf==0) break;
-
 
396
    for (j=1;;++j){
-
 
397
            fnd_item(buf,j,buf4);
-
 
398
            if (buf4[0]==0) {res = 3; goto ret;}
-
 
399
            p1=strchr(buf4,'=');
-
 
400
            if(p1==NULL) break;
-
 
401
            *p1=0;
-
 
402
            snprintf(buf5,sizeof(buf5),"%s_%s","user_techvar",buf4);
-
 
403
            getdef(namebuf,buf5,buf6);
-
 
404
            if(strcmp(buf6,p1+1)) break;
-
 
405
          }
-
 
406
  }
-
 
407
  ret:
381
  return i;
408
  return res;
382
}
409
}
383
 
410
 
384
/* return 1 if a word of bf2 is a substring of host
411
/* return 1 if a word of bf2 is a substring of host
385
  and if time restrictions are verified for wims_user
412
  and if time restrictions are verified for wims_user
386
 * Content of bf2 is destroyed.
413
 * Content of bf2 is destroyed.
Line 397... Line 424...
397
    if(scp!=NULL && *scp!=0) classp2=scp; else classp2=classp;
424
    if(scp!=NULL && *scp!=0) classp2=scp; else classp2=classp;
398
    if(p1>bf2 && !isspace(*(p1-1))) continue;
425
    if(p1>bf2 && !isspace(*(p1-1))) continue;
399
    if(!isalnum(*(p1+1))) continue;
426
    if(!isalnum(*(p1+1))) continue;
400
    p2=find_word_end(p1); if(p2>=p1+MAX_NAMELEN) continue;
427
    p2=find_word_end(p1); if(p2>=p1+MAX_NAMELEN) continue;
401
    memmove(buf2, p1+1, p2-p1-1); buf2[p2-p1-1]=0;
428
    memmove(buf2, p1+1, p2-p1-1); buf2[p2-p1-1]=0;
402
    /* get value of technical variable */
429
    /* get value of technical variable for user */
403
    snprintf(buf,sizeof(buf),"user_techvar_%s",buf2);
430
    snprintf(buf,sizeof(buf),"user_techvar_%s",buf2);
404
    if(strcmp(userp,"supervisor")==0)
431
    if(strcmp(userp,"supervisor")==0)
405
      mkfname(fbuf,"%s/%s/supervisor",class_base,classp);
432
      mkfname(fbuf,"%s/%s/supervisor",class_base,classp);
406
    else
433
    else
407
      mkfname(fbuf,"%s/%s/.users/%s",class_base,classp2,userp);
434
      mkfname(fbuf,"%s/%s/.users/%s",class_base,classp2,userp);
408
    getdef(fbuf,buf,buf2);
435
    getdef(fbuf,buf,buf2);
-
 
436
    /* end value for the user */
409
    if(buf2[0]==0) ovlstrcpy(buf2,"EMPTY"); /* in case of no value defined for the user*/
437
    if(buf2[0]==0) ovlstrcpy(buf2,"EMPTY"); /* in case of no value defined for the user*/
410
    /* get time restriction for this value */
438
    /* get time restriction for this value */
411
    snprintf(buf,sizeof(buf),"techvar_%s",buf2);
439
    snprintf(buf,sizeof(buf),"techvar_%s",buf2);
412
    /* mkfname(fbuf,"%s/%s/.E%s",class_base,classp,sheet);
440
    /* mkfname(fbuf,"%s/%s/.E%s",class_base,classp,sheet);
413
     * read time restriction corresponding to the value of
441
     * read time restriction corresponding to the value of
414
     * technical variable in the file of the sheet or exam
442
     * technical variable in the file of the sheet or exam
415
    */
443
    */
416
    getdef(ftbuf,buf,buf2);
444
    getdef(ftbuf,buf,buf2);
-
 
445
    /* value for techvar */
417
    if(buf2[0]==0) ovlstrcpy(buf2,"none");
446
    if(buf2[0]==0) ovlstrcpy(buf2,"none");
418
    /*string_modify(bf2,p1,p2,buf2);*/
447
    /*string_modify(bf2,p1,p2,buf2);*/
419
    bf2=buf2;
448
    bf2=buf2;
420
    p1+=strlen(buf2);
449
    p1+=strlen(buf2);
421
  }
450
  }