Diff for /loncom/homework/caparesponse/caparesponse.c between versions 1.14 and 1.17

version 1.14, 2004/11/16 23:37:40 version 1.17, 2005/02/15 22:15:05
Line 110  int caparesponse_capa_check_answer(char Line 110  int caparesponse_capa_check_answer(char
   }    }
   if (unit_str != NULL && unit_str[0]!='\0') {    if (unit_str != NULL && unit_str[0]!='\0') {
     strncpy(p.unit_str,unit_str,ANSWER_STRING_LENG-1);      strncpy(p.unit_str,unit_str,ANSWER_STRING_LENG-1);
     p.ans_unit   = u_parse_unit(unit_str);      //p.ans_unit = u_parse_unit(unit_str);
       p.ans_unit   = parse_unit_expr(unit_str);
       p.ans_unit   = process_utree(p.ans_unit);
       //print_unit_t(p.ans_unit);
   } else {    } else {
     p.unit_str[0]='\0';      p.unit_str[0]='\0';
     p.ans_unit=NULL;      p.ans_unit=NULL;
Line 130  int caparesponse_get_real_response (char Line 133  int caparesponse_get_real_response (char
   //double caparesponse_get_real_response (char* unit_str, char* answer) {    //double caparesponse_get_real_response (char* unit_str, char* answer) {
   int     input_len,all_alphabet,idx,outcome,result;    int     input_len,all_alphabet,idx,outcome,result;
   double  n_part,scale=1.0,given,target;    double  n_part,scale=1.0,given,target;
   char    input[ANSWER_STRING_LENG],filename[FILE_NAME_LENGTH];    char    input[ANSWER_STRING_LENG],filename[FILE_NAME_LENGTH],
       tmp_unit_str[ANSWER_STRING_LENG];
   Unit_t *ans_unit;    Unit_t *ans_unit;
   long    seed1,seed2;    long    seed1,seed2;
   FILE   *fp;    FILE   *fp;
Line 143  int caparesponse_get_real_response (char Line 147  int caparesponse_get_real_response (char
   fclose(fp);    fclose(fp);
   
   if (unit_str != NULL && unit_str[0]!='\0') {    if (unit_str != NULL && unit_str[0]!='\0') {
     ans_unit   = u_parse_unit(unit_str);      ans_unit   = parse_unit_expr(unit_str);
       ans_unit   = process_utree(ans_unit);
   } else {    } else {
     ans_unit=NULL;      ans_unit=NULL;
   }    }
Line 155  int caparesponse_get_real_response (char Line 160  int caparesponse_get_real_response (char
     }      }
   }    }
   if( !all_alphabet ) {    if( !all_alphabet ) {
     outcome = split_num_unit(answer,&n_part,input,unit_str);      tmp_unit_str[0]=NULL;
       outcome = split_num_unit(answer,&n_part,input,tmp_unit_str);
     if( outcome > 1 ) { /* with both num and unit parts or only unit part */      if( outcome > 1 ) { /* with both num and unit parts or only unit part */
       if( ans_unit != NULL ) {        if( ans_unit != NULL ) {
  result = check_correct_unit(unit_str,ans_unit,&scale);   result = check_correct_unit(tmp_unit_str,ans_unit,&scale);
       } else {        } else {
  /* what to do when no unit is specified but student entered a unit? */   /* what to do when no unit is specified but student entered a unit? */
  result = UNIT_NOTNEEDED;   result = UNIT_NOTNEEDED;

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


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