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 (23 years, 1 month 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_6,
version_2_11_5_msu,
version_2_11_5,
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.)
/* The LearningOnline Network with CAPA
* Definitons of the convertor API
* $Id: capaCommon.h,v 1.8 2001/12/05 18:58:21 albertel Exp $
*
* Copyright Michigan State University Board of Trustees
*
* This file is part of the LearningOnline Network with CAPA (LON-CAPA).
*
* LON-CAPA is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* LON-CAPA is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LON-CAPA; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* /home/httpd/html/adm/gpl.txt
*
* http://www.lon-capa.org/
*/
/**********************************************************/
/* This header defines Application Interface to the */
/* CAPA system. It needs capaParser.h and capaToken.h */
/* CAPA version 4.3 */
/* Date Oct 23 1995 */
/* Isaac Tsai */
/* */
/* Get rid of old style structure definition *_t */
/* Make all structure definition begin with T_ */
/* 1997, 1998, 1999 Isaac Tsai */
/**********************************************************/
#ifndef CAPA_COMMON_H
#define CAPA_COMMON_H
#include <stdio.h>
#ifdef linux
#include <stdlib.h>
#endif
#ifdef NeXT
#include <stdlib.h>
#include <libc.h>
#else
#include <malloc.h>
#include <unistd.h>
#endif
#include <math.h>
#include <string.h>
#include <time.h>
#include <sys/fcntl.h> /* lockf() */
#include <sys/file.h> /* flock() */
#include <sys/types.h>
#include <stdarg.h>
#include "capaParser.h"
#ifndef MAX
#define MAX(a,b) ((a>b)? (a):(b))
#endif
#define MAX_SECTION_SIZE 10240 /* Max # of students in the class */
#define MAX_SECTION_COUNT 1024
#define MAX_NAME_CHAR 30 /* Student's name max length */
#define MAX_STUDENT_NUMBER 9 /* Student Number length */
#define MAX_EMAIL_CHAR 40 /* Email address */
#define FILE_NAME_LENGTH 1024
#define MAX_PIN_CHAR 4
#define MAX_BUFFER_SIZE 2048
#define TMP_LINE_LENGTH 2048 /* used to read in log.db set.db dates.db */
#define SMALL_LINE_BUFFER 128 /* used to read classl, active.db */
#define SETDB_BUF_SIZE (256*1024)
/* user input string length now in capaParser.h*/
/*#define ANSWER_STRING_LENG 81*/
/*#define UNIT_STRING_LENG 64*/
#define FORMAT_STRING_LENG 32
/* -------- used in check_date() */
#define CHECK_OPEN_DATE 1
#define CHECK_DUE_DATE 2
#define CHECK_ANS_DATE 3
/******************************************************************************/
/* STRUCTURE FOR THE HEADER OF A DATABASE FILE */
/******************************************************************************/
typedef struct {
char num_questions[FORMAT_STRING_LENG];
char *weight;
char *partial_credit;
} T_header;
/******************************************************************************/
/* STRUCTURE FOR A NORMAL DATABASE FILE ENTRY */
/******************************************************************************/
typedef struct {
char student_number[MAX_STUDENT_NUMBER+1]; /* Student number */
int e_probs;
char *answers; /* String of answers */
char *tries;
} T_entry;
/******************************************************************************/
/* STRUCTURE FOR A STUDENT IN THE STUDENT ARRAY */
/******************************************************************************/
typedef struct _student {
struct _student *s_next;
struct _student *s_prev;
int s_sec;
int s_scores;
char s_key[MAX_NAME_CHAR+MAX_NAME_CHAR+2]; /* sorting key */
char s_sn[MAX_STUDENT_NUMBER+1];
char s_nm[MAX_NAME_CHAR+1];
char s_email[MAX_EMAIL_CHAR+1];
int s_capaid;
} T_student;
/******************************************************************************/
/* STRUCTURE FOR Login dates for a set */
/******************************************************************************/
/*section number DATE_DEFAULTs contains the default dates an assignment is due*/
#define DATE_DEFAULTS 0
#define OPEN_OFFSET 0
#define DUE_OFFSET 17
#define ANSWER_OFFSET 34
#define DATE_LENGTH 16
#define DATE_BUFFER 17
#define OPTION_INHIBIT_RESPONSE 100
#define OPTION_VIEW_PROBLEMS_AFTER_DUE 101
typedef struct _date {
struct _date *s_next;
int section_start;
int section_end;
char open_date[DATE_BUFFER];
char due_date[DATE_BUFFER];
char answer_date[DATE_BUFFER];
char duration[DATE_BUFFER];
int inhibit_response;
int view_problems_after_due;
} T_dates;
/******************************************************************************/
/* STRUCTURE FOR Login history for a student */
/******************************************************************************/
typedef struct {
int count; /* Number of questions */
char *answers; /* String of answers */
} login_history_t;
#define leap_year(yr) ((yr) <= 1752 ? !((yr) % 4) : !((yr) % 4) && (((yr) % 100) || !((yr) % 400)))
#define centuries_since_1700(yr) ((yr) > 1700 ? (yr) / 100 - 17 : 0)
#define quad_centuries_since_1700(yr) ((yr) > 1600 ? ((yr) - 1600) / 400 : 0)
#define leap_years_since_year_1(yr) ((yr) / 4 - centuries_since_1700(yr) + quad_centuries_since_1700(yr))
struct dyn_string {
int len;
int max;
char *str;
};
struct dyn_string dyn_out;
struct dyn_string dyn_delayed;
extern int dyn_maxlen;
extern char *import_prefix;
#define MAX_CACHE 100
#define CACHE_ERROR 100
extern struct dyn_string cached_data[MAX_CACHE];
extern int current_cache;
extern int do_cache[MAX_CACHE];
#define MAX_STREAMS 100
#define MAX_DEST 6
#define DEFAULT_DEST 0
#define HINT_DEST 1
#define EXP_DEST 2
#define ANS_DEST 3
#define ALL_STREAMS -1
extern struct dyn_string streams[MAX_DEST][MAX_STREAMS];
extern int num_streams[MAX_DEST];
extern int current_dest;
extern int mode[MAX_DEST][MAX_STREAMS];
#define MODE_NONE 0
#define MODE_COMMENT 1
#define MODE_BLOCK 2
#define MODE_SCRIPT 3
#define MODE_OUTTEXT 4
#define MODE_ANSWER 5
#define MODE_HINT 6
#define MODE_IMPORT 7
/* end_mode always sets this to 0, if you want to check if any other
mode has been entered. Set this to 1 and check again if it has been
set back to zero.
*/
extern int watch_mode[MAX_DEST][MAX_STREAMS];
extern int beg_mode[MAX_DEST][MAX_STREAMS];
/*=============================================================================*/
/* CAPA PROTOTYPES FOR FUNCTIONS IN COMMON.C */
/*=============================================================================*/
/*-----------------------------------------------------------------------------*/
int capa_parse(int set,Problem_t **problem,char *filename,int *num_questions,void (*func_ptr)());
void send(char* text,...);
void end_mode(void);
void end_mode_stream(int which_dest, int which);
void start_mode(int newmode,char* args);
void start_mode_stream(int which_dest, int which,int newmode,char* args);
void dyn_init(struct dyn_string *dyn);
void dyn_free(struct dyn_string *dyn);
int append_message(struct dyn_string *dyn_msg,char *format,va_list ap);
void add_delayed(char *format, ...);
void flush_delayed();
void start_delayed();
void end_delayed();
void send_stream(int which,char* text,...);
void start_streams(int which_dest, int num);
void end_streams(int which_dest, int which);
int is_dest_empty(int which_dest);
void change_destination(int which_dest);
void send_destination_to_default(int which_dest);
void new_cache();
void delete_cache();
void start_cache();
void stop_cache();
/*============================================================================*/
#endif /* CAPA_COMMON_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>