Annotation of loncom/homework/CAPA-converter/convert.c, revision 1.4
1.4 ! albertel 1: /* The LearningOnline Network with CAPA
! 2: * Main convert code, option parsing and startup
! 3: * $Id: gplheader.js,v 1.1 2001/11/29 19:06:47 www 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:
1.1 albertel 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>
1.3 albertel 40: #include <unistd.h>
1.1 albertel 41:
1.3 albertel 42: extern char *optarg;
43: extern int optind, opterr, optout;
1.1 albertel 44:
45: #define YES 1
46:
47: #include "capaCommon.h"
48:
49: char *progname;
1.3 albertel 50: char *import_prefix="/res/capa";
1.1 albertel 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:
1.3 albertel 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)
1.1 albertel 89: {
90: extern int Parsemode_f;
1.3 albertel 91:
92: /* unused
1.1 albertel 93: extern int managermode;
1.3 albertel 94: int num_answers, q_idx;
1.1 albertel 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;
1.3 albertel 100: Problem_t *p;
101: */
102: Problem_t *first_prob;
103: int result, setIdx = 1, q_cnt;
104: char * filename=NULL;
1.1 albertel 105:
106: Parsemode_f=ASCII_MODE;
1.3 albertel 107:
108: if ( get_options(argc,argv,&filename) == -1 || filename==NULL ) {
109: printf("USAGE: %s [-i prefix] -f filename\n",argv[0]);
1.1 albertel 110: exit(-1);
111: }
1.3 albertel 112:
113: result = capa_parse(setIdx, &first_prob, filename ,&q_cnt,NULL);
1.1 albertel 114:
115: return (0);
116: }
117:
118:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>