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:
13: /*need to initialize unit parser*/
14: sprintf(filename,"/home/httpd/html/res/adm/include/capa.units");
15: if ((fp=fopen(filename,"r"))==NULL) {
16: /* printf("Error: can't open %s\n",filename);*/
17: return (-1);
18: }
19: u_getunit(fp);
20: fclose(fp);
21:
22: p.ans_type = type;
23: p.answer = correct;
24: p.tol_type = tol_type;
25: p.tolerance = tolerance;
26: p.sig_l = sig_lbound;
27: p.sig_u = sig_ubound;
28: p.fmt = strsave(ans_fmt);
29: p.unit_str = strsave(unit_str);
30: p.ans_unit = u_parse_unit(unit_str);
31: p.calc_type = calc;
32:
33: /* assign_id_list and assign_pts_list exist in capaGrammerDef.y */
34: p.ans_id_list=NULL;
35: p.ans_pts_list=NULL;
36:
37:
38: result=capa_check_answer(&p,response,&error);
39:
40: if (error!=NULL) {free(error);}
41:
42: return result;
43: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>