--- capa/capa51/pProj/capaCgiUtils.c 1999/11/08 22:30:02 1.4 +++ capa/capa51/pProj/capaCgiUtils.c 2000/01/31 18:34:13 1.11 @@ -404,12 +404,9 @@ void w_get_responses(int x,int q_idx,cha sscanf(g_entries[x].name,"INPUT%d",&q_idx); if( q_idx > 0 && q_idx < MAX_PROBLEM_CNT ) { if ( ! is_all_ws(g_entries[x].val) ) { - leng = strlen(g_entries[x].val) + 1; g_stu_ans_pp[q_idx] = (StudentAnswer_t *)capa_malloc(sizeof(StudentAnswer_t),1); (g_stu_ans_pp[q_idx])->a_idx = 1; (g_stu_ans_pp[q_idx])->a_str = strsave(g_entries[x].val); - if (leng > ANSWER_STRING_LENG) - (g_stu_ans_pp[q_idx])->a_str[ANSWER_STRING_LENG] = '\0'; (g_stu_ans_pp[q_idx])->a_next = NULL; trim_response_ws((g_stu_ans_pp[q_idx])->a_str); } @@ -424,12 +421,11 @@ void w_get_responses(int x,int q_idx,cha if( q_idx > 0 && q_idx < MAX_PROBLEM_CNT ) { if ( ! is_all_ws(g_entries[x].val) ) { StudentAnswer_t *sa_p; - leng = strlen(g_entries[x].val) + 1; sa_p = (StudentAnswer_t *)capa_malloc(sizeof(StudentAnswer_t),1); sa_p->a_idx = sub_idx; sa_p->a_str = strsave(g_entries[x].val); - if (leng > ANSWER_STRING_LENG) sa_p->a_str[ANSWER_STRING_LENG] = '\0'; sa_p->a_next = NULL; + trim_response_ws(sa_p->a_str); if( g_stu_ans_pp[q_idx] == NULL ) { g_stu_ans_pp[q_idx] = sa_p; } else { @@ -451,22 +447,18 @@ void w_get_responses(int x,int q_idx,cha if( index(g_entries[x].name, ',' ) == NULL ) { /* only one answer */ sscanf(g_entries[x].name,"LAST%d",&q_idx); if( q_idx > 0 && q_idx < MAX_PROBLEM_CNT ) { - leng = strlen(g_entries[x].val) + 1; sa_p = (StudentAnswer_t *)capa_malloc(sizeof(StudentAnswer_t),1); sa_p->a_idx = 1; sa_p->a_str = strsave(g_entries[x].val); - if (leng > ANSWER_STRING_LENG) sa_p->a_str[ANSWER_STRING_LENG] = '\0'; sa_p->a_next = NULL; g_last_ans_pp[q_idx] = sa_p; } } else { sscanf(g_entries[x].name,"LAST%d,%d",&q_idx,&sub_idx); if( q_idx > 0 && q_idx < MAX_PROBLEM_CNT ) { - leng = strlen(g_entries[x].val) + 1; sa_p = (StudentAnswer_t *)capa_malloc(sizeof(StudentAnswer_t),1); sa_p->a_idx = sub_idx; sa_p->a_str = strsave(g_entries[x].val); - if (leng > ANSWER_STRING_LENG) sa_p->a_str[ANSWER_STRING_LENG] = '\0'; sa_p->a_next = NULL; if( g_last_ans_pp[q_idx] == NULL) { g_last_ans_pp[q_idx] = sa_p; @@ -809,7 +801,7 @@ void append_qtext(new_str) char * len,g_qchar_cnt,g_qsize); fflush(g_cgi); #endif /* CGI_DBUG */ - if (g_qchar_cnt+len>g_qsize-1) { + if (g_qchar_cnt+len>g_qsize-2) { char *temp_text; g_qsize=(g_qchar_cnt+len)*2; temp_text=capa_malloc(g_qsize,sizeof(char)); @@ -823,7 +815,7 @@ void append_qtext(new_str) char * g_qchar_cnt += len; g_question_txt[g_qchar_cnt+1]='\0'; #ifdef CGI_DBUG - fprintf(g_cgi,"after: len %d; g_qchar_cnt %d; g_qsize %d\n",len,g_qchar_cnt,g_qsize); + fprintf(g_cgi,"after: len %d; g_qchar_cnt %d; g_qsize %d; strlen(g_question_txt):%d\n",len,g_qchar_cnt,g_qsize,strlen(g_question_txt)); fflush(g_cgi); #endif /* CGI_DBUG */ } @@ -837,7 +829,7 @@ void append_stext(new_str) char * new_str,len,g_schar_cnt,g_ssize); fflush(g_cgi); #endif /* CGI_DBUG */ - if (g_schar_cnt+len>g_ssize-1) { + if (g_schar_cnt+len>g_ssize-2) { char *temp_text; g_ssize=(g_schar_cnt+len)*2; temp_text=capa_malloc(g_ssize,sizeof(char)); @@ -1043,11 +1035,11 @@ print_mainmenu(class,sn,pin)char *class; fprintf(stdout,"\n"); } outcome = check_termscore_option(); - fprintf(stdout,"\n",outcome); + fprintf(stdout,"\n",outcome); /*Termscore Button*/ if( outcome ) { fprintf(stdout,"
  • ",serverName,g_cgibin_path); + sprintf(buf,"action=\"http://%s/%s/%s/capasbin\">",serverName,g_cgibin_path,g_cowner); fprintf(stdout,"%s\n", buf); fprintf(stdout,"\n",class); fprintf(stdout,"\n",sn); @@ -1071,6 +1063,8 @@ print_page_header(mode,num_quest) int mo char *serverName; int configResult,term_summary_button=1; + buf[0]='\0'; + discussdir[0]='\0'; serverName=getenv("SERVER_NAME"); if (!serverName) { fprintf(stdout,"Enviroment variable SERVER_NAME not set.\n"); @@ -1569,6 +1563,7 @@ char *class_dir; char *c_owner;char *cla } } +/*if the assignment is passedue we come here to get what the answer was just in case*/ void get_response(char pcr,char u_db,int q_idx,Problem_t *p) { @@ -1895,7 +1890,9 @@ char buf[MAX_BUFFER_SIZE]; } /* returns a -1 if there were not enough answers, otherwise the number of responses - for the question is returned*/ + for the question is returned + !!!!!AS A SIDEEFFECT IT ALSO CROPS ANSWERS TO ANSWER_STRING_LENG!!!!!!! +*/ int gather_answers(char ***ans,int q_idx,Problem_t *p) { int cnt; @@ -1905,6 +1902,7 @@ int gather_answers(char ***ans,int q_idx sa_p= g_stu_ans_pp[q_idx+1]; for(i=0;((ians_cnt)&&(sa_p));i++){ ans[0][i]=sa_p->a_str; + if ((strlen(ans[0][i])+1) > ANSWER_STRING_LENG) ans[0][i][ANSWER_STRING_LENG]='\0'; sa_p=sa_p->a_next; } cnt=p->ans_cnt; @@ -1912,19 +1910,21 @@ int gather_answers(char ***ans,int q_idx } else { *ans=(char**)capa_malloc(p->ans_cnt,1); ans[0][0]=g_stu_ans_pp[q_idx+1]->a_str; + if ((strlen(ans[0][0])+1) > ANSWER_STRING_LENG) ans[0][0][ANSWER_STRING_LENG]='\0'; cnt=1; } return cnt; } +/*logging user's answer when it is passed due.*/ void log_user_ans(int q_idx,Problem_t *p) { char **ans; int cnt; if (p->ans_type==ANSWER_IS_SUBJECTIVE) { - capa_set_subjective(g_login_set,q_idx+1,g_student_number, - g_stu_ans_pp[q_idx+1]->a_str); + /*capa_set_subjective(g_login_set,q_idx+1,g_student_number, + g_stu_ans_pp[q_idx+1]->a_str);*/ } else { if (-1 != (cnt=gather_answers(&ans,q_idx,p))) { switch( capa_check_answers(p,ans,cnt) ) { @@ -2002,7 +2002,7 @@ int tries; submit_subjective(q_idx,p); return; } - + cnt=gather_answers(&ans,q_idx,p); if (cnt == -1) { g_tried[q_idx]--; @@ -2416,9 +2416,9 @@ FILE *out; float hw_w, qz_w, ex_w, fe_w, pc_w; int idx, entry_count, tmp_len; float *S, *F; - int *X; + int *X; /* array controlling whether to extrapolate scores */ char *capa_server; - int max_set[4]; + int max_set[4], width=600,height=750; /* width and height of applet*/ char **c_path_pp; /*Unused Vars @@ -2471,6 +2471,9 @@ FILE *out; return; } + + get_tscore_width_height(&width,&height); + c_path_pp = (char **)capa_malloc( 4, sizeof(char *)); tmp_len = strlen(class_fullpath) + 1; c_path_pp[0] = (char *)capa_malloc(tmp_len,sizeof(char)); @@ -2511,12 +2514,14 @@ FILE *out; c_path_pp[2] = (char *)capa_malloc( (tmp_len),sizeof(char)); sprintf(c_path_pp[2],"%s",buf); max_set[2] = check_class_get_maxset(c_path_pp[2]); + printf("\n",c_path_pp[2],max_set[2]); if( max_set[2] <= 0 ) { - /* should we continue ? */ - max_set[2] = 0; - for(idx=2;idx <= (fs*2); idx++) { + /* no sets */ + max_set[2] = 0; + } + /* start extrapolation with sets that don't yet exist */ + for(idx=2+(max_set[2]*2);idx <= (fs*2); idx++) { X[idx] = 1; - } } } else { /* if exam_path is not in capa.config, then skip exams */ fs = 0; @@ -2563,15 +2568,24 @@ FILE *out; term_score += set_score; capa_mfree(header.weight); capa_mfree(header.partial_credit); + printf("\n",c_path_pp[idx],set_score,valid_wgt); if(idx==2) { /* exam sets */ S[set_idx*2] = (float)set_score; F[set_idx*2] = (float)valid_wgt; - X[set_idx*2] = 0; + if (valid_wgt == 0) { + X[set_idx*2] = 1; + } else { + X[set_idx*2] = 0; + } } if(idx==3) { /* correction sets */ S[set_idx*2+1] = (float)set_score; F[set_idx*2+1] = (float)valid_wgt; - X[set_idx*2+1] = 0; + if (valid_wgt == 0 ) { + X[set_idx*2+1] = 1; + } else { + X[set_idx*2+1] = 0; + } } } if( (idx == 0) || (idx==1) ) { /* homeworks and quizzes */ @@ -2586,7 +2600,7 @@ FILE *out; fprintf(out,"
    \n"); - fprintf(out,"\n",capa_server); + fprintf(out,"\n",capa_server,width,height); fprintf(out,"\n", hw_w); fprintf(out,"\n", qz_w); fprintf(out,"\n", ex_w); @@ -2630,7 +2644,28 @@ FILE *out; capa_mfree((char *)capa_server); } - +void +get_tscore_width_height(width,height) +int *width;int *height; +{ + char buf[MAX_BUFFER_SIZE]; + int configResult; + + configResult=read_capa_config("tscore_width",buf); + if (configResult != 0 && configResult != -1 ) { + sscanf(buf,"%d", width); + if (*width <= 0 ) { *width = DEFAULT_WIDTH; } + } else { + printf("\n",configResult); + } + configResult=read_capa_config("tscore_height",buf); + if (configResult != 0 && configResult != -1 ) { + sscanf(buf,"%d", height); + if (*height <= 0 ) { *height = DEFAULT_HEIGHT; } + } else { + printf("\n",configResult); + } +} int get_termscore_params(hw,qw,ew,fw,pw,hc,qc,fs)