--- loncom/homework/caparesponse/caparesponse.c 2004/12/23 18:36:42 1.16 +++ loncom/homework/caparesponse/caparesponse.c 2005/11/07 23:37:39 1.18 @@ -1,6 +1,6 @@ /* The LearningOnline Network with CAPA * CAPA wrapper code - * $Id: caparesponse.c,v 1.16 2004/12/23 18:36:42 albertel Exp $ + * $Id: caparesponse.c,v 1.18 2005/11/07 23:37:39 albertel Exp $ * * Copyright Michigan State University Board of Trustees * @@ -34,7 +34,7 @@ PointsList_t * parse_pts_list (char *pts int done=0; /*fprintf(stderr,"ids %s\n",id_list); fprintf(stderr,"pts %s\n",pts_list);*/ - while (!done) { + while (!done && pts_list) { int idx; /*fprintf(stderr,"pts; %s\n",idx_pts);*/ new=gen_ptslist_str(idx_pts); @@ -97,6 +97,9 @@ int caparesponse_capa_check_answer(char if (type == ANSWER_IS_FORMULA) { p.id_list=id_list; p.pts_list=parse_pts_list(pts_list); + if ( p.id_list == NULL || p.pts_list == NULL) { + return BAD_FORMULA; + } } p.ans_type = type; p.answer = correct; @@ -110,7 +113,10 @@ int caparesponse_capa_check_answer(char } 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); + //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 { p.unit_str[0]='\0'; p.ans_unit=NULL; @@ -144,7 +150,8 @@ int caparesponse_get_real_response (char fclose(fp); 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 { ans_unit=NULL; }