Diff for /capa/capa51/pProj/capaCommon.c between versions 1.14 and 1.18

version 1.14, 2000/08/07 20:47:29 version 1.18, 2000/11/02 20:20:04
Line 48  int     yyparse(); Line 48  int     yyparse();
 extern  FILE *yyin;  extern  FILE *yyin;
 extern  void yyrestart();  extern  void yyrestart();
   
   extern  FILE *dfp;
   
 /*----------------------------------------------------------*/  /*----------------------------------------------------------*/
 /*  RETURN: -1 file error                                   */  /*  RETURN: -1 file error                                   */
 /*           0 success                                      */  /*           0 success                                      */
Line 3017  capa_check_ans(ai,ans, error) AnswerInfo Line 3019  capa_check_ans(ai,ans, error) AnswerInfo
               for(idx=0;idx<ANSWER_STRING_LENG;idx++) choice[idx] = 0;                for(idx=0;idx<ANSWER_STRING_LENG;idx++) choice[idx] = 0;
               result = EXACT_ANS;                result = EXACT_ANS;
               for(ii=0;ii<corr_len; ii++) {                for(ii=0;ii<corr_len; ii++) {
                 idx = toupper(correct[ii]) - 'A'; choice[idx] =  1;                  idx = toupper(s[ii]) - 'A'; choice[idx] =  1;
               }                }
               for(ii=0;ii<input_len;ii++) {                for(ii=0;ii<input_len;ii++) {
                 idx = toupper(answer[ii]) - 'A';                  idx = toupper(ans[ii]) - 'A';
                 if(choice[idx] != 1 )  result = INCORRECT;                  if(choice[idx] != 1 )  result = INCORRECT;
               }                }
             } else { result = INCORRECT; }              } else { result = INCORRECT; }
Line 3200  capa_check_answer(p, answer, error) Prob Line 3202  capa_check_answer(p, answer, error) Prob
          /* and the result will be given back as 0 or 1 to indicate the */           /* and the result will be given back as 0 or 1 to indicate the */
          /* given answer is correct or not */           /* given answer is correct or not */
          /* arguments are given to the program as */           /* 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;            break;
           
Line 3207  capa_check_answer(p, answer, error) Prob Line 3213  capa_check_answer(p, answer, error) Prob
   return (result);    return (result);
 }  }
   
 /* ----------------------------------------------------------------------------------- */  /* -------------------------------------------------------------------------- */
 /*   assumming the formula is *fml_str and the student input is *input_str             */  /*   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                  */  /*   according to the type of tolerance, we form the final formula as                  */
 /*      absolute tolerance:  (*fml_str) - (*input_str)                                 */  /*      absolute tolerance:  (*fml_str) - (*input_str)                                 */
Line 3367  Problem_t *p; char **answers; int cnt; c Line 3373  Problem_t *p; char **answers; int cnt; c
     outcomes = (int *)capa_malloc(sizeof(int),cnt);      outcomes = (int *)capa_malloc(sizeof(int),cnt);
     for(ii=0;ii<cnt;ii++) outcomes[ii]=0;  /* initialize the outcomes array */      for(ii=0;ii<cnt;ii++) outcomes[ii]=0;  /* initialize the outcomes array */
     outcomes[0] = capa_check_answer(p, answers[0], &errormsg[0]);      outcomes[0] = capa_check_answer(p, answers[0], &errormsg[0]);
   #ifdef    COMMON_DBUG
       printf("CAPA_CHECK_ANSWER(%s,%s):: outcome[0]=%d\n", 
          p->answer,answers[0],outcomes[0]); 
   #endif
     for(ii=1, ai = p->ans_list; ai; ii++,ai = ai->ans_next  ) {      for(ii=1, ai = p->ans_list; ai; ii++,ai = ai->ans_next  ) {
        outcomes[ii] =  capa_check_ans(ai,answers[ii],&(errormsg[ii]));         outcomes[ii] =  capa_check_ans(ai,answers[ii],&(errormsg[ii]));
   #ifdef    COMMON_DBUG
       printf("CAPA_CHECK_ANS(%s,%s): outcome[%d]=%d\n", ai->ans_str,answers[ii],ii,outcomes[ii]); 
   #endif
     }      }
     done = ii = 0;      done = ii = 0;
     result = 0;      result = 0;
Line 3383  Problem_t *p; char **answers; int cnt; c Line 3396  Problem_t *p; char **answers; int cnt; c
       ii++;        ii++;
       if(ii==cnt) done = 1;        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;        done = ii = 0;
       while( !done ) {        while( !done ) {
         if( outcomes[ii] == WANTED_NUMERIC ) {          if( outcomes[ii] == WANTED_NUMERIC || outcomes[ii] == BAD_FORMULA ) {
           result = outcomes[ii];            result = outcomes[ii];
           done = 1;            done = 1;
         }          }
Line 3394  Problem_t *p; char **answers; int cnt; c Line 3409  Problem_t *p; char **answers; int cnt; c
         if(ii==cnt) done = 1;          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;        done = ii = 0;
       while( !done ) {        while( !done ) {
         if( outcomes[ii] == SIG_FAIL ) {          if( outcomes[ii] == SIG_FAIL ) {
Line 3537  char *key_word;char *value; Line 3552  char *key_word;char *value;
   }    }
  }   }
  if (c=='\n') found=1;   if (c=='\n') found=1;
  if (((char)c)==((char)EOF)) break;   if (((char)c)==((char)EOF)) {failed=1;break;}
       }        }
     }      }
   } while (!done && !failed);     } while (!done && !failed); 

Removed from v.1.14  
changed lines
  Added in v.1.18


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>