Annotation of loncom/homework/caparesponse/caparesponse.c, revision 1.5
1.1 albertel 1: #include <capaCommon.h>
2: int caparesponse_capa_check_answer(char *response,char *correct,
3: int type,int tol_type,double tolerance,
4: int sig_lbound,int sig_ubound,
5: char *ans_fmt, char *unit_str,
6: int calc)
7: {
8: int result;
9: Problem_t p;
10: char *error=NULL,filename[FILE_NAME_LENGTH];
11: FILE *fp;
12:
1.3 albertel 13: printf("hi in caparesponse\n");
1.1 albertel 14: /*need to initialize unit parser*/
1.4 albertel 15: sprintf(filename,"/home/httpd/html/res/adm/includes/capa.units");
1.1 albertel 16: if ((fp=fopen(filename,"r"))==NULL) {
17: /* printf("Error: can't open %s\n",filename);*/
18: return (-1);
19: }
20: u_getunit(fp);
21: fclose(fp);
22:
1.2 albertel 23: p.ans_type = type;
24: p.answer = correct;
25: p.tol_type = tol_type;
26: p.tolerance = tolerance;
27: p.sig_lbound = sig_lbound;
28: p.sig_ubound = sig_ubound;
29: strncpy(p.ans_fmt,ans_fmt,ANSWER_STRING_LENG-1);
1.5 ! albertel 30: if (unit_str[0]!='\0') {
! 31: strncpy(p.unit_str,unit_str,ANSWER_STRING_LENG-1);
! 32: p.ans_unit = u_parse_unit(unit_str);
! 33: } else {
! 34: p.unit_str[0]='\0';
! 35: p.ans_unit=NULL;
! 36: }
1.2 albertel 37: p.calc = calc;
1.1 albertel 38:
39: /* assign_id_list and assign_pts_list exist in capaGrammerDef.y */
1.2 albertel 40: p.id_list=NULL;
41: p.pts_list=NULL;
1.1 albertel 42:
43: result=capa_check_answer(&p,response,&error);
44:
45: if (error!=NULL) {free(error);}
46:
47: return result;
48: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>