Version19.175

This commit is contained in:
acanas 2020-04-12 02:47:32 +02:00
parent d3082ecdc8
commit 9443a90eac
10 changed files with 330 additions and 206 deletions

View File

@ -231,6 +231,7 @@ static int API_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
char *NewEncryptedPassword); // Output char *NewEncryptedPassword); // Output
static int API_WriteSyllabusIntoHTMLBuffer (struct soap *soap, static int API_WriteSyllabusIntoHTMLBuffer (struct soap *soap,
struct Syl_Syllabus *Syllabus,
char **HTMLBuffer); char **HTMLBuffer);
static int API_WritePlainTextIntoHTMLBuffer (struct soap *soap, static int API_WritePlainTextIntoHTMLBuffer (struct soap *soap,
char **HTMLBuffer); char **HTMLBuffer);
@ -1369,6 +1370,7 @@ int swad__getCourseInfo (struct soap *soap,
struct swad__getCourseInfoOutput *getCourseInfo) // output struct swad__getCourseInfoOutput *getCourseInfo) // output
{ {
int ReturnCode; int ReturnCode;
struct Syl_Syllabus Syllabus;
Inf_InfoType_t InfoType; Inf_InfoType_t InfoType;
size_t Length; size_t Length;
Inf_InfoSrc_t InfoSrc; Inf_InfoSrc_t InfoSrc;
@ -1430,6 +1432,9 @@ int swad__getCourseInfo (struct soap *soap,
"Request forbidden", "Request forbidden",
"Requester must belong to course"); "Requester must belong to course");
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Get info source *****/ /***** Get info source *****/
for (InfoType = (Inf_InfoType_t) 0; for (InfoType = (Inf_InfoType_t) 0;
InfoType <= (Inf_InfoType_t) (Inf_NUM_INFO_TYPES - 1); InfoType <= (Inf_InfoType_t) (Inf_NUM_INFO_TYPES - 1);
@ -1441,7 +1446,10 @@ int swad__getCourseInfo (struct soap *soap,
"Bad info type", "Bad info type",
"Unknown requested info type"); "Unknown requested info type");
Gbl.Crs.Info.Type = InfoType; Gbl.Crs.Info.Type = InfoType;
Inf_GetAndCheckInfoSrcFromDB (Gbl.Hierarchy.Crs.CrsCod,Gbl.Crs.Info.Type,&InfoSrc,&MustBeRead); Inf_GetAndCheckInfoSrcFromDB (&Syllabus,
Gbl.Hierarchy.Crs.CrsCod,
Gbl.Crs.Info.Type,
&InfoSrc,&MustBeRead);
Length = strlen (NamesInWSForInfoSrc[InfoSrc]); Length = strlen (NamesInWSForInfoSrc[InfoSrc]);
getCourseInfo->infoSrc = (char *) soap_malloc (soap,Length + 1); getCourseInfo->infoSrc = (char *) soap_malloc (soap,Length + 1);
Str_Copy (getCourseInfo->infoSrc,NamesInWSForInfoSrc[InfoSrc], Str_Copy (getCourseInfo->infoSrc,NamesInWSForInfoSrc[InfoSrc],
@ -1461,7 +1469,7 @@ int swad__getCourseInfo (struct soap *soap,
{ {
case Inf_LECTURES: // Syllabus (lectures) case Inf_LECTURES: // Syllabus (lectures)
case Inf_PRACTICALS: // Syllabys (practicals) case Inf_PRACTICALS: // Syllabys (practicals)
Result = API_WriteSyllabusIntoHTMLBuffer (soap,&(getCourseInfo->infoTxt)); Result = API_WriteSyllabusIntoHTMLBuffer (soap,&Syllabus,&(getCourseInfo->infoTxt));
break; break;
default: default:
break; break;
@ -1495,6 +1503,7 @@ int swad__getCourseInfo (struct soap *soap,
/*****************************************************************************/ /*****************************************************************************/
static int API_WriteSyllabusIntoHTMLBuffer (struct soap *soap, static int API_WriteSyllabusIntoHTMLBuffer (struct soap *soap,
struct Syl_Syllabus *Syllabus,
char **HTMLBuffer) char **HTMLBuffer)
{ {
extern struct LstItemsSyllabus Syl_LstItemsSyllabus; extern struct LstItemsSyllabus Syl_LstItemsSyllabus;
@ -1506,7 +1515,7 @@ static int API_WriteSyllabusIntoHTMLBuffer (struct soap *soap,
*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_LoadListItemsSyllabusIntoMemory (Gbl.Hierarchy.Crs.CrsCod); Syl_LoadListItemsSyllabusIntoMemory (Syllabus,Gbl.Hierarchy.Crs.CrsCod);
if (Syl_LstItemsSyllabus.NumItems) if (Syl_LstItemsSyllabus.NumItems)
{ {

View File

@ -497,7 +497,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD: En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 19.174 (2020-04-11)" #define Log_PLATFORM_VERSION "SWAD 19.175 (2020-04-12)"
#define CSS_FILE "swad19.146.css" #define CSS_FILE "swad19.146.css"
#define JS_FILE "swad19.172.1.js" #define JS_FILE "swad19.172.1.js"
/* /*
@ -548,6 +548,7 @@ Funci
// TODO: Oresti Baños: cambiar ojos por candados en descriptores para prohibir/permitir y dejar los ojos para poder elegir descriptores // TODO: Oresti Baños: cambiar ojos por candados en descriptores para prohibir/permitir y dejar los ojos para poder elegir descriptores
// TODO: Integrar pull requests con traducciones del alemán del usuario eruedin en GitHub // TODO: Integrar pull requests con traducciones del alemán del usuario eruedin en GitHub
Version 19.175: Apr 12, 2020 Code refactoring in syllabus. (285345 lines)
Version 19.174: Apr 11, 2020 Code refactoring in messages. (285250 lines) Version 19.174: Apr 11, 2020 Code refactoring in messages. (285250 lines)
Version 19.173: Apr 11, 2020 Code refactoring in timetables. (285165 lines) Version 19.173: Apr 11, 2020 Code refactoring in timetables. (285165 lines)
Version 19.172.1: Apr 11, 2020 Fix bug in MathJax. (285144 lines) Version 19.172.1: Apr 11, 2020 Fix bug in MathJax. (285144 lines)

View File

@ -259,7 +259,9 @@ void Gbl_InitializeGlobals (void)
Gbl.DegTypes.Lst = NULL; Gbl.DegTypes.Lst = NULL;
Gbl.Crs.Info.ShowMsgMustBeRead = 0; Gbl.Crs.Info.ShowMsgMustBeRead = 0;
Gbl.Crs.Notices.HighlightNotCod = -1L; // No notice highlighted Gbl.Crs.Notices.HighlightNotCod = -1L; // No notice highlighted
Gbl.Crs.Grps.NumGrps = 0; Gbl.Crs.Grps.NumGrps = 0;
Gbl.Crs.Grps.WhichGrps = Grp_WHICH_GROUPS_DEFAULT; Gbl.Crs.Grps.WhichGrps = Grp_WHICH_GROUPS_DEFAULT;
Gbl.Crs.Grps.GrpTypes.LstGrpTypes = NULL; Gbl.Crs.Grps.GrpTypes.LstGrpTypes = NULL;
@ -278,6 +280,7 @@ void Gbl_InitializeGlobals (void)
Gbl.Crs.Grps.LstGrpsSel.GrpCods = NULL; Gbl.Crs.Grps.LstGrpsSel.GrpCods = NULL;
Gbl.Crs.Grps.LstGrpsSel.NumGrps = 0; Gbl.Crs.Grps.LstGrpsSel.NumGrps = 0;
Gbl.Crs.Grps.LstGrpsSel.NestedCalls = 0; Gbl.Crs.Grps.LstGrpsSel.NestedCalls = 0;
Gbl.Crs.Records.Field.Name[0] = '\0'; Gbl.Crs.Records.Field.Name[0] = '\0';
Gbl.Crs.Records.Field.NumLines = Rec_MIN_LINES_IN_EDITION_FIELD; Gbl.Crs.Records.Field.NumLines = Rec_MIN_LINES_IN_EDITION_FIELD;
Gbl.Crs.Records.Field.Visibility = Rec_HIDDEN_FIELD; Gbl.Crs.Records.Field.Visibility = Rec_HIDDEN_FIELD;
@ -285,9 +288,6 @@ void Gbl_InitializeGlobals (void)
Gbl.Crs.Records.LstFields.Num = 0; Gbl.Crs.Records.LstFields.Num = 0;
Gbl.Crs.Records.LstFields.NestedCalls = 0; Gbl.Crs.Records.LstFields.NestedCalls = 0;
Gbl.Syllabus.EditionIsActive = false;
Gbl.Syllabus.WhichSyllabus = Syl_DEFAULT_WHICH_SYLLABUS;
Gbl.Search.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT; Gbl.Search.WhatToSearch = Sch_WHAT_TO_SEARCH_DEFAULT;
Gbl.Search.Str[0] = '\0'; Gbl.Search.Str[0] = '\0';
Gbl.Search.LogSearch = false; Gbl.Search.LogSearch = false;

View File

@ -418,13 +418,7 @@ struct Globals
char PathRelPubl[PATH_MAX + 1]; // Relative path to the public directory of the course char PathRelPubl[PATH_MAX + 1]; // Relative path to the public directory of the course
char PathURLPubl[PATH_MAX + 1]; // Abolute URL to the public part of the course char PathURLPubl[PATH_MAX + 1]; // Abolute URL to the public part of the course
struct Grp_Groups Grps; struct Grp_Groups Grps;
struct struct Inf_Info Info;
{
Inf_InfoType_t Type;
char URL[Cns_MAX_BYTES_WWW + 1];
bool MustBeRead[Inf_NUM_INFO_TYPES]; // Students must read info?
bool ShowMsgMustBeRead;
} Info;
struct struct
{ {
struct RecordField Field; struct RecordField Field;
@ -435,14 +429,6 @@ struct Globals
long HighlightNotCod; // Notice code of a notice to be highlighted long HighlightNotCod; // Notice code of a notice to be highlighted
} Notices; } Notices;
} Crs; } Crs;
struct
{
char PathDir[PATH_MAX + 1];
unsigned NumItem; // Item being edited
unsigned ParamNumItem; // Used as parameter in forms
bool EditionIsActive;
Syl_WhichSyllabus_t WhichSyllabus;
} Syllabus;
struct struct
{ {
struct Exa_ExamCodeAndDate *Lst; // List of exam announcements struct Exa_ExamCodeAndDate *Lst; // List of exam announcements

View File

@ -288,8 +288,10 @@ static void Inf_BuildPathURL (long CrsCod,Inf_InfoType_t InfoType,
static void Inf_ShowPage (const char *URL); static void Inf_ShowPage (const char *URL);
static bool Inf_CheckIfInfoAvailable (Inf_InfoSrc_t InfoSrc); static bool Inf_CheckIfInfoAvailable (struct Syl_Syllabus *Syllabus,
static Inf_InfoType_t Inf_AsignInfoType (void); Inf_InfoSrc_t InfoSrc);
static void Inf_AsignInfoType (struct Inf_Info *Info,
struct Syl_Syllabus *Syllabus);
static void Inf_SetInfoTxtIntoDB (const char *InfoTxtHTML,const char *InfoTxtMD); static void Inf_SetInfoTxtIntoDB (const char *InfoTxtHTML,const char *InfoTxtMD);
static bool Inf_CheckPlainTxt (long CrsCod,Inf_InfoType_t InfoType); static bool Inf_CheckPlainTxt (long CrsCod,Inf_InfoType_t InfoType);
@ -306,6 +308,7 @@ void Inf_ShowInfo (void)
{ {
extern const char *Txt_INFO_TITLE[Inf_NUM_INFO_TYPES]; extern const char *Txt_INFO_TITLE[Inf_NUM_INFO_TYPES];
extern const char *Txt_No_information; extern const char *Txt_No_information;
struct Syl_Syllabus Syllabus;
Inf_InfoSrc_t InfoSrc; Inf_InfoSrc_t InfoSrc;
bool MustBeRead; bool MustBeRead;
bool Disabled; bool Disabled;
@ -324,11 +327,15 @@ void Inf_ShowInfo (void)
[Inf_ASSESSMENT ] = Hlp_ASSESSMENT_System, [Inf_ASSESSMENT ] = Hlp_ASSESSMENT_System,
}; };
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set info type *****/ /***** Set info type *****/
Gbl.Crs.Info.Type = Inf_AsignInfoType (); Inf_AsignInfoType (&Gbl.Crs.Info,&Syllabus);
/***** Get info source from database *****/ /***** Get info source from database *****/
Inf_GetAndCheckInfoSrcFromDB (Gbl.Hierarchy.Crs.CrsCod, Inf_GetAndCheckInfoSrcFromDB (&Syllabus,
Gbl.Hierarchy.Crs.CrsCod,
Gbl.Crs.Info.Type, Gbl.Crs.Info.Type,
&InfoSrc,&MustBeRead); &InfoSrc,&MustBeRead);
@ -336,7 +343,7 @@ void Inf_ShowInfo (void)
{ {
case Inf_LECTURES: case Inf_LECTURES:
case Inf_PRACTICALS: case Inf_PRACTICALS:
Syl_PutFormWhichSyllabus (); Syl_PutFormWhichSyllabus (Syllabus.WhichSyllabus);
break; break;
default: default:
break; break;
@ -382,7 +389,7 @@ void Inf_ShowInfo (void)
{ {
case Inf_LECTURES: case Inf_LECTURES:
case Inf_PRACTICALS: case Inf_PRACTICALS:
ShowWarningNoInfo = !Syl_CheckAndEditSyllabus (); ShowWarningNoInfo = !Syl_CheckAndEditSyllabus (&Syllabus);
break; break;
case Inf_INTRODUCTION: case Inf_INTRODUCTION:
case Inf_TEACHING_GUIDE: case Inf_TEACHING_GUIDE:
@ -606,10 +613,14 @@ void Inf_ChangeForceReadInfo (void)
{ {
extern const char *Txt_Students_now_are_required_to_read_this_information; extern const char *Txt_Students_now_are_required_to_read_this_information;
extern const char *Txt_Students_are_no_longer_obliged_to_read_this_information; extern const char *Txt_Students_are_no_longer_obliged_to_read_this_information;
struct Syl_Syllabus Syllabus;
bool MustBeRead = Inf_GetMustBeReadFromForm (); bool MustBeRead = Inf_GetMustBeReadFromForm ();
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set info type *****/ /***** Set info type *****/
Gbl.Crs.Info.Type = Inf_AsignInfoType (); Inf_AsignInfoType (&Gbl.Crs.Info,&Syllabus);
/***** Set status (if info must be read or not) into database *****/ /***** Set status (if info must be read or not) into database *****/
Inf_SetForceReadIntoDB (MustBeRead); Inf_SetForceReadIntoDB (MustBeRead);
@ -631,10 +642,14 @@ void Inf_ChangeIHaveReadInfo (void)
{ {
extern const char *Txt_You_have_confirmed_that_you_have_read_this_information; extern const char *Txt_You_have_confirmed_that_you_have_read_this_information;
extern const char *Txt_You_have_eliminated_the_confirmation_that_you_have_read_this_information; extern const char *Txt_You_have_eliminated_the_confirmation_that_you_have_read_this_information;
struct Syl_Syllabus Syllabus;
bool IHaveRead = Inf_GetIfIHaveReadFromForm (); bool IHaveRead = Inf_GetIfIHaveReadFromForm ();
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set info type *****/ /***** Set info type *****/
Gbl.Crs.Info.Type = Inf_AsignInfoType (); Inf_AsignInfoType (&Gbl.Crs.Info,&Syllabus);
/***** Set status (if I have read or not a information) into database *****/ /***** Set status (if I have read or not a information) into database *****/
Inf_SetIHaveReadIntoDB (IHaveRead); Inf_SetIHaveReadIntoDB (IHaveRead);
@ -966,10 +981,14 @@ static void Inf_ShowPage (const char *URL)
void Inf_SetInfoSrc (void) void Inf_SetInfoSrc (void)
{ {
struct Syl_Syllabus Syllabus;
Inf_InfoSrc_t InfoSrcSelected = Inf_GetInfoSrcFromForm (); Inf_InfoSrc_t InfoSrcSelected = Inf_GetInfoSrcFromForm ();
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set info type *****/ /***** Set info type *****/
Gbl.Crs.Info.Type = Inf_AsignInfoType (); Inf_AsignInfoType (&Gbl.Crs.Info,&Syllabus);
/***** Set info source into database *****/ /***** Set info source into database *****/
Inf_SetInfoSrcIntoDB (InfoSrcSelected); Inf_SetInfoSrcIntoDB (InfoSrcSelected);
@ -988,6 +1007,7 @@ void Inf_FormsToSelSendInfo (void)
extern const char *Txt_Source_of_information; extern const char *Txt_Source_of_information;
extern const char *Txt_INFO_SRC_FULL_TEXT[Inf_NUM_INFO_SOURCES]; extern const char *Txt_INFO_SRC_FULL_TEXT[Inf_NUM_INFO_SOURCES];
extern const char *Txt_INFO_SRC_HELP[Inf_NUM_INFO_SOURCES]; extern const char *Txt_INFO_SRC_HELP[Inf_NUM_INFO_SOURCES];
struct Syl_Syllabus Syllabus;
Inf_InfoSrc_t InfoSrc; Inf_InfoSrc_t InfoSrc;
Inf_InfoSrc_t InfoSrcSelected; Inf_InfoSrc_t InfoSrcSelected;
bool InfoAvailable[Inf_NUM_INFO_SOURCES]; bool InfoAvailable[Inf_NUM_INFO_SOURCES];
@ -1004,11 +1024,15 @@ void Inf_FormsToSelSendInfo (void)
[Inf_ASSESSMENT ] = Hlp_ASSESSMENT_System_edit, [Inf_ASSESSMENT ] = Hlp_ASSESSMENT_System_edit,
}; };
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set info type *****/ /***** Set info type *****/
Gbl.Crs.Info.Type = Inf_AsignInfoType (); Inf_AsignInfoType (&Gbl.Crs.Info,&Syllabus);
/***** Get current info source from database *****/ /***** Get current info source from database *****/
Inf_GetAndCheckInfoSrcFromDB (Gbl.Hierarchy.Crs.CrsCod, Inf_GetAndCheckInfoSrcFromDB (&Syllabus,
Gbl.Hierarchy.Crs.CrsCod,
Gbl.Crs.Info.Type, Gbl.Crs.Info.Type,
&InfoSrcSelected,&MustBeRead); &InfoSrcSelected,&MustBeRead);
@ -1016,7 +1040,7 @@ void Inf_FormsToSelSendInfo (void)
for (InfoSrc = (Inf_InfoSrc_t) 0; for (InfoSrc = (Inf_InfoSrc_t) 0;
InfoSrc <= (Inf_InfoSrc_t) (Inf_NUM_INFO_SOURCES - 1); InfoSrc <= (Inf_InfoSrc_t) (Inf_NUM_INFO_SOURCES - 1);
InfoSrc++) InfoSrc++)
InfoAvailable[InfoSrc] = Inf_CheckIfInfoAvailable (InfoSrc); InfoAvailable[InfoSrc] = Inf_CheckIfInfoAvailable (&Syllabus,InfoSrc);
/***** Set info source to none /***** Set info source to none
when no info available for the current source *****/ when no info available for the current source *****/
@ -1090,7 +1114,8 @@ void Inf_FormsToSelSendInfo (void)
/* Check if there is info available for current info type and a given source */ /* Check if there is info available for current info type and a given source */
/*****************************************************************************/ /*****************************************************************************/
static bool Inf_CheckIfInfoAvailable (Inf_InfoSrc_t InfoSrc) static bool Inf_CheckIfInfoAvailable (struct Syl_Syllabus *Syllabus,
Inf_InfoSrc_t InfoSrc)
{ {
switch (InfoSrc) switch (InfoSrc)
{ {
@ -1100,8 +1125,11 @@ static bool Inf_CheckIfInfoAvailable (Inf_InfoSrc_t InfoSrc)
switch (Gbl.Crs.Info.Type) switch (Gbl.Crs.Info.Type)
{ {
case Inf_LECTURES: case Inf_LECTURES:
Syllabus->WhichSyllabus = Syl_LECTURES;
return Syl_CheckSyllabus (Syllabus,Gbl.Hierarchy.Crs.CrsCod);
case Inf_PRACTICALS: case Inf_PRACTICALS:
return Syl_CheckSyllabus (Gbl.Hierarchy.Crs.CrsCod,Gbl.Crs.Info.Type); Syllabus->WhichSyllabus = Syl_PRACTICALS;
return Syl_CheckSyllabus (Syllabus,Gbl.Hierarchy.Crs.CrsCod);
default: default:
return false; return false;
} }
@ -1238,7 +1266,8 @@ void Inf_FormToSendURL (Inf_InfoSrc_t InfoSrc)
/******** Returns bibliography, assessment, etc. from Gbl.Action.Act *********/ /******** Returns bibliography, assessment, etc. from Gbl.Action.Act *********/
/*****************************************************************************/ /*****************************************************************************/
static Inf_InfoType_t Inf_AsignInfoType (void) static void Inf_AsignInfoType (struct Inf_Info *Info,
struct Syl_Syllabus *Syllabus)
{ {
switch (Gbl.Action.Act) switch (Gbl.Action.Act)
{ {
@ -1254,7 +1283,8 @@ static Inf_InfoType_t Inf_AsignInfoType (void)
case ActRchTxtEdiCrsInf: case ActRchTxtEdiCrsInf:
case ActRcvPlaTxtCrsInf: case ActRcvPlaTxtCrsInf:
case ActRcvRchTxtCrsInf: case ActRcvRchTxtCrsInf:
return Inf_INTRODUCTION; Info->Type = Inf_INTRODUCTION;
break;
case ActSeeTchGui: case ActSeeTchGui:
case ActEdiTchGui: case ActEdiTchGui:
case ActChgFrcReaTchGui: case ActChgFrcReaTchGui:
@ -1267,11 +1297,13 @@ static Inf_InfoType_t Inf_AsignInfoType (void)
case ActRchTxtEdiTchGui: case ActRchTxtEdiTchGui:
case ActRcvPlaTxtTchGui: case ActRcvPlaTxtTchGui:
case ActRcvRchTxtTchGui: case ActRcvRchTxtTchGui:
return Inf_TEACHING_GUIDE; Info->Type = Inf_TEACHING_GUIDE;
break;
case ActSeeSyl: case ActSeeSyl:
Syl_GetParamWhichSyllabus (); Syllabus->WhichSyllabus = Syl_GetParamWhichSyllabus ();
return (Gbl.Syllabus.WhichSyllabus == Syl_LECTURES ? Inf_LECTURES : Info->Type = (Syllabus->WhichSyllabus == Syl_LECTURES ? Inf_LECTURES :
Inf_PRACTICALS); Inf_PRACTICALS);
break;
case ActSeeSylLec: case ActSeeSylLec:
case ActEdiSylLec: case ActEdiSylLec:
case ActChgFrcReaSylLec: case ActChgFrcReaSylLec:
@ -1284,8 +1316,9 @@ static Inf_InfoType_t Inf_AsignInfoType (void)
case ActRchTxtEdiSylLec: case ActRchTxtEdiSylLec:
case ActRcvPlaTxtSylLec: case ActRcvPlaTxtSylLec:
case ActRcvRchTxtSylLec: case ActRcvRchTxtSylLec:
Gbl.Syllabus.WhichSyllabus = Syl_LECTURES; Syllabus->WhichSyllabus = Syl_LECTURES;
return Inf_LECTURES; Info->Type = Inf_LECTURES;
break;
case ActSeeSylPra: case ActSeeSylPra:
case ActEdiSylPra: case ActEdiSylPra:
case ActChgFrcReaSylPra: case ActChgFrcReaSylPra:
@ -1298,8 +1331,9 @@ static Inf_InfoType_t Inf_AsignInfoType (void)
case ActRchTxtEdiSylPra: case ActRchTxtEdiSylPra:
case ActRcvPlaTxtSylPra: case ActRcvPlaTxtSylPra:
case ActRcvRchTxtSylPra: case ActRcvRchTxtSylPra:
Gbl.Syllabus.WhichSyllabus = Syl_PRACTICALS; Syllabus->WhichSyllabus = Syl_PRACTICALS;
return Inf_PRACTICALS; Info->Type = Inf_PRACTICALS;
break;
case ActSeeBib: case ActSeeBib:
case ActEdiBib: case ActEdiBib:
case ActChgFrcReaBib: case ActChgFrcReaBib:
@ -1312,7 +1346,8 @@ static Inf_InfoType_t Inf_AsignInfoType (void)
case ActRchTxtEdiBib: case ActRchTxtEdiBib:
case ActRcvPlaTxtBib: case ActRcvPlaTxtBib:
case ActRcvRchTxtBib: case ActRcvRchTxtBib:
return Inf_BIBLIOGRAPHY; Info->Type = Inf_BIBLIOGRAPHY;
break;
case ActSeeFAQ: case ActSeeFAQ:
case ActEdiFAQ: case ActEdiFAQ:
case ActChgFrcReaFAQ: case ActChgFrcReaFAQ:
@ -1325,7 +1360,8 @@ static Inf_InfoType_t Inf_AsignInfoType (void)
case ActRchTxtEdiFAQ: case ActRchTxtEdiFAQ:
case ActRcvPlaTxtFAQ: case ActRcvPlaTxtFAQ:
case ActRcvRchTxtFAQ: case ActRcvRchTxtFAQ:
return Inf_FAQ; Info->Type = Inf_FAQ;
break;
case ActSeeCrsLnk: case ActSeeCrsLnk:
case ActEdiCrsLnk: case ActEdiCrsLnk:
case ActChgFrcReaCrsLnk: case ActChgFrcReaCrsLnk:
@ -1338,7 +1374,8 @@ static Inf_InfoType_t Inf_AsignInfoType (void)
case ActRchTxtEdiCrsLnk: case ActRchTxtEdiCrsLnk:
case ActRcvPlaTxtCrsLnk: case ActRcvPlaTxtCrsLnk:
case ActRcvRchTxtCrsLnk: case ActRcvRchTxtCrsLnk:
return Inf_LINKS; Info->Type = Inf_LINKS;
break;
case ActSeeAss: case ActSeeAss:
case ActEdiAss: case ActEdiAss:
case ActChgFrcReaAss: case ActChgFrcReaAss:
@ -1351,9 +1388,9 @@ static Inf_InfoType_t Inf_AsignInfoType (void)
case ActRchTxtEdiAss: case ActRchTxtEdiAss:
case ActRcvPlaTxtAss: case ActRcvPlaTxtAss:
case ActRcvRchTxtAss: case ActRcvRchTxtAss:
return Inf_ASSESSMENT; Info->Type = Inf_ASSESSMENT;
break;
} }
return (Inf_InfoType_t) 0; // If action is not one of the former ones, the returned value is not important
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1447,7 +1484,8 @@ Inf_InfoSrc_t Inf_GetInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType)
/***** Get and check info source for a type of course info from database *****/ /***** Get and check info source for a type of course info from database *****/
/*****************************************************************************/ /*****************************************************************************/
void Inf_GetAndCheckInfoSrcFromDB (long CrsCod, void Inf_GetAndCheckInfoSrcFromDB (struct Syl_Syllabus *Syllabus,
long CrsCod,
Inf_InfoType_t InfoType, Inf_InfoType_t InfoType,
Inf_InfoSrc_t *InfoSrc,bool *MustBeRead) Inf_InfoSrc_t *InfoSrc,bool *MustBeRead)
{ {
@ -1494,8 +1532,16 @@ void Inf_GetAndCheckInfoSrcFromDB (long CrsCod,
switch (InfoType) switch (InfoType)
{ {
case Inf_LECTURES: case Inf_LECTURES:
Syllabus->WhichSyllabus = Syl_LECTURES;
if (!Syl_CheckSyllabus (Syllabus,CrsCod))
{
*InfoSrc = Inf_INFO_SRC_NONE;
*MustBeRead = false;
}
break;
case Inf_PRACTICALS: case Inf_PRACTICALS:
if (!Syl_CheckSyllabus (CrsCod,InfoType)) Syllabus->WhichSyllabus = Syl_PRACTICALS;
if (!Syl_CheckSyllabus (Syllabus,CrsCod))
{ {
*InfoSrc = Inf_INFO_SRC_NONE; *InfoSrc = Inf_INFO_SRC_NONE;
*MustBeRead = false; *MustBeRead = false;
@ -1883,6 +1929,7 @@ void Inf_EditPlainTxtInfo (void)
{ {
extern const char *Txt_INFO_TITLE[Inf_NUM_INFO_TYPES]; extern const char *Txt_INFO_TITLE[Inf_NUM_INFO_TYPES];
extern const char *Txt_Save_changes; extern const char *Txt_Save_changes;
struct Syl_Syllabus Syllabus;
char TxtHTML[Cns_MAX_BYTES_LONG_TEXT + 1]; char TxtHTML[Cns_MAX_BYTES_LONG_TEXT + 1];
const char *HelpEdit[Inf_NUM_INFO_TYPES] = const char *HelpEdit[Inf_NUM_INFO_TYPES] =
{ {
@ -1896,8 +1943,11 @@ void Inf_EditPlainTxtInfo (void)
[Inf_ASSESSMENT ] = Hlp_ASSESSMENT_System_edit, [Inf_ASSESSMENT ] = Hlp_ASSESSMENT_System_edit,
}; };
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set info type *****/ /***** Set info type *****/
Gbl.Crs.Info.Type = Inf_AsignInfoType (); Inf_AsignInfoType (&Gbl.Crs.Info,&Syllabus);
/***** Begin form and box *****/ /***** Begin form and box *****/
Frm_StartForm (Inf_ActionsRcvPlaTxtInfo[Gbl.Crs.Info.Type]); Frm_StartForm (Inf_ActionsRcvPlaTxtInfo[Gbl.Crs.Info.Type]);
@ -1934,6 +1984,7 @@ void Inf_EditRichTxtInfo (void)
{ {
extern const char *Txt_INFO_TITLE[Inf_NUM_INFO_TYPES]; extern const char *Txt_INFO_TITLE[Inf_NUM_INFO_TYPES];
extern const char *Txt_Save_changes; extern const char *Txt_Save_changes;
struct Syl_Syllabus Syllabus;
char TxtHTML[Cns_MAX_BYTES_LONG_TEXT + 1]; char TxtHTML[Cns_MAX_BYTES_LONG_TEXT + 1];
const char *HelpEdit[Inf_NUM_INFO_TYPES] = const char *HelpEdit[Inf_NUM_INFO_TYPES] =
{ {
@ -1947,8 +1998,11 @@ void Inf_EditRichTxtInfo (void)
[Inf_ASSESSMENT ] = Hlp_ASSESSMENT_System_edit, [Inf_ASSESSMENT ] = Hlp_ASSESSMENT_System_edit,
}; };
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set info type *****/ /***** Set info type *****/
Gbl.Crs.Info.Type = Inf_AsignInfoType (); Inf_AsignInfoType (&Gbl.Crs.Info,&Syllabus);
/***** Begin form and box *****/ /***** Begin form and box *****/
Frm_StartForm (Inf_ActionsRcvRchTxtInfo[Gbl.Crs.Info.Type]); Frm_StartForm (Inf_ActionsRcvRchTxtInfo[Gbl.Crs.Info.Type]);
@ -1983,11 +2037,15 @@ void Inf_EditRichTxtInfo (void)
void Inf_RecAndChangePlainTxtInfo (void) void Inf_RecAndChangePlainTxtInfo (void)
{ {
struct Syl_Syllabus Syllabus;
char Txt_HTMLFormat [Cns_MAX_BYTES_LONG_TEXT + 1]; char Txt_HTMLFormat [Cns_MAX_BYTES_LONG_TEXT + 1];
char Txt_MarkdownFormat[Cns_MAX_BYTES_LONG_TEXT + 1]; char Txt_MarkdownFormat[Cns_MAX_BYTES_LONG_TEXT + 1];
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set info type *****/ /***** Set info type *****/
Gbl.Crs.Info.Type = Inf_AsignInfoType (); Inf_AsignInfoType (&Gbl.Crs.Info,&Syllabus);
/***** Get text with course information from form *****/ /***** Get text with course information from form *****/
Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat, Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,
@ -2019,11 +2077,15 @@ void Inf_RecAndChangePlainTxtInfo (void)
void Inf_RecAndChangeRichTxtInfo (void) void Inf_RecAndChangeRichTxtInfo (void)
{ {
struct Syl_Syllabus Syllabus;
char Txt_HTMLFormat [Cns_MAX_BYTES_LONG_TEXT + 1]; char Txt_HTMLFormat [Cns_MAX_BYTES_LONG_TEXT + 1];
char Txt_MarkdownFormat[Cns_MAX_BYTES_LONG_TEXT + 1]; char Txt_MarkdownFormat[Cns_MAX_BYTES_LONG_TEXT + 1];
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set info type *****/ /***** Set info type *****/
Gbl.Crs.Info.Type = Inf_AsignInfoType (); Inf_AsignInfoType (&Gbl.Crs.Info,&Syllabus);
/***** Get text with course information from form *****/ /***** Get text with course information from form *****/
Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat, Par_GetParameter (Par_PARAM_SINGLE,"Txt",Txt_HTMLFormat,
@ -2056,12 +2118,16 @@ void Inf_RecAndChangeRichTxtInfo (void)
void Inf_ReceiveURLInfo (void) void Inf_ReceiveURLInfo (void)
{ {
extern const char *Txt_The_URL_X_has_been_updated; extern const char *Txt_The_URL_X_has_been_updated;
struct Syl_Syllabus Syllabus;
char PathFile[PATH_MAX + 1]; char PathFile[PATH_MAX + 1];
FILE *FileURL; FILE *FileURL;
bool URLIsOK = false; bool URLIsOK = false;
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set info type *****/ /***** Set info type *****/
Gbl.Crs.Info.Type = Inf_AsignInfoType (); Inf_AsignInfoType (&Gbl.Crs.Info,&Syllabus);
/***** Get parameter with URL *****/ /***** Get parameter with URL *****/
Par_GetParToText ("InfoSrcURL",Gbl.Crs.Info.URL,Cns_MAX_BYTES_WWW); Par_GetParToText ("InfoSrcURL",Gbl.Crs.Info.URL,Cns_MAX_BYTES_WWW);
@ -2118,6 +2184,7 @@ void Inf_ReceivePagInfo (void)
extern const char *Txt_Found_an_index_htm_file; extern const char *Txt_Found_an_index_htm_file;
extern const char *Txt_No_file_index_html_index_htm_found_within_the_ZIP_file; extern const char *Txt_No_file_index_html_index_htm_found_within_the_ZIP_file;
extern const char *Txt_The_file_type_should_be_HTML_or_ZIP; extern const char *Txt_The_file_type_should_be_HTML_or_ZIP;
struct Syl_Syllabus Syllabus;
struct Param *Param; struct Param *Param;
char SourceFileName[PATH_MAX + 1]; char SourceFileName[PATH_MAX + 1];
char PathRelDirHTML[PATH_MAX + 1]; char PathRelDirHTML[PATH_MAX + 1];
@ -2128,8 +2195,11 @@ void Inf_ReceivePagInfo (void)
bool WrongType = false; bool WrongType = false;
bool FileIsOK = false; bool FileIsOK = false;
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set info type *****/ /***** Set info type *****/
Gbl.Crs.Info.Type = Inf_AsignInfoType (); Inf_AsignInfoType (&Gbl.Crs.Info,&Syllabus);
/***** First of all, store in disk the file from stdin (really from Gbl.F.Tmp) *****/ /***** First of all, store in disk the file from stdin (really from Gbl.F.Tmp) *****/
Param = Fil_StartReceptionOfFile (Fil_NAME_OF_PARAM_FILENAME_ORG, Param = Fil_StartReceptionOfFile (Fil_NAME_OF_PARAM_FILENAME_ORG,

View File

@ -30,6 +30,7 @@
#include <stdbool.h> // For boolean type #include <stdbool.h> // For boolean type
#include "swad_constant.h" #include "swad_constant.h"
#include "swad_syllabus.h"
/*****************************************************************************/ /*****************************************************************************/
/***************************** Public constants ******************************/ /***************************** Public constants ******************************/
@ -63,6 +64,14 @@ typedef enum
Inf_INFO_SRC_URL = 5, Inf_INFO_SRC_URL = 5,
} Inf_InfoSrc_t; } Inf_InfoSrc_t;
struct Inf_Info
{
Inf_InfoType_t Type;
char URL[Cns_MAX_BYTES_WWW + 1];
bool MustBeRead[Inf_NUM_INFO_TYPES]; // Students must read info?
bool ShowMsgMustBeRead;
};
/*****************************************************************************/ /*****************************************************************************/
/***************************** Public prototypes *****************************/ /***************************** Public prototypes *****************************/
/*****************************************************************************/ /*****************************************************************************/
@ -86,7 +95,8 @@ void Inf_FormToSendURL (Inf_InfoSrc_t InfoSrc);
Inf_InfoSrc_t Inf_GetInfoSrcFromForm (void); Inf_InfoSrc_t Inf_GetInfoSrcFromForm (void);
void Inf_SetInfoSrcIntoDB (Inf_InfoSrc_t InfoSrc); void Inf_SetInfoSrcIntoDB (Inf_InfoSrc_t InfoSrc);
Inf_InfoSrc_t Inf_GetInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType); Inf_InfoSrc_t Inf_GetInfoSrcFromDB (long CrsCod,Inf_InfoType_t InfoType);
void Inf_GetAndCheckInfoSrcFromDB (long CrsCod, void Inf_GetAndCheckInfoSrcFromDB (struct Syl_Syllabus *Syllabus,
long CrsCod,
Inf_InfoType_t InfoType, Inf_InfoType_t InfoType,
Inf_InfoSrc_t *InfoSrc,bool *MustBeRead); Inf_InfoSrc_t *InfoSrc,bool *MustBeRead);
Inf_InfoType_t Inf_ConvertFromStrDBToInfoType (const char *StrInfoTypeDB); Inf_InfoType_t Inf_ConvertFromStrDBToInfoType (const char *StrInfoTypeDB);

View File

@ -203,8 +203,6 @@ static void Msg_ResetMessages (struct Msg_Messages *Messages)
Messages->Reply.IsReply = false; Messages->Reply.IsReply = false;
Messages->Reply.OriginalMsgCod = -1L; Messages->Reply.OriginalMsgCod = -1L;
Messages->ShowOnlyOneRecipient = false; Messages->ShowOnlyOneRecipient = false;
Messages->FileNameMail[0] = '\0';
Messages->FileMail = NULL;
Messages->CurrentPage = 0; Messages->CurrentPage = 0;
Messages->MsgCod = -1L; Messages->MsgCod = -1L;
} }

View File

@ -77,8 +77,6 @@ struct Msg_Messages
long OriginalMsgCod; // Original message code when I am editing a reply long OriginalMsgCod; // Original message code when I am editing a reply
} Reply; } Reply;
bool ShowOnlyOneRecipient; // Shown only a selected recipient or also other potential recipients? bool ShowOnlyOneRecipient; // Shown only a selected recipient or also other potential recipients?
char FileNameMail[PATH_MAX + 1];
FILE *FileMail;
unsigned CurrentPage; unsigned CurrentPage;
long MsgCod; // Used as parameter with message to be removed long MsgCod; // Used as parameter with message to be removed
}; };

View File

@ -100,54 +100,77 @@ struct LstItemsSyllabus Syl_LstItemsSyllabus;
/***************************** Private prototypes ****************************/ /***************************** Private prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
static void Syl_SetSyllabusTypeFromAction (void); static unsigned Syl_GetParamItemNumber (void);
static void Syl_ShowSyllabus (bool PutIconToEdit);
static void Syl_ShowRowSyllabus (unsigned NumItem, static void Syl_SetSyllabusTypeFromAction (struct Syl_Syllabus *Syllabus);
static void Syl_ShowSyllabus (struct Syl_Syllabus *Syllabus,
bool PutIconToEdit);
static void Syl_ShowRowSyllabus (struct Syl_Syllabus *Syllabus,unsigned NumItem,
int Level,int *CodItem,const char *Text,bool NewItem); int Level,int *CodItem,const char *Text,bool NewItem);
static void Syl_PutFormItemSyllabus (bool NewItem,unsigned NumItem,int Level,int *CodItem,const char *Text); static void Syl_PutFormItemSyllabus (struct Syl_Syllabus *Syllabus,
bool NewItem,unsigned NumItem,int Level,int *CodItem,const char *Text);
static void Syl_PutParamNumItem (void *ParamNumItem); static void Syl_PutParamNumItem (void *ParamNumItem);
static void Syl_WriteNumItem (char *StrDst,FILE *FileTgt,int Level,int *CodItem); static void Syl_WriteNumItem (char *StrDst,FILE *FileTgt,int Level,int *CodItem);
static void Syl_ChangePlaceItemSyllabus (Syl_ChangePosItem_t UpOrDownPos);
static void Syl_ChangeLevelItemSyllabus (Syl_ChangeLevelItem_t IncreaseOrDecreaseLevel);
static void Syl_OpenSyllabusFile (const struct Syl_Syllabus *Syllabus,
char *PathFile);
/*****************************************************************************/
/************************** Reset syllabus context ***************************/
/*****************************************************************************/
void Syl_ResetSyllabus (struct Syl_Syllabus *Syllabus)
{
Syllabus->PathDir[0] = '\0';
Syllabus->NumItem = 0;
Syllabus->EditionIsActive = false;
Syllabus->WhichSyllabus = Syl_DEFAULT_WHICH_SYLLABUS;
}
/*****************************************************************************/ /*****************************************************************************/
/************* Get parameter about which syllabus I want to see **************/ /************* Get parameter about which syllabus I want to see **************/
/*****************************************************************************/ /*****************************************************************************/
void Syl_GetParamWhichSyllabus (void) Syl_WhichSyllabus_t Syl_GetParamWhichSyllabus (void)
{ {
/***** Get which syllabus I want to see *****/ /***** Get which syllabus I want to see *****/
Gbl.Syllabus.WhichSyllabus = (Syl_WhichSyllabus_t) return (Syl_WhichSyllabus_t)
Par_GetParToUnsignedLong ("WhichSyllabus", Par_GetParToUnsignedLong ("WhichSyllabus",
0, 0,
Syl_NUM_WHICH_SYLLABUS - 1, Syl_NUM_WHICH_SYLLABUS - 1,
(unsigned long) Syl_DEFAULT_WHICH_SYLLABUS); (unsigned long) Syl_DEFAULT_WHICH_SYLLABUS);
} }
/*****************************************************************************/ /*****************************************************************************/
/************************ Write form to select syllabus **********************/ /************************ Write form to select syllabus **********************/
/*****************************************************************************/ /*****************************************************************************/
void Syl_PutFormWhichSyllabus (void) void Syl_PutFormWhichSyllabus (Syl_WhichSyllabus_t SyllabusSelected)
{ {
extern const char *Txt_SYLLABUS_WHICH_SYLLABUS[Syl_NUM_WHICH_SYLLABUS]; extern const char *Txt_SYLLABUS_WHICH_SYLLABUS[Syl_NUM_WHICH_SYLLABUS];
Syl_WhichSyllabus_t WhichSyllabus; Syl_WhichSyllabus_t WhichSyl;
/***** Form to select which syllabus I want to see (lectures/practicals) *****/ /***** Form to select which syllabus I want to see (lectures/practicals) *****/
Frm_StartForm (ActSeeSyl); Frm_StartForm (ActSeeSyl);
HTM_DIV_Begin ("class=\"CM\""); HTM_DIV_Begin ("class=\"CM\"");
HTM_UL_Begin ("class=\"LIST_LEFT\""); HTM_UL_Begin ("class=\"LIST_LEFT\"");
for (WhichSyllabus = (Syl_WhichSyllabus_t) 0; for (WhichSyl = (Syl_WhichSyllabus_t) 0;
WhichSyllabus <= (Syl_WhichSyllabus_t) (For_NUM_FORUM_SETS - 1); WhichSyl <= (Syl_WhichSyllabus_t) (For_NUM_FORUM_SETS - 1);
WhichSyllabus++) WhichSyl++)
{ {
HTM_LI_Begin ("class=\"DAT LM\""); HTM_LI_Begin ("class=\"DAT LM\"");
HTM_LABEL_Begin (NULL); HTM_LABEL_Begin (NULL);
HTM_INPUT_RADIO ("WhichSyllabus",true, HTM_INPUT_RADIO ("WhichSyllabus",true,
"value=\"%u\"%s", "value=\"%u\"%s",
(unsigned) WhichSyllabus, (unsigned) WhichSyl,
WhichSyllabus == Gbl.Syllabus.WhichSyllabus ? " checked=\"checked\"" : ""); WhichSyl == SyllabusSelected ? " checked=\"checked\"" :
HTM_Txt (Txt_SYLLABUS_WHICH_SYLLABUS[WhichSyllabus]); "");
HTM_Txt (Txt_SYLLABUS_WHICH_SYLLABUS[WhichSyl]);
HTM_LABEL_End (); HTM_LABEL_End ();
HTM_LI_End (); HTM_LI_End ();
} }
@ -160,13 +183,12 @@ void Syl_PutFormWhichSyllabus (void)
/************ Get parameter item number in edition of syllabus ***************/ /************ Get parameter item number in edition of syllabus ***************/
/*****************************************************************************/ /*****************************************************************************/
void Syl_GetParamItemNumber (void) static unsigned Syl_GetParamItemNumber (void)
{ {
Gbl.Syllabus.NumItem = (unsigned) return (unsigned) Par_GetParToUnsignedLong ("NumI",
Par_GetParToUnsignedLong ("NumI", 0,
0, UINT_MAX,
UINT_MAX, 0);
0);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -174,25 +196,12 @@ void Syl_GetParamItemNumber (void)
/*****************************************************************************/ /*****************************************************************************/
// Return true if info available // Return true if info available
bool Syl_CheckSyllabus (long CrsCod,Inf_InfoType_t InfoType) bool Syl_CheckSyllabus (struct Syl_Syllabus *Syllabus,long CrsCod)
{ {
bool InfoAvailable; bool InfoAvailable;
/***** Set syllabus type *****/
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 *****/ /***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (CrsCod); Syl_LoadListItemsSyllabusIntoMemory (Syllabus,CrsCod);
/***** Number of items > 0 ==> info available *****/ /***** Number of items > 0 ==> info available *****/
InfoAvailable = (Syl_LstItemsSyllabus.NumItems != 0); InfoAvailable = (Syl_LstItemsSyllabus.NumItems != 0);
@ -208,7 +217,7 @@ bool Syl_CheckSyllabus (long CrsCod,Inf_InfoType_t InfoType)
/*****************************************************************************/ /*****************************************************************************/
// Return true if info available // Return true if info available
bool Syl_CheckAndEditSyllabus (void) bool Syl_CheckAndEditSyllabus (struct Syl_Syllabus *Syllabus)
{ {
extern const Act_Action_t Inf_ActionsSeeInfo[Inf_NUM_INFO_TYPES]; extern const Act_Action_t Inf_ActionsSeeInfo[Inf_NUM_INFO_TYPES];
extern const char *Txt_Done; extern const char *Txt_Done;
@ -216,25 +225,25 @@ bool Syl_CheckAndEditSyllabus (void)
bool PutIconToEdit; bool PutIconToEdit;
/***** Set syllabus type depending on current action *****/ /***** Set syllabus type depending on current action *****/
Syl_SetSyllabusTypeFromAction (); Syl_SetSyllabusTypeFromAction (Syllabus);
/***** Load syllabus from XML file to memory *****/ /***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (Gbl.Hierarchy.Crs.CrsCod); Syl_LoadListItemsSyllabusIntoMemory (Syllabus,Gbl.Hierarchy.Crs.CrsCod);
if (Gbl.Action.Act == ActEditorSylLec || if (Gbl.Action.Act == ActEditorSylLec ||
Gbl.Action.Act == ActEditorSylPra) Gbl.Action.Act == ActEditorSylPra)
Gbl.Syllabus.EditionIsActive = true; Syllabus->EditionIsActive = true;
if (Gbl.Syllabus.EditionIsActive || Syl_LstItemsSyllabus.NumItems) if (Syllabus->EditionIsActive || Syl_LstItemsSyllabus.NumItems)
{ {
ICanEdit = Gbl.Usrs.Me.Role.Logged == Rol_TCH || ICanEdit = Gbl.Usrs.Me.Role.Logged == Rol_TCH ||
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM; Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM;
PutIconToEdit = ICanEdit && !Gbl.Syllabus.EditionIsActive; PutIconToEdit = ICanEdit && !Syllabus->EditionIsActive;
/***** Write the current syllabus *****/ /***** Write the current syllabus *****/
Syl_ShowSyllabus (PutIconToEdit); Syl_ShowSyllabus (Syllabus,PutIconToEdit);
if (Gbl.Syllabus.EditionIsActive) if (Syllabus->EditionIsActive)
{ {
/***** Button to view *****/ /***** Button to view *****/
Frm_StartForm (Inf_ActionsSeeInfo[Gbl.Crs.Info.Type]); Frm_StartForm (Inf_ActionsSeeInfo[Gbl.Crs.Info.Type]);
@ -258,14 +267,20 @@ bool Syl_CheckAndEditSyllabus (void)
void Syl_EditSyllabus (void) void Syl_EditSyllabus (void)
{ {
(void) Syl_CheckAndEditSyllabus (); struct Syl_Syllabus Syllabus;
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Edit syllabus *****/
(void) Syl_CheckAndEditSyllabus (&Syllabus);
} }
/*****************************************************************************/ /*****************************************************************************/
/************* Set syllabus type depending on the current action *************/ /************* Set syllabus type depending on the current action *************/
/*****************************************************************************/ /*****************************************************************************/
static void Syl_SetSyllabusTypeFromAction (void) static void Syl_SetSyllabusTypeFromAction (struct Syl_Syllabus *Syllabus)
{ {
Gbl.Crs.Info.Type = Inf_LECTURES; Gbl.Crs.Info.Type = Inf_LECTURES;
@ -273,8 +288,8 @@ static void Syl_SetSyllabusTypeFromAction (void)
switch (Gbl.Action.Act) switch (Gbl.Action.Act)
{ {
case ActSeeSyl: case ActSeeSyl:
Gbl.Crs.Info.Type = (Gbl.Syllabus.WhichSyllabus == Syl_LECTURES ? Inf_LECTURES : Gbl.Crs.Info.Type = (Syllabus->WhichSyllabus == Syl_LECTURES ? Inf_LECTURES :
Inf_PRACTICALS); Inf_PRACTICALS);
break; break;
case ActSeeSylLec: case ActSeeSylLec:
case ActEdiSylLec: case ActEdiSylLec:
@ -295,7 +310,7 @@ static void Syl_SetSyllabusTypeFromAction (void)
case ActRchTxtEdiSylLec: case ActRchTxtEdiSylLec:
case ActRcvPlaTxtSylLec: case ActRcvPlaTxtSylLec:
case ActRcvRchTxtSylLec: case ActRcvRchTxtSylLec:
Gbl.Syllabus.WhichSyllabus = Syl_LECTURES; Syllabus->WhichSyllabus = Syl_LECTURES;
Gbl.Crs.Info.Type = Inf_LECTURES; Gbl.Crs.Info.Type = Inf_LECTURES;
break; break;
case ActSeeSylPra: case ActSeeSylPra:
@ -317,7 +332,7 @@ static void Syl_SetSyllabusTypeFromAction (void)
case ActRchTxtEdiSylPra: case ActRchTxtEdiSylPra:
case ActRcvPlaTxtSylPra: case ActRcvPlaTxtSylPra:
case ActRcvRchTxtSylPra: case ActRcvRchTxtSylPra:
Gbl.Syllabus.WhichSyllabus = Syl_PRACTICALS; Syllabus->WhichSyllabus = Syl_PRACTICALS;
Gbl.Crs.Info.Type = Inf_PRACTICALS; Gbl.Crs.Info.Type = Inf_PRACTICALS;
break; break;
default: default:
@ -330,7 +345,8 @@ static void Syl_SetSyllabusTypeFromAction (void)
/*** 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 ***/
/*****************************************************************************/ /*****************************************************************************/
void Syl_LoadListItemsSyllabusIntoMemory (long CrsCod) void Syl_LoadListItemsSyllabusIntoMemory (struct Syl_Syllabus *Syllabus,
long CrsCod)
{ {
char PathFile[PATH_MAX + 1]; char PathFile[PATH_MAX + 1];
long PostBeginList; long PostBeginList;
@ -341,14 +357,14 @@ void Syl_LoadListItemsSyllabusIntoMemory (long CrsCod)
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 */
snprintf (Gbl.Syllabus.PathDir,sizeof (Gbl.Syllabus.PathDir), snprintf (Syllabus->PathDir,sizeof (Syllabus->PathDir),
"%s/%ld/%s", "%s/%ld/%s",
Cfg_PATH_CRS_PRIVATE,CrsCod, Cfg_PATH_CRS_PRIVATE,CrsCod,
Gbl.Syllabus.WhichSyllabus == Syl_LECTURES ? Cfg_SYLLABUS_FOLDER_LECTURES : 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.Syllabus.PathDir,PathFile); Syl_OpenSyllabusFile (Syllabus,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))
@ -363,7 +379,8 @@ void Syl_LoadListItemsSyllabusIntoMemory (long CrsCod)
Syl_LstItemsSyllabus.NumItems++); Syl_LstItemsSyllabus.NumItems++);
/***** Allocate memory for the list of items *****/ /***** Allocate memory for the list of items *****/
if ((Syl_LstItemsSyllabus.Lst = (struct ItemSyllabus *) calloc (Syl_LstItemsSyllabus.NumItems + 1,sizeof (struct ItemSyllabus))) == NULL) if ((Syl_LstItemsSyllabus.Lst = (struct ItemSyllabus *) calloc (Syl_LstItemsSyllabus.NumItems + 1,
sizeof (struct ItemSyllabus))) == NULL)
Lay_NotEnoughMemoryExit (); Lay_NotEnoughMemoryExit ();
/***** Return to the start of the list *****/ /***** Return to the start of the list *****/
@ -495,15 +512,16 @@ int Syl_ReadLevelItemSyllabus (void)
/***************** Show a syllabus of lectures or practicals *****************/ /***************** Show a syllabus of lectures or practicals *****************/
/*****************************************************************************/ /*****************************************************************************/
static void Syl_ShowSyllabus (bool PutIconToEdit) static void Syl_ShowSyllabus (struct Syl_Syllabus *Syllabus,
bool PutIconToEdit)
{ {
extern const char *Txt_INFO_TITLE[Inf_NUM_INFO_TYPES]; extern const char *Txt_INFO_TITLE[Inf_NUM_INFO_TYPES];
extern const char *Hlp_COURSE_Syllabus_edit; extern const char *Hlp_COURSE_Syllabus_edit;
extern const char *Hlp_COURSE_Syllabus; extern const char *Hlp_COURSE_Syllabus;
unsigned NumItem; unsigned NumItem;
int i; int i;
int NumButtons = Gbl.Syllabus.EditionIsActive ? 5 : int NumButtons = 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 ||
Gbl.Action.Act == ActRgtIteSylLec || Gbl.Action.Act == ActRgtIteSylPra || Gbl.Action.Act == ActRgtIteSylLec || Gbl.Action.Act == ActRgtIteSylPra ||
@ -513,14 +531,14 @@ static void Syl_ShowSyllabus (bool PutIconToEdit)
if (PutIconToEdit) if (PutIconToEdit)
Box_BoxTableBegin (NULL,Txt_INFO_TITLE[Gbl.Crs.Info.Type], Box_BoxTableBegin (NULL,Txt_INFO_TITLE[Gbl.Crs.Info.Type],
Inf_PutIconToEditInfo,&Gbl.Crs.Info.Type, Inf_PutIconToEditInfo,&Gbl.Crs.Info.Type,
Gbl.Syllabus.EditionIsActive ? Hlp_COURSE_Syllabus_edit : Syllabus->EditionIsActive ? Hlp_COURSE_Syllabus_edit :
Hlp_COURSE_Syllabus, Hlp_COURSE_Syllabus,
Box_NOT_CLOSABLE,0); Box_NOT_CLOSABLE,0);
else else
Box_BoxTableBegin (NULL,Txt_INFO_TITLE[Gbl.Crs.Info.Type], Box_BoxTableBegin (NULL,Txt_INFO_TITLE[Gbl.Crs.Info.Type],
NULL,NULL, NULL,NULL,
Gbl.Syllabus.EditionIsActive ? Hlp_COURSE_Syllabus_edit : Syllabus->EditionIsActive ? Hlp_COURSE_Syllabus_edit :
Hlp_COURSE_Syllabus, Hlp_COURSE_Syllabus,
Box_NOT_CLOSABLE,0); Box_NOT_CLOSABLE,0);
/***** Set width of columns of the table *****/ /***** Set width of columns of the table *****/
@ -542,20 +560,21 @@ static void Syl_ShowSyllabus (bool PutIconToEdit)
NumItem < Syl_LstItemsSyllabus.NumItems; NumItem < Syl_LstItemsSyllabus.NumItems;
NumItem++) NumItem++)
{ {
Syl_ShowRowSyllabus (NumItem, Syl_ShowRowSyllabus (Syllabus,NumItem,
Syl_LstItemsSyllabus.Lst[NumItem].Level, Syl_LstItemsSyllabus.Lst[NumItem].Level,
Syl_LstItemsSyllabus.Lst[NumItem].CodItem, Syl_LstItemsSyllabus.Lst[NumItem].CodItem,
Syl_LstItemsSyllabus.Lst[NumItem].Text,false); Syl_LstItemsSyllabus.Lst[NumItem].Text,false);
if (ShowRowInsertNewItem && NumItem == Gbl.Syllabus.NumItem) if (ShowRowInsertNewItem && NumItem == 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 (Syllabus,NumItem + 1,
Syl_LstItemsSyllabus.Lst[NumItem].Level,NULL, Syl_LstItemsSyllabus.Lst[NumItem].Level,NULL,
"",true); "",true);
} }
else if (Gbl.Syllabus.EditionIsActive) else if (Syllabus->EditionIsActive)
/***** If the syllabus is empty ==> /***** If the syllabus is empty ==>
show form to add a iten to the end *****/ show form to add a iten to the end *****/
Syl_ShowRowSyllabus (0,1,Syl_LstItemsSyllabus.Lst[0].CodItem,"",true); Syl_ShowRowSyllabus (Syllabus,0,
1,Syl_LstItemsSyllabus.Lst[0].CodItem,"",true);
/***** End table *****/ /***** End table *****/
HTM_TABLE_End (); HTM_TABLE_End ();
@ -565,7 +584,7 @@ static void Syl_ShowSyllabus (bool PutIconToEdit)
/******** Write a row (item) of a syllabus of lectures or practicals *********/ /******** Write a row (item) of a syllabus of lectures or practicals *********/
/*****************************************************************************/ /*****************************************************************************/
static void Syl_ShowRowSyllabus (unsigned NumItem, static void Syl_ShowRowSyllabus (struct Syl_Syllabus *Syllabus,unsigned NumItem,
int Level,int *CodItem,const char *Text,bool NewItem) int Level,int *CodItem,const char *Text,bool NewItem)
{ {
extern const char *Txt_Move_up_X_and_its_subsections; extern const char *Txt_Move_up_X_and_its_subsections;
@ -583,7 +602,7 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
Subtree.ToGetDown.Ini = Subtree.ToGetDown.End = 0; Subtree.ToGetDown.Ini = Subtree.ToGetDown.End = 0;
Subtree.MovAllowed = false; Subtree.MovAllowed = false;
Gbl.Syllabus.ParamNumItem = NumItem; // Used as parameter in forms Syllabus->ParamNumItem = NumItem; // Used as parameter in forms
if (!NewItem) // If the item is new (not stored in file), it has no number if (!NewItem) // If the item is new (not stored in file), it has no number
Syl_WriteNumItem (StrItemCod,NULL,Level,CodItem); Syl_WriteNumItem (StrItemCod,NULL,Level,CodItem);
@ -591,7 +610,7 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
/***** Start the row *****/ /***** Start the row *****/
HTM_TR_Begin (NULL); HTM_TR_Begin (NULL);
if (Gbl.Syllabus.EditionIsActive) if (Syllabus->EditionIsActive)
{ {
if (NewItem) if (NewItem)
{ {
@ -608,7 +627,7 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
{ {
Frm_StartForm (Gbl.Crs.Info.Type == Inf_LECTURES ? ActDelItmSylLec : Frm_StartForm (Gbl.Crs.Info.Type == Inf_LECTURES ? ActDelItmSylLec :
ActDelItmSylPra); ActDelItmSylPra);
Syl_PutParamNumItem (&Gbl.Syllabus.ParamNumItem); Syl_PutParamNumItem (&Syllabus->ParamNumItem);
Ico_PutIconRemove (); Ico_PutIconRemove ();
Frm_EndForm (); Frm_EndForm ();
} }
@ -622,7 +641,7 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
Lay_PutContextualLinkOnlyIcon (Gbl.Crs.Info.Type == Inf_LECTURES ? ActUp_IteSylLec : Lay_PutContextualLinkOnlyIcon (Gbl.Crs.Info.Type == Inf_LECTURES ? ActUp_IteSylLec :
ActUp_IteSylPra, ActUp_IteSylPra,
NULL, NULL,
Syl_PutParamNumItem,&Gbl.Syllabus.ParamNumItem, Syl_PutParamNumItem,&Syllabus->ParamNumItem,
"arrow-up.svg", "arrow-up.svg",
Str_BuildStringStr (Syl_LstItemsSyllabus.Lst[NumItem].HasChildren ? Txt_Move_up_X_and_its_subsections : Str_BuildStringStr (Syl_LstItemsSyllabus.Lst[NumItem].HasChildren ? Txt_Move_up_X_and_its_subsections :
Txt_Move_up_X, Txt_Move_up_X,
@ -641,7 +660,7 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
Lay_PutContextualLinkOnlyIcon (Gbl.Crs.Info.Type == Inf_LECTURES ? ActDwnIteSylLec : Lay_PutContextualLinkOnlyIcon (Gbl.Crs.Info.Type == Inf_LECTURES ? ActDwnIteSylLec :
ActDwnIteSylPra, ActDwnIteSylPra,
NULL, NULL,
Syl_PutParamNumItem,&Gbl.Syllabus.ParamNumItem, Syl_PutParamNumItem,&Syllabus->ParamNumItem,
"arrow-down.svg", "arrow-down.svg",
Str_BuildStringStr (Syl_LstItemsSyllabus.Lst[NumItem].HasChildren ? Txt_Move_down_X_and_its_subsections : Str_BuildStringStr (Syl_LstItemsSyllabus.Lst[NumItem].HasChildren ? Txt_Move_down_X_and_its_subsections :
Txt_Move_down_X, Txt_Move_down_X,
@ -659,7 +678,7 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
Lay_PutContextualLinkOnlyIcon (Gbl.Crs.Info.Type == Inf_LECTURES ? ActRgtIteSylLec : Lay_PutContextualLinkOnlyIcon (Gbl.Crs.Info.Type == Inf_LECTURES ? ActRgtIteSylLec :
ActRgtIteSylPra, ActRgtIteSylPra,
NULL, NULL,
Syl_PutParamNumItem,&Gbl.Syllabus.ParamNumItem, Syl_PutParamNumItem,&Syllabus->ParamNumItem,
"arrow-left.svg", "arrow-left.svg",
Str_BuildStringStr (Txt_Increase_level_of_X, Str_BuildStringStr (Txt_Increase_level_of_X,
StrItemCod)); StrItemCod));
@ -677,7 +696,7 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
Lay_PutContextualLinkOnlyIcon (Gbl.Crs.Info.Type == Inf_LECTURES ? ActLftIteSylLec : Lay_PutContextualLinkOnlyIcon (Gbl.Crs.Info.Type == Inf_LECTURES ? ActLftIteSylLec :
ActLftIteSylPra, ActLftIteSylPra,
NULL, NULL,
Syl_PutParamNumItem,&Gbl.Syllabus.ParamNumItem, Syl_PutParamNumItem,&Syllabus->ParamNumItem,
"arrow-right.svg", "arrow-right.svg",
Str_BuildStringStr (Txt_Decrease_level_of_X, Str_BuildStringStr (Txt_Decrease_level_of_X,
StrItemCod)); StrItemCod));
@ -691,8 +710,8 @@ static void Syl_ShowRowSyllabus (unsigned NumItem,
} }
} }
if (Gbl.Syllabus.EditionIsActive) if (Syllabus->EditionIsActive)
Syl_PutFormItemSyllabus (NewItem,NumItem,Level,CodItem,Text); Syl_PutFormItemSyllabus (Syllabus,NewItem,NumItem,Level,CodItem,Text);
else else
{ {
/***** Indent depending on the level *****/ /***** Indent depending on the level *****/
@ -796,7 +815,8 @@ void Syl_WriteSyllabusIntoHTMLTmpFile (FILE *FileHTMLTmp)
/*************** Show a form to modify an item of the syllabus ***************/ /*************** Show a form to modify an item of the syllabus ***************/
/*****************************************************************************/ /*****************************************************************************/
static void Syl_PutFormItemSyllabus (bool NewItem,unsigned NumItem,int Level,int *CodItem,const char *Text) static void Syl_PutFormItemSyllabus (struct Syl_Syllabus *Syllabus,
bool NewItem,unsigned NumItem,int Level,int *CodItem,const char *Text)
{ {
extern const char *Txt_Enter_a_new_item_here; extern const char *Txt_Enter_a_new_item_here;
@ -836,8 +856,8 @@ static void Syl_PutFormItemSyllabus (bool NewItem,unsigned NumItem,int Level,int
ActInsIteSylPra) : ActInsIteSylPra) :
(Gbl.Crs.Info.Type == Inf_LECTURES ? ActModIteSylLec : (Gbl.Crs.Info.Type == Inf_LECTURES ? ActModIteSylLec :
ActModIteSylPra)); ActModIteSylPra));
Gbl.Syllabus.ParamNumItem = NumItem; Syllabus->ParamNumItem = NumItem;
Syl_PutParamNumItem (&Gbl.Syllabus.ParamNumItem); Syl_PutParamNumItem (&Syllabus->ParamNumItem);
HTM_INPUT_TEXT ("Txt",Syl_MAX_CHARS_TEXT_ITEM,Text,true, HTM_INPUT_TEXT ("Txt",Syl_MAX_CHARS_TEXT_ITEM,Text,true,
"size=\"60\" placeholder=\"%s\"%s", "size=\"60\" placeholder=\"%s\"%s",
Txt_Enter_a_new_item_here, Txt_Enter_a_new_item_here,
@ -898,25 +918,29 @@ static void Syl_WriteNumItem (char *StrDst,FILE *FileTgt,int Level,int *CodItem)
void Syl_RemoveItemSyllabus (void) void Syl_RemoveItemSyllabus (void)
{ {
struct Syl_Syllabus Syllabus;
char PathFile[PATH_MAX + 1]; char PathFile[PATH_MAX + 1];
char PathOldFile[PATH_MAX + 1]; char PathOldFile[PATH_MAX + 1];
char PathNewFile[PATH_MAX + 1]; char PathNewFile[PATH_MAX + 1];
FILE *NewFile; FILE *NewFile;
unsigned NumItem; unsigned NumItem;
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set syllabus type depending on current action *****/ /***** Set syllabus type depending on current action *****/
Syl_SetSyllabusTypeFromAction (); Syl_SetSyllabusTypeFromAction (&Syllabus);
/***** Load syllabus from XML file to memory *****/ /***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (Gbl.Hierarchy.Crs.CrsCod); Syl_LoadListItemsSyllabusIntoMemory (&Syllabus,Gbl.Hierarchy.Crs.CrsCod);
Gbl.Syllabus.EditionIsActive = true; Syllabus.EditionIsActive = true;
/***** Get item number *****/ /***** Get item number *****/
Syl_GetParamItemNumber (); Syllabus.NumItem = Syl_GetParamItemNumber ();
/***** Create a new file to make the update *****/ /***** Create a new file to make the update *****/
Syl_BuildPathFileSyllabus (PathFile); Syl_BuildPathFileSyllabus (&Syllabus,PathFile);
Fil_CreateUpdateFile (PathFile,".old",PathOldFile,PathNewFile,&NewFile); Fil_CreateUpdateFile (PathFile,".old",PathOldFile,PathNewFile,&NewFile);
/***** Create the new XML file *****/ /***** Create the new XML file *****/
@ -924,7 +948,7 @@ void Syl_RemoveItemSyllabus (void)
for (NumItem = 0; for (NumItem = 0;
NumItem < Syl_LstItemsSyllabus.NumItems; NumItem < Syl_LstItemsSyllabus.NumItems;
NumItem++) NumItem++)
if (NumItem != Gbl.Syllabus.NumItem) if (NumItem != Syllabus.NumItem)
Syl_WriteItemFileSyllabus (NewFile,Syl_LstItemsSyllabus.Lst[NumItem].Level,Syl_LstItemsSyllabus.Lst[NumItem].Text); Syl_WriteItemFileSyllabus (NewFile,Syl_LstItemsSyllabus.Lst[NumItem].Level,Syl_LstItemsSyllabus.Lst[NumItem].Text);
Syl_WriteEndFileSyllabus (NewFile); Syl_WriteEndFileSyllabus (NewFile);
@ -934,7 +958,7 @@ void Syl_RemoveItemSyllabus (void)
/***** We are editing a syllabus with the internal editor, /***** We are editing a syllabus with the internal editor,
so change info source to internal editor in database *****/ so change info source to internal editor in database *****/
Inf_SetInfoSrcIntoDB (Syl_LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR : Inf_SetInfoSrcIntoDB (Syl_LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR :
Inf_INFO_SRC_NONE); Inf_INFO_SRC_NONE);
/***** Show the updated syllabus to continue editing it *****/ /***** Show the updated syllabus to continue editing it *****/
Syl_FreeListItemsSyllabus (); Syl_FreeListItemsSyllabus ();
@ -963,8 +987,9 @@ void Syl_DownItemSyllabus (void)
/*************** Get up or get down a subtree of a syllabus ******************/ /*************** Get up or get down a subtree of a syllabus ******************/
/*****************************************************************************/ /*****************************************************************************/
void Syl_ChangePlaceItemSyllabus (Syl_ChangePosItem_t UpOrDownPos) static void Syl_ChangePlaceItemSyllabus (Syl_ChangePosItem_t UpOrDownPos)
{ {
struct Syl_Syllabus Syllabus;
char PathFile[PATH_MAX + 1]; char PathFile[PATH_MAX + 1];
char PathOldFile[PATH_MAX + 1]; char PathOldFile[PATH_MAX + 1];
char PathNewFile[PATH_MAX + 1]; char PathNewFile[PATH_MAX + 1];
@ -972,35 +997,38 @@ void Syl_ChangePlaceItemSyllabus (Syl_ChangePosItem_t UpOrDownPos)
unsigned NumItem; unsigned NumItem;
struct MoveSubtrees Subtree; struct MoveSubtrees Subtree;
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set syllabus type depending on current action *****/ /***** Set syllabus type depending on current action *****/
Syl_SetSyllabusTypeFromAction (); Syl_SetSyllabusTypeFromAction (&Syllabus);
/***** Load syllabus from XML file to memory *****/ /***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (Gbl.Hierarchy.Crs.CrsCod); Syl_LoadListItemsSyllabusIntoMemory (&Syllabus,Gbl.Hierarchy.Crs.CrsCod);
Gbl.Syllabus.EditionIsActive = true; Syllabus.EditionIsActive = true;
/***** Get item number *****/ /***** Get item number *****/
Syl_GetParamItemNumber (); Syllabus.NumItem = Syl_GetParamItemNumber ();
Subtree.ToGetUp.Ini = Subtree.ToGetUp.End = 0; Subtree.ToGetUp.Ini = Subtree.ToGetUp.End = 0;
Subtree.ToGetDown.Ini = Subtree.ToGetDown.End = 0; Subtree.ToGetDown.Ini = Subtree.ToGetDown.End = 0;
Subtree.MovAllowed = false; Subtree.MovAllowed = false;
if (Gbl.Syllabus.NumItem < Syl_LstItemsSyllabus.NumItems) if (Syllabus.NumItem < Syl_LstItemsSyllabus.NumItems)
{ {
/***** Create a new file where make the update *****/ /***** Create a new file where make the update *****/
Syl_BuildPathFileSyllabus (PathFile); Syl_BuildPathFileSyllabus (&Syllabus,PathFile);
Fil_CreateUpdateFile (PathFile,".old",PathOldFile,PathNewFile,&NewFile); Fil_CreateUpdateFile (PathFile,".old",PathOldFile,PathNewFile,&NewFile);
/***** Get up or get down position *****/ /***** Get up or get down position *****/
switch (UpOrDownPos) switch (UpOrDownPos)
{ {
case Syl_GET_UP: case Syl_GET_UP:
Syl_CalculateUpSubtreeSyllabus (&Subtree,Gbl.Syllabus.NumItem); Syl_CalculateUpSubtreeSyllabus (&Subtree,Syllabus.NumItem);
break; break;
case Syl_GET_DOWN: case Syl_GET_DOWN:
Syl_CalculateDownSubtreeSyllabus (&Subtree,Gbl.Syllabus.NumItem); Syl_CalculateDownSubtreeSyllabus (&Subtree,Syllabus.NumItem);
break; break;
} }
@ -1036,7 +1064,7 @@ void Syl_ChangePlaceItemSyllabus (Syl_ChangePosItem_t UpOrDownPos)
/***** We are editing a syllabus with the internal editor, /***** We are editing a syllabus with the internal editor,
so change info source to internal editor in database *****/ so change info source to internal editor in database *****/
Inf_SetInfoSrcIntoDB (Syl_LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR : Inf_SetInfoSrcIntoDB (Syl_LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR :
Inf_INFO_SRC_NONE); Inf_INFO_SRC_NONE);
/***** Show the updated syllabus to continue editing it *****/ /***** Show the updated syllabus to continue editing it *****/
Syl_FreeListItemsSyllabus (); Syl_FreeListItemsSyllabus ();
@ -1155,38 +1183,42 @@ void Syl_LeftItemSyllabus (void)
/********* Increase or decrease the level of an item of a syllabus ***********/ /********* Increase or decrease the level of an item of a syllabus ***********/
/*****************************************************************************/ /*****************************************************************************/
void Syl_ChangeLevelItemSyllabus (Syl_ChangeLevelItem_t IncreaseOrDecreaseLevel) static void Syl_ChangeLevelItemSyllabus (Syl_ChangeLevelItem_t IncreaseOrDecreaseLevel)
{ {
struct Syl_Syllabus Syllabus;
char PathFile[PATH_MAX + 1]; char PathFile[PATH_MAX + 1];
char PathOldFile[PATH_MAX + 1]; char PathOldFile[PATH_MAX + 1];
char PathNewFile[PATH_MAX + 1]; char PathNewFile[PATH_MAX + 1];
FILE *NewFile; FILE *NewFile;
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set syllabus type depending on current action *****/ /***** Set syllabus type depending on current action *****/
Syl_SetSyllabusTypeFromAction (); Syl_SetSyllabusTypeFromAction (&Syllabus);
/***** Load syllabus from XML file to memory *****/ /***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (Gbl.Hierarchy.Crs.CrsCod); Syl_LoadListItemsSyllabusIntoMemory (&Syllabus,Gbl.Hierarchy.Crs.CrsCod);
Gbl.Syllabus.EditionIsActive = true; Syllabus.EditionIsActive = true;
/***** Get item number *****/ /***** Get item number *****/
Syl_GetParamItemNumber (); Syllabus.NumItem = Syl_GetParamItemNumber ();
/***** Create a new file to do the update *****/ /***** Create a new file to do the update *****/
Syl_BuildPathFileSyllabus (PathFile); Syl_BuildPathFileSyllabus (&Syllabus,PathFile);
Fil_CreateUpdateFile (PathFile,".old",PathOldFile,PathNewFile,&NewFile); Fil_CreateUpdateFile (PathFile,".old",PathOldFile,PathNewFile,&NewFile);
/***** Increase or decrease level *****/ /***** Increase or decrease level *****/
switch (IncreaseOrDecreaseLevel) switch (IncreaseOrDecreaseLevel)
{ {
case Syl_INCREASE_LEVEL: case Syl_INCREASE_LEVEL:
if (Syl_LstItemsSyllabus.Lst[Gbl.Syllabus.NumItem].Level > 1) if (Syl_LstItemsSyllabus.Lst[Syllabus.NumItem].Level > 1)
Syl_LstItemsSyllabus.Lst[Gbl.Syllabus.NumItem].Level--; Syl_LstItemsSyllabus.Lst[Syllabus.NumItem].Level--;
break; break;
case Syl_DECREASE_LEVEL: case Syl_DECREASE_LEVEL:
if (Syl_LstItemsSyllabus.Lst[Gbl.Syllabus.NumItem].Level < Syl_MAX_LEVELS_SYLLABUS) if (Syl_LstItemsSyllabus.Lst[Syllabus.NumItem].Level < Syl_MAX_LEVELS_SYLLABUS)
Syl_LstItemsSyllabus.Lst[Gbl.Syllabus.NumItem].Level++; Syl_LstItemsSyllabus.Lst[Syllabus.NumItem].Level++;
break; break;
} }
@ -1201,7 +1233,7 @@ void Syl_ChangeLevelItemSyllabus (Syl_ChangeLevelItem_t IncreaseOrDecreaseLevel)
/***** We are editing a syllabus with the internal editor, /***** We are editing a syllabus with the internal editor,
so change info source to internal editor in database *****/ so change info source to internal editor in database *****/
Inf_SetInfoSrcIntoDB (Syl_LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR : Inf_SetInfoSrcIntoDB (Syl_LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR :
Inf_INFO_SRC_NONE); Inf_INFO_SRC_NONE);
/***** Show the updated syllabus to continue editing it *****/ /***** Show the updated syllabus to continue editing it *****/
Syl_FreeListItemsSyllabus (); Syl_FreeListItemsSyllabus ();
@ -1214,6 +1246,7 @@ void Syl_ChangeLevelItemSyllabus (Syl_ChangeLevelItem_t IncreaseOrDecreaseLevel)
void Syl_InsertItemSyllabus (void) void Syl_InsertItemSyllabus (void)
{ {
struct Syl_Syllabus Syllabus;
char PathFile[PATH_MAX + 1]; char PathFile[PATH_MAX + 1];
char PathOldFile[PATH_MAX + 1]; char PathOldFile[PATH_MAX + 1];
char PathNewFile[PATH_MAX + 1]; char PathNewFile[PATH_MAX + 1];
@ -1221,22 +1254,25 @@ void Syl_InsertItemSyllabus (void)
unsigned NumItem; unsigned NumItem;
char Txt[Syl_MAX_BYTES_TEXT_ITEM + 1]; char Txt[Syl_MAX_BYTES_TEXT_ITEM + 1];
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set syllabus type depending on current action *****/ /***** Set syllabus type depending on current action *****/
Syl_SetSyllabusTypeFromAction (); Syl_SetSyllabusTypeFromAction (&Syllabus);
/***** Load syllabus from XML file to memory *****/ /***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (Gbl.Hierarchy.Crs.CrsCod); Syl_LoadListItemsSyllabusIntoMemory (&Syllabus,Gbl.Hierarchy.Crs.CrsCod);
Gbl.Syllabus.EditionIsActive = true; Syllabus.EditionIsActive = true;
/***** Get item number *****/ /***** Get item number *****/
Syl_GetParamItemNumber (); Syllabus.NumItem = Syl_GetParamItemNumber ();
/***** Get item body *****/ /***** Get item body *****/
Par_GetParToHTML ("Txt",Txt,Syl_MAX_BYTES_TEXT_ITEM); Par_GetParToHTML ("Txt",Txt,Syl_MAX_BYTES_TEXT_ITEM);
/***** Create a new file to do the update *****/ /***** Create a new file to do the update *****/
Syl_BuildPathFileSyllabus (PathFile); Syl_BuildPathFileSyllabus (&Syllabus,PathFile);
Fil_CreateUpdateFile (PathFile,".old",PathOldFile,PathNewFile,&NewFile); Fil_CreateUpdateFile (PathFile,".old",PathOldFile,PathNewFile,&NewFile);
/***** Create the new XML file *****/ /***** Create the new XML file *****/
@ -1244,7 +1280,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.Syllabus.NumItem; NumItem < Syllabus.NumItem;
NumItem++) NumItem++)
Syl_WriteItemFileSyllabus (NewFile,Syl_LstItemsSyllabus.Lst[NumItem].Level,Syl_LstItemsSyllabus.Lst[NumItem].Text); Syl_WriteItemFileSyllabus (NewFile,Syl_LstItemsSyllabus.Lst[NumItem].Level,Syl_LstItemsSyllabus.Lst[NumItem].Text);
@ -1268,7 +1304,7 @@ void Syl_InsertItemSyllabus (void)
/***** We are editing a syllabus with the internal editor, /***** We are editing a syllabus with the internal editor,
so change info source to internal editor in database *****/ so change info source to internal editor in database *****/
Inf_SetInfoSrcIntoDB (Syl_LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR : Inf_SetInfoSrcIntoDB (Syl_LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR :
Inf_INFO_SRC_NONE); Inf_INFO_SRC_NONE);
/***** Show the updated syllabus to continue editing it *****/ /***** Show the updated syllabus to continue editing it *****/
Syl_FreeListItemsSyllabus (); Syl_FreeListItemsSyllabus ();
@ -1281,28 +1317,32 @@ void Syl_InsertItemSyllabus (void)
void Syl_ModifyItemSyllabus (void) void Syl_ModifyItemSyllabus (void)
{ {
struct Syl_Syllabus Syllabus;
char PathFile[PATH_MAX + 1]; char PathFile[PATH_MAX + 1];
char PathOldFile[PATH_MAX + 1]; char PathOldFile[PATH_MAX + 1];
char PathNewFile[PATH_MAX + 1]; char PathNewFile[PATH_MAX + 1];
FILE *NewFile; FILE *NewFile;
/***** Reset syllabus context *****/
Syl_ResetSyllabus (&Syllabus);
/***** Set syllabus type depending on current action *****/ /***** Set syllabus type depending on current action *****/
Syl_SetSyllabusTypeFromAction (); Syl_SetSyllabusTypeFromAction (&Syllabus);
/***** Load syllabus from XML file to memory *****/ /***** Load syllabus from XML file to memory *****/
Syl_LoadListItemsSyllabusIntoMemory (Gbl.Hierarchy.Crs.CrsCod); Syl_LoadListItemsSyllabusIntoMemory (&Syllabus,Gbl.Hierarchy.Crs.CrsCod);
Gbl.Syllabus.EditionIsActive = true; Syllabus.EditionIsActive = true;
/***** Get item number *****/ /***** Get item number *****/
Syl_GetParamItemNumber (); Syllabus.NumItem = Syl_GetParamItemNumber ();
/***** Get item body *****/ /***** Get item body *****/
Par_GetParToHTML ("Txt",Syl_LstItemsSyllabus.Lst[Gbl.Syllabus.NumItem].Text, Par_GetParToHTML ("Txt",Syl_LstItemsSyllabus.Lst[Syllabus.NumItem].Text,
Syl_MAX_BYTES_TEXT_ITEM); 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 (&Syllabus,PathFile);
Fil_CreateUpdateFile (PathFile,".old",PathOldFile,PathNewFile,&NewFile); Fil_CreateUpdateFile (PathFile,".old",PathOldFile,PathNewFile,&NewFile);
/***** Create the new XML file *****/ /***** Create the new XML file *****/
@ -1316,7 +1356,7 @@ void Syl_ModifyItemSyllabus (void)
/***** We are editing a syllabus with the internal editor, /***** We are editing a syllabus with the internal editor,
so change info source to internal editor in database *****/ so change info source to internal editor in database *****/
Inf_SetInfoSrcIntoDB (Syl_LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR : Inf_SetInfoSrcIntoDB (Syl_LstItemsSyllabus.NumItems ? Inf_INFO_SRC_EDITOR :
Inf_INFO_SRC_NONE); Inf_INFO_SRC_NONE);
/***** Show the updated syllabus to continue editing it *****/ /***** Show the updated syllabus to continue editing it *****/
Syl_FreeListItemsSyllabus (); Syl_FreeListItemsSyllabus ();
@ -1327,13 +1367,14 @@ void Syl_ModifyItemSyllabus (void)
/************ Build the path of the file XML with the syllabus ***************/ /************ Build the path of the file XML with the syllabus ***************/
/*****************************************************************************/ /*****************************************************************************/
void Syl_BuildPathFileSyllabus (char *PathFile) void Syl_BuildPathFileSyllabus (const struct Syl_Syllabus *Syllabus,
char *PathFile)
{ {
char Path[PATH_MAX + 1 + NAME_MAX + 1]; char Path[PATH_MAX + 1 + NAME_MAX + 1];
snprintf (Path,sizeof (Path), snprintf (Path,sizeof (Path),
"%s/%s", "%s/%s",
Gbl.Syllabus.PathDir,Cfg_SYLLABUS_FILENAME); Syllabus->PathDir,Cfg_SYLLABUS_FILENAME);
Str_Copy (PathFile,Path, Str_Copy (PathFile,Path,
PATH_MAX); PATH_MAX);
} }
@ -1342,19 +1383,20 @@ void Syl_BuildPathFileSyllabus (char *PathFile)
/*********************** Open file with the syllabus *************************/ /*********************** Open file with the syllabus *************************/
/*****************************************************************************/ /*****************************************************************************/
void Syl_OpenSyllabusFile (const char *PathDir,char *PathFile) static void Syl_OpenSyllabusFile (const struct Syl_Syllabus *Syllabus,
char *PathFile)
{ {
if (Gbl.F.XML == NULL) // If it's not open in this moment... if (Gbl.F.XML == NULL) // If it's not open in this moment...
{ {
/* If the directory does not exist, create it */ /* If the directory does not exist, create it */
Fil_CreateDirIfNotExists (PathDir); Fil_CreateDirIfNotExists (Syllabus->PathDir);
/* Open the file for reading */ /* Open the file for reading */
Syl_BuildPathFileSyllabus (PathFile); Syl_BuildPathFileSyllabus (Syllabus,PathFile);
if ((Gbl.F.XML = fopen (PathFile,"rb")) == NULL) if ((Gbl.F.XML = fopen (PathFile,"rb")) == NULL)
{ {
/* Can't open the file */ /* Can't open the file */
if (!Fil_CheckIfPathExists (PathDir)) // Strange error, since it is just created if (!Fil_CheckIfPathExists (Syllabus->PathDir)) // Strange error, since it is just created
Lay_ShowErrorAndExit ("Can not open syllabus file."); Lay_ShowErrorAndExit ("Can not open syllabus file.");
else else
{ {

View File

@ -69,20 +69,30 @@ struct MoveSubtrees
bool MovAllowed; bool MovAllowed;
}; };
struct Syl_Syllabus
{
char PathDir[PATH_MAX + 1];
unsigned NumItem; // Item being edited
unsigned ParamNumItem; // Used as parameter in forms
bool EditionIsActive;
Syl_WhichSyllabus_t WhichSyllabus;
};
/*****************************************************************************/ /*****************************************************************************/
/***************************** Public prototypes *****************************/ /***************************** Public prototypes *****************************/
/*****************************************************************************/ /*****************************************************************************/
void Syl_GetParamWhichSyllabus (void); void Syl_ResetSyllabus (struct Syl_Syllabus *Syllabus);
void Syl_PutFormWhichSyllabus (void);
void Syl_GetParamItemNumber (void); Syl_WhichSyllabus_t Syl_GetParamWhichSyllabus (void);
void Syl_PutFormWhichSyllabus (Syl_WhichSyllabus_t SyllabusSelected);
bool Syl_CheckSyllabus (long CrsCod,Inf_InfoType_t InfoType); bool Syl_CheckSyllabus (struct Syl_Syllabus *Syllabus,long CrsCod);
bool Syl_CheckAndEditSyllabus (void); bool Syl_CheckAndEditSyllabus (struct Syl_Syllabus *Syllabus);
void Syl_EditSyllabus (void); void Syl_EditSyllabus (void);
void Syl_LoadListItemsSyllabusIntoMemory (long CrsCod); void Syl_LoadListItemsSyllabusIntoMemory (struct Syl_Syllabus *Syllabus,
long CrsCod);
void Syl_FreeListItemsSyllabus (void); void Syl_FreeListItemsSyllabus (void);
int Syl_ReadLevelItemSyllabus (void); int Syl_ReadLevelItemSyllabus (void);
@ -92,16 +102,16 @@ void Syl_WriteSyllabusIntoHTMLTmpFile (FILE *FileHTMLTmp);
void Syl_RemoveItemSyllabus (void); void Syl_RemoveItemSyllabus (void);
void Syl_UpItemSyllabus (void); void Syl_UpItemSyllabus (void);
void Syl_DownItemSyllabus (void); void Syl_DownItemSyllabus (void);
void Syl_ChangePlaceItemSyllabus (Syl_ChangePosItem_t UpOrDownPos);
void Syl_CalculateUpSubtreeSyllabus (struct MoveSubtrees *Subtree,unsigned NumItem); void Syl_CalculateUpSubtreeSyllabus (struct MoveSubtrees *Subtree,unsigned NumItem);
void Syl_CalculateDownSubtreeSyllabus (struct MoveSubtrees *Subtree,unsigned NumItem); void Syl_CalculateDownSubtreeSyllabus (struct MoveSubtrees *Subtree,unsigned NumItem);
void Syl_RightItemSyllabus (void); void Syl_RightItemSyllabus (void);
void Syl_LeftItemSyllabus (void); void Syl_LeftItemSyllabus (void);
void Syl_ChangeLevelItemSyllabus (Syl_ChangeLevelItem_t IncreaseOrDecreaseLevel);
void Syl_InsertItemSyllabus (void); void Syl_InsertItemSyllabus (void);
void Syl_ModifyItemSyllabus (void); void Syl_ModifyItemSyllabus (void);
void Syl_BuildPathFileSyllabus (char *PathFile); void Syl_BuildPathFileSyllabus (const struct Syl_Syllabus *Syllabus,
void Syl_OpenSyllabusFile (const char *PathDir,char *PathFile); char *PathFile);
void Syl_WriteStartFileSyllabus (FILE *FileSyllabus); void Syl_WriteStartFileSyllabus (FILE *FileSyllabus);
void Syl_WriteAllItemsFileSyllabus (FILE *FileSyllabus); void Syl_WriteAllItemsFileSyllabus (FILE *FileSyllabus);
void Syl_WriteItemFileSyllabus (FILE *FileSyllabus,int Level,const char *Text); void Syl_WriteItemFileSyllabus (FILE *FileSyllabus,int Level,const char *Text);