Diff for /capa/capa51/pProj/capaCommon.c between versions 1.25 and 1.27

version 1.25, 2005/12/01 20:05:22 version 1.27, 2005/12/20 19:59:57
Line 2934  capa_check_ans(ai,ans, error) AnswerInfo Line 2934  capa_check_ans(ai,ans, error) AnswerInfo
   char    *us;    /* ans_unit_str */    char    *us;    /* ans_unit_str */
   Unit_t  *u_p;   /* ans_unit     */    Unit_t  *u_p;   /* ans_unit     */
   int      input_len, all_alphabet = 1, idx, ii, type;    int      input_len, all_alphabet = 1, idx, ii, type;
   int      outcome, result = INCORRECT;    int      outcome=-1, result = INCORRECT;
   int      sig, corr_len;    int      sig, corr_len;
   int      choice[ANSWER_STRING_LENG];    int      choice[ANSWER_STRING_LENG];
   char     num_str[ANSWER_STRING_LENG], unit_str[ANSWER_STRING_LENG];    char     num_str[ANSWER_STRING_LENG], unit_str[ANSWER_STRING_LENG];
Line 3103  capa_check_answer(p, answer, error) Prob Line 3103  capa_check_answer(p, answer, error) Prob
   char   *fmt;    char   *fmt;
   int     choice[ANSWER_STRING_LENG], correctans[ANSWER_STRING_LENG];    int     choice[ANSWER_STRING_LENG], correctans[ANSWER_STRING_LENG];
   int     ii, idx, corr_len, input_len;    int     ii, idx, corr_len, input_len;
   int     result = INCORRECT, sig, outcome, all_alphabet;    int     result = INCORRECT, sig, outcome=-1, all_alphabet;
   char    fmted[FORMAT_STRING_LENG];    char    fmted[FORMAT_STRING_LENG];
   double  given, target, ratio, fmted_target, target_u, target_l, scale=1.0;    double  given, target, ratio, fmted_target, target_u, target_l, scale=1.0;
   double  delta;    double  delta;
Line 3250  capa_check_answer(p, answer, error) Prob Line 3250  capa_check_answer(p, answer, error) Prob
   return (result);    return (result);
 }  }
   
   int check_tol (formula_val,tol_type,tol)
   double formula_val;int tol_type;double tol;
   {
     double diff;
     int outcome=APPROX_ANS;
     if( tol_type == TOL_ABSOLUTE ) {
       diff = tol - formula_val;
       if( diff < 0.0 )  {
         outcome = INCORRECT;
       }
     } else {
       diff = fabs(1.0 - formula_val) * 100.0 ;
       if( diff > tol ) {
         outcome = INCORRECT;
       }
     }
     return outcome;
   }
   
 /* -------------------------------------------------------------------------- */  /* -------------------------------------------------------------------------- */
 /*   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                  */
Line 3262  char *fml_str;char *input_str;char *var_ Line 3281  char *fml_str;char *input_str;char *var_
   char         *check_fml_str;    char         *check_fml_str;
   int           f_len, i_len, outcome, error_code;    int           f_len, i_len, outcome, error_code;
   PointsList_t *pt, *next;    PointsList_t *pt, *next;
   double        formula_val, diff;    double        formula_val;
       
   f_len = strlen(fml_str);    f_len = strlen(fml_str);
   i_len = strlen(input_str);    i_len = strlen(input_str);
Line 3274  char *fml_str;char *input_str;char *var_ Line 3293  char *fml_str;char *input_str;char *var_
     sprintf(check_fml_str,"(%s) / (%s)",input_str,fml_str);      sprintf(check_fml_str,"(%s) / (%s)",input_str,fml_str);
   }    }
   outcome = APPROX_ANS;    outcome = APPROX_ANS;
     if( pts_list==NULL ) {
       error_code = f_eval_formula(&formula_val,check_fml_str, var_list, NULL);
       if( ! error_code ) {
         outcome = check_tol(formula_val,tol_type,tol);
       } else {
         outcome = BAD_FORMULA;
       }      
     }
   
   for(pt= pts_list; pt!=NULL ; pt=next) {    for(pt= pts_list; pt!=NULL ; pt=next) {
     next=pt->pts_next;      next=pt->pts_next;
     error_code = f_eval_formula(&formula_val,check_fml_str, var_list, pt->pts_str);      error_code = f_eval_formula(&formula_val,check_fml_str, var_list, pt->pts_str);
     if( ! error_code ) {      if( ! error_code ) {
       if( tol_type == TOL_ABSOLUTE ) {        outcome = check_tol(formula_val,tol_type,tol);
         diff = tol - formula_val;  
         if( diff < 0.0 )  {  
           outcome = INCORRECT;  
         }  
       } else {  
         diff = abs(1.0 - formula_val) * 100.0 ;  
         if( diff > tol ) {  
           outcome = INCORRECT;  
         }  
       }  
     } else {      } else {
       outcome = BAD_FORMULA;        outcome = BAD_FORMULA;
       break;        break;

Removed from v.1.25  
changed lines
  Added in v.1.27


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