File:  [LON-CAPA] / capa / capa51 / pProj / capaRQO.c
Revision 1.2: download - view: text, annotated - select for diffs
Fri Jun 30 21:36:16 2000 UTC (23 years, 11 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- gave everyone the GPL header

    1: /* broken start to a module to support questions appearing in a randomized order
    2:    Copyright (C) 1992-2000 Michigan State University
    3: 
    4:    The CAPA system is free software; you can redistribute it and/or
    5:    modify it under the terms of the GNU Library General Public License as
    6:    published by the Free Software Foundation; either version 2 of the
    7:    License, or (at your option) any later version.
    8: 
    9:    The CAPA system is distributed in the hope that it will be useful,
   10:    but WITHOUT ANY WARRANTY; without even the implied warranty of
   11:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12:    Library General Public License for more details.
   13: 
   14:    You should have received a copy of the GNU Library General Public
   15:    License along with the CAPA system; see the file COPYING.  If not,
   16:    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   17:    Boston, MA 02111-1307, USA.  */
   18: 
   19: #include <stdio.h>
   20: #include "capaCommon.h"
   21: #include "capaParser.h"
   22: #include "capaRQO.h"
   23: extern RandQO_t          *QuestionOrder;
   24: 
   25: /*FIXME I don't actually do anything yet*/
   26: void rqo_finish()
   27: {
   28:   printf("rqo_finish\n");
   29: }
   30: 
   31: void rqo_1spec()
   32: {
   33:   printf("rqo_1spec\n");
   34: }
   35: 
   36: void rqo_2spec()
   37: {
   38:   printf("rqo_2spec\n");
   39: }
   40: 
   41: void init_rqo()
   42: {
   43:   QuestionOrder=(RandQO_t*) capa_malloc(sizeof(RandQO_t),1);
   44:   QuestionOrder->num=0;
   45:   QuestionOrder->used=(int *) capa_malloc(sizeof(int)*MAX_BUFFER_SIZE,1);
   46:   QuestionOrder->length=MAX_BUFFER_SIZE;
   47:   QuestionOrder->groups=(RandGroup_t**)capa_malloc(sizeof(RandGroup_t*)*MAX_BUFFER_SIZE,1);
   48:   QuestionOrder->length=MAX_BUFFER_SIZE;
   49: }
   50: 
   51: int rqo_used(int a)
   52: {
   53:   if (QuestionOrder->used[a]) return 1;
   54:   QuestionOrder->used[a]=1;
   55:   return 0;
   56: }
   57: 
   58: void rqo_expand_range()
   59: {
   60:   /*int num=QuestionOrder->num-1;*/
   61: }
   62: 
   63: void start_rqo_type(int type)
   64: {
   65:   int num;
   66:   printf("start_rqo_type,%d\n",type);
   67:   if (!QuestionOrder) {init_rqo();}
   68:   if (QuestionOrder->groups[(QuestionOrder->num)-1]->type == RANGE) rqo_expand_range();
   69:   num=QuestionOrder->num;
   70:   QuestionOrder->groups[num]=(RandGroup_t*)capa_malloc(sizeof(RandGroup_t),1);
   71:   QuestionOrder->groups[num]->type=type;
   72:   QuestionOrder->groups[num]->length=0;
   73:   QuestionOrder->groups[num]->list=(int *) capa_malloc(sizeof(int)*MAX_BUFFER_SIZE,1);
   74:   QuestionOrder->num++;
   75: }
   76: 
   77: void append_rqo(Symbol*s)
   78: {
   79:   int num=QuestionOrder->num-1;
   80:   printf("append_rqo,%ld\n",s->s_int);
   81:   QuestionOrder->groups[num]->list[QuestionOrder->groups[num]->length]=s->s_int;
   82:   QuestionOrder->groups[num]->length++;
   83:   if (rqo_used(s->s_int)) {
   84:     char warn_msg[WARN_MSG_LENGTH];
   85:     sprintf(warn_msg,"Question %ld, used twice in /RQO",s->s_int);
   86:     capa_msg(MESSAGE_ERROR,warn_msg);
   87:   }
   88:   capa_mfree((char*)s);
   89: }
   90: 
   91: void prefix_rqo(Symbol*s)
   92: {
   93:   int i, num=QuestionOrder->num-1;
   94:   printf("prefix_rqo,%ld\n",s->s_int);
   95:   for(i=(QuestionOrder->groups[num]->length);i>0;i--) {
   96:       QuestionOrder->groups[num]->list[i]=QuestionOrder->groups[num]->list[i-1];
   97:   }
   98:   QuestionOrder->groups[num]->list[0]=s->s_int;
   99:   QuestionOrder->groups[num]->length++;
  100:   if (rqo_used(s->s_int)) {
  101:     char warn_msg[WARN_MSG_LENGTH];
  102:     sprintf(warn_msg,"Question %ld, used twice in /RQO",s->s_int);
  103:     capa_msg(MESSAGE_ERROR,warn_msg);
  104:   }
  105:   capa_mfree((char*)s);
  106: }
  107: 

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