Annotation of loncom/homework/CAPA-converter/capaCommon.h, revision 1.8

1.7       albertel    1: /* The LearningOnline Network with CAPA
                      2:  * Definitons of the convertor API 
1.8     ! albertel    3:  * $Id: capaCommon.h,v 1.7 2001/12/04 15:17:57 albertel Exp $
1.7       albertel    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:  */
1.1       albertel   27: 
                     28: /**********************************************************/
                     29: /*   This header defines Application Interface to the     */
                     30: /*    CAPA system.  It needs capaParser.h and capaToken.h */
                     31: /*    CAPA version 4.3                                    */
                     32: /*    Date Oct 23 1995                                    */
                     33: /*   Isaac Tsai                                           */
                     34: /*                                                        */
                     35: /*   Get rid of old style structure definition *_t        */
                     36: /*   Make all structure definition begin with T_          */
                     37: /*   1997, 1998, 1999  Isaac Tsai                         */
                     38: /**********************************************************/
                     39: 
                     40: #ifndef   CAPA_COMMON_H
                     41: #define   CAPA_COMMON_H
                     42: 
                     43: #include <stdio.h>
                     44: #ifdef linux
                     45: #include <stdlib.h>
                     46: #endif
                     47: #ifdef NeXT
                     48: #include <stdlib.h>
                     49: #include <libc.h>
                     50: #else
                     51: #include <malloc.h>
                     52: #include <unistd.h>
                     53: #endif
                     54: 
                     55: #include <math.h>
                     56: #include <string.h>
                     57: #include <time.h>
                     58: #include <sys/fcntl.h>    /* lockf()  */
                     59: #include <sys/file.h>     /* flock()  */
                     60: #include <sys/types.h>
1.2       albertel   61: #include <stdarg.h>
1.1       albertel   62: #include "capaParser.h"
                     63: 
                     64: #ifndef    MAX
                     65: #define    MAX(a,b) ((a>b)? (a):(b))
                     66: #endif
                     67: 
                     68: #define    MAX_SECTION_SIZE    10240    /* Max # of students in the class */
                     69: #define    MAX_SECTION_COUNT   1024
                     70: #define    MAX_NAME_CHAR       30      /* Student's name max length      */
                     71: #define    MAX_STUDENT_NUMBER   9      /* Student Number length          */
                     72: #define    MAX_EMAIL_CHAR      40      /* Email address */
                     73: #define    FILE_NAME_LENGTH    1024
                     74: #define    MAX_PIN_CHAR        4
                     75: #define    MAX_BUFFER_SIZE     2048
                     76: #define    TMP_LINE_LENGTH     2048     /* used to read in log.db set.db dates.db */
                     77: #define    SMALL_LINE_BUFFER   128     /* used to read classl, active.db */
                     78: #define    SETDB_BUF_SIZE      (256*1024)
                     79: /*  user input string length now in capaParser.h*/
                     80: /*#define    ANSWER_STRING_LENG       81*/
                     81: /*#define    UNIT_STRING_LENG         64*/
                     82: #define    FORMAT_STRING_LENG       32
                     83: 
                     84: /* -------- used in check_date() */
                     85: #define    CHECK_OPEN_DATE      1
                     86: #define    CHECK_DUE_DATE       2
                     87: #define    CHECK_ANS_DATE       3
                     88: 
                     89: 
                     90: 
                     91: /******************************************************************************/
                     92: /* STRUCTURE FOR THE HEADER OF A DATABASE FILE                                */
                     93: /******************************************************************************/
                     94: 
                     95: typedef struct {
                     96:   char   num_questions[FORMAT_STRING_LENG];
                     97:   char   *weight;
                     98:   char   *partial_credit;
                     99: }  T_header;
                    100: 
                    101: /******************************************************************************/
                    102: /* STRUCTURE FOR A NORMAL DATABASE FILE ENTRY                                 */
                    103: /******************************************************************************/
                    104: 
                    105: typedef struct {
                    106:  char    student_number[MAX_STUDENT_NUMBER+1]; /* Student number */
                    107:  int     e_probs;
                    108:  char   *answers; /* String of answers */
                    109:  char   *tries;
                    110: } T_entry;
                    111: 
                    112: /******************************************************************************/
                    113: /* STRUCTURE FOR A STUDENT IN THE STUDENT ARRAY                               */
                    114: /******************************************************************************/
                    115: 
                    116: typedef struct _student {
                    117:    struct _student *s_next;
                    118:    struct _student *s_prev;
                    119:    int    s_sec;
                    120:    int    s_scores;
                    121:    char   s_key[MAX_NAME_CHAR+MAX_NAME_CHAR+2]; /* sorting key */
                    122:    char   s_sn[MAX_STUDENT_NUMBER+1];
                    123:    char   s_nm[MAX_NAME_CHAR+1];
                    124:    char   s_email[MAX_EMAIL_CHAR+1];
                    125:    int    s_capaid;
                    126: }  T_student;
                    127: 
                    128: /******************************************************************************/
                    129: /* STRUCTURE FOR Login dates for a set                                        */
                    130: /******************************************************************************/
                    131: /*section number DATE_DEFAULTs contains the default dates an assignment is due*/ 
                    132: #define DATE_DEFAULTS 0
                    133: #define OPEN_OFFSET 0
                    134: #define DUE_OFFSET 17
                    135: #define ANSWER_OFFSET 34
                    136: #define DATE_LENGTH 16
                    137: #define DATE_BUFFER 17
                    138: #define OPTION_INHIBIT_RESPONSE 100
                    139: #define OPTION_VIEW_PROBLEMS_AFTER_DUE 101
                    140: typedef struct _date {
                    141:   struct _date *s_next;
                    142:   int    section_start;
                    143:   int    section_end;
                    144:   char   open_date[DATE_BUFFER];
                    145:   char   due_date[DATE_BUFFER];
                    146:   char   answer_date[DATE_BUFFER];
                    147:   char   duration[DATE_BUFFER];
                    148:   int    inhibit_response;
                    149:   int    view_problems_after_due;
                    150: } T_dates;
                    151: 
                    152: /******************************************************************************/
                    153: /* STRUCTURE FOR Login history for a student                                  */
                    154: /******************************************************************************/
                    155: typedef struct {
                    156:  int     count;  /* Number of questions */
                    157:  char   *answers; /* String of answers   */
                    158: } login_history_t;
                    159: 
                    160: #define	leap_year(yr) ((yr) <= 1752 ? !((yr) % 4) : !((yr) % 4) && (((yr) % 100) || !((yr) % 400)))
                    161: 
                    162: #define	centuries_since_1700(yr) ((yr) > 1700 ? (yr) / 100 - 17 : 0)
                    163: 
                    164: #define	quad_centuries_since_1700(yr)  ((yr) > 1600 ? ((yr) - 1600) / 400 : 0)
                    165: 
                    166: #define	leap_years_since_year_1(yr)  ((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr))
                    167: 
1.3       albertel  168: struct dyn_string {
                    169:     int len;
                    170:     int max;
                    171:     char *str;
                    172: };
                    173: struct dyn_string dyn_out;
                    174: struct dyn_string dyn_delayed;
                    175: extern int dyn_maxlen;
1.6       albertel  176: extern char *import_prefix;
                    177: 
                    178: #define MAX_CACHE 100
                    179: #define CACHE_ERROR 100
                    180: extern struct dyn_string cached_data[MAX_CACHE];
                    181: extern int current_cache;
                    182: extern int do_cache[MAX_CACHE];
                    183: 
                    184: #define MAX_STREAMS 100
1.8     ! albertel  185: 
        !           186: #define MAX_DEST 6
        !           187: #define DEFAULT_DEST 0
        !           188: #define HINT_DEST 1
        !           189: #define EXP_DEST 2
        !           190: #define ANS_DEST 3
        !           191: 
1.6       albertel  192: #define ALL_STREAMS -1
1.8     ! albertel  193: extern struct dyn_string streams[MAX_DEST][MAX_STREAMS];
        !           194: extern int num_streams[MAX_DEST];
        !           195: extern int current_dest;
1.6       albertel  196: 
1.8     ! albertel  197: extern int mode[MAX_DEST][MAX_STREAMS];
1.6       albertel  198: #define MODE_NONE    0
                    199: #define MODE_COMMENT 1
                    200: #define MODE_BLOCK   2
                    201: #define MODE_SCRIPT  3
                    202: #define MODE_OUTTEXT 4
                    203: #define MODE_ANSWER  5
                    204: #define MODE_HINT    6
                    205: #define MODE_IMPORT  7
                    206: /* end_mode always sets this to 0, if you want to check if any other
                    207:    mode has been entered. Set this to 1 and check again if it has been
                    208:    set back to zero.
                    209: */
1.8     ! albertel  210: extern int watch_mode[MAX_DEST][MAX_STREAMS];
        !           211: extern int beg_mode[MAX_DEST][MAX_STREAMS];
1.1       albertel  212: /*=============================================================================*/
                    213: /* CAPA PROTOTYPES FOR FUNCTIONS IN COMMON.C                                   */
                    214: /*=============================================================================*/
                    215: /*-----------------------------------------------------------------------------*/
1.6       albertel  216: int capa_parse(int  set,Problem_t **problem,char *filename,int *num_questions,void (*func_ptr)());
                    217: void send(char* text,...);
                    218: void end_mode(void);
1.8     ! albertel  219: void end_mode_stream(int which_dest, int which);
1.6       albertel  220: void start_mode(int newmode,char* args);
1.8     ! albertel  221: void start_mode_stream(int which_dest, int which,int newmode,char* args);
1.6       albertel  222: void dyn_init(struct dyn_string *dyn);
                    223: void dyn_free(struct dyn_string *dyn);
1.3       albertel  224: int append_message(struct dyn_string *dyn_msg,char *format,va_list ap);
1.4       albertel  225: void add_delayed(char *format, ...);
1.3       albertel  226: void flush_delayed();
                    227: void start_delayed();
                    228: void end_delayed();
1.6       albertel  229: void send_stream(int which,char* text,...);
1.8     ! albertel  230: void start_streams(int which_dest, int num);
        !           231: void end_streams(int which_dest, int which);
        !           232: int is_dest_empty(int which_dest);
        !           233: void change_destination(int which_dest);
        !           234: void send_destination_to_default(int which_dest);
1.6       albertel  235: void new_cache();
                    236: void delete_cache();
                    237: void start_cache();
                    238: void stop_cache();
1.1       albertel  239: /*============================================================================*/
                    240: 
                    241: #endif  /* CAPA_COMMON_H  */
                    242: 

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