--- capa/capa51/pProj/capaCommon.c 1999/12/01 18:22:00 1.3 +++ capa/capa51/pProj/capaCommon.c 2000/02/04 21:29:20 1.6 @@ -329,6 +329,7 @@ long offset; /* entry->answers*3 == entry->tries, + fudge factor*/ a_line=capa_malloc(strlen(entry->tries)*5+MAX_STUDENT_NUMBER,1); sprintf(a_line,"%s %s,%s\n",entry->student_number,entry->answers,entry->tries); + printf("Setting:%s\n",a_line);/*TEST*/ new_len = strlen(a_line); sprintf(fmtbuf, "%%%dc",MAX_STUDENT_NUMBER); flockstream(fp); /* <==== lock the setX.db file */ @@ -569,8 +570,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; @@ -605,6 +608,7 @@ int set; } ans_p[nq]='\0';tries_p[3*(nq)+2]='\0';tries_p[3*length-1]=','; } + printf("Got:%s:%s:\n",ans_p,tries_p);/*TEST*/ } return (offset); } @@ -3079,7 +3083,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 ) { @@ -3151,6 +3155,10 @@ 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 */ + break; } @@ -3467,6 +3475,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))) ) {