Annotation of loncom/homework/CAPA-converter/convert.c, revision 1.3

1.1       albertel    1: /* ======================================================================== */
                      2: /*       Feb. 10 1997   Isaac Tsai                                          */
                      3: /* ======================================================================== */
                      4: 
                      5: #include <stdio.h>
                      6: #include <ctype.h>
                      7: #include <sys/types.h>
                      8: #include <sys/stat.h>  
                      9: #include <signal.h>
                     10: #include <time.h>
                     11: #include <math.h>
                     12: #include <string.h>
1.3     ! albertel   13: #include <unistd.h>
1.1       albertel   14: 
1.3     ! albertel   15: extern char *optarg;
        !            16: extern int optind, opterr, optout;
1.1       albertel   17: 
                     18: #define   YES    1
                     19: 
                     20: #include "capaCommon.h"
                     21: 
                     22: char    *progname;
1.3     ! albertel   23: char *import_prefix="/res/capa";
1.1       albertel   24: 
                     25: void
                     26: print_answer(FILE *o_fp,int ans_cnt,char *ans,char *lower,char *upper,char *unit)
                     27: {
                     28:   if (unit && (strlen(unit)>0)) 
                     29:     if(ans_cnt==2)  fprintf(o_fp,"ANS:%s %s %s %s\n",ans,lower,upper,unit); 
                     30:     else  fprintf(o_fp,"ANS:%s %s\n",lower,unit);
                     31:   else 
                     32:     if(ans_cnt==2)  fprintf(o_fp,"ANS:%s %s %s\n",ans,lower,upper); 
                     33:     else  fprintf(o_fp,"ANS:%s\n",lower);
                     34: }
                     35: 
                     36: void print_question (FILE *o_fp,char *question)
                     37: {
                     38:   fprintf(o_fp,"BQES:\n%s\nEQES:\n",question);
                     39: }
                     40: 
1.3     ! albertel   41: int get_options ( int argc, char **argv, char ** filename)
        !            42: {
        !            43:   int opt;
        !            44:   /*opterr=0;*/
        !            45:   while ((opt=getopt(argc,argv,"i:f:"))!=-1) {
        !            46:     switch (opt) {
        !            47:     case 'i': 
        !            48:       import_prefix=optarg;
        !            49:       break;
        !            50:     case 'f': 
        !            51:       *filename=optarg;
        !            52:       break;
        !            53:     case '?':
        !            54:       return -1;
        !            55:       break;
        !            56:     }
        !            57:   }
        !            58:   return 0;
        !            59: }
        !            60: 
        !            61: int main (int argc, char **argv) 
1.1       albertel   62: {
                     63:   extern  int        Parsemode_f;
1.3     ! albertel   64: 
        !            65:   /* unused  
1.1       albertel   66:   extern  int        managermode;
1.3     ! albertel   67:   int         num_answers, q_idx;
1.1       albertel   68:   char        lower[ANSWER_STRING_LENG], upper[ANSWER_STRING_LENG];
                     69:   int         StartSet = 1, EndSet = 1;
                     70:   char        tmp_str[ANSWER_STRING_LENG];
                     71:   double      tmp_ans;
                     72:   T_student   a_student;
1.3     ! albertel   73:   Problem_t  *p;
        !            74:   */
        !            75:   Problem_t  *first_prob;
        !            76:   int result, setIdx = 1, q_cnt;
        !            77:   char *      filename=NULL;
1.1       albertel   78: 
                     79:   Parsemode_f=ASCII_MODE;
1.3     ! albertel   80:   
        !            81:   if ( get_options(argc,argv,&filename) == -1 || filename==NULL ) {
        !            82:     printf("USAGE: %s [-i prefix] -f filename\n",argv[0]);
1.1       albertel   83:     exit(-1);
                     84:   }
1.3     ! albertel   85: 
        !            86:   result = capa_parse(setIdx, &first_prob, filename ,&q_cnt,NULL);
1.1       albertel   87: 
                     88:   return (0);
                     89: }
                     90: 
                     91: 

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