--- capa/capa51/pProj/capaCommon.c 1999/09/28 21:26:21 1.1.1.1 +++ capa/capa51/pProj/capaCommon.c 2000/02/22 18:19:02 1.9 @@ -46,8 +46,6 @@ capa_excuse(int set,int prob,int secti /* Calculate parameters */ if (capa_get_header(&header,set)) return (-1); sscanf(header.num_questions,"%d", &nq); - capa_mfree(header.weight); - capa_mfree(header.partial_credit); if( ( prob > nq ) || (section < 0 ) || (section > MAX_SECTION_COUNT) ) return (-1); num_students= 0; @@ -57,15 +55,24 @@ capa_excuse(int set,int prob,int secti offset = capa_get_entry(&entry,tmp_number,set); if(offset < 0 ) offset = -offset; switch(entry.answers[prob-1]) { + case '0': case '-': entry.answers[prob-1] = 'E'; break; case 'N': entry.answers[prob-1] = 'E'; break; case 'n': entry.answers[prob-1] = 'e'; break; + case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + if (entry.answers[prob-1] < header.weight[prob-1]) { + entry.answers[prob-1] = 'E'; + } + break; default : break; } capa_set_entry(&entry,tmp_number,set,offset); capa_mfree(entry.answers); entry.answers = NULL; capa_mfree(entry.tries); entry.tries = NULL; } + capa_mfree(header.weight); + capa_mfree(header.partial_credit); free_students(student_p); return (0); } @@ -562,8 +569,8 @@ int set; } funlockstream(fp); fclose(fp); if(!found) { - ans_p = capa_malloc(nq+1,1); - tries_p = capa_malloc(3*nq+2,1); /* space and \0 */ + ans_p = capa_malloc(nq+2,1); + tries_p = capa_malloc(3*nq+3,1); /* space and \0 */ for(ii=0;iianswers = ans_p; entry->tries = tries_p; entry->e_probs = nq; @@ -1350,12 +1359,12 @@ int capa_check_option(int option,int set } /*----------------------------------------------------------*/ -/* INPUT: set the X in logX.db */ +/* INPUT: time the current time */ +/* datetime the datetime string to compare */ /* OUTPUT: none */ /* */ -/* RETURN: -1 file error */ -/* 0 no login */ -/* >0 number of logins in that logX.db file */ +/* RETURN: -1 time is earlier then datetime */ +/* 1 time is later than datetime */ /*----------------------------------------------------------*/ int compare_datetime(time,datetime) @@ -1384,7 +1393,8 @@ char *datetime; /* What if: [7,3] date_info */ /* [3,7] date_info */ /* 4 date_info */ - +/* RETURN: -1 if not pass time */ +/* 1 if pass time (or no time available */ int capa_check_date(int which,char *student_number, int section,int set) { int result; @@ -2990,6 +3000,9 @@ capa_check_ans(ai,ans) AnswerInfo_t *ai result = check_formula_ans(s,ans,ai->ans_id_list,ai->ans_pts_list,tt,to); break; case ANSWER_IS_EXTERNAL: /* Not yet implemented */ + + + break; } return (result); @@ -3071,7 +3084,7 @@ capa_check_answer(p, answer) Problem_t * } given = n_part * scale; /* convert the given answer into proper scale for units */ sig = calc_sig( input ); - if( (sig < sig_l) || (sig > sig_u) ) { + if( ((sig < sig_l) || (sig > sig_u)) && (sig!=0)) { result = SIG_FAIL; } else { switch( tol_type ) { @@ -3143,6 +3156,11 @@ capa_check_answer(p, answer) Problem_t * result = check_formula_ans(correct,answer,p->id_list,p->pts_list,tol_type,tol); break; case ANSWER_IS_EXTERNAL: /* not yet implemented */ + /* we assume the external program is called through popen() */ + /* and the result will be given back as 0 or 1 to indicate the */ + /* given answer is correct or not */ + /* arguments are given to the program as */ + break; } @@ -3459,6 +3477,7 @@ char *key_word;char *value; fclose(fp); if (done) { + trim_response_ws(right); /*get rid of leading and trailing spaces*/ for(i=0,j=0;i<(strlen(right)+1);i++) { value[j]='\0'; if (right[i] == '\\' && (i < (strlen(right))) ) {