Annotation of loncom/homework/caparesponse/caparesponse.c, revision 1.4
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);
30: strncpy(p.unit_str,unit_str,ANSWER_STRING_LENG-1);
31: p.ans_unit = u_parse_unit(unit_str);
32: p.calc = calc;
1.1 albertel 33:
34: /* assign_id_list and assign_pts_list exist in capaGrammerDef.y */
1.2 albertel 35: p.id_list=NULL;
36: p.pts_list=NULL;
1.1 albertel 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>