= g_qsize ) {
+ if ( g_qchar_cnt+2 > g_qsize-2 ) {
char *temp_text;
- g_qsize=g_qchar_cnt*2;
+ g_qsize=(g_qchar_cnt+2)*2;
temp_text=capa_malloc(g_qsize,sizeof(char));
strncpy(temp_text,g_question_txt,g_qsize);
capa_mfree(g_question_txt);
@@ -1474,30 +1504,43 @@ char *class_dir; char *c_owner;char *cla
append_qtext("
\n");
}
}
+ */
}
}
}
if(mode == VIEW_PREVIOUS_MODE) { /* VIEW_PREVIOUS_MODE */
- if( display_ans ) {
+ /*
if( prob_idx->ans_type == ANSWER_IS_FLOAT ) {
a = (double)atof(prob_idx->answer);
sprintf(cmp_ans,prob_idx->ans_fmt, a);
} else {
- strcpy(cmp_ans,prob_idx->answer);
+ if ( prob_idx->ans_type == ANSWER_IS_SUBJECTIVE) {
+ strcpy(cmp_ans,"Subjective Answer");
+ } else {
+ if (prob_idx->answer) {
+ strcpy(cmp_ans,prob_idx->answer);
+ } else {
+ strcpy(cmp_ans,"No Answer");
+ }
+ }
}
if( prob_idx->ans_unit ) {
sprintf(buf,"Answer: %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{
@@ -1521,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 */
@@ -1569,6 +1612,7 @@ char *class_dir; char *c_owner;char *cla
}
}
+/*if the assignment is passedue we come here to get what the answer was just in case*/
void
get_response(char pcr,char u_db,int q_idx,Problem_t *p)
{
@@ -1895,47 +1939,54 @@ char buf[MAX_BUFFER_SIZE];
}
/* returns a -1 if there were not enough answers, otherwise the number of responses
- for the question is returned*/
+ for the question is returned
+ !!!!!AS A SIDEEFFECT IT ALSO CROPS ANSWERS TO ANSWER_STRING_LENG!!!!!!!
+*/
int gather_answers(char ***ans,int q_idx,Problem_t *p)
{
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;((ians_cnt)&&(sa_p));i++){
ans[0][i]=sa_p->a_str;
+ if ((strlen(ans[0][i])+1) > ANSWER_STRING_LENG) ans[0][i][ANSWER_STRING_LENG]='\0';
sa_p=sa_p->a_next;
}
cnt=p->ans_cnt;
if (ians_cnt) return -1;
} else {
- *ans=(char**)capa_malloc(p->ans_cnt,1);
+ *ans=(char**)capa_malloc(p->ans_cnt,sizeof(char*));
ans[0][0]=g_stu_ans_pp[q_idx+1]->a_str;
+ if ((strlen(ans[0][0])+1) > ANSWER_STRING_LENG) ans[0][0][ANSWER_STRING_LENG]='\0';
cnt=1;
}
return cnt;
}
+/*logging user's answer when it is passed due.*/
void
log_user_ans(int q_idx,Problem_t *p)
{
char **ans;
+ char *error;
int cnt;
if (p->ans_type==ANSWER_IS_SUBJECTIVE) {
- capa_set_subjective(g_login_set,q_idx+1,g_student_number,
- g_stu_ans_pp[q_idx+1]->a_str);
+ /*capa_set_subjective(g_login_set,q_idx+1,g_student_number,
+ g_stu_ans_pp[q_idx+1]->a_str);*/
} else {
if (-1 != (cnt=gather_answers(&ans,q_idx,p))) {
- switch( capa_check_answers(p,ans,cnt) ) {
+ switch( capa_check_answers(p,ans,cnt,&error) ) {
case EXACT_ANS: g_log_string[q_idx]='Y'; break;
case APPROX_ANS: g_log_string[q_idx]='Y'; break;
- case SIG_FAIL: g_log_string[q_idx]='S'; break;
- case UNIT_FAIL: g_log_string[q_idx]='U'; break;
- case UNIT_NOTNEEDED: g_log_string[q_idx]='U'; break;
+ case SIG_FAIL: g_log_string[q_idx]='S'; capa_mfree(error); break;
+ case UNIT_FAIL: g_log_string[q_idx]='U'; capa_mfree(error); break;
+ case UNIT_NOTNEEDED: g_log_string[q_idx]='U'; capa_mfree(error); break;
case NO_UNIT: g_log_string[q_idx]='u'; break;
case BAD_FORMULA: g_log_string[q_idx]='F'; break;
case INCORRECT: g_log_string[q_idx]='N'; break;
+ case WANTED_NUMERIC: g_log_string[q_idx]='s'; break;
}
}
}
@@ -1980,7 +2031,8 @@ int sig_u;
char *a_fmt;
int tries;
char buf[MAX_BUFFER_SIZE];
-
+ char *error;
+
a_tpe = p->ans_type;
t_tpe = p->tol_type;
tol = p->tolerance;
@@ -2002,7 +2054,7 @@ int tries;
submit_subjective(q_idx,p);
return;
}
-
+
cnt=gather_answers(&ans,q_idx,p);
if (cnt == -1) {
g_tried[q_idx]--;
@@ -2017,7 +2069,7 @@ int tries;
return;
}
- switch( capa_check_answers(p,ans,cnt) ) {
+ switch( capa_check_answers(p,ans,cnt,&error) ) {
case EXACT_ANS:
case APPROX_ANS:
c_ans=answers_string(ANSWER_STRING_MODE, p);
@@ -2027,18 +2079,28 @@ int tries;
g_log_string[q_idx]='Y';
capa_mfree(c_ans);
break;
+ case WANTED_NUMERIC:
+ create_answer_area(p,q_idx);
+ g_tried[q_idx]--; /* don't count as a try */
+ sprintf(buf,"
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';
@@ -2416,9 +2487,9 @@ FILE *out;
float hw_w, qz_w, ex_w, fe_w, pc_w;
int idx, entry_count, tmp_len;
float *S, *F;
- int *X;
+ int *X; /* array controlling whether to extrapolate scores */
char *capa_server;
- int max_set[4];
+ int max_set[4], width=600,height=750; /* width and height of applet*/
char **c_path_pp;
/*Unused Vars
@@ -2471,6 +2542,9 @@ FILE *out;
return;
}
+
+ get_tscore_width_height(&width,&height);
+
c_path_pp = (char **)capa_malloc( 4, sizeof(char *));
tmp_len = strlen(class_fullpath) + 1;
c_path_pp[0] = (char *)capa_malloc(tmp_len,sizeof(char));
@@ -2511,12 +2585,14 @@ FILE *out;
c_path_pp[2] = (char *)capa_malloc( (tmp_len),sizeof(char));
sprintf(c_path_pp[2],"%s",buf);
max_set[2] = check_class_get_maxset(c_path_pp[2]);
+ printf("\n",c_path_pp[2],max_set[2]);
if( max_set[2] <= 0 ) {
- /* should we continue ? */
- max_set[2] = 0;
- for(idx=2;idx <= (fs*2); idx++) {
+ /* no sets */
+ max_set[2] = 0;
+ }
+ /* start extrapolation with sets that don't yet exist */
+ for(idx=2+(max_set[2]*2);idx <= (fs*2); idx++) {
X[idx] = 1;
- }
}
} else { /* if exam_path is not in capa.config, then skip exams */
fs = 0;
@@ -2563,15 +2639,24 @@ FILE *out;
term_score += set_score;
capa_mfree(header.weight);
capa_mfree(header.partial_credit);
+ printf("\n",c_path_pp[idx],set_score,valid_wgt);
if(idx==2) { /* exam sets */
S[set_idx*2] = (float)set_score;
F[set_idx*2] = (float)valid_wgt;
- X[set_idx*2] = 0;
+ if (valid_wgt == 0) {
+ X[set_idx*2] = 1;
+ } else {
+ X[set_idx*2] = 0;
+ }
}
if(idx==3) { /* correction sets */
S[set_idx*2+1] = (float)set_score;
F[set_idx*2+1] = (float)valid_wgt;
- X[set_idx*2+1] = 0;
+ if (valid_wgt == 0 ) {
+ X[set_idx*2+1] = 1;
+ } else {
+ X[set_idx*2+1] = 0;
+ }
}
}
if( (idx == 0) || (idx==1) ) { /* homeworks and quizzes */
@@ -2586,7 +2671,7 @@ FILE *out;
fprintf(out,"\n");
- fprintf(out,"