// swad_syllabus.c: syllabus /* SWAD (Shared Workspace At a Distance), is a web platform developed at the University of Granada (Spain), and used to support university teaching. This file is part of SWAD core. Copyright (C) 1999-2019 Antonio Cañas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ /*****************************************************************************/ /********************************* Headers ***********************************/ /*****************************************************************************/ #include // For SEEK_SET #include // For PATH_MAX #include // For NULL #include // For SOAP_OK and soap functions #include // For free () #include // For string functions #include // For time () #include "swad_box.h" #include "swad_changelog.h" #include "swad_config.h" #include "swad_database.h" #include "swad_form.h" #include "swad_global.h" #include "swad_HTML.h" #include "swad_parameter.h" #include "swad_string.h" #include "swad_xml.h" /*****************************************************************************/ /************** External global variables from others modules ****************/ /*****************************************************************************/ extern struct Globals Gbl; /*****************************************************************************/ /***************************** Private constants *****************************/ /*****************************************************************************/ #define Syl_MAX_LEVELS_SYLLABUS 10 #define Syl_MAX_BYTES_ITEM_COD (Syl_MAX_LEVELS_SYLLABUS * (10 + 1) - 1) #define Syl_MAX_CHARS_TEXT_ITEM (1024 - 1) // 1023 #define Syl_MAX_BYTES_TEXT_ITEM ((Syl_MAX_CHARS_TEXT_ITEM + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 16383 #define Syl_WIDTH_NUM_SYLLABUS 20 static const char *StyleSyllabus[1 + Syl_MAX_LEVELS_SYLLABUS] = { "", "T1", "T2", "T3", "T3", "T3", "T3", "T3", "T3", "T3", "T3", }; /*****************************************************************************/ /******************************* Private types *******************************/ /*****************************************************************************/ struct ItemSyllabus { int Level; int CodItem[1 + Syl_MAX_LEVELS_SYLLABUS]; bool HasChildren; char Text[Syl_MAX_BYTES_TEXT_ITEM + 1]; }; /*****************************************************************************/ /***************************** Private variables *****************************/ /*****************************************************************************/ struct { struct ItemSyllabus *Lst; // List of items of a syllabus unsigned NumItems; // Number of items in the list unsigned NumItemsWithChildren; // Number of items with children int NumLevels; // Number of levels in the list } LstItemsSyllabus; /*****************************************************************************/ /***************************** Private prototypes ****************************/ /*****************************************************************************/ static void Syl_SetSyllabusTypeFromAction (void); static void Syl_ShowSyllabus (bool PutIconToEdit); static void Syl_ShowRowSyllabus (unsigned NumItem, int Level,int *CodItem,const char *Text,bool NewItem); static void Syl_WriteSyllabusIntoHTMLTmpFile (FILE *FileHTMLTmp); static void Syl_PutFormItemSyllabus (bool NewItem,unsigned NumItem,int Level,int *CodItem,const char *Text); static void Syl_PutParamNumItem (void); static void Syl_WriteNumItem (char *StrDst,FILE *FileTgt,int Level,int *CodItem); /*****************************************************************************/ /************* Get parameter about which syllabus I want to see **************/ /*****************************************************************************/ void Syl_GetParamWhichSyllabus (void) { /***** Get which syllabus I want to see *****/ Gbl.Syllabus.WhichSyllabus = (Syl_WhichSyllabus_t) Par_GetParToUnsignedLong ("WhichSyllabus", 0, Syl_NUM_WHICH_SYLLABUS - 1, (unsigned long) Syl_DEFAULT_WHICH_SYLLABUS); } /*****************************************************************************/ /************************ Write form to select syllabus **********************/ /*****************************************************************************/ void Syl_PutFormWhichSyllabus (void) { extern const char *Txt_SYLLABUS_WHICH_SYLLABUS[Syl_NUM_WHICH_SYLLABUS]; Syl_WhichSyllabus_t WhichSyllabus; /***** Form to select which syllabus I want to see (lectures/practicals) *****/ Frm_StartForm (ActSeeSyl); HTM_DIV_Begin ("class=\"CM\""); HTM_UL_Begin ("class=\"LIST_LEFT\""); for (WhichSyllabus = (Syl_WhichSyllabus_t) 0; WhichSyllabus < For_NUM_FORUM_SETS; WhichSyllabus++) { HTM_LI_Begin ("class=\"DAT LM\""); fprintf (Gbl.F.Out,"