From 47d68b773e73d430063d3496d8d05cb53b0cbb11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sun, 29 Dec 2019 14:20:17 +0100 Subject: [PATCH] Version19.104.1 --- swad_action.c | 11 +-- swad_changelog.h | 3 +- swad_course.c | 186 +------------------------------------------ swad_course.h | 11 +-- swad_course_config.c | 175 ++++++++++++++++++++++++++++++++++++++++ swad_course_config.h | 6 ++ 6 files changed, 197 insertions(+), 195 deletions(-) diff --git a/swad_action.c b/swad_action.c index deb8f75b..490ac5b1 100644 --- a/swad_action.c +++ b/swad_action.c @@ -40,6 +40,7 @@ #include "swad_cookie.h" #include "swad_country.h" #include "swad_course.h" +#include "swad_course_config.h" #include "swad_chat.h" #include "swad_database.h" #include "swad_date.h" @@ -1912,11 +1913,11 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = // Actions not in menu: [ActPrnCrsInf ] = {1028,-1,TabUnk,ActSeeCrsInf ,0x3F8,0x3C7, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,CrsCfg_PrintConfiguration ,NULL}, - [ActChgCrsDegCfg ] = {1587,-1,TabUnk,ActSeeCrsInf ,0x380,0x380, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Crs_ChangeCrsDegInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, - [ActRenCrsShoCfg ] = {1601,-1,TabUnk,ActSeeCrsInf ,0x3C0,0x3C0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Crs_RenameCourseShortInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, - [ActRenCrsFulCfg ] = {1600,-1,TabUnk,ActSeeCrsInf ,0x3C0,0x3C0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Crs_RenameCourseFullInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, - [ActChgInsCrsCodCfg ] = {1024,-1,TabUnk,ActSeeCrsInf ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Crs_ChangeInsCrsCodInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, - [ActChgCrsYeaCfg ] = {1573,-1,TabUnk,ActSeeCrsInf ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Crs_ChangeCrsYearInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, + [ActChgCrsDegCfg ] = {1587,-1,TabUnk,ActSeeCrsInf ,0x380,0x380, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_ChangeCrsDegInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, + [ActRenCrsShoCfg ] = {1601,-1,TabUnk,ActSeeCrsInf ,0x3C0,0x3C0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_RenameCourseShortInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, + [ActRenCrsFulCfg ] = {1600,-1,TabUnk,ActSeeCrsInf ,0x3C0,0x3C0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_RenameCourseFullInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, + [ActChgInsCrsCodCfg ] = {1024,-1,TabUnk,ActSeeCrsInf ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_ChangeInsCrsCodInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, + [ActChgCrsYeaCfg ] = {1573,-1,TabUnk,ActSeeCrsInf ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_ChangeCrsYearInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, [ActEdiCrsInf ] = { 848,-1,TabUnk,ActSeeCrsInf ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Inf_FormsToSelSendInfo ,NULL}, [ActEdiTchGui ] = { 785,-1,TabUnk,ActSeeTchGui ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Inf_FormsToSelSendInfo ,NULL}, diff --git a/swad_changelog.h b/swad_changelog.h index c9953db0..af3c006f 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -492,7 +492,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.104 (2019-12-29)" +#define Log_PLATFORM_VERSION "SWAD 19.104.1 (2019-12-29)" #define CSS_FILE "swad19.101.5.css" #define JS_FILE "swad19.91.1.js" /* @@ -502,6 +502,7 @@ ps2pdf source.ps destination.pdf Version 19.10x: Dec 29, 2019 Map in country information. (? lines) Version 19.10x: Dec 29, 2019 Map in institution information. (? lines) + Version 19.104.1: Dec 29, 2019 Code refactoring in course configuration. (249536 lines) Version 19.104: Dec 29, 2019 New module swad_centre_config for centre configuration. (249534 lines) Version 19.103: Dec 29, 2019 New module swad_degree_config for degree configuration. (249457 lines) Version 19.102: Dec 29, 2019 New module swad_course_config for course configuration. (249397 lines) diff --git a/swad_course.c b/swad_course.c index 75551e39..498c54f2 100644 --- a/swad_course.c +++ b/swad_course.c @@ -90,19 +90,12 @@ static void Crs_GetParamsNewCourse (struct Course *Crs); static void Crs_CreateCourse (unsigned Status); static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row); -static void Crs_UpdateCrsDegDB (long CrsCod,long DegCod); - -static void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear); - static void Crs_GetShortNamesByCod (long CrsCod, char CrsShortName[Hie_MAX_BYTES_SHRT_NAME + 1], char DegShortName[Hie_MAX_BYTES_SHRT_NAME + 1]); static void Crs_EmptyCourseCompletely (long CrsCod); -static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName); -static bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod, - long DegCod,unsigned Year); static void Crs_UpdateCrsNameDB (long CrsCod,const char *FieldName,const char *NewCrsName); static void Crs_PutButtonToGoToCrs (void); @@ -1882,35 +1875,6 @@ static void Crs_EmptyCourseCompletely (long CrsCod) } } -/*****************************************************************************/ -/***** Change the institutional code of a course in course configuration *****/ -/*****************************************************************************/ - -void Crs_ChangeInsCrsCodInConfig (void) - { - extern const char *Txt_The_institutional_code_of_the_course_X_has_changed_to_Y; - extern const char *Txt_The_institutional_code_of_the_course_X_has_not_changed; - char NewInstitutionalCrsCod[Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD + 1]; - - /***** Get institutional code from form *****/ - Par_GetParToText ("InsCrsCod",NewInstitutionalCrsCod,Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD); - - /***** Change the institutional course code *****/ - if (strcmp (NewInstitutionalCrsCod,Gbl.Hierarchy.Crs.InstitutionalCrsCod)) - { - Crs_UpdateInstitutionalCrsCod (&Gbl.Hierarchy.Crs,NewInstitutionalCrsCod); - - Ale_CreateAlert (Ale_SUCCESS,NULL, - Txt_The_institutional_code_of_the_course_X_has_changed_to_Y, - Gbl.Hierarchy.Crs.ShrtName, - NewInstitutionalCrsCod); - } - else // The same institutional code - Ale_CreateAlert (Ale_INFO,NULL, - Txt_The_institutional_code_of_the_course_X_has_not_changed, - Gbl.Hierarchy.Crs.ShrtName); - } - /*****************************************************************************/ /************** Change the institutional code of a course ********************/ /*****************************************************************************/ @@ -1954,134 +1918,6 @@ void Crs_ChangeInsCrsCod (void) Lay_NoPermissionExit (); } -/*****************************************************************************/ -/***************** Change the degree of the current course *******************/ -/*****************************************************************************/ - -void Crs_ChangeCrsDegInConfig (void) - { - extern const char *Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z; - extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; - extern const char *Txt_The_course_X_has_been_moved_to_the_degree_Y; - struct Degree NewDeg; - - /***** Get parameter with degree code *****/ - NewDeg.DegCod = Deg_GetAndCheckParamOtherDegCod (1); - - /***** Check if degree has changed *****/ - if (NewDeg.DegCod != Gbl.Hierarchy.Crs.DegCod) - { - /***** Get data of new degree *****/ - Deg_GetDataOfDegreeByCod (&NewDeg,Deg_GET_BASIC_DATA); - - /***** If name of course was in database in the new degree... *****/ - if (Crs_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Hierarchy.Crs.ShrtName,-1L, - NewDeg.DegCod,Gbl.Hierarchy.Crs.Year)) - Ale_CreateAlert (Ale_WARNING,NULL, - Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z, - Txt_YEAR_OF_DEGREE[Gbl.Hierarchy.Crs.Year], - NewDeg.FullName, - Gbl.Hierarchy.Crs.ShrtName); - else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Hierarchy.Crs.FullName,-1L, - NewDeg.DegCod,Gbl.Hierarchy.Crs.Year)) - Ale_CreateAlert (Ale_WARNING,NULL, - Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z, - Txt_YEAR_OF_DEGREE[Gbl.Hierarchy.Crs.Year], - NewDeg.FullName, - Gbl.Hierarchy.Crs.FullName); - else // Update degree in database - { - /***** Update degree in table of courses *****/ - Crs_UpdateCrsDegDB (Gbl.Hierarchy.Crs.CrsCod,NewDeg.DegCod); - Gbl.Hierarchy.Crs.DegCod = - Gbl.Hierarchy.Deg.DegCod = NewDeg.DegCod; - - /***** Initialize again current course, degree, centre... *****/ - Hie_InitHierarchy (); - - /***** Create alert to show the change made *****/ - Ale_CreateAlert (Ale_SUCCESS,NULL, - Txt_The_course_X_has_been_moved_to_the_degree_Y, - Gbl.Hierarchy.Crs.FullName, - Gbl.Hierarchy.Deg.FullName); - } - } - } - -/*****************************************************************************/ -/** Show message of success after changing a course in course configuration **/ -/*****************************************************************************/ - -void CrsCfg_ContEditAfterChgCrsInConfig (void) - { - /***** Write error/success message *****/ - Ale_ShowAlerts (NULL); - - /***** Show the form again *****/ - Crs_ShowIntroduction (); - } - -/*****************************************************************************/ -/********************** Update degree in table of courses ********************/ -/*****************************************************************************/ - -static void Crs_UpdateCrsDegDB (long CrsCod,long DegCod) - { - /***** Update degree in table of courses *****/ - DB_QueryUPDATE ("can not move course to another degree", - "UPDATE courses SET DegCod=%ld WHERE CrsCod=%ld", - DegCod,CrsCod); - } - -/*****************************************************************************/ -/*********** Change the year of a course in course configuration *************/ -/*****************************************************************************/ - -void Crs_ChangeCrsYearInConfig (void) - { - extern const char *Txt_The_course_X_already_exists_in_year_Y; - extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; - extern const char *Txt_The_year_of_the_course_X_has_changed; - extern const char *Txt_The_year_X_is_not_allowed; - char YearStr[2 + 1]; - unsigned NewYear; - - /***** Get parameter with year/semester *****/ - Par_GetParToText ("OthCrsYear",YearStr,2); - NewYear = Deg_ConvStrToYear (YearStr); - - if (NewYear <= Deg_MAX_YEARS_PER_DEGREE) // If year is valid - { - /***** If name of course was in database in the new year... *****/ - if (Crs_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Hierarchy.Crs.ShrtName,-1L, - Gbl.Hierarchy.Crs.DegCod,NewYear)) - Ale_CreateAlert (Ale_WARNING,NULL, - Txt_The_course_X_already_exists_in_year_Y, - Gbl.Hierarchy.Crs.ShrtName, - Txt_YEAR_OF_DEGREE[NewYear]); - else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Hierarchy.Crs.FullName,-1L, - Gbl.Hierarchy.Crs.DegCod,NewYear)) - Ale_CreateAlert (Ale_WARNING,NULL, - Txt_The_course_X_already_exists_in_year_Y, - Gbl.Hierarchy.Crs.FullName, - Txt_YEAR_OF_DEGREE[NewYear]); - else // Update year in database - { - /***** Update year in table of courses *****/ - Crs_UpdateCrsYear (&Gbl.Hierarchy.Crs,NewYear); - - /***** Create alert to show the change made *****/ - Ale_CreateAlert (Ale_SUCCESS,NULL, - Txt_The_year_of_the_course_X_has_changed, - Gbl.Hierarchy.Crs.ShrtName); - } - } - else // Year not valid - Ale_CreateAlert (Ale_WARNING,NULL, - Txt_The_year_X_is_not_allowed, - NewYear); - } - /*****************************************************************************/ /************************ Change the year of a course ************************/ /*****************************************************************************/ @@ -2149,7 +1985,7 @@ void Crs_ChangeCrsYear (void) /****************** Change the year/semester of a course *********************/ /*****************************************************************************/ -static void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear) +void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear) { /***** Update year/semester in table of courses *****/ DB_QueryUPDATE ("can not update the year of a course", @@ -2201,25 +2037,11 @@ void Crs_RenameCourseFull (void) Crs_RenameCourse (Crs_EditingCrs,Cns_FULL_NAME); } -/*****************************************************************************/ -/*************** Change the name of a course in configuration ****************/ -/*****************************************************************************/ - -void Crs_RenameCourseShortInConfig (void) - { - Crs_RenameCourse (&Gbl.Hierarchy.Crs,Cns_SHRT_NAME); - } - -void Crs_RenameCourseFullInConfig (void) - { - Crs_RenameCourse (&Gbl.Hierarchy.Crs,Cns_FULL_NAME); - } - /*****************************************************************************/ /************************ Change the name of a course ************************/ /*****************************************************************************/ -static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName) +void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName) { extern const char *Txt_The_course_X_already_exists; extern const char *Txt_The_name_of_the_course_X_has_changed_to_Y; @@ -2299,8 +2121,8 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull /********** Check if the name of course exists in existing courses ***********/ /*****************************************************************************/ -static bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod, - long DegCod,unsigned Year) +bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod, + long DegCod,unsigned Year) { /***** Get number of courses in a year of a degree and with a name from database *****/ return (DB_QueryCOUNT ("can not check if the name" diff --git a/swad_course.h b/swad_course.h index 50ee6ca6..74ef6812 100644 --- a/swad_course.h +++ b/swad_course.h @@ -99,8 +99,6 @@ typedef enum /*****************************************************************************/ void Crs_ShowIntroduction (void); -void CrsCfg_PrintConfiguration (void); -void CrsCfg_ContEditAfterChgCrsInConfig (void); unsigned Crs_GetNumCrssTotal (void); unsigned Crs_GetNumCrssInCty (long CtyCod); @@ -123,16 +121,15 @@ void Crs_RemoveCourse (void); bool Crs_GetDataOfCourseByCod (struct Course *Crs, Crs_GetExtraData_t GetExtraData); void Crs_RemoveCourseCompletely (long CrsCod); -void Crs_ChangeInsCrsCodInConfig (void); void Crs_ChangeInsCrsCod (void); -void Crs_ChangeCrsDegInConfig (void); -void Crs_ChangeCrsYearInConfig (void); void Crs_ChangeCrsYear (void); +void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear); void Crs_UpdateInstitutionalCrsCod (struct Course *Crs,const char *NewInstitutionalCrsCod); void Crs_RenameCourseShort (void); void Crs_RenameCourseFull (void); -void Crs_RenameCourseShortInConfig (void); -void Crs_RenameCourseFullInConfig (void); +void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName); +bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod, + long DegCod,unsigned Year); void Crs_ChangeCrsStatus (void); void Crs_ContEditAfterChgCrs (void); diff --git a/swad_course_config.c b/swad_course_config.c index 562e9263..43376978 100644 --- a/swad_course_config.c +++ b/swad_course_config.c @@ -27,7 +27,9 @@ #include // For boolean type #include // For NULL +#include // For string functions +#include "swad_database.h" #include "swad_form.h" #include "swad_global.h" #include "swad_HTML.h" @@ -69,6 +71,8 @@ static void CrsCfg_QR (void); static void CrsCfg_NumUsrsInCrs (Rol_Role_t Role); static void CrsCfg_Indicators (void); +static void CrsCfg_UpdateCrsDegDB (long CrsCod,long DegCod); + /*****************************************************************************/ /***************** Configuration of the current course ***********************/ /*****************************************************************************/ @@ -466,3 +470,174 @@ static void CrsCfg_Indicators (void) HTM_TR_End (); } + +/*****************************************************************************/ +/***************** Change the degree of the current course *******************/ +/*****************************************************************************/ + +void CrsCfg_ChangeCrsDegInConfig (void) + { + extern const char *Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z; + extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; + extern const char *Txt_The_course_X_has_been_moved_to_the_degree_Y; + struct Degree NewDeg; + + /***** Get parameter with degree code *****/ + NewDeg.DegCod = Deg_GetAndCheckParamOtherDegCod (1); + + /***** Check if degree has changed *****/ + if (NewDeg.DegCod != Gbl.Hierarchy.Crs.DegCod) + { + /***** Get data of new degree *****/ + Deg_GetDataOfDegreeByCod (&NewDeg,Deg_GET_BASIC_DATA); + + /***** If name of course was in database in the new degree... *****/ + if (Crs_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Hierarchy.Crs.ShrtName,-1L, + NewDeg.DegCod,Gbl.Hierarchy.Crs.Year)) + Ale_CreateAlert (Ale_WARNING,NULL, + Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z, + Txt_YEAR_OF_DEGREE[Gbl.Hierarchy.Crs.Year], + NewDeg.FullName, + Gbl.Hierarchy.Crs.ShrtName); + else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Hierarchy.Crs.FullName,-1L, + NewDeg.DegCod,Gbl.Hierarchy.Crs.Year)) + Ale_CreateAlert (Ale_WARNING,NULL, + Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z, + Txt_YEAR_OF_DEGREE[Gbl.Hierarchy.Crs.Year], + NewDeg.FullName, + Gbl.Hierarchy.Crs.FullName); + else // Update degree in database + { + /***** Update degree in table of courses *****/ + CrsCfg_UpdateCrsDegDB (Gbl.Hierarchy.Crs.CrsCod,NewDeg.DegCod); + Gbl.Hierarchy.Crs.DegCod = + Gbl.Hierarchy.Deg.DegCod = NewDeg.DegCod; + + /***** Initialize again current course, degree, centre... *****/ + Hie_InitHierarchy (); + + /***** Create alert to show the change made *****/ + Ale_CreateAlert (Ale_SUCCESS,NULL, + Txt_The_course_X_has_been_moved_to_the_degree_Y, + Gbl.Hierarchy.Crs.FullName, + Gbl.Hierarchy.Deg.FullName); + } + } + } + +/*****************************************************************************/ +/********************** Update degree in table of courses ********************/ +/*****************************************************************************/ + +static void CrsCfg_UpdateCrsDegDB (long CrsCod,long DegCod) + { + /***** Update degree in table of courses *****/ + DB_QueryUPDATE ("can not move course to another degree", + "UPDATE courses SET DegCod=%ld WHERE CrsCod=%ld", + DegCod,CrsCod); + } + +/*****************************************************************************/ +/*************** Change the name of a course in configuration ****************/ +/*****************************************************************************/ + +void CrsCfg_RenameCourseShortInConfig (void) + { + Crs_RenameCourse (&Gbl.Hierarchy.Crs,Cns_SHRT_NAME); + } + +void CrsCfg_RenameCourseFullInConfig (void) + { + Crs_RenameCourse (&Gbl.Hierarchy.Crs,Cns_FULL_NAME); + } + +/*****************************************************************************/ +/*********** Change the year of a course in course configuration *************/ +/*****************************************************************************/ + +void CrsCfg_ChangeCrsYearInConfig (void) + { + extern const char *Txt_The_course_X_already_exists_in_year_Y; + extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; + extern const char *Txt_The_year_of_the_course_X_has_changed; + extern const char *Txt_The_year_X_is_not_allowed; + char YearStr[2 + 1]; + unsigned NewYear; + + /***** Get parameter with year/semester *****/ + Par_GetParToText ("OthCrsYear",YearStr,2); + NewYear = Deg_ConvStrToYear (YearStr); + + if (NewYear <= Deg_MAX_YEARS_PER_DEGREE) // If year is valid + { + /***** If name of course was in database in the new year... *****/ + if (Crs_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Hierarchy.Crs.ShrtName,-1L, + Gbl.Hierarchy.Crs.DegCod,NewYear)) + Ale_CreateAlert (Ale_WARNING,NULL, + Txt_The_course_X_already_exists_in_year_Y, + Gbl.Hierarchy.Crs.ShrtName, + Txt_YEAR_OF_DEGREE[NewYear]); + else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Hierarchy.Crs.FullName,-1L, + Gbl.Hierarchy.Crs.DegCod,NewYear)) + Ale_CreateAlert (Ale_WARNING,NULL, + Txt_The_course_X_already_exists_in_year_Y, + Gbl.Hierarchy.Crs.FullName, + Txt_YEAR_OF_DEGREE[NewYear]); + else // Update year in database + { + /***** Update year in table of courses *****/ + Crs_UpdateCrsYear (&Gbl.Hierarchy.Crs,NewYear); + + /***** Create alert to show the change made *****/ + Ale_CreateAlert (Ale_SUCCESS,NULL, + Txt_The_year_of_the_course_X_has_changed, + Gbl.Hierarchy.Crs.ShrtName); + } + } + else // Year not valid + Ale_CreateAlert (Ale_WARNING,NULL, + Txt_The_year_X_is_not_allowed, + NewYear); + } + +/*****************************************************************************/ +/***** Change the institutional code of a course in course configuration *****/ +/*****************************************************************************/ + +void CrsCfg_ChangeInsCrsCodInConfig (void) + { + extern const char *Txt_The_institutional_code_of_the_course_X_has_changed_to_Y; + extern const char *Txt_The_institutional_code_of_the_course_X_has_not_changed; + char NewInstitutionalCrsCod[Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD + 1]; + + /***** Get institutional code from form *****/ + Par_GetParToText ("InsCrsCod",NewInstitutionalCrsCod,Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD); + + /***** Change the institutional course code *****/ + if (strcmp (NewInstitutionalCrsCod,Gbl.Hierarchy.Crs.InstitutionalCrsCod)) + { + Crs_UpdateInstitutionalCrsCod (&Gbl.Hierarchy.Crs,NewInstitutionalCrsCod); + + Ale_CreateAlert (Ale_SUCCESS,NULL, + Txt_The_institutional_code_of_the_course_X_has_changed_to_Y, + Gbl.Hierarchy.Crs.ShrtName, + NewInstitutionalCrsCod); + } + else // The same institutional code + Ale_CreateAlert (Ale_INFO,NULL, + Txt_The_institutional_code_of_the_course_X_has_not_changed, + Gbl.Hierarchy.Crs.ShrtName); + } + +/*****************************************************************************/ +/** Show message of success after changing a course in course configuration **/ +/*****************************************************************************/ + +void CrsCfg_ContEditAfterChgCrsInConfig (void) + { + /***** Write error/success message *****/ + Ale_ShowAlerts (NULL); + + /***** Show the form again *****/ + Crs_ShowIntroduction (); + } diff --git a/swad_course_config.h b/swad_course_config.h index 8fa4d07f..7022fe8a 100644 --- a/swad_course_config.h +++ b/swad_course_config.h @@ -43,6 +43,12 @@ void CrsCfg_Configuration (bool PrintView); void CrsCfg_PrintConfiguration (void); + +void CrsCfg_ChangeCrsDegInConfig (void); +void CrsCfg_RenameCourseShortInConfig (void); +void CrsCfg_RenameCourseFullInConfig (void); +void CrsCfg_ChangeCrsYearInConfig (void); +void CrsCfg_ChangeInsCrsCodInConfig (void); void CrsCfg_ContEditAfterChgCrsInConfig (void); #endif