Rev 16626 | Rev 16711 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 16626 | Rev 16647 | ||
---|---|---|---|
Line 1022... | Line 1022... | ||
1022 | 1022 | ||
1023 | /* retain initializing parameters, for use in user references */ |
1023 | /* retain initializing parameters, for use in user references */ |
1024 | void set_init_parm(void) |
1024 | void set_init_parm(void) |
1025 | { |
1025 | { |
1026 | char *rq, rqv[MAX_LINELEN*2+2], *u, *sh, *seedr, *exotrymax; |
1026 | char *rq, rqv[MAX_LINELEN*2+2], *u, *sh, *seedr, *exotrymax; |
1027 | char *shname; |
1027 | char *shname, *dirname; |
1028 | int public_sheet; |
1028 | int public_sheet, freework_sheet; |
1029 | 1029 | ||
1030 | if(isexam) return; |
1030 | if(isexam) return; |
- | 1031 | /* reset sheet number and exo nomber for a sheet */ |
|
1031 | force_setvar("wims_sheet",""); force_setvar("wims_exo",""); |
1032 | force_setvar("wims_sheet",""); force_setvar("wims_exo",""); |
- | 1033 | /* reset freework number and exo number for a freework */ |
|
- | 1034 | force_setvar("wims_fwnumber",""); force_setvar("wims_fwexo",""); |
|
1032 | rq=getenv("QUERY_STRING"); |
1035 | rq=getenv("QUERY_STRING"); |
1033 | if(rq==NULL || *rq==0) { |
1036 | if(rq==NULL || *rq==0) { |
1034 | empty: |
1037 | empty: |
1035 | setvar("module_init_parm",""); return; |
1038 | setvar("module_init_parm",""); return; |
1036 | } |
1039 | } |
1037 | if(strlen(rq)>=MAX_LINELEN*2) goto empty; |
1040 | if(strlen(rq)>=MAX_LINELEN*2) goto empty; |
1038 | _http2env(rqv,rq); prep_init_parm(rqv); |
1041 | _http2env(rqv,rq); prep_init_parm(rqv); |
1039 | setvar("module_init_parm",rqv); public_sheet=0; |
1042 | setvar("module_init_parm",rqv); public_sheet=0; freework_sheet=0; |
1040 | /* seedrepeat=1 or an integer |
1043 | /* seedrepeat=1 or an integer |
1041 | must be in the url and seedrepeat |
1044 | must be in the url and seedrepeat |
1042 | in the var.def of the module to be used */ |
1045 | in the var.def of the module to be used */ |
1043 | seedr=getvar("seedrepeat"); |
1046 | seedr=getvar("seedrepeat"); |
1044 | force_setvar("wims_seed_repeat",seedr); |
1047 | force_setvar("wims_seed_repeat",seedr); |
1045 | exotrymax=getvar("exotrymax"); |
1048 | exotrymax=getvar("exotrymax"); |
1046 | force_setvar("wims_exotrymax",exotrymax); |
1049 | force_setvar("wims_exotrymax",exotrymax); |
1047 | /* now determine the sheet number for user */ |
1050 | /* now determine the sheet number for user */ |
1048 | sh=getvar(ro_name[ro_worksheet]); if(sh==NULL) return; |
1051 | sh=getvar(ro_name[ro_worksheet]); if(sh==NULL) return; |
- | 1052 | if(*sh=='P') {public_sheet=1; sh++;} /* for public sheet file is in session */ |
|
1049 | if(*sh== |
1053 | if(*sh=='F') { /* for freework */ |
- | 1054 | freework_sheet=1; sh++; |
|
- | 1055 | shname="Wfreework"; |
|
- | 1056 | dirname="freeworks"; |
|
- | 1057 | } |
|
- | 1058 | else { /* for sheet */ |
|
1050 | shname="sheet"; |
1059 | shname="sheet"; |
- | 1060 | dirname="sheets"; |
|
- | 1061 | } |
|
1051 | u=getvar("wims_user"); if(u==NULL) u=""; |
1062 | u=getvar("wims_user"); if(u==NULL) u=""; |
1052 | if(sh!=NULL && *sh!=0) { |
1063 | if(sh!=NULL && *sh!=0) { |
1053 | char buf[MAX_LINELEN+1],ubuf[32], nbuf[1024], *c, *m; |
1064 | char buf[MAX_LINELEN+1],ubuf[32], nbuf[1024], *c, *m; |
1054 | char *p1,*p2,*p3,*p4,*p5; |
1065 | char *p1,*p2,*p3,*p4,*p5; |
1055 | int i,j,sheet; |
1066 | int i,j,sheet; |
1056 | sheet=atoi(sh); if(sheet<=0 || sheet>MAX_SHEETS) return; |
1067 | sheet=atoi(sh); if(sheet<=0 || sheet>MAX_SHEETS) return; |
1057 | m=getvar(ro_name[ro_module]); |
1068 | m=getvar(ro_name[ro_module]); |
1058 | if(m==NULL) internal_error("set_init_parm(): module name disapears."); |
1069 | if(m==NULL) internal_error("set_init_parm(): module name disapears."); |
1059 | if(*u==0) public_sheet=1; |
1070 | if(*u==0) public_sheet=1; |
1060 | if(!public_sheet) { |
1071 | if(!public_sheet) { |
- | 1072 | /* make filename for data on a freework or a sheet in a class */ |
|
1061 | c=getvar("wims_class"); if(c==NULL) c=""; |
1073 | c=getvar("wims_class"); if(c==NULL) c=""; |
1062 | snprintf(nbuf,sizeof(nbuf),"%s/ |
1074 | snprintf(nbuf,sizeof(nbuf),"%s/%s/.%s%d", |
1063 | class_dir,shname,sheet); |
1075 | class_dir,dirname,shname,sheet); |
1064 | } |
1076 | } |
1065 | else { |
1077 | else { |
- | 1078 | /* make filename for data in case of a public sheet */ |
|
1066 | char bf[MAX_LINELEN+1]; |
1079 | char bf[MAX_LINELEN+1]; |
1067 | int i; |
1080 | int i; |
1068 | accessfile(bf,"r","%s/.sheets",session_prefix); |
1081 | accessfile(bf,"r","%s/.sheets",session_prefix); |
1069 | if(bf[0]==0) return; |
1082 | if(bf[0]==0) return; |
1070 | for(i=1, p1=bf;i<sheet;i++,p1=p2) { |
1083 | for(i=1, p1=bf;i<sheet;i++,p1=p2) { |
Line 1072... | Line 1085... | ||
1072 | if(p2!=NULL) *p2++=0; else p2=p1+strlen(p1); |
1085 | if(p2!=NULL) *p2++=0; else p2=p1+strlen(p1); |
1073 | } |
1086 | } |
1074 | p2=strchr(p1,'\n'); if(p2) *p2=0; |
1087 | p2=strchr(p1,'\n'); if(p2) *p2=0; |
1075 | snprintf(nbuf,sizeof(nbuf),"bases/sheet/%s.def",p1); |
1088 | snprintf(nbuf,sizeof(nbuf),"bases/sheet/%s.def",p1); |
1076 | } |
1089 | } |
- | 1090 | /* now nbuf is the filename for data in any case of ressource (sheet / public_sheet / freework) */ |
|
1077 | if(readfile(nbuf,buf,sizeof(buf))==NULL) return; |
1091 | if(readfile(nbuf,buf,sizeof(buf))==NULL) return; |
- | 1092 | /* buf is the data of ressources. nbuf no more needed */ |
|
1078 | for(p1=strstr(buf,"&+");p1!=NULL;p1=strstr(++p1,"&+")) |
1093 | for(p1=strstr(buf,"&+");p1!=NULL;p1=strstr(++p1,"&+")) /* ???? */ |
1079 | ovlstrcpy(p1+1,p1+2); |
1094 | ovlstrcpy(p1+1,p1+2); |
- | 1095 | /* in case of use an exercice of the class instead of a public exercise */ |
|
1080 | if(strncmp(m,"classes/",strlen("classes/"))==0) { |
1096 | if(strncmp(m,"classes/",strlen("classes/"))==0) { |
1081 | m="classes/"; |
1097 | m="classes/"; |
1082 | for(p1=strstr(buf,":classes/");p1;p1=strstr(p1+1,":classes/")) { |
1098 | for(p1=strstr(buf,":classes/");p1;p1=strstr(p1+1,":classes/")) { |
1083 | if(p1==buf || *(p1-1)=='\n') { |
1099 | if(p1==buf || *(p1-1)=='\n') { |
1084 | p1+=strlen(":classes/"); |
1100 | p1+=strlen(":classes/"); |
1085 | p2=find_word_end(p1); if(p2>p1 && *p2=='\n') ovlstrcpy(p1,p2); |
1101 | p2=find_word_end(p1); if(p2>p1 && *p2=='\n') ovlstrcpy(p1,p2); |
1086 | } |
1102 | } |
1087 | } |
1103 | } |
1088 | } |
1104 | } |
1089 | snprintf(nbuf,sizeof(nbuf),":%s\n%s\n",m,rqv); |
1105 | snprintf(nbuf,sizeof(nbuf),":%s\n%s\n",m,rqv); /* rqv : execution parameters for the module ; m is the name of exercise module */ |
1090 | p1=strstr(buf,nbuf); |
1106 | p1=strstr(buf,nbuf); |
- | 1107 | /* this boucle search exercise parameters in buf |
|
- | 1108 | calculate num of the exercice in the ressources (sheet /public_sheet / freework) |
|
- | 1109 | */ |
|
1091 | while(p1>buf && *(p1-1)!='\n') p1=strstr(p1+1,nbuf); |
1110 | while(p1>buf && *(p1-1)!='\n') p1=strstr(p1+1,nbuf); |
1092 | if(p1!=NULL) { |
1111 | if(p1!=NULL) { |
1093 | p2=strchr(buf,':'); |
1112 | p2=strchr(buf,':'); |
1094 | while(p2>buf && *(p2-1)!='\n') p2=strchr(p2+1,':'); |
1113 | while(p2>buf && *(p2-1)!='\n') p2=strchr(p2+1,':'); |
1095 | for(i=1;p2!=NULL && p2<p1;i++) { |
1114 | for(i=1;p2!=NULL && p2<p1;i++) { |
1096 | p2=strchr(p2+1,':'); |
1115 | p2=strchr(p2+1,':'); |
1097 | while(p2>buf && *(p2-1)!='\n') p2=strchr(p2+1,':'); |
1116 | while(p2>buf && *(p2-1)!='\n') p2=strchr(p2+1,':'); |
1098 | } |
1117 | } |
1099 | if(p2==NULL) return; /* error which should not occur */ |
1118 | if(p2==NULL) return; /* error which should not occur */ |
1100 | snprintf(ubuf,sizeof(ubuf),"%d",i); |
1119 | snprintf(ubuf,sizeof(ubuf),"%d",i); |
1101 | /* look for dependency information */ |
1120 | /* look for dependency information */ /* pas utile pour freework mais non active tant que les données ne dépasse pas .... */ |
1102 | for(j=0, p3=strchr(p1+strlen(nbuf),'\n'); |
1121 | for(j=0, p3=strchr(p1+strlen(nbuf),'\n'); |
1103 | j<3 && p3 && *(p3+1)!=':'; |
1122 | j<3 && p3 && *(p3+1)!=':'; |
1104 | j++, p3=strchr(p3+1,'\n')); |
1123 | j++, p3=strchr(p3+1,'\n')); |
1105 | if(j>=3 && p3!=NULL && *(p3+1)!=':') { |
1124 | if(j>=3 && p3!=NULL && *(p3+1)!=':') { |
1106 | p3++; p4=strchr(p3,'\n'); |
1125 | p3++; p4=strchr(p3,'\n'); |
Line 1121... | Line 1140... | ||
1121 | if(public_sheet) { |
1140 | if(public_sheet) { |
1122 | char bf[32]; |
1141 | char bf[32]; |
1123 | snprintf(bf,16,"P%s",sh); |
1142 | snprintf(bf,16,"P%s",sh); |
1124 | force_setvar("wims_sheet",bf); |
1143 | force_setvar("wims_sheet",bf); |
1125 | } |
1144 | } |
- | 1145 | else { |
|
- | 1146 | if(freework_sheet) { |
|
- | 1147 | force_setvar("wims_fwnumber",sh); |
|
- | 1148 | force_setvar("wims_fwexo",ubuf); |
|
- | 1149 | } else { |
|
1126 |
|
1150 | force_setvar("wims_sheet",sh); |
1127 | force_setvar("wims_exo",ubuf); |
1151 | force_setvar("wims_exo",ubuf); |
1128 | wims_sheet=sheet; wims_exo=i; |
1152 | wims_sheet=sheet; wims_exo=i; |
- | 1153 | } |
|
- | 1154 | } |
|
1129 | } |
1155 | } |
1130 | } |
1156 | } |
1131 | } |
1157 | } |
1132 | 1158 | ||
1133 | /* user with class: whether exercise is registered |
1159 | /* user with class: whether exercise is registered |