--- capa/capa51/pProj/capaCgiUtils.c 2000/02/22 18:13:20 1.12 +++ capa/capa51/pProj/capaCgiUtils.c 2000/06/27 18:52:33 1.17 @@ -229,14 +229,6 @@ void web_printheader(FILE *out) fprintf(out,"
\n"); fprintf(out,"\n"); } - -#ifdef CAPA_WEB - fprintf(out,"\n", - CAPA_VER,COMPILE_DATE); -#else - fprintf(out,"\n", - CAPA_VER,COMPILE_DATE); -#endif } void web_printfooter(FILE *out) @@ -790,6 +782,42 @@ and have entered you student id correctl return (error); } +void append_qtext_addbr(new_str) char *new_str; +{ + int ii,jj,len; + char *br_added; + if (new_str==NULL) return; + len=strlen(new_str); + br_added=capa_malloc(len*5,sizeof(char)); + for (ii=0,jj=0;iiAnswer: %s %s
\n",cmp_ans, prob_idx->unit_str);
} else {
sprintf(buf,"
Answer: %s
\n",cmp_ans);
}
+ */
+ if( display_ans ) {
+ c_ans=answers_string(ANSWER_STRING_MODE, prob_idx);
+ sprintf(buf,"
Answer: %s
",c_ans);
append_qtext(buf);
+ capa_mfree(c_ans);
if ( prob_idx->explain) {
sprintf(buf,"
Explanation: \n
%s
\n",prob_idx->explain);
append_qtext(buf);
}
- }
- } else { /* could be TRY_SET_MODE, CHECK_ANSWER_MODE */
-
+ }
+ } else { /* could be TRY_SET_MODE, CHECK_ANSWER_MODE */
if( g_passdue ) {
get_response(header.partial_credit[question_idx],entry.answers[question_idx],question_idx,prob_idx);
}else{
@@ -1515,7 +1564,7 @@ char *class_dir; char *c_owner;char *cla
append_qtext("\n\n");
if( EndText_p ) append_qtext(EndText_p);
free_problems(first_prob);
-
+ free_units();
#ifdef CGI_DBUG
fprintf(g_cgi,"End display each problem\n"); fflush(g_cgi);
#endif /* CGI_DBUG */
@@ -1898,7 +1947,7 @@ int gather_answers(char ***ans,int q_idx
int cnt;
if(p->ans_op==ANS_AND) {
int i; StudentAnswer_t *sa_p;
- *ans=(char**)capa_malloc(p->ans_cnt,1);
+ *ans=(char**)capa_malloc(p->ans_cnt,sizeof(char*));
sa_p= g_stu_ans_pp[q_idx+1];
for(i=0;((i
This question expects a numeric answer, tries %d/%d.\n",g_tried[q_idx],tries);
+ append_qtext(buf);
+ g_new_answerdb[q_idx] = 'N';
+ g_log_string[q_idx]='s';
+ break;
case SIG_FAIL:
create_answer_area(p,q_idx);
g_tried[q_idx]--; /* don't count as a try */
- sprintf(buf,"
Please adjust significant figures, tries %d/%d.\n",g_tried[q_idx],tries);
+ sprintf(buf,"
Please adjust significant figures, you provided %s significant figures, tries %d/%d.\n",error,g_tried[q_idx],tries);
append_qtext(buf);
+ capa_mfree(error);
g_new_answerdb[q_idx] = 'N';
g_log_string[q_idx]='S';
break;
case UNIT_FAIL:
create_answer_area(p,q_idx);
g_tried[q_idx]--; /* don't count as a try */
- sprintf(buf,"
Units incorrect, tries %d/%d.\n",g_tried[q_idx],tries);
+ sprintf(buf,"
Units incorrect, Computer reads units as %s, tries %d/%d.\n",error,g_tried[q_idx],tries);
+ capa_mfree(error);
append_qtext(buf);
g_new_answerdb[q_idx] = 'N';
g_log_string[q_idx]='U';
@@ -2047,9 +2109,10 @@ int tries;
create_answer_area(p,q_idx);
g_tried[q_idx]--; /* don't count as a try */
if(tries > 0) {
- sprintf(buf,"
Only a number required, tries %d/%d.\n",g_tried[q_idx],tries);
+ sprintf(buf,"
Only a number required, Computer reads units of %s, tries %d/%d.\n",error,g_tried[q_idx],tries);
append_qtext(buf);
}
+ capa_mfree(error);
g_new_answerdb[q_idx] = 'N';
g_log_string[q_idx]='U';
break;
@@ -2100,7 +2163,8 @@ int sig_u;
char *a_fmt;
int tries;
char buf[MAX_BUFFER_SIZE];
-
+ char *error;
+
a_tpe = p->ans_type;
c_ans = p->answer;
t_tpe = p->tol_type;
@@ -2139,23 +2203,30 @@ int tries;
return;
}
- switch( capa_check_answers(p,ans,cnt) ) {
+ switch( capa_check_answers(p,ans,cnt,&error) ) {
case EXACT_ANS:
case APPROX_ANS:
g_new_answerdb[q_idx] = 'Y';
g_log_string[q_idx]='Y';
break;
+ case WANTED_NUMERIC:
+ g_new_answerdb[q_idx] = 'N';
+ g_log_string[q_idx]='s';
+ break;
case SIG_FAIL:
g_new_answerdb[q_idx] = 'N';
g_log_string[q_idx]='S';
+ capa_mfree(error);
break;
case UNIT_FAIL:
g_new_answerdb[q_idx] = 'N';
g_log_string[q_idx]='U';
+ capa_mfree(error);
break;
case UNIT_NOTNEEDED:
g_new_answerdb[q_idx] = 'N';
g_log_string[q_idx]='U';
+ capa_mfree(error);
break;
case NO_UNIT:
g_new_answerdb[q_idx] = 'N';
@@ -2680,7 +2751,7 @@ int *hc;int *qc;int *fs;
configResult=read_capa_config("homework_weight",buf);
if (configResult != 0 && configResult != -1 ) {
sscanf(buf,"%f", &hw_w);
- if(hw_w <= 0.0 ) {
+ if(hw_w < 0.0 ) {
hw_w = DEFAULT_HW_W;
}
} else {
@@ -2689,7 +2760,7 @@ int *hc;int *qc;int *fs;
configResult=read_capa_config("quiz_weight",buf);
if (configResult != 0 && configResult != -1 ) {
sscanf(buf,"%f", &qz_w);
- if(qz_w <= 0.0 ) {
+ if(qz_w < 0.0 ) {
qz_w = DEFAULT_QZ_W;
}
} else {
@@ -2698,7 +2769,7 @@ int *hc;int *qc;int *fs;
configResult=read_capa_config("exam_weight",buf);
if (configResult != 0 && configResult != -1 ) {
sscanf(buf,"%f", &ex_w);
- if(ex_w <= 0.0 ) {
+ if(ex_w < 0.0 ) {
ex_w = DEFAULT_EX_W;
}
} else {
@@ -2707,7 +2778,7 @@ int *hc;int *qc;int *fs;
configResult=read_capa_config("final_weight",buf);
if (configResult != 0 && configResult != -1 ) {
sscanf(buf,"%f", &fe_w);
- if(fe_w <= 0.0 ) {
+ if(fe_w < 0.0 ) {
fe_w = DEFAULT_FE_W;
}
} else {
@@ -2716,7 +2787,7 @@ int *hc;int *qc;int *fs;
configResult=read_capa_config("correction_weight",buf);
if (configResult != 0 && configResult != -1 ) {
sscanf(buf,"%f", &pc_w);
- if(pc_w <= 0.0 ) {
+ if(pc_w < 0.0 ) {
pc_w = DEFAULT_PC_W;
}
} else {