--- capa/capa51/pProj/capaCgiUtils.c 1999/09/28 21:26:20 1.1.1.1 +++ capa/capa51/pProj/capaCgiUtils.c 1999/11/18 17:55:24 1.5 @@ -404,12 +404,9 @@ void w_get_responses(int x,int q_idx,cha sscanf(g_entries[x].name,"INPUT%d",&q_idx); if( q_idx > 0 && q_idx < MAX_PROBLEM_CNT ) { if ( ! is_all_ws(g_entries[x].val) ) { - leng = strlen(g_entries[x].val) + 1; g_stu_ans_pp[q_idx] = (StudentAnswer_t *)capa_malloc(sizeof(StudentAnswer_t),1); (g_stu_ans_pp[q_idx])->a_idx = 1; (g_stu_ans_pp[q_idx])->a_str = strsave(g_entries[x].val); - if (leng > ANSWER_STRING_LENG) - (g_stu_ans_pp[q_idx])->a_str[ANSWER_STRING_LENG] = '\0'; (g_stu_ans_pp[q_idx])->a_next = NULL; trim_response_ws((g_stu_ans_pp[q_idx])->a_str); } @@ -424,11 +421,9 @@ void w_get_responses(int x,int q_idx,cha if( q_idx > 0 && q_idx < MAX_PROBLEM_CNT ) { if ( ! is_all_ws(g_entries[x].val) ) { StudentAnswer_t *sa_p; - leng = strlen(g_entries[x].val) + 1; sa_p = (StudentAnswer_t *)capa_malloc(sizeof(StudentAnswer_t),1); sa_p->a_idx = sub_idx; sa_p->a_str = strsave(g_entries[x].val); - if (leng > ANSWER_STRING_LENG) sa_p->a_str[ANSWER_STRING_LENG] = '\0'; sa_p->a_next = NULL; if( g_stu_ans_pp[q_idx] == NULL ) { g_stu_ans_pp[q_idx] = sa_p; @@ -451,22 +446,18 @@ void w_get_responses(int x,int q_idx,cha if( index(g_entries[x].name, ',' ) == NULL ) { /* only one answer */ sscanf(g_entries[x].name,"LAST%d",&q_idx); if( q_idx > 0 && q_idx < MAX_PROBLEM_CNT ) { - leng = strlen(g_entries[x].val) + 1; sa_p = (StudentAnswer_t *)capa_malloc(sizeof(StudentAnswer_t),1); sa_p->a_idx = 1; sa_p->a_str = strsave(g_entries[x].val); - if (leng > ANSWER_STRING_LENG) sa_p->a_str[ANSWER_STRING_LENG] = '\0'; sa_p->a_next = NULL; g_last_ans_pp[q_idx] = sa_p; } } else { sscanf(g_entries[x].name,"LAST%d,%d",&q_idx,&sub_idx); if( q_idx > 0 && q_idx < MAX_PROBLEM_CNT ) { - leng = strlen(g_entries[x].val) + 1; sa_p = (StudentAnswer_t *)capa_malloc(sizeof(StudentAnswer_t),1); sa_p->a_idx = sub_idx; sa_p->a_str = strsave(g_entries[x].val); - if (leng > ANSWER_STRING_LENG) sa_p->a_str[ANSWER_STRING_LENG] = '\0'; sa_p->a_next = NULL; if( g_last_ans_pp[q_idx] == NULL) { g_last_ans_pp[q_idx] = sa_p; @@ -1067,7 +1058,7 @@ print_mainmenu(class,sn,pin)char *class; void print_page_header(mode,num_quest) int mode;int num_quest; { - char buf[MAX_BUFFER_SIZE]; + char buf[MAX_BUFFER_SIZE], discussdir[MAX_BUFFER_SIZE]; char *serverName; int configResult,term_summary_button=1; @@ -1206,6 +1197,20 @@ print_page_header(mode,num_quest) int mo fprintf(stdout,""); } + /*Discuss Button*/ + + sprintf(discussdir,"%s/discussion/%d",g_class_fullpath,g_login_set); + if ( access(discussdir,F_OK) == 0 ) { + fprintf(stdout,"
",serverName,g_cgibin_path,g_cowner); + fprintf(stdout,"%s\n", buf); + fprintf(stdout,"\n",g_class_name); + fprintf(stdout,"\n",g_student_number); + fprintf(stdout,"\n",g_entered_pin); + fprintf(stdout,"\n",g_login_set); + fprintf(stdout,"\n
"); + } + fprintf(stdout,"\n\n"); fflush(stdout); } @@ -1440,23 +1445,25 @@ char *class_dir; char *c_owner;char *cla append_qtext("Top"); sprintf(buf,"  Next",question_idx+2); append_qtext(buf); }*/ - q_leng = strlen(prob_idx->question); - if ( !prob_idx->show_br ) { - append_qtext(prob_idx->question); - } else { - for(idx=0;idx= g_qsize ) { - char *temp_text; - g_qsize=g_qchar_cnt*2; - temp_text=capa_malloc(g_qsize,sizeof(char)); - strncpy(temp_text,g_question_txt,g_qsize); - capa_mfree(g_question_txt); - g_question_txt=temp_text; - } - g_question_txt[g_qchar_cnt]=prob_idx->question[idx]; - g_qchar_cnt++; - if(prob_idx->question[idx] == '\n' ) { - append_qtext("
\n"); + if (prob_idx->question != NULL) { + q_leng = strlen(prob_idx->question); + if ( !prob_idx->show_br ) { + append_qtext(prob_idx->question); + } else { + for(idx=0;idx= g_qsize ) { + char *temp_text; + g_qsize=g_qchar_cnt*2; + temp_text=capa_malloc(g_qsize,sizeof(char)); + strncpy(temp_text,g_question_txt,g_qsize); + capa_mfree(g_question_txt); + g_question_txt=temp_text; + } + g_question_txt[g_qchar_cnt]=prob_idx->question[idx]; + g_qchar_cnt++; + if(prob_idx->question[idx] == '\n' ) { + append_qtext("
\n"); + } } } } @@ -1669,9 +1676,9 @@ void display_last_subjective(int q_idx) void create_answer_area(Problem_t *p,int q_idx) { - int ii; + int ii=0; char buf[MAX_BUFFER_SIZE]; - + AnswerInfo_t *ai; #ifdef CGI_DBUG fprintf(g_cgi,"Enter create_answer_area() [%d]\n",q_idx); fflush(g_cgi); #endif /* CGI_DBUG */ @@ -1681,9 +1688,16 @@ void create_answer_area(Problem_t *p,int } if ( p->show_ans_box ) { if ( p->ans_op == ANS_AND ) { - for(ii=0;iians_cnt;ii++) { - if (p->ans_type == ANSWER_IS_FORMULA) { + if (p->ans_type == ANSWER_IS_FORMULA) { + /* first answer is stored in p, the rest are linked off of p->ans_list */ sprintf(buf,"

Answer %d of %d:\n",ii+1,p->ans_cnt,q_idx+1,ii+1); + } else { + sprintf(buf,"

Answer %d of %d:\n",ii+1,p->ans_cnt,q_idx+1,ii+1); + } + append_qtext(buf); + for(ii=1, ai=p->ans_list;iians_cnt;ai=ai->ans_next,ii++) { + if (ai->ans_type == ANSWER_IS_FORMULA) { + sprintf(buf,"

Answer %d of %d:\n",ii+1,p->ans_cnt,q_idx+1,ii+1); } else { sprintf(buf,"

Answer %d of %d:\n",ii+1,p->ans_cnt,q_idx+1,ii+1); } @@ -1872,7 +1886,9 @@ 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; @@ -1882,6 +1898,7 @@ int gather_answers(char ***ans,int q_idx 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; @@ -1889,6 +1906,7 @@ int gather_answers(char ***ans,int q_idx } else { *ans=(char**)capa_malloc(p->ans_cnt,1); 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; @@ -1979,7 +1997,7 @@ int tries; submit_subjective(q_idx,p); return; } - + cnt=gather_answers(&ans,q_idx,p); if (cnt == -1) { g_tried[q_idx]--; @@ -2171,7 +2189,8 @@ char *class_dir;char *class;char *studen set_score, /* Score on a set */ term_score=0, /* Total points received */ term_valid=0, /* Total points possible */ - result; + result, + tot_num_sets=0; T_entry entry; /* Database entry for a set */ char buf[MAX_BUFFER_SIZE]; /* Output line buffer */ char buf2[MAX_BUFFER_SIZE]; /* Output line buffer */ @@ -2186,7 +2205,7 @@ char *class_dir;char *class;char *studen fprintf(stdout,"Unable to complete actions.\n"); return; } - + printf(""); sprintf(class_fullpath,"%s/%s",class_dir,class); chdir(class_fullpath); configResult=read_capa_config("web_status_line_length",buf); @@ -2207,9 +2226,18 @@ char *class_dir;char *class;char *studen for (set_idx=1; set_idx<=set; set_idx++) { g_inhibit_response=capa_check_option(OPTION_INHIBIT_RESPONSE,set_idx, g_student_data.s_sec); - if (g_inhibit_response > 0) continue; + if (g_inhibit_response > 0) { + printf("\n",set_idx); + continue; + } + if ( capa_check_date(CHECK_OPEN_DATE,g_student_number, + g_student_data.s_sec,set_idx) < 0 ){ + printf("\n",set_idx); + continue; + } if (capa_get_header(&header,set_idx)) return; + tot_num_sets++; capa_get_entry(&entry,student_number,set_idx); sscanf(header.num_questions,"%d", &(question_cnt) ); valid_wgt = 0; set_score = 0; @@ -2253,7 +2281,11 @@ char *class_dir;char *class;char *studen printf("\n\n


\n"); /* SHOW TOTALS */ /* if capalogin_show_summary_score is set to none don't show it */ - sprintf(buf,"%d sets, total = %3d/%3d (%d%%)\n", set, term_score, term_valid, 100*term_score/term_valid); + if (term_valid > 0) { + sprintf(buf,"%d sets, total = %3d/%3d (%d%%)\n", tot_num_sets, term_score, term_valid, 100*term_score/term_valid); + } else { + sprintf(buf,"%d sets, total = %3d/%3d\n", tot_num_sets, term_score, term_valid); + } result=read_capa_config("capalogin_show_summary_score",buf2); if (result != 0 && result != -1) { if (strcasecmp(buf2,"none")==0) { @@ -2369,27 +2401,28 @@ FILE *out; i, /* Question counter */ set_score, /* Score on a set */ term_score=0, /* Total points received */ - term_valid=0, /* Total points possible */ - result; + term_valid=0; /* Total points possible */ T_entry entry; /* Database entry for a set */ char buf[MAX_BUFFER_SIZE]; /* Output line buffer */ - char buf2[MAX_BUFFER_SIZE]; /* Output line buffer */ T_header header; /* Problem set header */ - int question_cnt,valid_wgt, rate,configResult, - status_line_length=DEFAULT_STATUS_LINE_LENGTH,row; + int question_cnt,valid_wgt,configResult; char class_fullpath[ONE_K],*serverName; int hw_c, hw_r, qz_c, qz_r, fs, homework_count, quiz_count; - int ex_c, epc_c; float hw_w, qz_w, ex_w, fe_w, pc_w; int idx, entry_count, tmp_len; float *S, *F; int *X; - char *capa_server, *qz_p, *ex_p, *epc_p; + char *capa_server; int max_set[4]; char **c_path_pp; - - - + + /*Unused Vars + char buf2[MAX_BUFFER_SIZE]; + char *qz_p, *ex_p, *epc_p; + int ex_c, epc_c, result; + int rate, status_line_length=DEFAULT_STATUS_LINE_LENGTH,row; + */ + serverName=getenv("SERVER_NAME"); if (!serverName) { fprintf(out,"Enviroment variable SERVER_NAME not set.\n");