--- loncom/homework/caparesponse/caparesponse.c 2001/12/04 15:17:57 1.7 +++ loncom/homework/caparesponse/caparesponse.c 2003/05/27 15:29:02 1.8 @@ -1,6 +1,6 @@ /* The LearningOnline Network with CAPA * CAPA wrapper code - * $Id: caparesponse.c,v 1.7 2001/12/04 15:17:57 albertel Exp $ + * $Id: caparesponse.c,v 1.8 2003/05/27 15:29:02 bowersj2 Exp $ * * Copyright Michigan State University Board of Trustees * @@ -76,8 +76,7 @@ int caparesponse_capa_check_answer(char char *error=NULL,filename[FILE_NAME_LENGTH]; FILE *fp; - /*fprintf(stderr,"hi in caparesponse\n");*/ - /*need to initialize unit parser*/ + /* eed to initialize unit parser*/ sprintf(filename,"/home/httpd/html/res/adm/includes/capa.units"); if ((fp=fopen(filename,"r"))==NULL) { /* printf("Error: can't open %s\n",filename);*/ @@ -104,17 +103,18 @@ int caparesponse_capa_check_answer(char p.tolerance = tolerance; p.sig_lbound = sig_lbound; p.sig_ubound = sig_ubound; - strncpy(p.ans_fmt,ans_fmt,ANSWER_STRING_LENG-1); - if (unit_str[0]!='\0') { + + if (ans_fmt != NULL ) { + strncpy(p.ans_fmt,ans_fmt,ANSWER_STRING_LENG-1); + } + if (unit_str != NULL && unit_str[0]!='\0') { strncpy(p.unit_str,unit_str,ANSWER_STRING_LENG-1); p.ans_unit = u_parse_unit(unit_str); } else { p.unit_str[0]='\0'; - p.ans_unit=NULL; } p.calc = calc; - result=capa_check_answer(&p,response,&error); if (error!=NULL) {free(error);}