Subversion Repositories wimsdev

Rev

Rev 8155 | Rev 8340 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. /*    Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis
  2.  *
  3.  *  This program is free software; you can redistribute it and/or modify
  4.  *  it under the terms of the GNU General Public License as published by
  5.  *  the Free Software Foundation; either version 2 of the License, or
  6.  *  (at your option) any later version.
  7.  *
  8.  *  This program is distributed in the hope that it will be useful,
  9.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.  *  GNU General Public License for more details.
  12.  *
  13.  *  You should have received a copy of the GNU General Public License
  14.  *  along with this program; if not, write to the Free Software
  15.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17.  
  18. /* Routines treating user scores. */
  19. #include "wims.h"
  20.  
  21. double oldfactor=0.85;     /* quality factor, should remain stable. */
  22.  
  23. enum {sr_require, sr_weight, sr_score, sr_mean, sr_remain, sr_last, sr_try, sr_best, sr_level};
  24. char scorebuf[MAX_CLASSEXOS*sizeof(scoreresult)+32];
  25. struct scoreresult *rscore;
  26. int scorecnt;
  27. double scoresum[MAX_SHEETS];
  28. int sheetstart[MAX_SHEETS], shexocnt[MAX_SHEETS];
  29. int examstart, examcnt;
  30. char rscore_class[MAX_CLASSLEN+1];
  31. char rscore_user[MAX_NAMELEN+1];
  32.  
  33. int totsheets=0;
  34. int score_ispublic=0;
  35. int score_status=-1;          /* save of score status */
  36. int score_statussheet=-1;
  37. int score_statusisexam=-1;
  38. double scorerecfactor=0.9;
  39.  
  40. /* gather user score, core routine. */
  41. int getscoreuser(char *classe, char *user)
  42. {
  43.   int i, j, osh, sh;
  44.   double s;
  45.   char *nowuser, *nowsheet, *nowexo, *nowscore;
  46.   char *pp;
  47.   if(*user==0) {
  48.     user=getvar("wims_user");
  49.     if(user==NULL || *user==0) return -1;
  50.   }
  51.   if(strcmp(classe,rscore_class)==0 && strcmp(user,rscore_user)==0) return 0;
  52.   nowsheet=nowexo=nowscore="";
  53.   nowuser=getvar("wims_user"); if(nowuser!=NULL && strcmp(user,nowuser)==0) {
  54.     nowscore=getvar("module_score"); if(nowscore!=NULL && *nowscore!=0) {
  55.       nowsheet=getvar("wims_sheet"); if(nowsheet==NULL) nowsheet="";
  56.       nowexo=getvar("wims_exo"); if(nowexo==NULL) nowexo="";
  57.     }
  58.     else nowscore="";
  59.   }
  60.   snprintf(scorebuf+sizeof(int),sizeof(scorebuf)-sizeof(int),
  61.        "-c%s -u%s getscore %s %s %s",
  62.        classe,user,nowsheet,nowexo,nowscore);
  63.   i=kerneld(scorebuf,sizeof(scorebuf));
  64.   if(i<0)  internal_error("getscoreuser(): daemon failure.");
  65.   if(memcmp(scorebuf+sizeof(int),"OK",2)!=0) {
  66.     if(memcmp(scorebuf+sizeof(int),"ERROR",5)==0) {
  67.       module_error(find_word_start(scorebuf+sizeof(int)+8));
  68.     }
  69.     else internal_error("getscoreuser(): communication error with wimslogd.");
  70.   }
  71.   pp=scorebuf+sizeof(int)+3; rscore=(struct scoreresult *) pp;
  72.   scorecnt=(i-sizeof(int)-3)/sizeof(scoreresult);
  73.   if(scorecnt>MAX_CLASSEXOS) module_error("too_many_exercises");
  74.   s=0; for(i=osh=0;i<scorecnt;i++) {
  75.     sh=(rscore[i].num>>8)+1;
  76.     if(sh<1 || sh>MAX_SHEETS) break;
  77.     if(osh>0 && osh<sh) {scoresum[osh-1]=s; s=0;}
  78.     for(;osh<sh && osh<MAX_SHEETS;osh++) sheetstart[osh]=i;
  79.     s+=rscore[i].require*rscore[i].weight;
  80.   }
  81.   if(osh>0) scoresum[osh-1]=s; totsheets=osh;
  82.   for(j=0;j<totsheets-1;j++) shexocnt[j]=sheetstart[j+1]-sheetstart[j];
  83.   shexocnt[totsheets-1]=i-sheetstart[totsheets-1];
  84.   examstart=i; examcnt=scorecnt-examstart;
  85.   mystrncpy(rscore_class,classe,sizeof(rscore_class));
  86.   mystrncpy(rscore_user,user,sizeof(rscore_user));
  87.   return 0;
  88. }
  89. /* work : exo */
  90. char *scorepname[]={
  91.      "class","user","sheet","work","exam"
  92. };
  93. #define scorepname_no (sizeof(scorepname)/sizeof(scorepname[0]))
  94. char score_class[MAX_CLASSLEN+1];
  95. int score_sheet,score_exo,score_isexam;
  96. char score_user[256];
  97.  
  98. /* Uniformed treatment of score command parameters
  99.  * format: class=? user=? sheet=? work=?
  100.  * all are optional.
  101.  */
  102. void _scoreparm(char *p)
  103. {
  104.     int i;
  105.     char *pn, *pe, *pd, *pf;
  106.     char sav;
  107.  
  108.     score_sheet=score_exo=score_isexam=score_ispublic=0; *score_class=0;
  109.     score_user[0]=0;
  110.     for(i=0;i<scorepname_no;i++) {
  111.      pf=p;
  112.      ahead:
  113.      pn=strstr(pf,scorepname[i]); pf=pn+1;
  114.      if(pn==NULL) continue;
  115.      if(pn>p && !isspace(*(pn-1))) goto ahead;
  116.      pe=find_word_start(pn+strlen(scorepname[i]));
  117.      if(*pe!='=') goto ahead;
  118.      pd=find_word_start(pe+1);
  119.      pf=find_word_end(pd);
  120.      if(pf<=pd) continue;
  121.      sav=*pf; *pf=0;
  122.      switch(i) {
  123.          case 0: /* class */
  124.            mystrncpy(score_class,pd,sizeof(score_class)); break;
  125.          case 1: /* user */
  126.            mystrncpy(score_user,pd,sizeof(score_user)); break;
  127.          case 2: { /* sheet */
  128.           if(*pd=='P') {pd++; score_ispublic=1;}
  129.           score_sheet=atoi(pd);
  130.           break;
  131.          }
  132.          case 3: /* work=exo */
  133.            score_exo=atoi(pd); break;
  134.          case 4: /* exam */
  135.            score_isexam=1; break;
  136.      }
  137.      *pf=sav; ovlstrcpy(pn, pf);
  138.     }
  139.     *p=0;
  140.     if((*score_class!=0 || score_user[0]!=0) && !trusted_module()) {
  141.      module_error("not_trusted"); return;
  142.     }
  143.     if(*score_class==0) {
  144.      char *classe;
  145.      classe=getvar("wims_class");
  146.      if(classe==NULL || *classe==0) return;
  147.      else mystrncpy(score_class,classe,sizeof(score_class));
  148.     }
  149.     if(score_user[0]==0) {
  150.      char *user;
  151.      user=getvar("wims_user");
  152.      if(user!=NULL) mystrncpy(score_user,user,sizeof(score_user));
  153.     }
  154. }
  155.  
  156. /* gather score: relatif to some of the
  157.  *  user class work sheet exam
  158.  *  dtype can be require weight score mean remain best last level try
  159.  */
  160.  
  161. void _getscore(char *p,int dtype)
  162. {
  163.     int i,sh,ex,osh;
  164.     float d;
  165.     char *p1;
  166.  
  167.     _scoreparm(p);
  168.     if(*score_class==0 || *score_user==0) return;
  169.     if(getscoreuser(score_class,score_user)<0) return;
  170. /*  2^8 no_sheet + no_exo_in_the_sheet so limit no_exo to 2^8 */
  171.     for(i=osh=0,p1=p;i<scorecnt && p1-p<MAX_LINELEN-32;i++) {
  172.      sh=(rscore[i].num>>8)+1; if(sh<1 || sh>MAX_SHEETS) break;
  173.      if(score_sheet!=0) {
  174.          if(sh<score_sheet) continue;
  175.          if(sh>score_sheet || sh>MAX_SHEETS) break;
  176.      }
  177.      ex=((rscore[i].num)&255)+1;
  178.      if(score_exo!=0 && ex!=score_exo) continue;
  179.      if(osh!=0 && sh!=osh) *p1++='\n';
  180.      switch(dtype) {
  181.          case sr_require: {d=rscore[i].require; break;}
  182.          case sr_weight: {d=rscore[i].weight; break;}
  183.          case sr_score: {d=rscore[i].score; break;}
  184.          case sr_mean: {d=rscore[i].mean; break;}
  185.          case sr_remain: {d=rscore[i].require-rscore[i].score; break;}
  186.          case sr_last: {d=rscore[i].last; break;}
  187.          case sr_try: {d=rscore[i].try; break;}
  188.          case sr_best: {d=rscore[i].best; break;}
  189.          case sr_level: {d=rscore[i].level ;break;}
  190.          default: {d=0; break;}
  191.      }
  192.      p1=moneyprint(p1,d); *p1++=' ';
  193.      osh=sh;
  194.     }
  195.     *p1++='\n'; *p1=0;
  196. }
  197.  
  198. /* gather user score. */
  199. void calc_getscore(char *p)
  200. {
  201.   _getscore(p,sr_score);
  202. }
  203.  
  204. /* gather user score average. */
  205. void calc_getscoremean(char *p)
  206. {
  207.   _getscore(p,sr_mean);
  208. }
  209.  
  210. /* gather remaining of score to get for user. */
  211. void calc_getscoreremain(char *p)
  212. {
  213.   _getscore(p,sr_remain);
  214. }
  215.  
  216. /* Require score table. */
  217. void calc_getscorerequire(char *p)
  218. {
  219.   _getscore(p,sr_require);
  220. }
  221.  
  222. /* Score weight table. */
  223. void calc_getscoreweight(char *p)
  224. {
  225.   _getscore(p,sr_weight);
  226. }
  227. /* user last score*/
  228. void calc_getscorelast(char *p)
  229. {
  230.   _getscore(p,sr_last);
  231. }
  232.  
  233. /* gather user score try numbers. */
  234. void calc_getscoretry(char *p)
  235. {
  236.   _getscore(p,sr_try);
  237. }
  238.  
  239. /* if the required points are 10* N, gather N user best scores */
  240. void calc_getscorebest(char *p)
  241. {
  242.   _getscore(p,sr_best);
  243. }
  244.  
  245. /* gather user score average. */
  246. void calc_getscorelevel(char *p)
  247. {
  248.   _getscore(p,sr_level);
  249. }
  250.  
  251. /* percentage of work done for each sheet:
  252.  * score mean best level
  253.  * as follows
  254.  * score=100*cumulative_points/required_points) (< 100)
  255.  * mean=quality (<10)
  256.  * best=10*(required/10 best_scores)/required_points (< 100)
  257.  * level=minimum of the required/10 best_scores (< 10)
  258.  */
  259.  
  260.  void calc_getscorepercent(char *p)
  261. {
  262.   int i,j,jend;
  263.   double tot, mean, totb, totl, totw, d;
  264.   char *p1;
  265.  
  266.   _scoreparm(p);
  267.   if(*score_class==0 || *score_user==0) return;
  268.   if(getscoreuser(score_class,score_user)<0) return;
  269.   for(p1=p,i=0;i<totsheets && p1-p<MAX_LINELEN-32;i++) {
  270.     if(scoresum[i]==0) {
  271.       ovlstrcpy(p1,"0 0 0 0\n"); p1+=strlen(p1); continue;
  272.     }
  273.     if(score_sheet!=0 && i!=score_sheet-1) continue;
  274.     if(scoresum[i]<=0) *p1++='\n';
  275.     tot=mean=totb=totl=totw=0; jend=sheetstart[i]+shexocnt[i];
  276.     for(j=sheetstart[i];j<jend;j++) {
  277. /* if mean<1 then ignore score.
  278.  * if mean<2 then half score.
  279.  */
  280.       if(rscore[j].mean>=1) {
  281.         double dt=rscore[j].score;
  282.         float db=rscore[j].best;
  283.         float dl=rscore[j].level;
  284.         if(rscore[j].mean<2) {dt=dt/2; db=db/2; dl=dl/2;}
  285.         d=dt*rscore[j].weight;
  286. /* quality */
  287.         mean+=rscore[j].mean*d;
  288. /* cumulative score */
  289.         tot+=d;
  290. /* best */
  291.         totb+=db*rscore[j].weight;
  292. /* level */
  293.         totl+=dl*rscore[j].weight;
  294.         totw+=rscore[j].weight;
  295.       }
  296.     }
  297.     if(tot>0) {d=mean/tot;} else d=0;
  298. /* cumulative score */
  299.     p1=moneyprint(p1,rint(100*tot/scoresum[i])); *p1++=' ';
  300. /* quality */
  301.     p1=moneyprint(p1,d); *p1++=' ';
  302. /* best */
  303.     p1=moneyprint(p1,rint(100*totb/scoresum[i])); *p1++=' ';
  304. /* level */
  305.     p1=moneyprint(p1,rint(10*totl/totw));
  306.  
  307.    *p1++='\n';
  308.   }
  309.   *p1=0;
  310. }
  311.  
  312. /* Returns the status of a sheet, or -1 if error */
  313. int getsheetstatus(char *classe, int sheet)
  314. {
  315.   char *p, *st, buf[MAX_LINELEN+1], namebuf[MAX_FNAME+1];
  316.   int i;
  317.  
  318.   if(isexam || score_isexam) st="exam"; else st="sheet";
  319.   mkfname(namebuf,"%s/%s/%ss/.%ss",class_base,classe,st,st);
  320.   direct_datafile=1;datafile_fnd_record(namebuf,sheet,buf);direct_datafile=0;
  321.   p=find_word_start(buf); if(*p==0) return -1;
  322.   i=*p-'0'; if(i>5 || i<0) i=-1;
  323.   if((isexam || score_isexam) && i==0) {
  324.     p=getvar("wims_user"); if(p!=NULL && strcmp(p,"supervisor")==0) i=1;
  325.   }
  326.   return i;
  327. }
  328.  
  329. /* return 1 if a word of bf2 is a substring of host.
  330.  * Content of bf2 is destroyed.
  331.  */
  332. int _subword(char bf2[])
  333. {
  334.   char *p1, *p2;
  335.   for(p1=strchr(bf2,'\\'); p1!=NULL; p1=strchr(p1+1,'\\')) {
  336.     char buf[MAX_LINELEN+1], buf2[MAX_LINELEN+1], fbuf[MAX_FNAME+1];
  337.     char *classp, *classp2, *userp, *scp;
  338.     classp=getvar("wims_class"); userp=getvar("wims_user");
  339.     if(classp==NULL || userp==NULL || *classp==0 || *userp==0) break;
  340.     scp=getvar("wims_superclass");
  341.     if(scp!=NULL && *scp!=0) classp2=scp; else classp2=classp;
  342.     if(p1>bf2 && !isspace(*(p1-1))) continue;
  343.     if(!isalnum(*(p1+1))) continue;
  344.     p2=find_word_end(p1); if(p2>=p1+MAX_NAMELEN) continue;
  345.     memmove(buf2, p1+1, p2-p1-1); buf2[p2-p1-1]=0;
  346.     snprintf(buf,sizeof(buf),"user__%s",buf2);
  347.     if(strcmp(userp,"supervisor")==0)
  348.       mkfname(fbuf,"%s/%s/supervisor",class_base,classp);
  349.     else
  350.       mkfname(fbuf,"%s/%s/.users/%s",class_base,classp2,userp);
  351.     getdef(fbuf,buf,buf2); if(buf2[0]==0) ovlstrcpy(buf2,"none");
  352.     string_modify(bf2,p1,p2,buf2);
  353.     p1+=strlen(buf2);
  354.   }
  355.   if((isexam || score_isexam) && bf2[0]=='#') return 1;
  356.   if(wordchr(bf2,"none")!=NULL) return 0;
  357.   if(wordchr(bf2,"all")!=NULL) return 1;
  358.   p1=find_word_start(bf2); if(*p1==0) return 1;
  359.   return checkhostt(p1);
  360. }
  361.  
  362. /* Returns 1 if score registration is open, 0 otherwise. */
  363. int _getscorestatus(char *classe, int sheet)
  364. {
  365.   char nbuf[MAX_LINELEN+1], gbuf[MAX_LINELEN+1];
  366.   char *es;
  367.  
  368.   if(classe==NULL || *classe==0 || sheet<=0) return 1;
  369.   if(getsheetstatus(classe,sheet)!=1) return 0;
  370.   if(*remote_addr==0) return 0;
  371.   if(isexam || score_isexam) {     /* exam simulation */
  372.     accessfile(nbuf,"r","%s/%s/.E%d",class_base,classe,sheet);
  373.     if(nbuf[0]=='#') return 1;
  374.   }
  375. /* Global restriction data */
  376.   accessfile(nbuf,"r","%s/%s/.security",class_base,classe);
  377.   if(nbuf[0]) {
  378.     _getdef(nbuf,"allow",gbuf);
  379.     if(*find_word_start(gbuf)!=0 && _subword(gbuf)==0)
  380.       return 0;
  381.     _getdef(nbuf,"except",gbuf);
  382.     if(*find_word_start(gbuf)!=0 && _subword(gbuf)==1)
  383.       return 0;
  384.   }
  385.  
  386. /* Sheet restriction data */
  387.   if(isexam || score_isexam) es="E"; else es="";
  388.   accessfile(nbuf,"r","%s/%s/.%s%d",class_base,classe,es,sheet);
  389.   if(*find_word_start(nbuf)==0) return 1;
  390.   return _subword(nbuf);
  391. }
  392.  
  393. /* Returns 1 if score registration is open, 0 otherwise. */
  394. int getscorestatus(char *classe, int sheet)
  395. {
  396.   if(score_status<0 || score_statussheet!=sheet
  397.      || score_statusisexam!=isexam) {
  398.     score_statussheet=sheet; score_statusisexam=isexam;
  399.     score_status=_getscorestatus(classe,sheet); score_isexam=0;
  400.     if(score_status==1 && (cmd_type==cmd_new || cmd_type==cmd_renew
  401.                || isexam)) {
  402.       char *p;
  403.       p=getvar("wims_scorereg");
  404.       if(p==NULL || strcmp(p,"suspend")!=0)
  405.          setvar("wims_scoring","pending");
  406.       else setvar("wims_scoring","");
  407.     }
  408.   }
  409.   if(isexam && score_status==0) {
  410.     char *p;
  411.     p=getvar("wims_user"); if(p==NULL || strcmp(p,"supervisor")!=0)
  412.                  user_error("exam_closed");
  413.   }
  414.   return score_status;
  415. }
  416.  
  417. /* Whether score registering is open */
  418. void calc_getscorestatus(char *p)
  419. {
  420.   _scoreparm(p);
  421.   if(*score_class==0 || score_sheet==0 || *score_user==0) {
  422.     *p=0; return;
  423.   }
  424.   if(getscorestatus(score_class, score_sheet))
  425.     ovlstrcpy(p,"yes");
  426.   else ovlstrcpy(p,"no");
  427. }
  428.  
  429. double exam_scoredata[MAX_EXOS];
  430.  
  431. /* get current exam score */
  432. void exam_currscore(int esh)
  433. {
  434.   char *p, *bf, pb[MAX_FNAME+1];
  435.   char *s, *p1, *p2, *e1, *e2;
  436.   int i;
  437.  
  438.   for(i=0;i<MAX_EXOS;i++) exam_scoredata[i]=-1000;
  439. /* session_prefix is not yet defined here */
  440.   s=getvar("wims_session"); if(s==NULL || *s==0) return;
  441.   mystrncpy(pb,s,sizeof(pb));
  442.   p=strchr(pb,'_'); if(p!=NULL) *p=0;
  443.   bf=readfile(mkfname(NULL,"%s/%s/examscore.%d",session_dir,pb,esh),NULL,WORKFILE_LIMIT);
  444.   if(bf==NULL) return;
  445.   for(p1=bf;*p1;p1=p2) {
  446.     p2=strchr(p1,'\n'); if(*p2) *p2++=0;
  447.     else p2=p1+strlen(p1);
  448.     p1=find_word_start(find_word_end(find_word_start(p1)));
  449.     e1=find_word_end(p1); if(*e1) *e1++=0;
  450.     e1=find_word_start(e1); e2=find_word_start(find_word_end(e1));
  451.     *find_word_end(e1)=0;
  452.     i=atoi(p1);
  453.     if(i>=1 && i<=MAX_EXOS &&
  454.        exam_scoredata[i-1]==-1000 && strcmp(e1,"score")==0) {
  455.       *find_word_end(e2)=0;
  456.       exam_scoredata[i-1]=atof(e2);
  457.     }
  458.   }
  459.   free(bf);
  460. }
  461.  
  462. /* Gather exam score. */
  463. void calc_examscore(char *p)
  464. {
  465.   char *p1;
  466.   int i;
  467.  
  468.   _scoreparm(p); *p=0;
  469.   if(*score_class==0 || *score_user==0) return;
  470.   if(getscoreuser(score_class,score_user)<0) return;
  471.   p1=p;
  472.   for(i=0; i<examcnt && p1-p<MAX_LINELEN-32; i++) {
  473.     p1=moneyprint(p1,rscore[examstart+i].score); *p1++=' ';
  474.   }
  475.   *p1++='\n';
  476.   for(i=0; i<examcnt && p1-p<MAX_LINELEN-32; i++) {
  477.     p1=moneyprint(p1,rscore[examstart+i].require); *p1++=' ';
  478.     p1=moneyprint(p1,floor(rscore[examstart+i].mean/2)); *p1++=' ';
  479.     p1=moneyprint(p1,(int) rscore[examstart+i].mean%2); *p1++='\n';
  480.   }
  481.   *p1=0;
  482. }
  483.  
  484. /* check score dependency.
  485.  * returns 1 if requirements are met.
  486.  */
  487. int _depcheck(char *ds, struct scoreresult *rs, int ecnt)
  488. {
  489.   char *p1, *p2, *p3, *p4, *pp;
  490.   int perc, t, sum;
  491.   double tgot, ttot, tmean;
  492.  
  493.   for(p1=ds; *p1; p1=p3) {
  494.     p2=strchr(p1,':'); if(p2==NULL) break;
  495.     *p2++=0; p2=find_word_start(p2);
  496.     for(p3=p2; myisdigit(*p3); p3++);
  497.     if(p3<=p2) break;
  498.     *p3++=0; perc=atoi(p2);
  499.     if(perc<=0 || perc>100) break;
  500.     for(pp=p1; *pp; pp++) if(!myisdigit(*pp)) *pp=' ';
  501.     tgot=ttot=tmean=0; sum=0;
  502.     for(pp=find_word_start(p1); *pp; pp=find_word_start(p4)) {
  503.       p4=find_word_end(pp); if(*p4) *p4++=0;
  504.       t=atoi(pp); if(t<=0 || t>ecnt) goto lend;
  505.       t--;
  506.       ttot+=rs[t].require; tgot+=rs[t].score; tmean+=rs[t].mean;
  507.       sum++;
  508.     }
  509.     if(ttot<10) continue;
  510.     if(tgot/ttot*sqrt(tmean/(sum*10))*100<perc) {
  511.       for(pp=p1;pp<p2-1;pp++) if(!*pp) *pp=',';
  512.       *pp=0; setvar("dep_list",p1);
  513.       return 0;
  514.     }
  515.   lend: ;
  516.   }
  517.   return 1;
  518. }
  519.  
  520. int depcheck(char *sh, int exo, char *deps)
  521. {
  522.   char buf[MAX_LINELEN+1];
  523.   char *s, sbuf[64];
  524.   int i, is;
  525.  
  526.   s=getvar("wims_session");
  527.   if(s==NULL || *s==0 || strstr(s,"robot")!=NULL) return 0;
  528.   mystrncpy(sbuf,s,sizeof(sbuf));
  529.   s=strchr(sbuf,'_'); if(s) *s=0;
  530.   accessfile(buf,"r","../sessions/%s/exodep.%s",sbuf,sh);
  531.   if(buf[0]==0) {     /* no dep file found */
  532.     is=atoi(sh); if(is<=0 || is>totsheets) return 0;
  533.     s=getvar("wims_class"); if(s==NULL || *s==0) return 0;
  534.     getscoreuser(s,"");
  535.     return _depcheck(deps,rscore+sheetstart[is-1],shexocnt[is-1]);
  536.   }
  537.   for(i=1,s=strchr(buf,':'); s && i<exo; i++, s=strchr(s+1,':'));
  538.   if(s==NULL) return 0;     /* bad file or exo number */
  539.   if(myisdigit(*++s)) return 0; else return 1;
  540. }
  541.  
  542. int exam_depcheck(char *deps, int exam)
  543. {
  544.   struct scoreresult esc[MAX_EXOS];
  545.   int i;
  546.   exam_currscore(exam);
  547.   for(i=0;i<MAX_EXOS;i++) {
  548.     esc[i].require=esc[i].mean=10;
  549.     if(exam_scoredata[i]==-1000) esc[i].score=0;
  550.     else esc[i].score=exam_scoredata[i];
  551.   }
  552.   return _depcheck(deps,esc,MAX_EXOS);
  553. }
  554.