Diff for /capa/capa51/pProj/capaCommon.c between versions 1.4 and 1.6

version 1.4, 2000/01/25 17:14:29 version 1.6, 2000/02/04 21:29:20
Line 329  long       offset; Line 329  long       offset;
    /* entry->answers*3 == entry->tries, + fudge factor*/     /* entry->answers*3 == entry->tries, + fudge factor*/
    a_line=capa_malloc(strlen(entry->tries)*5+MAX_STUDENT_NUMBER,1);     a_line=capa_malloc(strlen(entry->tries)*5+MAX_STUDENT_NUMBER,1);
    sprintf(a_line,"%s %s,%s\n",entry->student_number,entry->answers,entry->tries);     sprintf(a_line,"%s %s,%s\n",entry->student_number,entry->answers,entry->tries);
      printf("Setting:%s\n",a_line);/*TEST*/
    new_len = strlen(a_line);     new_len = strlen(a_line);
    sprintf(fmtbuf, "%%%dc",MAX_STUDENT_NUMBER);     sprintf(fmtbuf, "%%%dc",MAX_STUDENT_NUMBER);
    flockstream(fp);  /* <==== lock the setX.db file */     flockstream(fp);  /* <==== lock the setX.db file */
Line 569  int        set; Line 570  int        set;
    }     }
    funlockstream(fp); fclose(fp);     funlockstream(fp); fclose(fp);
    if(!found) {     if(!found) {
      ans_p = capa_malloc(nq+1,1);        ans_p = capa_malloc(nq+2,1); 
      tries_p = capa_malloc(3*nq+2,1); /* space and \0 */       tries_p = capa_malloc(3*nq+3,1); /* space and \0 */
      for(ii=0;ii<nq;ii++) { /* Initialize answer string and tries string */       for(ii=0;ii<nq;ii++) { /* Initialize answer string and tries string */
        ans_p[ii] = '-'; tries_p[3*ii] = ' '; tries_p[3*ii + 1] = '0';         ans_p[ii] = '-'; tries_p[3*ii] = ' '; tries_p[3*ii + 1] = '0';
        if(ii < nq-1) tries_p[3*ii + 2] = ',';         if(ii < nq-1) tries_p[3*ii + 2] = ',';
Line 585  int        set; Line 586  int        set;
      comma=index(oneline,',');       comma=index(oneline,',');
      length=((int)(comma-oneline))-(MAX_STUDENT_NUMBER+1);       length=((int)(comma-oneline))-(MAX_STUDENT_NUMBER+1);
      if (length < nq) {       if (length < nq) {
        ans_p = capa_malloc(nq+1,1);          ans_p = capa_malloc(nq+2,1); 
        tries_p = capa_malloc(3*nq+2,1); /* space and \0 */         tries_p = capa_malloc(3*nq+3,1); /* space and \0 */
      } else {       } else {
        ans_p = capa_malloc(length+1,1);          ans_p = capa_malloc(length+2,1); 
        tries_p = capa_malloc(3*length+2,1); /* space and \0 */         tries_p = capa_malloc(3*length+3,1); /* space and \0 */
      }       }
      sprintf(fmtbuf, "%%%dc",length);       sprintf(fmtbuf, "%%%dc",length);
      sscanf(oneline + MAX_STUDENT_NUMBER+1,fmtbuf,ans_p);       sscanf(oneline + MAX_STUDENT_NUMBER+1,fmtbuf,ans_p);
        ans_p[length]='\0';
      sprintf(fmtbuf, "%%%dc",(3*length-1));       sprintf(fmtbuf, "%%%dc",(3*length-1));
      sscanf(oneline + MAX_STUDENT_NUMBER+1+length+1,fmtbuf,tries_p);       sscanf(oneline + MAX_STUDENT_NUMBER+1+length+1,fmtbuf,tries_p);
        tries_p[3*length-1];
      entry->answers = ans_p;       entry->answers = ans_p;
      entry->tries   = tries_p;       entry->tries   = tries_p;
      entry->e_probs = nq;       entry->e_probs = nq;
Line 605  int        set; Line 608  int        set;
        }         }
        ans_p[nq]='\0';tries_p[3*(nq)+2]='\0';tries_p[3*length-1]=',';         ans_p[nq]='\0';tries_p[3*(nq)+2]='\0';tries_p[3*length-1]=',';
      }       }
        printf("Got:%s:%s:\n",ans_p,tries_p);/*TEST*/
    }     }
    return (offset);     return (offset);
 }  }
Line 3079  capa_check_answer(p, answer) Problem_t * Line 3083  capa_check_answer(p, answer) Problem_t *
                 }                  }
                 given = n_part * scale; /* convert the given answer into proper scale for units */                  given = n_part * scale; /* convert the given answer into proper scale for units */
                 sig = calc_sig( input );                  sig = calc_sig( input );
                 if( (sig < sig_l) || (sig > sig_u) ) {                  if( ((sig < sig_l) || (sig > sig_u)) && (sig!=0)) {
                   result = SIG_FAIL;                    result = SIG_FAIL;
                 } else {                  } else {
                   switch( tol_type ) {                    switch( tol_type ) {
Line 3151  capa_check_answer(p, answer) Problem_t * Line 3155  capa_check_answer(p, answer) Problem_t *
           result = check_formula_ans(correct,answer,p->id_list,p->pts_list,tol_type,tol);            result = check_formula_ans(correct,answer,p->id_list,p->pts_list,tol_type,tol);
           break;            break;
     case ANSWER_IS_EXTERNAL: /* not yet implemented */      case ANSWER_IS_EXTERNAL: /* not yet implemented */
            /* we assume the external program is called through popen() */
            /* and the result will be given back as 0 or 1 to indicate the */
            /* given answer is correct or not */
            
           break;            break;
           
   }    }

Removed from v.1.4  
changed lines
  Added in v.1.6


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>