File:  [LON-CAPA] / loncom / homework / CAPA-converter / capaCommon.h
Revision 1.8: download - view: text, annotated - select for diffs
Wed Dec 5 18:58:21 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
- added multiple "destinations", to do large scale rearrangement of problem chunks. (Notably Hints and explanations now appear in the correct location.)

    1: /* The LearningOnline Network with CAPA
    2:  * Definitons of the convertor API 
    3:  * $Id: capaCommon.h,v 1.8 2001/12/05 18:58:21 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: /*   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>
   61: #include <stdarg.h>
   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: 
  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;
  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
  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: 
  192: #define ALL_STREAMS -1
  193: extern struct dyn_string streams[MAX_DEST][MAX_STREAMS];
  194: extern int num_streams[MAX_DEST];
  195: extern int current_dest;
  196: 
  197: extern int mode[MAX_DEST][MAX_STREAMS];
  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: */
  210: extern int watch_mode[MAX_DEST][MAX_STREAMS];
  211: extern int beg_mode[MAX_DEST][MAX_STREAMS];
  212: /*=============================================================================*/
  213: /* CAPA PROTOTYPES FOR FUNCTIONS IN COMMON.C                                   */
  214: /*=============================================================================*/
  215: /*-----------------------------------------------------------------------------*/
  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);
  219: void end_mode_stream(int which_dest, int which);
  220: void start_mode(int newmode,char* args);
  221: void start_mode_stream(int which_dest, int which,int newmode,char* args);
  222: void dyn_init(struct dyn_string *dyn);
  223: void dyn_free(struct dyn_string *dyn);
  224: int append_message(struct dyn_string *dyn_msg,char *format,va_list ap);
  225: void add_delayed(char *format, ...);
  226: void flush_delayed();
  227: void start_delayed();
  228: void end_delayed();
  229: void send_stream(int which,char* text,...);
  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);
  235: void new_cache();
  236: void delete_cache();
  237: void start_cache();
  238: void stop_cache();
  239: /*============================================================================*/
  240: 
  241: #endif  /* CAPA_COMMON_H  */
  242: 

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