/* TABLIX, PGA highschool timetable generator */ /* Copyright (C) 2002 Tomaz Solc */ /* This program 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. */ /* This program 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 this program; if not, write to the Free Software */ /* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* $Id */ /* * AUTHOR: * * Antonio Duran Terres * * DESCRIPTION: * * Use this module if you have two subjects that you don't want * scheduled in the same day. * * Example scenario: you are using double_period.so module and need the * the facilities provided by subject_sameday.so applied to all * subjects in the "group". * * DEFINED CLASS RESTRICTIONS: * * subject teacher * * This restriction specifies that current subject should never be taught * in the same day as the subject specified in the restriction. * * Example config for the above scenario: * * * * MATH_FIRST * * * MATH_FIRST Cronin * * * With this config you get two blocks of two hours each, and one * of one hour.This is only necessary if you need MATH_LAB defined * as another subject different from MATH_FIRST (for example: you need * an hour in the lab room). * With the not-same-day restriction you get the chance to prevent * the theory and lab lessons from being scheduled in the same day. * */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "modsup.h" #include "data.h" #include "gettext.h" struct sameday { int sid1; int sid2; }; struct sameday *samedayas; int numsa; int getconflict(char *type, char *cont, int tid) { char title[256], teacher[256]; int c; int confsid; c=sscanf(cont, "%s %s", title, teacher); if(c<1) { strcpy(moderror, _("invalid format of not-same-day restriction")); return(1); } confsid=find_subject(title, teacher); if (confsid==-1) { strcpy(moderror, _("invalid subject in not-same-day restriction")); return(1); } samedayas[numsa].sid1= tuplemap[tid].sid; samedayas[numsa].sid2=confsid; numsa++; return 0; } parop tuple_restrictions[] = { { type : "not-same-day", parfunc: getconflict }, { type : 0, parfunc: 0 } }; int init_mod() { samedayas=malloc(sizeof(*samedayas)*tuplenum); if(samedayas==NULL) { strcpy(moderror, _("Not enough memory")); return 1; } numsa=0; return 0; } int is_sameday (int sid1, int sid2) { int c; for(c=0;c