File:  [LON-CAPA] / loncom / homework / CAPA-converter / convert.c
Revision 1.4: download - view: text, annotated - select for diffs
Tue Dec 4 15:17:57 2001 UTC (22 years, 5 months ago) by albertel
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_99_0, version_2_9_1, version_2_9_0, version_2_8_X, version_2_8_99_1, version_2_8_99_0, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_X, version_2_7_99_1, version_2_7_99_0, version_2_7_1, version_2_7_0, version_2_6_X, version_2_6_99_1, version_2_6_99_0, version_2_6_3, version_2_6_2, version_2_6_1, version_2_6_0, version_2_5_X, version_2_5_99_1, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_X, version_2_2_99_1, version_2_2_99_0, version_2_2_2, version_2_2_1, version_2_2_0, version_2_1_X, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, version_2_1_3, version_2_1_2, version_2_1_1, version_2_1_0, version_2_12_X, version_2_11_X, version_2_11_4_uiuc, version_2_11_4_msu, version_2_11_4, version_2_11_3_uiuc, version_2_11_3_msu, version_2_11_3, version_2_11_2_uiuc, version_2_11_2_msu, version_2_11_2_educog, version_2_11_2, version_2_11_1, version_2_11_0_RC3, version_2_11_0_RC2, version_2_11_0_RC1, version_2_11_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0_RC1, version_2_10_0, version_2_0_X, version_2_0_99_1, version_2_0_2, version_2_0_1, version_2_0_0, version_1_99_3, version_1_99_2, version_1_99_1_tmcc, version_1_99_1, version_1_99_0_tmcc, version_1_99_0, version_1_3_X, version_1_3_3, version_1_3_2, version_1_3_1, version_1_3_0, version_1_2_X, version_1_2_99_1, version_1_2_99_0, version_1_2_1, version_1_2_0, version_1_1_X, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, version_1_1_99_0, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, version_1_0_3, version_1_0_2, version_1_0_1, version_1_0_0, version_0_99_5, version_0_99_4, version_0_99_3, version_0_99_2, version_0_99_1, version_0_99_0, version_0_6_2, version_0_6, version_0_5_1, version_0_5, version_0_4, stable_2002_spring, stable_2002_july, stable_2002_april, stable_2001_fall, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, conference_2003, bz6209-base, bz6209, bz5969, bz2851, STABLE, PRINT_INCOMPLETE_base, PRINT_INCOMPLETE, HEAD, GCI_3, GCI_2, GCI_1, BZ5971-printing-apage, BZ5434-fox, BZ4492-merge, BZ4492-feature_horizontal_radioresponse, BZ4492-feature_Support_horizontal_radioresponse, BZ4492-Support_horizontal_radioresponse
- GPL headers

    1: /* The LearningOnline Network with CAPA
    2:  * Main convert code, option parsing and startup 
    3:  * $Id: convert.c,v 1.4 2001/12/04 15:17:57 albertel Exp $
    4:  *
    5:  * Copyright Michigan State University Board of Trustees
    6:  *
    7:  * This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    8:  *
    9:  * LON-CAPA is free software; you can redistribute it and/or modify
   10:  * it under the terms of the GNU General Public License as published by
   11:  * the Free Software Foundation; either version 2 of the License, or
   12:  * (at your option) any later version.
   13:  *
   14:  * LON-CAPA is distributed in the hope that it will be useful,
   15:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   16:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17:  * GNU General Public License for more details.
   18:  *
   19:  * You should have received a copy of the GNU General Public License
   20:  * along with LON-CAPA; if not, write to the Free Software
   21:  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   22:  *
   23:  * /home/httpd/html/adm/gpl.txt
   24:  *
   25:  * http://www.lon-capa.org/
   26:  */
   27: 
   28: /* ======================================================================== */
   29: /*       Feb. 10 1997   Isaac Tsai                                          */
   30: /* ======================================================================== */
   31: 
   32: #include <stdio.h>
   33: #include <ctype.h>
   34: #include <sys/types.h>
   35: #include <sys/stat.h>  
   36: #include <signal.h>
   37: #include <time.h>
   38: #include <math.h>
   39: #include <string.h>
   40: #include <unistd.h>
   41: 
   42: extern char *optarg;
   43: extern int optind, opterr, optout;
   44: 
   45: #define   YES    1
   46: 
   47: #include "capaCommon.h"
   48: 
   49: char    *progname;
   50: char *import_prefix="/res/capa";
   51: 
   52: void
   53: print_answer(FILE *o_fp,int ans_cnt,char *ans,char *lower,char *upper,char *unit)
   54: {
   55:   if (unit && (strlen(unit)>0)) 
   56:     if(ans_cnt==2)  fprintf(o_fp,"ANS:%s %s %s %s\n",ans,lower,upper,unit); 
   57:     else  fprintf(o_fp,"ANS:%s %s\n",lower,unit);
   58:   else 
   59:     if(ans_cnt==2)  fprintf(o_fp,"ANS:%s %s %s\n",ans,lower,upper); 
   60:     else  fprintf(o_fp,"ANS:%s\n",lower);
   61: }
   62: 
   63: void print_question (FILE *o_fp,char *question)
   64: {
   65:   fprintf(o_fp,"BQES:\n%s\nEQES:\n",question);
   66: }
   67: 
   68: int get_options ( int argc, char **argv, char ** filename)
   69: {
   70:   int opt;
   71:   /*opterr=0;*/
   72:   while ((opt=getopt(argc,argv,"i:f:"))!=-1) {
   73:     switch (opt) {
   74:     case 'i': 
   75:       import_prefix=optarg;
   76:       break;
   77:     case 'f': 
   78:       *filename=optarg;
   79:       break;
   80:     case '?':
   81:       return -1;
   82:       break;
   83:     }
   84:   }
   85:   return 0;
   86: }
   87: 
   88: int main (int argc, char **argv) 
   89: {
   90:   extern  int        Parsemode_f;
   91: 
   92:   /* unused  
   93:   extern  int        managermode;
   94:   int         num_answers, q_idx;
   95:   char        lower[ANSWER_STRING_LENG], upper[ANSWER_STRING_LENG];
   96:   int         StartSet = 1, EndSet = 1;
   97:   char        tmp_str[ANSWER_STRING_LENG];
   98:   double      tmp_ans;
   99:   T_student   a_student;
  100:   Problem_t  *p;
  101:   */
  102:   Problem_t  *first_prob;
  103:   int result, setIdx = 1, q_cnt;
  104:   char *      filename=NULL;
  105: 
  106:   Parsemode_f=ASCII_MODE;
  107:   
  108:   if ( get_options(argc,argv,&filename) == -1 || filename==NULL ) {
  109:     printf("USAGE: %s [-i prefix] -f filename\n",argv[0]);
  110:     exit(-1);
  111:   }
  112: 
  113:   result = capa_parse(setIdx, &first_prob, filename ,&q_cnt,NULL);
  114: 
  115:   return (0);
  116: }
  117: 
  118: 

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