Rev 16717 | Rev 16725 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 16717 | Rev 16724 | ||
---|---|---|---|
Line 1052... | Line 1052... | ||
1052 | if(*sh=='P') {public_sheet=1; sh++;} /* for public sheet file is in session */ |
1052 | if(*sh=='P') {public_sheet=1; sh++;} /* for public sheet file is in session */ |
1053 | if(*sh=='F') { /* for freework */ |
1053 | if(*sh=='F') { /* for freework */ |
1054 | freework_sheet=1; sh++; |
1054 | freework_sheet=1; sh++; |
1055 | shname="Wfreework"; |
1055 | shname="Wfreework"; |
1056 | dirname="freeworks"; |
1056 | dirname="freeworks"; |
1057 | } |
1057 | } |
1058 | else { /* for sheet */ |
1058 | else { /* for sheet */ |
1059 | shname="sheet"; |
1059 | shname="sheet"; |
1060 | dirname="sheets"; |
1060 | dirname="sheets"; |
1061 | } |
1061 | } |
1062 | u=getvar("wims_user"); if(u==NULL) u=""; |
1062 | u=getvar("wims_user"); if(u==NULL) u=""; |
1063 | if(sh!=NULL && *sh!=0) { |
1063 | if(sh!=NULL && *sh!=0) { |
1064 | char buf[MAX_LINELEN+1],ubuf[32], nbuf[1024], *c, *m; |
1064 | char buf[MAX_LINELEN+1],ubuf[32], nbuf[1024], *c, *m; |
1065 | char *p1,*p2,*p3,*p4,*p5; |
1065 | char *p1,*p2,*p3,*p4,*p5; |
1066 | int i,j,sheet; |
1066 | int i,j,sheet; |
Line 1102... | Line 1102... | ||
1102 | } |
1102 | } |
1103 | } |
1103 | } |
1104 | } |
1104 | } |
1105 | snprintf(nbuf,sizeof(nbuf),":%s\n%s\n",m,rqv); /* rqv : execution parameters for the module ; m is the name of exercise module */ |
1105 | snprintf(nbuf,sizeof(nbuf),":%s\n%s\n",m,rqv); /* rqv : execution parameters for the module ; m is the name of exercise module */ |
1106 | p1=strstr(buf,nbuf); |
1106 | p1=strstr(buf,nbuf); |
1107 | /* this boucle search exercise parameters in buf |
1107 | /* this boucle search exercise parameters in buf |
1108 | calculate num of the exercice in the ressources (sheet /public_sheet / freework) |
1108 | calculate num of the exercice in the ressources (sheet /public_sheet / freework) |
1109 | */ |
1109 | */ |
1110 | while(p1>buf && *(p1-1)!='\n') p1=strstr(p1+1,nbuf); |
1110 | while(p1>buf && *(p1-1)!='\n') p1=strstr(p1+1,nbuf); |
1111 | if(p1!=NULL) { |
1111 | if(p1!=NULL) { |
1112 | p2=strchr(buf,':'); |
1112 | p2=strchr(buf,':'); |
Line 1149... | Line 1149... | ||
1149 | getvar("wims_home"),getvar("wims_class"),sh,u,ubuf); |
1149 | getvar("wims_home"),getvar("wims_class"),sh,u,ubuf); |
1150 | if(ftest(mkfname(NULL,"%s",nbuf))!=is_file) { |
1150 | if(ftest(mkfname(NULL,"%s",nbuf))!=is_file) { |
1151 | force_setvar("wims_fwnumber",sh); |
1151 | force_setvar("wims_fwnumber",sh); |
1152 | force_setvar("wims_fwexo",ubuf); |
1152 | force_setvar("wims_fwexo",ubuf); |
1153 | } |
1153 | } |
1154 | } |
1154 | } |
1155 | else { |
1155 | else { |
1156 | force_setvar("wims_sheet",sh); |
1156 | force_setvar("wims_sheet",sh); |
1157 | force_setvar("wims_exo",ubuf); |
1157 | force_setvar("wims_exo",ubuf); |
1158 | wims_sheet=sheet; wims_exo=i; |
1158 | wims_sheet=sheet; wims_exo=i; |
1159 | } |
1159 | } |
Line 1279... | Line 1279... | ||
1279 | if (cmd_type==cmd_reply && strcmp(mp,home_module)!=0){ |
1279 | if (cmd_type==cmd_reply && strcmp(mp,home_module)!=0){ |
1280 | snprintf(buf,sizeof(buf),"%d",atoi(seedcnt)+1); |
1280 | snprintf(buf,sizeof(buf),"%d",atoi(seedcnt)+1); |
1281 | force_setvar("wims_seedcnt",buf); |
1281 | force_setvar("wims_seedcnt",buf); |
1282 | seedcnt=getvar("wims_seedcnt"); |
1282 | seedcnt=getvar("wims_seedcnt"); |
1283 | force_setvar("wims_seedlastcnt","0"); |
1283 | force_setvar("wims_seedlastcnt","0"); |
1284 | } |
1284 | } |
1285 | else { |
1285 | else { |
1286 | if (strcmp(mp,home_module)==0 || cmd_type==cmd_intro) { |
1286 | if (strcmp(mp,home_module)==0 || cmd_type==cmd_intro) { |
1287 | force_setvar("wims_seedcnt","0"); |
1287 | force_setvar("wims_seedcnt","0"); |
1288 | force_setvar("wims_seedlastcnt","0"); |
1288 | force_setvar("wims_seedlastcnt","0"); |
1289 | } |
1289 | } |
1290 | } |
1290 | } |
Line 1504... | Line 1504... | ||
1504 | /* save exercise parm for registered users */ |
1504 | /* save exercise parm for registered users */ |
1505 | void save_parmreg(void) |
1505 | void save_parmreg(void) |
1506 | { |
1506 | { |
1507 | char *p, *u, *sh, *ex, nbuf[MAX_FNAME+1], dbuf[MAX_FNAME+1]; |
1507 | char *p, *u, *sh, *ex, nbuf[MAX_FNAME+1], dbuf[MAX_FNAME+1]; |
1508 | int s; |
1508 | int s; |
1509 | FILE *varf; |
1509 | FILE *varf; |
1510 | 1510 | ||
1511 | if(cmd_type!=cmd_reply && cmd_type!=cmd_new && cmd_type!=cmd_renew) |
1511 | if(cmd_type!=cmd_reply && cmd_type!=cmd_new && cmd_type!=cmd_renew) |
1512 | return; |
1512 | return; |
1513 | u=getvar("wims_user"); |
1513 | u=getvar("wims_user"); |
1514 | if(class_dir[0]==0 || *u==0) return; |
1514 | if(class_dir[0]==0 || *u==0) return; |
Line 1578... | Line 1578... | ||
1578 | fprintf(varf,"w_wims_checktime1=%lu\n\ |
1578 | fprintf(varf,"w_wims_checktime1=%lu\n\ |
1579 | w_wims_checktime2=%s\n",nowtime,nowstr); |
1579 | w_wims_checktime2=%s\n",nowtime,nowstr); |
1580 | _write_var("wims_seed",varf,1,1); |
1580 | _write_var("wims_seed",varf,1,1); |
1581 | _write_vars(varf); |
1581 | _write_vars(varf); |
1582 | fclose(varf); |
1582 | fclose(varf); |
1583 | } |
1583 | } |
1584 | } |
1584 | } |
1585 | 1585 | ||
1586 | /* save variables to session var file */ |
1586 | /* save variables to session var file */ |
1587 | void save_session_vars(void) |
1587 | void save_session_vars(void) |
1588 | { |
1588 | { |
1589 | int i; |
1589 | int i; |
Line 1635... | Line 1635... | ||
1635 | mkfname(buf,"%s/exolog.%s.%s",session_prefix,sh,ex); |
1635 | mkfname(buf,"%s/exolog.%s.%s",session_prefix,sh,ex); |
1636 | } |
1636 | } |
1637 | else { mkfname(buf,"%s/exolog",session_prefix);} |
1637 | else { mkfname(buf,"%s/exolog",session_prefix);} |
1638 | if(cmd_type==cmd_new || cmd_type==cmd_renew) unlink(buf); |
1638 | if(cmd_type==cmd_new || cmd_type==cmd_renew) unlink(buf); |
1639 | exolog(buf); |
1639 | exolog(buf); |
1640 | } |
1640 | } |
1641 | /* for auto log of exercise in freework */ |
1641 | /* for auto log of exercise in freework */ |
1642 | if(freeworklogf[0]!=0) { |
1642 | if(freeworklogf[0]!=0) { |
1643 | char buf[MAX_FNAME+1],*sess,*varf,*varg,c; |
1643 | char buf[MAX_FNAME+1],*sess,*varf,*varg,c; |
1644 | mkdirs(freeworklogd); |
1644 | mkdirs(freeworklogd); |
1645 | sess=getvar("wims_session"); |
1645 | sess=getvar("wims_session"); |
Line 1654... | Line 1654... | ||
1654 | } |
1654 | } |
1655 | } |
1655 | } |
1656 | } |
1656 | } |
1657 | } |
1657 | } |
1658 | if(var_def_buf) free(var_def_buf); |
1658 | if(var_def_buf) free(var_def_buf); |
- | 1659 | } |
|
- | 1660 | ||
- | 1661 | void my_debug(char*s,...) |
|
- | 1662 | { |
|
- | 1663 | va_list vp; |
|
- | 1664 | char buf[MAX_LINELEN+1]; |
|
- | 1665 | ||
- | 1666 | va_start(vp,s); |
|
- | 1667 | vsnprintf(buf,sizeof(buf),s,vp); |
|
- | 1668 | va_end(vp); |
|
- | 1669 | // better with zsh, but not always install |
|
- | 1670 | call_sh("echo -n '%s' >> /home/svn/wims/tmp/debug",buf); |
|
- | 1671 | // the directory must be changed according to the installation ! |
|
1659 | } |
1672 | } |