--- capa/capa51/pProj/capaCgiUtils.c 1999/09/28 21:26:20 1.1 +++ capa/capa51/pProj/capaCgiUtils.c 2000/10/10 20:03:23 1.21 @@ -1,5 +1,28 @@ +/* Most of the web output generation routines. + Copyright (C) 1992-2000 Michigan State University + + The CAPA system is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + The CAPA system is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with the CAPA system; see the file COPYING. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + As a special exception, you have permission to link this program + with the TtH/TtM library and distribute executables, as long as you + follow the requirements of the GNU GPL in regard to all of the + software in the executable aside from TtH/TtM. +*/ + /* ===================================================================== */ -/* copyrighted by Isaac Tsai, 1998, 1999, 2000 */ /* ===================================================================== */ #include #include @@ -229,14 +252,6 @@ void web_printheader(FILE *out) fprintf(out,"\n"); fprintf(out,"\n"); } - -#ifdef CAPA_WEB - fprintf(out,"\n", - CAPA_VER,COMPILE_DATE); -#else - fprintf(out,"\n", - CAPA_VER,COMPILE_DATE); -#endif } void web_printfooter(FILE *out) @@ -388,7 +403,7 @@ char *log_string; tmtime=localtime(&t); strftime(timeStr,FILE_NAME_LENGTH,"%d/%m %X",tmtime); /*ct[ strlen(ct)-1 ]=0;*/ /* Trash newline */ - protect_log_string(log_string); + /*protect_log_string(log_string);*/ /* done on indiviual answers now*/ fprintf(fp,"%s\t%s\t%s\n",student_number,timeStr,log_string); fflush(fp); fclose(fp); return (0); @@ -398,24 +413,24 @@ char *log_string; void w_get_responses(int x,int q_idx,char* submissions_str) { int leng, sub_idx; - char buf[MAX_BUFFER_SIZE]; + char buf[MAX_BUFFER_SIZE],*tmp; if( !strncmp(g_entries[x].name,"INPUT",5) ) { if( index(g_entries[x].name, ',' ) == NULL ) { /* only one answer */ 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); } leng = strlen( g_entries[x].val ); if ( leng > 0 ) { - sprintf(buf,"%d\t%s\t",q_idx,g_entries[x].val); + tmp=strsave(g_entries[x].val); + protect_log_string(tmp); + sprintf(buf,"%d\t%s\t",q_idx,tmp); + capa_mfree(tmp); strcat(submissions_str,buf); } } @@ -424,12 +439,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 { @@ -440,7 +454,10 @@ void w_get_responses(int x,int q_idx,cha } leng = strlen( g_entries[x].val ); if ( leng > 0 ) { - sprintf(buf,"%d\t%s\t",q_idx,g_entries[x].val); + tmp=strsave(g_entries[x].val); + protect_log_string(tmp); + sprintf(buf,"%d\t%s\t",q_idx,tmp); + capa_mfree(tmp); strcat(submissions_str,buf); } } @@ -451,22 +468,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; @@ -798,6 +811,42 @@ and have entered you student id correctl return (error); } +void append_qtext_addbr(new_str) char *new_str; +{ + int ii,jj,len; + char *br_added; + if (new_str==NULL) return; + len=strlen(new_str); + br_added=capa_malloc(len*5,sizeof(char)); + for (ii=0,jj=0;iig_qsize-1) { + if (g_qchar_cnt+len>g_qsize-3) { char *temp_text; g_qsize=(g_qchar_cnt+len)*2; temp_text=capa_malloc(g_qsize,sizeof(char)); strncpy(temp_text,g_question_txt,g_qchar_cnt); + temp_text[g_qchar_cnt]='\0'; capa_mfree(g_question_txt); g_question_txt=temp_text; + /* + g_qsize=(g_qchar_cnt+len)*2; + g_question_txt=realloc(g_question_txt,g_qsize); + */ } for(ii=0;iig_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 +1097,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); @@ -1067,10 +1121,12 @@ print_mainmenu(class,sn,pin)char *class; void print_page_header(mode,num_quest) int mode;int num_quest; { - char buf[MAX_BUFFER_SIZE]; + char buf[MAX_BUFFER_SIZE], discussdir[MAX_BUFFER_SIZE]; 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"); @@ -1206,6 +1262,20 @@ print_page_header(mode,num_quest) int mo fprintf(stdout,"
    "); } + /*Discuss Button*/ + + sprintf(discussdir,"%s/discussion/%d",g_class_fullpath,g_login_set); + if ( access(discussdir,F_OK) == 0 ) { + fprintf(stdout,"
    ",serverName,g_cgibin_path,g_cowner); + fprintf(stdout,"%s\n", buf); + fprintf(stdout,"\n",g_class_name); + fprintf(stdout,"\n",g_student_number); + fprintf(stdout,"\n",g_entered_pin); + fprintf(stdout,"\n",g_login_set); + fprintf(stdout,"\n
    "); + } + fprintf(stdout,"\n\n"); fflush(stdout); } @@ -1295,6 +1365,7 @@ char *class_dir; char *c_owner;char *cla char cmp_ans[MAX_BUFFER_SIZE],date_str[DATE_BUFFER]; time_t curtime; char *serverName; + char *c_ans; serverName=getenv("SERVER_NAME"); if (!serverName) { @@ -1371,7 +1442,7 @@ char *class_dir; char *c_owner;char *cla } } - if ((mode==CHECK_ANSWER_MODE) || (mode== TRY_SET_MODE)) + if ((mode==CHECK_ANSWER_MODE) || (mode== TRY_SET_MODE) || (mode==VIEW_PREVIOUS_MODE)) capa_set_login_time(g_student_number,set); capa_get_header(&header,set); @@ -1400,7 +1471,7 @@ char *class_dir; char *c_owner;char *cla if ( result != 0 ) { if( !g_passdue ) { - append_qtext("
    ",serverName, g_cgibin_path,c_owner); append_qtext(buf); @@ -1440,48 +1511,65 @@ char *class_dir; char *c_owner;char *cla append_qtext("Top"); sprintf(buf,"  Next",question_idx+2); append_qtext(buf); }*/ - q_leng = strlen(prob_idx->question); - if ( !prob_idx->show_br ) { - append_qtext(prob_idx->question); - } else { - for(idx=0;idx= g_qsize ) { - char *temp_text; - g_qsize=g_qchar_cnt*2; - temp_text=capa_malloc(g_qsize,sizeof(char)); - strncpy(temp_text,g_question_txt,g_qsize); - capa_mfree(g_question_txt); - g_question_txt=temp_text; - } - g_question_txt[g_qchar_cnt]=prob_idx->question[idx]; - g_qchar_cnt++; - if(prob_idx->question[idx] == '\n' ) { - append_qtext("
    \n"); + if (prob_idx->question != NULL) { + q_leng = strlen(prob_idx->question); + if ( !prob_idx->show_br ) { + append_qtext(prob_idx->question); + } else { + append_qtext_addbr(prob_idx->question); + /* + for(idx=0;idx g_qsize-2 ) { + char *temp_text; + g_qsize=(g_qchar_cnt+2)*2; + temp_text=capa_malloc(g_qsize,sizeof(char)); + strncpy(temp_text,g_question_txt,g_qsize); + capa_mfree(g_question_txt); + g_question_txt=temp_text; + } + g_question_txt[g_qchar_cnt]=prob_idx->question[idx]; + g_qchar_cnt++; + if(prob_idx->question[idx] == '\n' ) { + append_qtext("
    \n"); + } } + */ } } } if(mode == VIEW_PREVIOUS_MODE) { /* VIEW_PREVIOUS_MODE */ - if( display_ans ) { + /* if( prob_idx->ans_type == ANSWER_IS_FLOAT ) { a = (double)atof(prob_idx->answer); sprintf(cmp_ans,prob_idx->ans_fmt, a); } else { - strcpy(cmp_ans,prob_idx->answer); + if ( prob_idx->ans_type == ANSWER_IS_SUBJECTIVE) { + strcpy(cmp_ans,"Subjective Answer"); + } else { + if (prob_idx->answer) { + strcpy(cmp_ans,prob_idx->answer); + } else { + strcpy(cmp_ans,"No Answer"); + } + } } if( prob_idx->ans_unit ) { sprintf(buf,"

    Answer: %s %s
    \n",cmp_ans, prob_idx->unit_str); } else { sprintf(buf,"

    Answer: %s
    \n",cmp_ans); } + */ + if( display_ans ) { + c_ans=answers_string(ANSWER_STRING_MODE, prob_idx); + sprintf(buf,"

    Answer: %s
    ",c_ans); append_qtext(buf); + capa_mfree(c_ans); if ( prob_idx->explain) { sprintf(buf,"

    Explanation: \n

    %s
    \n",prob_idx->explain); append_qtext(buf); } - } - } else { /* could be TRY_SET_MODE, CHECK_ANSWER_MODE */ - + } + } else { /* could be TRY_SET_MODE, CHECK_ANSWER_MODE */ if( g_passdue ) { get_response(header.partial_credit[question_idx],entry.answers[question_idx],question_idx,prob_idx); }else{ @@ -1505,7 +1593,7 @@ char *class_dir; char *c_owner;char *cla append_qtext("\n\n"); if( EndText_p ) append_qtext(EndText_p); free_problems(first_prob); - + free_units(); #ifdef CGI_DBUG fprintf(g_cgi,"End display each problem\n"); fflush(g_cgi); #endif /* CGI_DBUG */ @@ -1553,6 +1641,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) { @@ -1669,9 +1758,9 @@ void display_last_subjective(int q_idx) void create_answer_area(Problem_t *p,int q_idx) { - int ii; + int ii=0; char buf[MAX_BUFFER_SIZE]; - + AnswerInfo_t *ai; #ifdef CGI_DBUG fprintf(g_cgi,"Enter create_answer_area() [%d]\n",q_idx); fflush(g_cgi); #endif /* CGI_DBUG */ @@ -1681,9 +1770,16 @@ void create_answer_area(Problem_t *p,int } if ( p->show_ans_box ) { if ( p->ans_op == ANS_AND ) { - for(ii=0;iians_cnt;ii++) { - if (p->ans_type == ANSWER_IS_FORMULA) { + if (p->ans_type == ANSWER_IS_FORMULA) { + /* first answer is stored in p, the rest are linked off of p->ans_list */ sprintf(buf,"

    Answer %d of %d:\n",ii+1,p->ans_cnt,q_idx+1,ii+1); + } else { + sprintf(buf,"

    Answer %d of %d:\n",ii+1,p->ans_cnt,q_idx+1,ii+1); + } + append_qtext(buf); + for(ii=1, ai=p->ans_list;iians_cnt;ai=ai->ans_next,ii++) { + if (ai->ans_type == ANSWER_IS_FORMULA) { + sprintf(buf,"

    Answer %d of %d:\n",ii+1,p->ans_cnt,q_idx+1,ii+1); } else { sprintf(buf,"

    Answer %d of %d:\n",ii+1,p->ans_cnt,q_idx+1,ii+1); } @@ -1872,47 +1968,54 @@ 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; if(p->ans_op==ANS_AND) { int i; StudentAnswer_t *sa_p; - *ans=(char**)capa_malloc(p->ans_cnt,1); + *ans=(char**)capa_malloc(p->ans_cnt,sizeof(char*)); 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; if (ians_cnt) return -1; } else { - *ans=(char**)capa_malloc(p->ans_cnt,1); + *ans=(char**)capa_malloc(p->ans_cnt,sizeof(char*)); 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; + char *error; 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) ) { + switch( capa_check_answers(p,ans,cnt,&error) ) { case EXACT_ANS: g_log_string[q_idx]='Y'; break; case APPROX_ANS: g_log_string[q_idx]='Y'; break; - case SIG_FAIL: g_log_string[q_idx]='S'; break; - case UNIT_FAIL: g_log_string[q_idx]='U'; break; - case UNIT_NOTNEEDED: g_log_string[q_idx]='U'; break; + case SIG_FAIL: g_log_string[q_idx]='S'; capa_mfree(error); break; + case UNIT_FAIL: g_log_string[q_idx]='U'; capa_mfree(error); break; + case UNIT_NOTNEEDED: g_log_string[q_idx]='U'; capa_mfree(error); break; case NO_UNIT: g_log_string[q_idx]='u'; break; case BAD_FORMULA: g_log_string[q_idx]='F'; break; case INCORRECT: g_log_string[q_idx]='N'; break; + case WANTED_NUMERIC: g_log_string[q_idx]='s'; break; } } } @@ -1957,7 +2060,8 @@ int sig_u; char *a_fmt; int tries; char buf[MAX_BUFFER_SIZE]; - + char *error; + a_tpe = p->ans_type; t_tpe = p->tol_type; tol = p->tolerance; @@ -1979,7 +2083,7 @@ int tries; submit_subjective(q_idx,p); return; } - + cnt=gather_answers(&ans,q_idx,p); if (cnt == -1) { g_tried[q_idx]--; @@ -1994,7 +2098,7 @@ int tries; return; } - switch( capa_check_answers(p,ans,cnt) ) { + switch( capa_check_answers(p,ans,cnt,&error) ) { case EXACT_ANS: case APPROX_ANS: c_ans=answers_string(ANSWER_STRING_MODE, p); @@ -2004,18 +2108,28 @@ int tries; g_log_string[q_idx]='Y'; capa_mfree(c_ans); break; + case WANTED_NUMERIC: + create_answer_area(p,q_idx); + g_tried[q_idx]--; /* don't count as a try */ + sprintf(buf,"
    This question expects a numeric answer, tries %d/%d.\n",g_tried[q_idx],tries); + append_qtext(buf); + g_new_answerdb[q_idx] = 'N'; + g_log_string[q_idx]='s'; + break; case SIG_FAIL: create_answer_area(p,q_idx); g_tried[q_idx]--; /* don't count as a try */ - sprintf(buf,"
    Please adjust significant figures, tries %d/%d.\n",g_tried[q_idx],tries); + sprintf(buf,"
    Please adjust significant figures, you provided %s significant figures, tries %d/%d.\n",error,g_tried[q_idx],tries); append_qtext(buf); + capa_mfree(error); g_new_answerdb[q_idx] = 'N'; g_log_string[q_idx]='S'; break; case UNIT_FAIL: create_answer_area(p,q_idx); g_tried[q_idx]--; /* don't count as a try */ - sprintf(buf,"
    Units incorrect, tries %d/%d.\n",g_tried[q_idx],tries); + sprintf(buf,"
    Units incorrect, Computer reads units as %s, tries %d/%d.\n",error,g_tried[q_idx],tries); + capa_mfree(error); append_qtext(buf); g_new_answerdb[q_idx] = 'N'; g_log_string[q_idx]='U'; @@ -2024,9 +2138,10 @@ int tries; create_answer_area(p,q_idx); g_tried[q_idx]--; /* don't count as a try */ if(tries > 0) { - sprintf(buf,"
    Only a number required, tries %d/%d.\n",g_tried[q_idx],tries); + sprintf(buf,"
    Only a number required, Computer reads units of %s, tries %d/%d.\n",error,g_tried[q_idx],tries); append_qtext(buf); } + capa_mfree(error); g_new_answerdb[q_idx] = 'N'; g_log_string[q_idx]='U'; break; @@ -2077,7 +2192,8 @@ int sig_u; char *a_fmt; int tries; char buf[MAX_BUFFER_SIZE]; - + char *error; + a_tpe = p->ans_type; c_ans = p->answer; t_tpe = p->tol_type; @@ -2116,23 +2232,30 @@ int tries; return; } - switch( capa_check_answers(p,ans,cnt) ) { + switch( capa_check_answers(p,ans,cnt,&error) ) { case EXACT_ANS: case APPROX_ANS: g_new_answerdb[q_idx] = 'Y'; g_log_string[q_idx]='Y'; break; + case WANTED_NUMERIC: + g_new_answerdb[q_idx] = 'N'; + g_log_string[q_idx]='s'; + break; case SIG_FAIL: g_new_answerdb[q_idx] = 'N'; g_log_string[q_idx]='S'; + capa_mfree(error); break; case UNIT_FAIL: g_new_answerdb[q_idx] = 'N'; g_log_string[q_idx]='U'; + capa_mfree(error); break; case UNIT_NOTNEEDED: g_new_answerdb[q_idx] = 'N'; g_log_string[q_idx]='U'; + capa_mfree(error); break; case NO_UNIT: g_new_answerdb[q_idx] = 'N'; @@ -2171,7 +2294,8 @@ char *class_dir;char *class;char *studen set_score, /* Score on a set */ term_score=0, /* Total points received */ term_valid=0, /* Total points possible */ - result; + result, + tot_num_sets=0; T_entry entry; /* Database entry for a set */ char buf[MAX_BUFFER_SIZE]; /* Output line buffer */ char buf2[MAX_BUFFER_SIZE]; /* Output line buffer */ @@ -2186,7 +2310,7 @@ char *class_dir;char *class;char *studen fprintf(stdout,"Unable to complete actions.\n"); return; } - + printf(""); sprintf(class_fullpath,"%s/%s",class_dir,class); chdir(class_fullpath); configResult=read_capa_config("web_status_line_length",buf); @@ -2207,9 +2331,18 @@ char *class_dir;char *class;char *studen for (set_idx=1; set_idx<=set; set_idx++) { g_inhibit_response=capa_check_option(OPTION_INHIBIT_RESPONSE,set_idx, g_student_data.s_sec); - if (g_inhibit_response > 0) continue; + if (g_inhibit_response > 0) { + printf("\n",set_idx); + continue; + } + if ( capa_check_date(CHECK_OPEN_DATE,g_student_number, + g_student_data.s_sec,set_idx) < 0 ){ + printf("\n",set_idx); + continue; + } if (capa_get_header(&header,set_idx)) return; + tot_num_sets++; capa_get_entry(&entry,student_number,set_idx); sscanf(header.num_questions,"%d", &(question_cnt) ); valid_wgt = 0; set_score = 0; @@ -2253,7 +2386,11 @@ char *class_dir;char *class;char *studen printf("\n\n


    \n"); /* SHOW TOTALS */ /* if capalogin_show_summary_score is set to none don't show it */ - sprintf(buf,"%d sets, total = %3d/%3d (%d%%)\n", set, term_score, term_valid, 100*term_score/term_valid); + if (term_valid > 0) { + sprintf(buf,"%d sets, total = %3d/%3d (%d%%)\n", tot_num_sets, term_score, term_valid, 100*term_score/term_valid); + } else { + sprintf(buf,"%d sets, total = %3d/%3d\n", tot_num_sets, term_score, term_valid); + } result=read_capa_config("capalogin_show_summary_score",buf2); if (result != 0 && result != -1) { if (strcasecmp(buf2,"none")==0) { @@ -2369,27 +2506,28 @@ FILE *out; i, /* Question counter */ set_score, /* Score on a set */ term_score=0, /* Total points received */ - term_valid=0, /* Total points possible */ - result; + term_valid=0; /* Total points possible */ T_entry entry; /* Database entry for a set */ char buf[MAX_BUFFER_SIZE]; /* Output line buffer */ - char buf2[MAX_BUFFER_SIZE]; /* Output line buffer */ T_header header; /* Problem set header */ - int question_cnt,valid_wgt, rate,configResult, - status_line_length=DEFAULT_STATUS_LINE_LENGTH,row; + int question_cnt,valid_wgt,configResult; char class_fullpath[ONE_K],*serverName; int hw_c, hw_r, qz_c, qz_r, fs, homework_count, quiz_count; - int ex_c, epc_c; float hw_w, qz_w, ex_w, fe_w, pc_w; int idx, entry_count, tmp_len; float *S, *F; - int *X; - char *capa_server, *qz_p, *ex_p, *epc_p; - int max_set[4]; + int *X; /* array controlling whether to extrapolate scores */ + char *capa_server; + int max_set[4], width=600,height=750; /* width and height of applet*/ char **c_path_pp; - - - + + /*Unused Vars + char buf2[MAX_BUFFER_SIZE]; + char *qz_p, *ex_p, *epc_p; + int ex_c, epc_c, result; + int rate, status_line_length=DEFAULT_STATUS_LINE_LENGTH,row; + */ + serverName=getenv("SERVER_NAME"); if (!serverName) { fprintf(out,"Enviroment variable SERVER_NAME not set.\n"); @@ -2433,6 +2571,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)); @@ -2473,12 +2614,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; @@ -2525,15 +2668,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 */ @@ -2548,7 +2700,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); @@ -2592,7 +2744,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) @@ -2607,7 +2780,7 @@ int *hc;int *qc;int *fs; configResult=read_capa_config("homework_weight",buf); if (configResult != 0 && configResult != -1 ) { sscanf(buf,"%f", &hw_w); - if(hw_w <= 0.0 ) { + if(hw_w < 0.0 ) { hw_w = DEFAULT_HW_W; } } else { @@ -2616,7 +2789,7 @@ int *hc;int *qc;int *fs; configResult=read_capa_config("quiz_weight",buf); if (configResult != 0 && configResult != -1 ) { sscanf(buf,"%f", &qz_w); - if(qz_w <= 0.0 ) { + if(qz_w < 0.0 ) { qz_w = DEFAULT_QZ_W; } } else { @@ -2625,7 +2798,7 @@ int *hc;int *qc;int *fs; configResult=read_capa_config("exam_weight",buf); if (configResult != 0 && configResult != -1 ) { sscanf(buf,"%f", &ex_w); - if(ex_w <= 0.0 ) { + if(ex_w < 0.0 ) { ex_w = DEFAULT_EX_W; } } else { @@ -2634,7 +2807,7 @@ int *hc;int *qc;int *fs; configResult=read_capa_config("final_weight",buf); if (configResult != 0 && configResult != -1 ) { sscanf(buf,"%f", &fe_w); - if(fe_w <= 0.0 ) { + if(fe_w < 0.0 ) { fe_w = DEFAULT_FE_W; } } else { @@ -2643,7 +2816,7 @@ int *hc;int *qc;int *fs; configResult=read_capa_config("correction_weight",buf); if (configResult != 0 && configResult != -1 ) { sscanf(buf,"%f", &pc_w); - if(pc_w <= 0.0 ) { + if(pc_w < 0.0 ) { pc_w = DEFAULT_PC_W; } } else {