--- capa/capa51/pProj/capaCommon.c 2000/07/07 18:33:03 1.13 +++ capa/capa51/pProj/capaCommon.c 2000/09/14 20:20:45 1.16 @@ -2,16 +2,16 @@ 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 Library General Public License as + 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 - Library General Public License for more details. + General Public License for more details. - You should have received a copy of the GNU Library General Public + 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. @@ -48,6 +48,8 @@ int yyparse(); extern FILE *yyin; extern void yyrestart(); +extern FILE *dfp; + /*----------------------------------------------------------*/ /* RETURN: -1 file error */ /* 0 success */ @@ -3200,6 +3202,10 @@ capa_check_answer(p, answer, error) Prob /* 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 */ + /* before running the program, check its existance first */ + /* should we specify a time out period in capa.config file? */ + /* set up a timer for this purpose */ + /* FILE *popen (const char *command,const char *type ); */ break; @@ -3207,7 +3213,7 @@ capa_check_answer(p, answer, error) Prob return (result); } -/* ----------------------------------------------------------------------------------- */ +/* -------------------------------------------------------------------------- */ /* assumming the formula is *fml_str and the student input is *input_str */ /* according to the type of tolerance, we form the final formula as */ /* absolute tolerance: (*fml_str) - (*input_str) */ @@ -3367,8 +3373,15 @@ Problem_t *p; char **answers; int cnt; c outcomes = (int *)capa_malloc(sizeof(int),cnt); for(ii=0;iianswer,answers[0],outcomes[0]); fflush(dfp); +#endif for(ii=1, ai = p->ans_list; ai; ii++,ai = ai->ans_next ) { outcomes[ii] = capa_check_ans(ai,answers[ii],&(errormsg[ii])); +#ifdef COMMON_DBUG + fprintf(dfp,"CAPA_CHECK_ANS(%s,%s): outcome[%d]=%d\n", ai->ans_str,answers[ii],ii,outcomes[ii]); fflush(dfp); +#endif } done = ii = 0; result = 0; @@ -3383,10 +3396,12 @@ Problem_t *p; char **answers; int cnt; c ii++; if(ii==cnt) done = 1; } - if( result == 0 ) { /* check if any of the outcome has failed to be a numeric */ + if( result == 0 ) { + /* check if any of the outcome has failed to be a numeric + or was a malformed equation */ done = ii = 0; while( !done ) { - if( outcomes[ii] == WANTED_NUMERIC ) { + if( outcomes[ii] == WANTED_NUMERIC || outcomes[ii] == BAD_FORMULA ) { result = outcomes[ii]; done = 1; } @@ -3394,7 +3409,7 @@ Problem_t *p; char **answers; int cnt; c if(ii==cnt) done = 1; } } - if( result == 0 ) { /* check if any of the outcome has failed on sig figs */ + if( result == 0 ) {/*check if any of the outcome has failed on sig figs*/ done = ii = 0; while( !done ) { if( outcomes[ii] == SIG_FAIL ) {