Version 15.212.1

This commit is contained in:
Antonio Cañas Vargas 2016-05-30 15:25:21 +02:00
parent 05ba149c14
commit 0c27252948
6 changed files with 141 additions and 83 deletions

View File

@ -143,13 +143,14 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.212 (2016-05-30)" #define Log_PLATFORM_VERSION "SWAD 15.212.1 (2016-05-30)"
#define CSS_FILE "swad15.210.css" #define CSS_FILE "swad15.210.css"
#define JS_FILE "swad15.197.js" #define JS_FILE "swad15.197.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/* /*
Version 15.212.1: May 30, 2016 Fixed bug in course information. (201515 lines)
Version 15.212: May 30, 2016 Fixed bug in edition of syllabus, reported by Raymon Moreno Colina and Javier Fernández Baldomero. Version 15.212: May 30, 2016 Fixed bug in edition of syllabus, reported by Raymon Moreno Colina and Javier Fernández Baldomero.
Code refactoring related to course info. (201471 lines) Code refactoring related to course info. (201471 lines)
Version 15.211.2: May 13, 2016 Fixed bug in test questions, reported by Nuria Torres Rosell. (201394 lines) Version 15.211.2: May 13, 2016 Fixed bug in test questions, reported by Nuria Torres Rosell. (201394 lines)

View File

@ -337,8 +337,8 @@ void Gbl_InitializeGlobals (void)
Gbl.CurrentCrs.Records.LstFields.Num = 0; Gbl.CurrentCrs.Records.LstFields.Num = 0;
Gbl.CurrentCrs.Records.LstFields.NestedCalls = 0; Gbl.CurrentCrs.Records.LstFields.NestedCalls = 0;
Gbl.CurrentCrs.Syllabus.EditionIsActive = false; Gbl.Syllabus.EditionIsActive = false;
Gbl.CurrentCrs.Syllabus.WhichSyllabus = Syl_DEFAULT_WHICH_SYLLABUS; Gbl.Syllabus.WhichSyllabus = Syl_DEFAULT_WHICH_SYLLABUS;
Gbl.Search.WhatToSearch = Sch_SEARCH_ALL; Gbl.Search.WhatToSearch = Sch_SEARCH_ALL;
Gbl.Search.Str[0] = '\0'; Gbl.Search.Str[0] = '\0';

View File

@ -460,13 +460,6 @@ struct Globals
bool MustBeRead[Inf_NUM_INFO_TYPES]; // Students must read info? bool MustBeRead[Inf_NUM_INFO_TYPES]; // Students must read info?
bool ShowMsgMustBeRead; bool ShowMsgMustBeRead;
} Info; } Info;
struct
{
char PathDir[PATH_MAX+1];
unsigned NumItem;
bool EditionIsActive;
Syl_WhichSyllabus_t WhichSyllabus;
} Syllabus;
struct struct
{ {
struct RecordField Field; struct RecordField Field;
@ -477,6 +470,13 @@ struct Globals
long HighlightNotCod; // Notice code of a notice to be highlighted long HighlightNotCod; // Notice code of a notice to be highlighted
} Notices; } Notices;
} CurrentCrs; } CurrentCrs;
struct
{
char PathDir[PATH_MAX+1];
unsigned NumItem;
bool EditionIsActive;
Syl_WhichSyllabus_t WhichSyllabus;
} Syllabus;
struct struct
{ {
long CrsCod; long CrsCod;

View File

@ -1129,7 +1129,7 @@ static bool Inf_CheckIfInfoAvailable (Inf_InfoSrc_t InfoSrc)
{ {
case Inf_LECTURES: case Inf_LECTURES:
case Inf_PRACTICALS: case Inf_PRACTICALS:
return Syl_CheckSyllabus (); return Syl_CheckSyllabus (Gbl.CurrentCrs.Crs.CrsCod,Gbl.CurrentCrs.Info.Type);
default: default:
return false; return false;
} }
@ -1310,7 +1310,7 @@ static Inf_InfoType_t Inf_AsignInfoType (void)
return Inf_TEACHING_GUIDE; return Inf_TEACHING_GUIDE;
case ActSeeSyl: case ActSeeSyl:
Syl_GetParamWhichSyllabus (); Syl_GetParamWhichSyllabus ();
return (Gbl.CurrentCrs.Syllabus.WhichSyllabus == Syl_LECTURES ? Inf_LECTURES : return (Gbl.Syllabus.WhichSyllabus == Syl_LECTURES ? Inf_LECTURES :
Inf_PRACTICALS); Inf_PRACTICALS);
case ActSeeSylLec: case ActSeeSylLec:
case ActEdiSylLec: case ActEdiSylLec:
@ -1324,7 +1324,7 @@ static Inf_InfoType_t Inf_AsignInfoType (void)
case ActRchTxtEdiSylLec: case ActRchTxtEdiSylLec:
case ActRcvPlaTxtSylLec: case ActRcvPlaTxtSylLec:
case ActRcvRchTxtSylLec: case ActRcvRchTxtSylLec:
Gbl.CurrentCrs.Syllabus.WhichSyllabus = Syl_LECTURES; Gbl.Syllabus.WhichSyllabus = Syl_LECTURES;
return Inf_LECTURES; return Inf_LECTURES;
case ActSeeSylPra: case ActSeeSylPra:
case ActEdiSylPra: case ActEdiSylPra:
@ -1338,7 +1338,7 @@ static Inf_InfoType_t Inf_AsignInfoType (void)
case ActRchTxtEdiSylPra: case ActRchTxtEdiSylPra:
case ActRcvPlaTxtSylPra: case ActRcvPlaTxtSylPra:
case ActRcvRchTxtSylPra: case ActRcvRchTxtSylPra:
Gbl.CurrentCrs.Syllabus.WhichSyllabus = Syl_PRACTICALS; Gbl.Syllabus.WhichSyllabus = Syl_PRACTICALS;
return Inf_PRACTICALS; return Inf_PRACTICALS;
case ActSeeBib: case ActSeeBib:
case ActEdiBib: case ActEdiBib:
@ -1508,7 +1508,7 @@ void Inf_GetInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType,
{ {
case Inf_LECTURES: case Inf_LECTURES:
case Inf_PRACTICALS: case Inf_PRACTICALS:
if (!Syl_CheckSyllabus ()) if (!Syl_CheckSyllabus (CrsCod,InfoType))
{ {
*InfoSrc = Inf_INFO_SRC_NONE; *InfoSrc = Inf_INFO_SRC_NONE;
*MustBeRead = false; *MustBeRead = false;

View File

@ -100,8 +100,7 @@ struct
/***************************** Private prototypes ****************************/ /***************************** Private prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
static void Syl_SetSyllabusTypeAndLoadToMemory (void); static void Syl_SetSyllabusTypeFromAction (void);
static void Syl_LoadToMemory (void);
static void Syl_ShowSyllabus (void); static void Syl_ShowSyllabus (void);
static void Syl_ShowRowSyllabus (unsigned NumItem, static void Syl_ShowRowSyllabus (unsigned NumItem,
int Level,int *CodItem,const char *Text,bool NewItem); int Level,int *CodItem,const char *Text,bool NewItem);
@ -120,9 +119,9 @@ void Syl_GetParamWhichSyllabus (void)
/***** Get which syllabus I want to see *****/ /***** Get which syllabus I want to see *****/
Par_GetParToText ("WhichSyllabus",UnsignedStr,10); Par_GetParToText ("WhichSyllabus",UnsignedStr,10);
if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1) if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1)
Gbl.CurrentCrs.Syllabus.WhichSyllabus = (Syl_WhichSyllabus_t) UnsignedNum; Gbl.Syllabus.WhichSyllabus = (Syl_WhichSyllabus_t) UnsignedNum;
else else
Gbl.CurrentCrs.Syllabus.WhichSyllabus = Syl_DEFAULT_WHICH_SYLLABUS; Gbl.Syllabus.WhichSyllabus = Syl_DEFAULT_WHICH_SYLLABUS;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -148,7 +147,7 @@ void Syl_PutFormWhichSyllabus (void)
" style=\"display:inline;\">" " style=\"display:inline;\">"
"<input type=\"radio\" name=\"WhichSyllabus\" value=\"%u\"", "<input type=\"radio\" name=\"WhichSyllabus\" value=\"%u\"",
(unsigned) WhichSyllabus); (unsigned) WhichSyllabus);
if (WhichSyllabus == Gbl.CurrentCrs.Syllabus.WhichSyllabus) if (WhichSyllabus == Gbl.Syllabus.WhichSyllabus)
fprintf (Gbl.F.Out," checked=\"checked\""); fprintf (Gbl.F.Out," checked=\"checked\"");
fprintf (Gbl.F.Out," onclick=\"document.getElementById('%s').submit();\" />" fprintf (Gbl.F.Out," onclick=\"document.getElementById('%s').submit();\" />"
"%s" "%s"
@ -169,7 +168,7 @@ void Syl_GetParamItemNumber (void)
char UnsignedStr[10+1]; char UnsignedStr[10+1];
Par_GetParToText ("NumI",UnsignedStr,10); Par_GetParToText ("NumI",UnsignedStr,10);
if (sscanf (UnsignedStr,"%u",&Gbl.CurrentCrs.Syllabus.NumItem) != 1) if (sscanf (UnsignedStr,"%u",&Gbl.Syllabus.NumItem) != 1)
Lay_ShowErrorAndExit ("Item is missing."); Lay_ShowErrorAndExit ("Item is missing.");
} }
@ -178,13 +177,33 @@ void Syl_GetParamItemNumber (void)
/*****************************************************************************/ /*****************************************************************************/
// Return true if info available // Return true if info available
bool Syl_CheckSyllabus (void) bool Syl_CheckSyllabus (long CrsCod,Inf_InfoType_t InfoType)
{ {
/***** Set syllabus type and load syllabus from XML file to memory *****/ bool InfoAvailable;
Syl_SetSyllabusTypeAndLoadToMemory ();
/***** Start frame *****/ /***** Set syllabus type *****/
return (LstItemsSyllabus.NumItems != 0); switch (InfoType)
{
case Inf_LECTURES:
Gbl.Syllabus.WhichSyllabus = Syl_LECTURES;
break;
case Inf_PRACTICALS:
Gbl.Syllabus.WhichSyllabus = Syl_PRACTICALS;
break;
default:
return false;
}
/***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (CrsCod);
/***** Number of items > 0 ==> info available *****/
InfoAvailable = (LstItemsSyllabus.NumItems != 0);
/***** Free memory used to store items *****/
Syl_FreeListItemsSyllabus ();
return InfoAvailable;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -200,19 +219,22 @@ bool Syl_CheckAndEditSyllabus (void)
bool ICanEdit; bool ICanEdit;
bool PutIconToEdit; bool PutIconToEdit;
/***** Set syllabus type and load syllabus from XML file to memory *****/ /***** Set syllabus type depending on current action *****/
Syl_SetSyllabusTypeAndLoadToMemory (); Syl_SetSyllabusTypeFromAction ();
/***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (Gbl.CurrentCrs.Crs.CrsCod);
if (Gbl.Action.Act == ActEditorSylLec || if (Gbl.Action.Act == ActEditorSylLec ||
Gbl.Action.Act == ActEditorSylPra) Gbl.Action.Act == ActEditorSylPra)
Gbl.CurrentCrs.Syllabus.EditionIsActive = true; Gbl.Syllabus.EditionIsActive = true;
/***** Start frame *****/ /***** Start frame *****/
if (Gbl.CurrentCrs.Syllabus.EditionIsActive || LstItemsSyllabus.NumItems) if (Gbl.Syllabus.EditionIsActive || LstItemsSyllabus.NumItems)
{ {
ICanEdit = Gbl.Usrs.Me.LoggedRole == Rol_TEACHER || ICanEdit = Gbl.Usrs.Me.LoggedRole == Rol_TEACHER ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM; Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM;
PutIconToEdit = ICanEdit && !Gbl.CurrentCrs.Syllabus.EditionIsActive; PutIconToEdit = ICanEdit && !Gbl.Syllabus.EditionIsActive;
Lay_StartRoundFrame (NULL,Txt_INFO_TITLE[Gbl.CurrentCrs.Info.Type], Lay_StartRoundFrame (NULL,Txt_INFO_TITLE[Gbl.CurrentCrs.Info.Type],
PutIconToEdit ? Inf_PutIconToEditInfo : PutIconToEdit ? Inf_PutIconToEditInfo :
NULL); NULL);
@ -223,13 +245,13 @@ bool Syl_CheckAndEditSyllabus (void)
Syl_ShowSyllabus (); Syl_ShowSyllabus ();
/***** If the syllabus is empty ==> show form to add a iten to the end *****/ /***** If the syllabus is empty ==> show form to add a iten to the end *****/
if (Gbl.CurrentCrs.Syllabus.EditionIsActive && LstItemsSyllabus.NumItems == 0) if (Gbl.Syllabus.EditionIsActive && LstItemsSyllabus.NumItems == 0)
Syl_ShowRowSyllabus (0,1,LstItemsSyllabus.Lst[0].CodItem,"",true); Syl_ShowRowSyllabus (0,1,LstItemsSyllabus.Lst[0].CodItem,"",true);
/***** End table *****/ /***** End table *****/
fprintf (Gbl.F.Out,"</table>"); fprintf (Gbl.F.Out,"</table>");
if (Gbl.CurrentCrs.Syllabus.EditionIsActive) if (Gbl.Syllabus.EditionIsActive)
{ {
/***** Button to view *****/ /***** Button to view *****/
Act_FormStart (Inf_ActionsSeeInfo[Gbl.CurrentCrs.Info.Type]); Act_FormStart (Inf_ActionsSeeInfo[Gbl.CurrentCrs.Info.Type]);
@ -260,7 +282,7 @@ void Syl_EditSyllabus (void)
/************* Set syllabus type depending on the current action *************/ /************* Set syllabus type depending on the current action *************/
/*****************************************************************************/ /*****************************************************************************/
static void Syl_SetSyllabusTypeAndLoadToMemory (void) static void Syl_SetSyllabusTypeFromAction (void)
{ {
Gbl.CurrentCrs.Info.Type = Inf_LECTURES; Gbl.CurrentCrs.Info.Type = Inf_LECTURES;
@ -268,7 +290,7 @@ static void Syl_SetSyllabusTypeAndLoadToMemory (void)
switch (Gbl.Action.Act) switch (Gbl.Action.Act)
{ {
case ActSeeSyl: case ActSeeSyl:
Gbl.CurrentCrs.Info.Type = (Gbl.CurrentCrs.Syllabus.WhichSyllabus == Syl_LECTURES ? Inf_LECTURES : Gbl.CurrentCrs.Info.Type = (Gbl.Syllabus.WhichSyllabus == Syl_LECTURES ? Inf_LECTURES :
Inf_PRACTICALS); Inf_PRACTICALS);
break; break;
case ActSeeSylLec: case ActSeeSylLec:
@ -290,7 +312,7 @@ static void Syl_SetSyllabusTypeAndLoadToMemory (void)
case ActRchTxtEdiSylLec: case ActRchTxtEdiSylLec:
case ActRcvPlaTxtSylLec: case ActRcvPlaTxtSylLec:
case ActRcvRchTxtSylLec: case ActRcvRchTxtSylLec:
Gbl.CurrentCrs.Syllabus.WhichSyllabus = Syl_LECTURES; Gbl.Syllabus.WhichSyllabus = Syl_LECTURES;
Gbl.CurrentCrs.Info.Type = Inf_LECTURES; Gbl.CurrentCrs.Info.Type = Inf_LECTURES;
break; break;
case ActSeeSylPra: case ActSeeSylPra:
@ -312,28 +334,20 @@ static void Syl_SetSyllabusTypeAndLoadToMemory (void)
case ActRchTxtEdiSylPra: case ActRchTxtEdiSylPra:
case ActRcvPlaTxtSylPra: case ActRcvPlaTxtSylPra:
case ActRcvRchTxtSylPra: case ActRcvRchTxtSylPra:
Gbl.CurrentCrs.Syllabus.WhichSyllabus = Syl_PRACTICALS; Gbl.Syllabus.WhichSyllabus = Syl_PRACTICALS;
Gbl.CurrentCrs.Info.Type = Inf_PRACTICALS; Gbl.CurrentCrs.Info.Type = Inf_PRACTICALS;
break; break;
default: default:
Lay_ShowErrorAndExit ("Wrong action."); Lay_ShowErrorAndExit ("Wrong action.");
break; break;
} }
/***** Load syllabus from XML file to memory *****/
Syl_LoadToMemory ();
/***** We are editing a syllabus with the internal editor,
so change info source to internal editor in database *****/
Inf_SetInfoSrcIntoDB (LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR :
Inf_INFO_SRC_NONE);
} }
/*****************************************************************************/ /*****************************************************************************/
/*** Read from XML and load in memory a syllabus of lectures or practicals ***/ /*** Read from XML and load in memory a syllabus of lectures or practicals ***/
/*****************************************************************************/ /*****************************************************************************/
static void Syl_LoadToMemory (void) void Syl_LoadListItemsSyllabusIntoMemory (long CrsCod)
{ {
char PathFile[PATH_MAX+1]; char PathFile[PATH_MAX+1];
long PostBeginList; long PostBeginList;
@ -344,13 +358,13 @@ static void Syl_LoadToMemory (void)
unsigned NumItemsWithChildren = 0; unsigned NumItemsWithChildren = 0;
/* Path of the private directory for the XML file with the syllabus */ /* Path of the private directory for the XML file with the syllabus */
sprintf (Gbl.CurrentCrs.Syllabus.PathDir,"%s/%s", sprintf (Gbl.Syllabus.PathDir,"%s/%s/%ld/%s",
Gbl.CurrentCrs.PathPriv, Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,CrsCod,
Gbl.CurrentCrs.Info.Type == Inf_LECTURES ? Cfg_SYLLABUS_FOLDER_LECTURES : Gbl.Syllabus.WhichSyllabus == Syl_LECTURES ? Cfg_SYLLABUS_FOLDER_LECTURES :
Cfg_SYLLABUS_FOLDER_PRACTICALS); Cfg_SYLLABUS_FOLDER_PRACTICALS);
/***** Open the file with the syllabus *****/ /***** Open the file with the syllabus *****/
Syl_OpenSyllabusFile (Gbl.CurrentCrs.Syllabus.PathDir,PathFile); Syl_OpenSyllabusFile (Gbl.Syllabus.PathDir,PathFile);
/***** Go to the start of the list of items *****/ /***** Go to the start of the list of items *****/
if (!Str_FindStrInFile (Gbl.F.XML,"<lista>",Str_NO_SKIP_HTML_COMMENTS)) if (!Str_FindStrInFile (Gbl.F.XML,"<lista>",Str_NO_SKIP_HTML_COMMENTS))
@ -463,6 +477,7 @@ void Syl_FreeListItemsSyllabus (void)
{ {
free ((void *) LstItemsSyllabus.Lst); free ((void *) LstItemsSyllabus.Lst);
LstItemsSyllabus.Lst = NULL; LstItemsSyllabus.Lst = NULL;
LstItemsSyllabus.NumItems = 0;
} }
} }
@ -500,7 +515,7 @@ static void Syl_ShowSyllabus (void)
{ {
unsigned NumItem; unsigned NumItem;
int i; int i;
int NumButtons = Gbl.CurrentCrs.Syllabus.EditionIsActive ? 5 : int NumButtons = Gbl.Syllabus.EditionIsActive ? 5 :
0; 0;
bool ShowRowInsertNewItem = (Gbl.Action.Act == ActInsIteSylLec || Gbl.Action.Act == ActInsIteSylPra || bool ShowRowInsertNewItem = (Gbl.Action.Act == ActInsIteSylLec || Gbl.Action.Act == ActInsIteSylPra ||
Gbl.Action.Act == ActModIteSylLec || Gbl.Action.Act == ActModIteSylPra || Gbl.Action.Act == ActModIteSylLec || Gbl.Action.Act == ActModIteSylPra ||
@ -530,7 +545,7 @@ static void Syl_ShowSyllabus (void)
LstItemsSyllabus.Lst[NumItem].Level, LstItemsSyllabus.Lst[NumItem].Level,
LstItemsSyllabus.Lst[NumItem].CodItem, LstItemsSyllabus.Lst[NumItem].CodItem,
LstItemsSyllabus.Lst[NumItem].Text,false); LstItemsSyllabus.Lst[NumItem].Text,false);
if (ShowRowInsertNewItem && NumItem == Gbl.CurrentCrs.Syllabus.NumItem) if (ShowRowInsertNewItem && NumItem == Gbl.Syllabus.NumItem)
// Mostrar a new row where se puede insert a new item // Mostrar a new row where se puede insert a new item
Syl_ShowRowSyllabus (NumItem + 1, Syl_ShowRowSyllabus (NumItem + 1,
LstItemsSyllabus.Lst[NumItem].Level,NULL, LstItemsSyllabus.Lst[NumItem].Level,NULL,
@ -566,7 +581,7 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
/***** Start the row *****/ /***** Start the row *****/
fprintf (Gbl.F.Out,"<tr>"); fprintf (Gbl.F.Out,"<tr>");
if (Gbl.CurrentCrs.Syllabus.EditionIsActive) if (Gbl.Syllabus.EditionIsActive)
{ {
if (NewItem) if (NewItem)
fprintf (Gbl.F.Out,"<td colspan=\"5\" class=\"COLOR%u\">" fprintf (Gbl.F.Out,"<td colspan=\"5\" class=\"COLOR%u\">"
@ -706,7 +721,7 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
} }
} }
if (Gbl.CurrentCrs.Syllabus.EditionIsActive) if (Gbl.Syllabus.EditionIsActive)
Syl_PutFormItemSyllabus (NewItem,NumItem,Level,CodItem,Text); Syl_PutFormItemSyllabus (NewItem,NumItem,Level,CodItem,Text);
else else
{ {
@ -756,7 +771,7 @@ int Syl_WriteSyllabusIntoHTMLBuffer (char **HTMLBuffer)
*HTMLBuffer = NULL; *HTMLBuffer = NULL;
/***** Load syllabus from XML file to list of items in memory *****/ /***** Load syllabus from XML file to list of items in memory *****/
Syl_LoadToMemory (); Syl_LoadListItemsSyllabusIntoMemory (Gbl.CurrentCrs.Crs.CrsCod);
if (LstItemsSyllabus.NumItems) if (LstItemsSyllabus.NumItems)
{ {
@ -996,10 +1011,13 @@ void Syl_RemoveItemSyllabus (void)
FILE *NewFile; FILE *NewFile;
unsigned NumItem; unsigned NumItem;
/***** Load syllabus from XML file to memory *****/ /***** Set syllabus type depending on current action *****/
Syl_SetSyllabusTypeAndLoadToMemory (); Syl_SetSyllabusTypeFromAction ();
Gbl.CurrentCrs.Syllabus.EditionIsActive = true; /***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (Gbl.CurrentCrs.Crs.CrsCod);
Gbl.Syllabus.EditionIsActive = true;
/***** Get item number *****/ /***** Get item number *****/
Syl_GetParamItemNumber (); Syl_GetParamItemNumber ();
@ -1013,13 +1031,18 @@ void Syl_RemoveItemSyllabus (void)
for (NumItem = 0; for (NumItem = 0;
NumItem < LstItemsSyllabus.NumItems; NumItem < LstItemsSyllabus.NumItems;
NumItem++) NumItem++)
if (NumItem != Gbl.CurrentCrs.Syllabus.NumItem) if (NumItem != Gbl.Syllabus.NumItem)
Syl_WriteItemFileSyllabus (NewFile,LstItemsSyllabus.Lst[NumItem].Level,LstItemsSyllabus.Lst[NumItem].Text); Syl_WriteItemFileSyllabus (NewFile,LstItemsSyllabus.Lst[NumItem].Level,LstItemsSyllabus.Lst[NumItem].Text);
Syl_WriteEndFileSyllabus (NewFile); Syl_WriteEndFileSyllabus (NewFile);
/***** Close the files *****/ /***** Close the files *****/
Fil_CloseUpdateFile (PathFile,PathOldFile,PathNewFile,NewFile); Fil_CloseUpdateFile (PathFile,PathOldFile,PathNewFile,NewFile);
/***** We are editing a syllabus with the internal editor,
so change info source to internal editor in database *****/
Inf_SetInfoSrcIntoDB (LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR :
Inf_INFO_SRC_NONE);
/***** Show the updated syllabus to continue editing it *****/ /***** Show the updated syllabus to continue editing it *****/
Syl_FreeListItemsSyllabus (); Syl_FreeListItemsSyllabus ();
Syl_EditSyllabus (); Syl_EditSyllabus ();
@ -1056,10 +1079,13 @@ void Syl_ChangePlaceItemSyllabus (Syl_ChangePosItem_t UpOrDownPos)
unsigned NumItem; unsigned NumItem;
struct MoveSubtrees Subtree; struct MoveSubtrees Subtree;
/***** Load syllabus from XML file to memory *****/ /***** Set syllabus type depending on current action *****/
Syl_SetSyllabusTypeAndLoadToMemory (); Syl_SetSyllabusTypeFromAction ();
Gbl.CurrentCrs.Syllabus.EditionIsActive = true; /***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (Gbl.CurrentCrs.Crs.CrsCod);
Gbl.Syllabus.EditionIsActive = true;
/***** Get item number *****/ /***** Get item number *****/
Syl_GetParamItemNumber (); Syl_GetParamItemNumber ();
@ -1068,7 +1094,7 @@ void Syl_ChangePlaceItemSyllabus (Syl_ChangePosItem_t UpOrDownPos)
Subtree.ToGetDown.Ini = Subtree.ToGetDown.End = 0; Subtree.ToGetDown.Ini = Subtree.ToGetDown.End = 0;
Subtree.MovAllowed = false; Subtree.MovAllowed = false;
if (Gbl.CurrentCrs.Syllabus.NumItem < LstItemsSyllabus.NumItems) if (Gbl.Syllabus.NumItem < LstItemsSyllabus.NumItems)
{ {
/***** Create a new file where make the update *****/ /***** Create a new file where make the update *****/
Syl_BuildPathFileSyllabus (PathFile); Syl_BuildPathFileSyllabus (PathFile);
@ -1078,10 +1104,10 @@ void Syl_ChangePlaceItemSyllabus (Syl_ChangePosItem_t UpOrDownPos)
switch (UpOrDownPos) switch (UpOrDownPos)
{ {
case Syl_GET_UP: case Syl_GET_UP:
Syl_CalculateUpSubtreeSyllabus (&Subtree,Gbl.CurrentCrs.Syllabus.NumItem); Syl_CalculateUpSubtreeSyllabus (&Subtree,Gbl.Syllabus.NumItem);
break; break;
case Syl_GET_DOWN: case Syl_GET_DOWN:
Syl_CalculateDownSubtreeSyllabus (&Subtree,Gbl.CurrentCrs.Syllabus.NumItem); Syl_CalculateDownSubtreeSyllabus (&Subtree,Gbl.Syllabus.NumItem);
break; break;
} }
@ -1114,6 +1140,11 @@ void Syl_ChangePlaceItemSyllabus (Syl_ChangePosItem_t UpOrDownPos)
Fil_CloseUpdateFile (PathFile,PathOldFile,PathNewFile,NewFile); Fil_CloseUpdateFile (PathFile,PathOldFile,PathNewFile,NewFile);
} }
/***** We are editing a syllabus with the internal editor,
so change info source to internal editor in database *****/
Inf_SetInfoSrcIntoDB (LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR :
Inf_INFO_SRC_NONE);
/***** Show the updated syllabus to continue editing it *****/ /***** Show the updated syllabus to continue editing it *****/
Syl_FreeListItemsSyllabus (); Syl_FreeListItemsSyllabus ();
Syl_EditSyllabus (); Syl_EditSyllabus ();
@ -1238,10 +1269,13 @@ void Syl_ChangeLevelItemSyllabus (Syl_ChangeLevelItem_t IncreaseOrDecreaseLevel)
char PathNewFile[PATH_MAX+1]; char PathNewFile[PATH_MAX+1];
FILE *NewFile; FILE *NewFile;
/***** Load syllabus from XML file to memory *****/ /***** Set syllabus type depending on current action *****/
Syl_SetSyllabusTypeAndLoadToMemory (); Syl_SetSyllabusTypeFromAction ();
Gbl.CurrentCrs.Syllabus.EditionIsActive = true; /***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (Gbl.CurrentCrs.Crs.CrsCod);
Gbl.Syllabus.EditionIsActive = true;
/***** Get item number *****/ /***** Get item number *****/
Syl_GetParamItemNumber (); Syl_GetParamItemNumber ();
@ -1254,12 +1288,12 @@ void Syl_ChangeLevelItemSyllabus (Syl_ChangeLevelItem_t IncreaseOrDecreaseLevel)
switch (IncreaseOrDecreaseLevel) switch (IncreaseOrDecreaseLevel)
{ {
case Syl_INCREASE_LEVEL: case Syl_INCREASE_LEVEL:
if (LstItemsSyllabus.Lst[Gbl.CurrentCrs.Syllabus.NumItem].Level > 1) if (LstItemsSyllabus.Lst[Gbl.Syllabus.NumItem].Level > 1)
LstItemsSyllabus.Lst[Gbl.CurrentCrs.Syllabus.NumItem].Level--; LstItemsSyllabus.Lst[Gbl.Syllabus.NumItem].Level--;
break; break;
case Syl_DECREASE_LEVEL: case Syl_DECREASE_LEVEL:
if (LstItemsSyllabus.Lst[Gbl.CurrentCrs.Syllabus.NumItem].Level < Syl_MAX_LEVELS_SYLLABUS) if (LstItemsSyllabus.Lst[Gbl.Syllabus.NumItem].Level < Syl_MAX_LEVELS_SYLLABUS)
LstItemsSyllabus.Lst[Gbl.CurrentCrs.Syllabus.NumItem].Level++; LstItemsSyllabus.Lst[Gbl.Syllabus.NumItem].Level++;
break; break;
} }
@ -1271,6 +1305,11 @@ void Syl_ChangeLevelItemSyllabus (Syl_ChangeLevelItem_t IncreaseOrDecreaseLevel)
/***** Close the files *****/ /***** Close the files *****/
Fil_CloseUpdateFile (PathFile,PathOldFile,PathNewFile,NewFile); Fil_CloseUpdateFile (PathFile,PathOldFile,PathNewFile,NewFile);
/***** We are editing a syllabus with the internal editor,
so change info source to internal editor in database *****/
Inf_SetInfoSrcIntoDB (LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR :
Inf_INFO_SRC_NONE);
/***** Show the updated syllabus to continue editing it *****/ /***** Show the updated syllabus to continue editing it *****/
Syl_FreeListItemsSyllabus (); Syl_FreeListItemsSyllabus ();
Syl_EditSyllabus (); Syl_EditSyllabus ();
@ -1289,10 +1328,13 @@ void Syl_InsertItemSyllabus (void)
unsigned NumItem; unsigned NumItem;
char Txt[Syl_MAX_BYTES_TEXT_ITEM+1]; char Txt[Syl_MAX_BYTES_TEXT_ITEM+1];
/***** Load syllabus from XML file to memory *****/ /***** Set syllabus type depending on current action *****/
Syl_SetSyllabusTypeAndLoadToMemory (); Syl_SetSyllabusTypeFromAction ();
Gbl.CurrentCrs.Syllabus.EditionIsActive = true; /***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (Gbl.CurrentCrs.Crs.CrsCod);
Gbl.Syllabus.EditionIsActive = true;
/***** Get item number *****/ /***** Get item number *****/
Syl_GetParamItemNumber (); Syl_GetParamItemNumber ();
@ -1309,7 +1351,7 @@ void Syl_InsertItemSyllabus (void)
/* Write items before the one to be inserted */ /* Write items before the one to be inserted */
for (NumItem = 0; for (NumItem = 0;
NumItem < Gbl.CurrentCrs.Syllabus.NumItem; NumItem < Gbl.Syllabus.NumItem;
NumItem++) NumItem++)
Syl_WriteItemFileSyllabus (NewFile,LstItemsSyllabus.Lst[NumItem].Level,LstItemsSyllabus.Lst[NumItem].Text); Syl_WriteItemFileSyllabus (NewFile,LstItemsSyllabus.Lst[NumItem].Level,LstItemsSyllabus.Lst[NumItem].Text);
@ -1330,6 +1372,11 @@ void Syl_InsertItemSyllabus (void)
/***** Close the files *****/ /***** Close the files *****/
Fil_CloseUpdateFile (PathFile,PathOldFile,PathNewFile,NewFile); Fil_CloseUpdateFile (PathFile,PathOldFile,PathNewFile,NewFile);
/***** We are editing a syllabus with the internal editor,
so change info source to internal editor in database *****/
Inf_SetInfoSrcIntoDB (LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR :
Inf_INFO_SRC_NONE);
/***** Show the updated syllabus to continue editing it *****/ /***** Show the updated syllabus to continue editing it *****/
Syl_FreeListItemsSyllabus (); Syl_FreeListItemsSyllabus ();
Syl_EditSyllabus (); Syl_EditSyllabus ();
@ -1346,16 +1393,19 @@ void Syl_ModifyItemSyllabus (void)
char PathNewFile[PATH_MAX+1]; char PathNewFile[PATH_MAX+1];
FILE *NewFile; FILE *NewFile;
/***** Load syllabus from XML file to memory *****/ /***** Set syllabus type depending on current action *****/
Syl_SetSyllabusTypeAndLoadToMemory (); Syl_SetSyllabusTypeFromAction ();
Gbl.CurrentCrs.Syllabus.EditionIsActive = true; /***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (Gbl.CurrentCrs.Crs.CrsCod);
Gbl.Syllabus.EditionIsActive = true;
/***** Get item number *****/ /***** Get item number *****/
Syl_GetParamItemNumber (); Syl_GetParamItemNumber ();
/***** Get item body *****/ /***** Get item body *****/
Par_GetParToHTML ("Txt",LstItemsSyllabus.Lst[Gbl.CurrentCrs.Syllabus.NumItem].Text,Syl_MAX_BYTES_TEXT_ITEM); Par_GetParToHTML ("Txt",LstItemsSyllabus.Lst[Gbl.Syllabus.NumItem].Text,Syl_MAX_BYTES_TEXT_ITEM);
/***** Create a new file where make the update *****/ /***** Create a new file where make the update *****/
Syl_BuildPathFileSyllabus (PathFile); Syl_BuildPathFileSyllabus (PathFile);
@ -1369,6 +1419,11 @@ void Syl_ModifyItemSyllabus (void)
/***** Close the files *****/ /***** Close the files *****/
Fil_CloseUpdateFile (PathFile,PathOldFile,PathNewFile,NewFile); Fil_CloseUpdateFile (PathFile,PathOldFile,PathNewFile,NewFile);
/***** We are editing a syllabus with the internal editor,
so change info source to internal editor in database *****/
Inf_SetInfoSrcIntoDB (LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR :
Inf_INFO_SRC_NONE);
/***** Show the updated syllabus to continue editing it *****/ /***** Show the updated syllabus to continue editing it *****/
Syl_FreeListItemsSyllabus (); Syl_FreeListItemsSyllabus ();
Syl_EditSyllabus (); Syl_EditSyllabus ();
@ -1380,7 +1435,7 @@ void Syl_ModifyItemSyllabus (void)
void Syl_BuildPathFileSyllabus (char *PathFile) void Syl_BuildPathFileSyllabus (char *PathFile)
{ {
sprintf (PathFile,"%s/%s",Gbl.CurrentCrs.Syllabus.PathDir,Cfg_SYLLABUS_FILENAME); sprintf (PathFile,"%s/%s",Gbl.Syllabus.PathDir,Cfg_SYLLABUS_FILENAME);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -70,11 +70,13 @@ void Syl_PutFormWhichSyllabus (void);
void Syl_GetParamItemNumber (void); void Syl_GetParamItemNumber (void);
bool Syl_CheckSyllabus (void); bool Syl_CheckSyllabus (long CrsCod,Inf_InfoType_t InfoType);
bool Syl_CheckAndEditSyllabus (void); bool Syl_CheckAndEditSyllabus (void);
void Syl_EditSyllabus (void); void Syl_EditSyllabus (void);
void Syl_LoadListItemsSyllabusIntoMemory (long CrsCod);
void Syl_FreeListItemsSyllabus (void); void Syl_FreeListItemsSyllabus (void);
int Syl_ReadLevelItemSyllabus (void); int Syl_ReadLevelItemSyllabus (void);
int Syl_WriteSyllabusIntoHTMLBuffer (char **HTMLBuffer); int Syl_WriteSyllabusIntoHTMLBuffer (char **HTMLBuffer);
void Syl_PutParamNumItem (unsigned NumItem); void Syl_PutParamNumItem (unsigned NumItem);