mirror of https://github.com/acanas/swad-core.git
Version 16.212
This commit is contained in:
parent
cb1bb78847
commit
a8f24fc3c2
|
@ -1342,12 +1342,6 @@ a:hover /* Default ==> underlined */
|
|||
background-image:-webkit-linear-gradient(rgba(0,0,0,0),rgba(0,0,0,0.2)); /* Safari */
|
||||
background-image:linear-gradient(rgba(0,0,0,0),rgba(0,0,0,0.2));
|
||||
}
|
||||
.BUTTONS_AFTER_ALERT
|
||||
{
|
||||
text-align:center;
|
||||
vertical-align:middle;
|
||||
padding:8px 0 16px 0;
|
||||
}
|
||||
|
||||
/********************************** Notice ***********************************/
|
||||
.NOTICE_CONTAINER_ACTIVE
|
||||
|
|
|
@ -235,13 +235,14 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 16.211.2 (2017-05-10)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 16.212 (2017-05-10)"
|
||||
#define CSS_FILE "swad16.209.3.css"
|
||||
#define JS_FILE "swad16.206.3.js"
|
||||
|
||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
|
||||
/*
|
||||
Version 16.212: May 11, 2017 Changes in edition of courses and degrees. (218870 lines)
|
||||
Version 16.211.2: May 11, 2017 Fixed bug in alerts. (218879 lines)
|
||||
Version 16.211.1: May 11, 2017 Change in layout of forms to edit groups. (218882 lines)
|
||||
Version 16.211: May 10, 2017 Code refactoring related to alerts. (218879 lines)
|
||||
|
|
133
swad_course.c
133
swad_course.c
|
@ -95,7 +95,7 @@ static void Crs_PutHeadCoursesForEdition (void);
|
|||
static void Crs_RecFormRequestOrCreateCrs (unsigned Status);
|
||||
static void Crs_GetParamsNewCourse (struct Course *Crs);
|
||||
|
||||
static void Crs_CreateCourse (struct Course *Crs,unsigned Status);
|
||||
static void Crs_CreateCourse (unsigned Status);
|
||||
static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row);
|
||||
|
||||
static void Crs_UpdateCrsDegDB (long CrsCod,long DegCod);
|
||||
|
@ -1614,7 +1614,6 @@ static void Crs_PutFormToCreateCourse (void)
|
|||
extern const char *Txt_New_course;
|
||||
extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE];
|
||||
extern const char *Txt_Create_course;
|
||||
struct Course *Crs;
|
||||
unsigned Year;
|
||||
|
||||
/***** Start form *****/
|
||||
|
@ -1625,9 +1624,6 @@ static void Crs_PutFormToCreateCourse (void)
|
|||
else
|
||||
Lay_ShowErrorAndExit ("You can not edit courses.");
|
||||
|
||||
/***** Course data *****/
|
||||
Crs = &Gbl.Degs.EditingCrs;
|
||||
|
||||
/***** Write heading *****/
|
||||
Lay_StartRoundFrameTable (NULL,Txt_New_course,NULL,NULL,2);
|
||||
Crs_PutHeadCoursesForEdition ();
|
||||
|
@ -1646,7 +1642,7 @@ static void Crs_PutFormToCreateCourse (void)
|
|||
" class=\"INPUT_INS_CODE\" />"
|
||||
"</td>",
|
||||
Crs_MAX_CHARS_INSTITUTIONAL_CRS_COD,
|
||||
Crs->InstitutionalCrsCod);
|
||||
Gbl.Degs.EditingCrs.InstitutionalCrsCod);
|
||||
|
||||
/***** Year *****/
|
||||
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
|
||||
|
@ -1656,8 +1652,8 @@ static void Crs_PutFormToCreateCourse (void)
|
|||
Year++)
|
||||
fprintf (Gbl.F.Out,"<option value=\"%u\"%s>%s</option>",
|
||||
Year,
|
||||
Year == Crs->Year ? " selected=\"selected\"" :
|
||||
"",
|
||||
Year == Gbl.Degs.EditingCrs.Year ? " selected=\"selected\"" :
|
||||
"",
|
||||
Txt_YEAR_OF_DEGREE[Year]);
|
||||
fprintf (Gbl.F.Out,"</select>"
|
||||
"</td>");
|
||||
|
@ -1669,7 +1665,7 @@ static void Crs_PutFormToCreateCourse (void)
|
|||
" class=\"INPUT_SHORT_NAME\""
|
||||
" required=\"required\" />"
|
||||
"</td>",
|
||||
Hie_MAX_CHARS_SHRT_NAME,Crs->ShrtName);
|
||||
Hie_MAX_CHARS_SHRT_NAME,Gbl.Degs.EditingCrs.ShrtName);
|
||||
|
||||
/***** Course full name *****/
|
||||
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE\">"
|
||||
|
@ -1678,7 +1674,7 @@ static void Crs_PutFormToCreateCourse (void)
|
|||
" class=\"INPUT_FULL_NAME\""
|
||||
" required=\"required\" />"
|
||||
"</td>",
|
||||
Hie_MAX_CHARS_FULL_NAME,Crs->FullName);
|
||||
Hie_MAX_CHARS_FULL_NAME,Gbl.Degs.EditingCrs.FullName);
|
||||
|
||||
/***** Current number of teachers in this course *****/
|
||||
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE\">"
|
||||
|
@ -1829,42 +1825,39 @@ static void Crs_RecFormRequestOrCreateCrs (unsigned Status)
|
|||
extern const char *Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_course;
|
||||
extern const char *Txt_The_year_X_is_not_allowed;
|
||||
extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE];
|
||||
struct Course *Crs;
|
||||
struct Degree Deg;
|
||||
|
||||
Crs = &Gbl.Degs.EditingCrs;
|
||||
|
||||
/***** Get parameters from form *****/
|
||||
/* Set course degree */
|
||||
Deg.DegCod = Crs->DegCod = Gbl.CurrentDeg.Deg.DegCod;
|
||||
Deg.DegCod = Gbl.Degs.EditingCrs.DegCod = Gbl.CurrentDeg.Deg.DegCod;
|
||||
|
||||
/* Get parameters of the new course */
|
||||
Crs_GetParamsNewCourse (Crs);
|
||||
Crs_GetParamsNewCourse (&Gbl.Degs.EditingCrs);
|
||||
|
||||
/***** Check if year is correct *****/
|
||||
Deg_GetDataOfDegreeByCod (&Deg);
|
||||
if (Crs->Year <= Deg_MAX_YEARS_PER_DEGREE) // If year is valid
|
||||
if (Gbl.Degs.EditingCrs.Year <= Deg_MAX_YEARS_PER_DEGREE) // If year is valid
|
||||
{
|
||||
if (Crs->ShrtName[0] &&
|
||||
Crs->FullName[0]) // If there's a course name
|
||||
if (Gbl.Degs.EditingCrs.ShrtName[0] &&
|
||||
Gbl.Degs.EditingCrs.FullName[0]) // If there's a course name
|
||||
{
|
||||
/***** If name of course was in database... *****/
|
||||
if (Crs_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Crs->ShrtName,-1L,
|
||||
Crs->DegCod,Crs->Year))
|
||||
if (Crs_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Degs.EditingCrs.ShrtName,-1L,
|
||||
Gbl.Degs.EditingCrs.DegCod,Gbl.Degs.EditingCrs.Year))
|
||||
{
|
||||
Gbl.Alert.Type = Lay_WARNING;
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_course_X_already_exists,
|
||||
Crs->ShrtName);
|
||||
Gbl.Degs.EditingCrs.ShrtName);
|
||||
}
|
||||
else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Crs->FullName,-1L,
|
||||
Crs->DegCod,Crs->Year))
|
||||
else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Degs.EditingCrs.FullName,-1L,
|
||||
Gbl.Degs.EditingCrs.DegCod,Gbl.Degs.EditingCrs.Year))
|
||||
{
|
||||
Gbl.Alert.Type = Lay_WARNING;
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_course_X_already_exists,
|
||||
Crs->FullName);
|
||||
Gbl.Degs.EditingCrs.FullName);
|
||||
}
|
||||
else // Add new requested course to database
|
||||
Crs_CreateCourse (Crs,Status);
|
||||
Crs_CreateCourse (Status);
|
||||
}
|
||||
else // If there is not a course name
|
||||
{
|
||||
|
@ -1875,7 +1868,8 @@ static void Crs_RecFormRequestOrCreateCrs (unsigned Status)
|
|||
else // Year not valid
|
||||
{
|
||||
Gbl.Alert.Type = Lay_WARNING;
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_year_X_is_not_allowed,Crs->Year);
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_year_X_is_not_allowed,
|
||||
Gbl.Degs.EditingCrs.Year);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1905,8 +1899,9 @@ static void Crs_GetParamsNewCourse (struct Course *Crs)
|
|||
/*****************************************************************************/
|
||||
/************* Add a new requested course to pending requests ****************/
|
||||
/*****************************************************************************/
|
||||
// Gbl.Degs.EditingCrs must hold the course beeing edited
|
||||
|
||||
static void Crs_CreateCourse (struct Course *Crs,unsigned Status)
|
||||
static void Crs_CreateCourse (unsigned Status)
|
||||
{
|
||||
extern const char *Txt_Created_new_course_X;
|
||||
char Query[512 +
|
||||
|
@ -1918,16 +1913,17 @@ static void Crs_CreateCourse (struct Course *Crs,unsigned Status)
|
|||
" (DegCod,Year,InsCrsCod,Status,RequesterUsrCod,ShortName,FullName)"
|
||||
" VALUES"
|
||||
" (%ld,%u,'%s',%u,%ld,'%s','%s')",
|
||||
Crs->DegCod,Crs->Year,
|
||||
Crs->InstitutionalCrsCod,
|
||||
Gbl.Degs.EditingCrs.DegCod,Gbl.Degs.EditingCrs.Year,
|
||||
Gbl.Degs.EditingCrs.InstitutionalCrsCod,
|
||||
Status,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Crs->ShrtName,Crs->FullName);
|
||||
Crs->CrsCod = DB_QueryINSERTandReturnCode (Query,"can not create a new course");
|
||||
Gbl.Degs.EditingCrs.ShrtName,Gbl.Degs.EditingCrs.FullName);
|
||||
Gbl.Degs.EditingCrs.CrsCod = DB_QueryINSERTandReturnCode (Query,"can not create a new course");
|
||||
|
||||
/***** Create success message *****/
|
||||
Gbl.Alert.Type = Lay_SUCCESS;
|
||||
sprintf (Gbl.Alert.Txt,Txt_Created_new_course_X,Crs->FullName);
|
||||
sprintf (Gbl.Alert.Txt,Txt_Created_new_course_X,
|
||||
Gbl.Degs.EditingCrs.FullName);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2286,35 +2282,32 @@ void Crs_ChangeInsCrsCod (void)
|
|||
extern const char *Txt_The_institutional_code_of_the_course_X_has_not_changed;
|
||||
extern const char *Txt_You_dont_have_permission_to_edit_this_course;
|
||||
char NewInstitutionalCrsCod[Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD + 1];
|
||||
struct Course *Crs;
|
||||
|
||||
Crs = &Gbl.Degs.EditingCrs;
|
||||
|
||||
/***** Get parameters from form *****/
|
||||
/* Get course code */
|
||||
Crs->CrsCod = Crs_GetAndCheckParamOtherCrsCod ();
|
||||
Gbl.Degs.EditingCrs.CrsCod = Crs_GetAndCheckParamOtherCrsCod ();
|
||||
|
||||
/* Get institutional code */
|
||||
Par_GetParToText ("InsCrsCod",NewInstitutionalCrsCod,Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD);
|
||||
|
||||
/* Get data of the course */
|
||||
Crs_GetDataOfCourseByCod (Crs);
|
||||
Crs_GetDataOfCourseByCod (&Gbl.Degs.EditingCrs);
|
||||
|
||||
if (Crs_CheckIfICanEdit (Crs))
|
||||
if (Crs_CheckIfICanEdit (&Gbl.Degs.EditingCrs))
|
||||
{
|
||||
/***** Change the institutional course code *****/
|
||||
if (strcmp (NewInstitutionalCrsCod,Crs->InstitutionalCrsCod))
|
||||
if (strcmp (NewInstitutionalCrsCod,Gbl.Degs.EditingCrs.InstitutionalCrsCod))
|
||||
{
|
||||
Crs_UpdateInstitutionalCrsCod (Crs,NewInstitutionalCrsCod);
|
||||
Crs_UpdateInstitutionalCrsCod (&Gbl.Degs.EditingCrs,NewInstitutionalCrsCod);
|
||||
Gbl.Alert.Type = Lay_SUCCESS;
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_institutional_code_of_the_course_X_has_changed_to_Y,
|
||||
Crs->ShrtName,NewInstitutionalCrsCod);
|
||||
Gbl.Degs.EditingCrs.ShrtName,NewInstitutionalCrsCod);
|
||||
}
|
||||
else // The same institutional code
|
||||
{
|
||||
Gbl.Alert.Type = Lay_INFO;
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_institutional_code_of_the_course_X_has_not_changed,
|
||||
Crs->ShrtName);
|
||||
Gbl.Degs.EditingCrs.ShrtName);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2468,54 +2461,51 @@ void Crs_ChangeCrsYear (void)
|
|||
extern const char *Txt_The_year_of_the_course_X_has_changed;
|
||||
extern const char *Txt_The_year_X_is_not_allowed;
|
||||
extern const char *Txt_You_dont_have_permission_to_edit_this_course;
|
||||
struct Course *Crs;
|
||||
struct Degree Deg;
|
||||
char YearStr[2 + 1];
|
||||
unsigned NewYear;
|
||||
|
||||
Crs = &Gbl.Degs.EditingCrs;
|
||||
|
||||
/***** Get parameters from form *****/
|
||||
/* Get course code */
|
||||
Crs->CrsCod = Crs_GetAndCheckParamOtherCrsCod ();
|
||||
Gbl.Degs.EditingCrs.CrsCod = Crs_GetAndCheckParamOtherCrsCod ();
|
||||
|
||||
/* Get parameter with year */
|
||||
Par_GetParToText ("OthCrsYear",YearStr,2);
|
||||
NewYear = Deg_ConvStrToYear (YearStr);
|
||||
|
||||
Crs_GetDataOfCourseByCod (Crs);
|
||||
Crs_GetDataOfCourseByCod (&Gbl.Degs.EditingCrs);
|
||||
|
||||
if (Crs_CheckIfICanEdit (Crs))
|
||||
if (Crs_CheckIfICanEdit (&Gbl.Degs.EditingCrs))
|
||||
{
|
||||
Deg.DegCod = Crs->DegCod;
|
||||
Deg.DegCod = Gbl.Degs.EditingCrs.DegCod;
|
||||
Deg_GetDataOfDegreeByCod (&Deg);
|
||||
|
||||
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",Crs->ShrtName,-1L,
|
||||
Crs->DegCod,NewYear))
|
||||
if (Crs_CheckIfCrsNameExistsInYearOfDeg ("ShortName",Gbl.Degs.EditingCrs.ShrtName,-1L,
|
||||
Gbl.Degs.EditingCrs.DegCod,NewYear))
|
||||
{
|
||||
Gbl.Alert.Type = Lay_WARNING;
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_course_X_already_exists_in_year_Y,
|
||||
Crs->ShrtName,Txt_YEAR_OF_DEGREE[NewYear]);
|
||||
Gbl.Degs.EditingCrs.ShrtName,Txt_YEAR_OF_DEGREE[NewYear]);
|
||||
}
|
||||
else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Crs->FullName,-1L,
|
||||
Crs->DegCod,NewYear))
|
||||
else if (Crs_CheckIfCrsNameExistsInYearOfDeg ("FullName",Gbl.Degs.EditingCrs.FullName,-1L,
|
||||
Gbl.Degs.EditingCrs.DegCod,NewYear))
|
||||
{
|
||||
Gbl.Alert.Type = Lay_WARNING;
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_course_X_already_exists_in_year_Y,
|
||||
Crs->FullName,Txt_YEAR_OF_DEGREE[NewYear]);
|
||||
Gbl.Degs.EditingCrs.FullName,Txt_YEAR_OF_DEGREE[NewYear]);
|
||||
}
|
||||
else // Update year in database
|
||||
{
|
||||
/***** Update year in table of courses *****/
|
||||
Crs_UpdateCrsYear (Crs,NewYear);
|
||||
Crs_UpdateCrsYear (&Gbl.Degs.EditingCrs,NewYear);
|
||||
|
||||
/***** Create message to show the change made *****/
|
||||
Gbl.Alert.Type = Lay_SUCCESS;
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_year_of_the_course_X_has_changed,
|
||||
Crs->ShrtName);
|
||||
Gbl.Degs.EditingCrs.ShrtName);
|
||||
}
|
||||
}
|
||||
else // Year not valid
|
||||
|
@ -2726,16 +2716,13 @@ static void Crs_UpdateCrsNameDB (long CrsCod,const char *FieldName,const char *N
|
|||
void Crs_ChangeCrsStatus (void)
|
||||
{
|
||||
extern const char *Txt_The_status_of_the_course_X_has_changed;
|
||||
struct Course *Crs;
|
||||
char Query[256];
|
||||
Crs_Status_t Status;
|
||||
Crs_StatusTxt_t StatusTxt;
|
||||
|
||||
Crs = &Gbl.Degs.EditingCrs;
|
||||
|
||||
/***** Get parameters from form *****/
|
||||
/* Get course code */
|
||||
Crs->CrsCod = Crs_GetAndCheckParamOtherCrsCod ();
|
||||
Gbl.Degs.EditingCrs.CrsCod = Crs_GetAndCheckParamOtherCrsCod ();
|
||||
|
||||
/* Get parameter with status */
|
||||
Status = (Crs_Status_t)
|
||||
|
@ -2749,18 +2736,17 @@ void Crs_ChangeCrsStatus (void)
|
|||
Status = Crs_GetStatusBitsFromStatusTxt (StatusTxt); // New status
|
||||
|
||||
/***** Get data of course *****/
|
||||
Crs_GetDataOfCourseByCod (Crs);
|
||||
Crs_GetDataOfCourseByCod (&Gbl.Degs.EditingCrs);
|
||||
|
||||
/***** Update status in table of courses *****/
|
||||
sprintf (Query,"UPDATE courses SET Status=%u WHERE CrsCod=%ld",
|
||||
(unsigned) Status,Crs->CrsCod);
|
||||
(unsigned) Status,Gbl.Degs.EditingCrs.CrsCod);
|
||||
DB_QueryUPDATE (Query,"can not update the status of a course");
|
||||
|
||||
Crs->Status = Status;
|
||||
Gbl.Degs.EditingCrs.Status = Status;
|
||||
|
||||
/***** Create message to show the change made *****/
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_status_of_the_course_X_has_changed,
|
||||
Crs->ShrtName);
|
||||
Gbl.Degs.EditingCrs.ShrtName);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -2771,13 +2757,11 @@ void Crs_ContEditAfterChgCrs (void)
|
|||
{
|
||||
bool PutButtonToRequestRegistration;
|
||||
|
||||
/***** Write warning / success message *****/
|
||||
Lay_ShowPendingAlert ();
|
||||
/***** Start alert *****/
|
||||
Lay_ShowAlertAndButton1 (Gbl.Alert.Type,Gbl.Alert.Txt);
|
||||
|
||||
if (Gbl.Alert.Type == Lay_SUCCESS)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<div class=\"BUTTONS_AFTER_ALERT\">");
|
||||
|
||||
/***** Put button to go to course changed *****/
|
||||
Crs_PutButtonToGoToCrs (&Gbl.Degs.EditingCrs);
|
||||
|
||||
|
@ -2806,10 +2790,11 @@ void Crs_ContEditAfterChgCrs (void)
|
|||
}
|
||||
if (PutButtonToRequestRegistration)
|
||||
Crs_PutButtonToRegisterInCrs (&Gbl.Degs.EditingCrs);
|
||||
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
}
|
||||
|
||||
/***** End alert *****/
|
||||
Lay_ShowAlertAndButton2 (ActUnk,NULL,NULL,Lay_NO_BUTTON,NULL);
|
||||
|
||||
/***** Show the form again *****/
|
||||
Crs_EditCourses ();
|
||||
}
|
||||
|
@ -2828,7 +2813,7 @@ static void Crs_PutButtonToGoToCrs (struct Course *Crs)
|
|||
Act_FormStart (ActSeeCrsInf);
|
||||
Crs_PutParamCrsCod (Crs->CrsCod);
|
||||
sprintf (Gbl.Title,Txt_Go_to_X,Crs->ShrtName);
|
||||
Lay_PutConfirmButtonInline (Gbl.Title);
|
||||
Lay_PutConfirmButton (Gbl.Title);
|
||||
Act_FormEnd ();
|
||||
}
|
||||
}
|
||||
|
@ -2845,7 +2830,7 @@ static void Crs_PutButtonToRegisterInCrs (struct Course *Crs)
|
|||
if (Crs->CrsCod != Gbl.CurrentCrs.Crs.CrsCod) // If the course is different to the current one...
|
||||
Crs_PutParamCrsCod (Crs->CrsCod);
|
||||
sprintf (Gbl.Title,Txt_Register_me_in_X,Crs->ShrtName);
|
||||
Lay_PutCreateButtonInline (Gbl.Title);
|
||||
Lay_PutCreateButton (Gbl.Title);
|
||||
Act_FormEnd ();
|
||||
}
|
||||
|
||||
|
|
144
swad_degree.c
144
swad_degree.c
|
@ -92,7 +92,7 @@ static Deg_Status_t Deg_GetStatusBitsFromStatusTxt (Deg_StatusTxt_t StatusTxt);
|
|||
static void Deg_PutFormToCreateDegree (void);
|
||||
static void Deg_PutHeadDegreesForSeeing (void);
|
||||
static void Deg_PutHeadDegreesForEdition (void);
|
||||
static void Deg_CreateDegree (struct Degree *Deg,unsigned Status);
|
||||
static void Deg_CreateDegree (unsigned Status);
|
||||
|
||||
static void Deg_ListDegrees (void);
|
||||
static bool Deg_CheckIfICanCreateDegrees (void);
|
||||
|
@ -115,6 +115,8 @@ static void Deg_UpdateDegNameDB (long DegCod,const char *FieldName,const char *N
|
|||
static void Deg_UpdateDegCtrDB (long DegCod,long CtrCod);
|
||||
static void Deg_UpdateDegWWWDB (long DegCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]);
|
||||
|
||||
static void Deg_PutParamGoToDeg (void);
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* List degrees with pending courses ***********************/
|
||||
/*****************************************************************************/
|
||||
|
@ -1117,8 +1119,9 @@ unsigned Deg_ConvStrToYear (const char *StrYear)
|
|||
/*****************************************************************************/
|
||||
/***************************** Create a new degree ***************************/
|
||||
/*****************************************************************************/
|
||||
// Gbl.Degs.EditingDeg must hold the degree
|
||||
|
||||
static void Deg_CreateDegree (struct Degree *Deg,unsigned Status)
|
||||
static void Deg_CreateDegree (unsigned Status)
|
||||
{
|
||||
extern const char *Txt_Created_new_degree_X;
|
||||
char Query[512 +
|
||||
|
@ -1127,21 +1130,24 @@ static void Deg_CreateDegree (struct Degree *Deg,unsigned Status)
|
|||
Cns_MAX_BYTES_WWW];
|
||||
|
||||
/***** Create a new degree *****/
|
||||
sprintf (Query,"INSERT INTO degrees"
|
||||
" (CtrCod,DegTypCod,Status,RequesterUsrCod,ShortName,FullName,WWW)"
|
||||
" VALUES"
|
||||
" (%ld,%ld,%u,%ld,'%s','%s','%s')",
|
||||
Deg->CtrCod,Deg->DegTypCod,Status,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,Deg->ShrtName,Deg->FullName,Deg->WWW);
|
||||
Deg->DegCod = DB_QueryINSERTandReturnCode (Query,"can not create a new degree");
|
||||
sprintf (Query,"INSERT INTO degrees (CtrCod,DegTypCod,Status,"
|
||||
"RequesterUsrCod,ShortName,FullName,WWW)"
|
||||
" VALUES (%ld,%ld,%u,%ld,'%s','%s','%s')",
|
||||
Gbl.Degs.EditingDeg.CtrCod,
|
||||
Gbl.Degs.EditingDeg.DegTypCod,
|
||||
Status,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
Gbl.Degs.EditingDeg.ShrtName,
|
||||
Gbl.Degs.EditingDeg.FullName,
|
||||
Gbl.Degs.EditingDeg.WWW);
|
||||
Gbl.Degs.EditingDeg.DegCod = DB_QueryINSERTandReturnCode (Query,"can not create a new degree");
|
||||
|
||||
/***** Write success message *****/
|
||||
/***** Write message to show the change made
|
||||
and put button to go to degree created *****/
|
||||
Gbl.Alert.Type = Lay_SUCCESS;
|
||||
sprintf (Gbl.Alert.Txt,Txt_Created_new_degree_X,
|
||||
Deg->FullName);
|
||||
Lay_ShowAlert (Lay_SUCCESS,Gbl.Alert.Txt);
|
||||
|
||||
/***** Put button to go to degree created *****/
|
||||
Deg_PutButtonToGoToDeg (Deg);
|
||||
Gbl.Degs.EditingDeg.FullName);
|
||||
Deg_ShowAlertAndButtonToGoToDeg ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -1521,46 +1527,44 @@ static void Deg_RecFormRequestOrCreateDeg (unsigned Status)
|
|||
extern const char *Txt_The_degree_X_already_exists;
|
||||
extern const char *Txt_You_must_specify_the_web_address_of_the_new_degree;
|
||||
extern const char *Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_degree;
|
||||
struct Degree *Deg;
|
||||
|
||||
Deg = &Gbl.Degs.EditingDeg;
|
||||
|
||||
/***** Get parameters from form *****/
|
||||
/* Set degree centre */
|
||||
Deg->CtrCod = Gbl.CurrentCtr.Ctr.CtrCod;
|
||||
Gbl.Degs.EditingDeg.CtrCod = Gbl.CurrentCtr.Ctr.CtrCod;
|
||||
|
||||
/* Get degree short name */
|
||||
Par_GetParToText ("ShortName",Deg->ShrtName,Hie_MAX_BYTES_SHRT_NAME);
|
||||
Par_GetParToText ("ShortName",Gbl.Degs.EditingDeg.ShrtName,Hie_MAX_BYTES_SHRT_NAME);
|
||||
|
||||
/* Get degree full name */
|
||||
Par_GetParToText ("FullName",Deg->FullName,Hie_MAX_BYTES_FULL_NAME);
|
||||
Par_GetParToText ("FullName",Gbl.Degs.EditingDeg.FullName,Hie_MAX_BYTES_FULL_NAME);
|
||||
|
||||
/* Get degree type */
|
||||
if ((Deg->DegTypCod = DT_GetParamOtherDegTypCod ()) <= 0)
|
||||
if ((Gbl.Degs.EditingDeg.DegTypCod = DT_GetParamOtherDegTypCod ()) <= 0)
|
||||
Lay_ShowAlert (Lay_ERROR,"Wrong type of degree.");
|
||||
|
||||
/* Get degree WWW */
|
||||
Par_GetParToText ("WWW",Deg->WWW,Cns_MAX_BYTES_WWW);
|
||||
Par_GetParToText ("WWW",Gbl.Degs.EditingDeg.WWW,Cns_MAX_BYTES_WWW);
|
||||
|
||||
if (Deg->ShrtName[0] && Deg->FullName[0]) // If there's a degree name
|
||||
if (Gbl.Degs.EditingDeg.ShrtName[0] &&
|
||||
Gbl.Degs.EditingDeg.FullName[0]) // If there's a degree name
|
||||
{
|
||||
if (Deg->WWW[0])
|
||||
if (Gbl.Degs.EditingDeg.WWW[0])
|
||||
{
|
||||
/***** If name of degree was in database... *****/
|
||||
if (Deg_CheckIfDegNameExistsInCtr ("ShortName",Deg->ShrtName,-1L,Deg->CtrCod))
|
||||
if (Deg_CheckIfDegNameExistsInCtr ("ShortName",Gbl.Degs.EditingDeg.ShrtName,-1L,Gbl.Degs.EditingDeg.CtrCod))
|
||||
{
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_degree_X_already_exists,
|
||||
Deg->ShrtName);
|
||||
Gbl.Degs.EditingDeg.ShrtName);
|
||||
Lay_ShowAlert (Lay_WARNING,Gbl.Alert.Txt);
|
||||
}
|
||||
else if (Deg_CheckIfDegNameExistsInCtr ("FullName",Deg->FullName,-1L,Deg->CtrCod))
|
||||
else if (Deg_CheckIfDegNameExistsInCtr ("FullName",Gbl.Degs.EditingDeg.FullName,-1L,Gbl.Degs.EditingDeg.CtrCod))
|
||||
{
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_degree_X_already_exists,
|
||||
Deg->FullName);
|
||||
Gbl.Degs.EditingDeg.FullName);
|
||||
Lay_ShowAlert (Lay_WARNING,Gbl.Alert.Txt);
|
||||
}
|
||||
else // Add new degree to database
|
||||
Deg_CreateDegree (Deg,Status);
|
||||
Deg_CreateDegree (Status);
|
||||
}
|
||||
else // If there is not a degree logo or web
|
||||
{
|
||||
|
@ -2114,35 +2118,31 @@ void Deg_ChangeDegWWW (void)
|
|||
{
|
||||
extern const char *Txt_The_new_web_address_is_X;
|
||||
extern const char *Txt_You_can_not_leave_the_web_address_empty;
|
||||
struct Degree *Deg;
|
||||
char NewWWW[Cns_MAX_BYTES_WWW + 1];
|
||||
|
||||
Deg = &Gbl.Degs.EditingDeg;
|
||||
|
||||
/***** Get parameters from form *****/
|
||||
/* Get the code of the degree */
|
||||
Deg->DegCod = Deg_GetAndCheckParamOtherDegCod ();
|
||||
Gbl.Degs.EditingDeg.DegCod = Deg_GetAndCheckParamOtherDegCod ();
|
||||
|
||||
/* Get the new WWW for the degree */
|
||||
Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW);
|
||||
|
||||
/***** Get data of degree *****/
|
||||
Deg_GetDataOfDegreeByCod (Deg);
|
||||
Deg_GetDataOfDegreeByCod (&Gbl.Degs.EditingDeg);
|
||||
|
||||
/***** Check if new WWW is empty *****/
|
||||
if (NewWWW[0])
|
||||
{
|
||||
/***** Update the table changing old WWW by new WWW *****/
|
||||
Deg_UpdateDegWWWDB (Deg->DegCod,NewWWW);
|
||||
Str_Copy (Deg->WWW,NewWWW,
|
||||
Deg_UpdateDegWWWDB (Gbl.Degs.EditingDeg.DegCod,NewWWW);
|
||||
Str_Copy (Gbl.Degs.EditingDeg.WWW,NewWWW,
|
||||
Cns_MAX_BYTES_WWW);
|
||||
|
||||
/***** Write message to show the change made *****/
|
||||
/***** Write message to show the change made
|
||||
and put button to go to degree changed *****/
|
||||
Gbl.Alert.Type = Lay_SUCCESS;
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_new_web_address_is_X,NewWWW);
|
||||
Lay_ShowAlert (Lay_SUCCESS,Gbl.Alert.Txt);
|
||||
|
||||
/***** Put button to go to degree changed *****/
|
||||
Deg_PutButtonToGoToDeg (Deg);
|
||||
Deg_ShowAlertAndButtonToGoToDeg ();
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_You_can_not_leave_the_web_address_empty);
|
||||
|
@ -2201,16 +2201,13 @@ static void Deg_UpdateDegWWWDB (long DegCod,const char NewWWW[Cns_MAX_BYTES_WWW
|
|||
void Deg_ChangeDegStatus (void)
|
||||
{
|
||||
extern const char *Txt_The_status_of_the_degree_X_has_changed;
|
||||
struct Degree *Deg;
|
||||
char Query[128];
|
||||
Deg_Status_t Status;
|
||||
Deg_StatusTxt_t StatusTxt;
|
||||
|
||||
Deg = &Gbl.Degs.EditingDeg;
|
||||
|
||||
/***** Get parameters from form *****/
|
||||
/* Get degree code */
|
||||
Deg->DegCod = Deg_GetAndCheckParamOtherDegCod ();
|
||||
Gbl.Degs.EditingDeg.DegCod = Deg_GetAndCheckParamOtherDegCod ();
|
||||
|
||||
/* Get parameter with status */
|
||||
Status = (Deg_Status_t)
|
||||
|
@ -2224,22 +2221,21 @@ void Deg_ChangeDegStatus (void)
|
|||
Status = Deg_GetStatusBitsFromStatusTxt (StatusTxt); // New status
|
||||
|
||||
/***** Get data of degree *****/
|
||||
Deg_GetDataOfDegreeByCod (Deg);
|
||||
Deg_GetDataOfDegreeByCod (&Gbl.Degs.EditingDeg);
|
||||
|
||||
/***** Update status in table of degrees *****/
|
||||
sprintf (Query,"UPDATE degrees SET Status=%u WHERE DegCod=%ld",
|
||||
(unsigned) Status,Deg->DegCod);
|
||||
(unsigned) Status,Gbl.Degs.EditingDeg.DegCod);
|
||||
DB_QueryUPDATE (Query,"can not update the status of a degree");
|
||||
|
||||
Deg->Status = Status;
|
||||
Gbl.Degs.EditingDeg.Status = Status;
|
||||
|
||||
/***** Write message to show the change made *****/
|
||||
/***** Write message to show the change made
|
||||
and put button to go to degree changed *****/
|
||||
Gbl.Alert.Type = Lay_SUCCESS;
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_status_of_the_degree_X_has_changed,
|
||||
Deg->ShrtName);
|
||||
Lay_ShowAlert (Lay_SUCCESS,Gbl.Alert.Txt);
|
||||
|
||||
/***** Put button to go to degree changed *****/
|
||||
Deg_PutButtonToGoToDeg (Deg);
|
||||
Gbl.Degs.EditingDeg.ShrtName);
|
||||
Deg_ShowAlertAndButtonToGoToDeg ();
|
||||
|
||||
/***** Show the form again *****/
|
||||
Deg_EditDegrees ();
|
||||
|
@ -2251,12 +2247,8 @@ void Deg_ChangeDegStatus (void)
|
|||
|
||||
void Deg_ContEditAfterChgDeg (void)
|
||||
{
|
||||
/***** Write success / warning message *****/
|
||||
Lay_ShowPendingAlert ();
|
||||
|
||||
if (Gbl.Alert.Type == Lay_SUCCESS)
|
||||
/***** Put button to go to degree changed *****/
|
||||
Deg_PutButtonToGoToDeg (&Gbl.Degs.EditingDeg);
|
||||
/***** Put button to go to degree changed *****/
|
||||
Deg_ShowAlertAndButtonToGoToDeg ();
|
||||
|
||||
/***** Show the form again *****/
|
||||
Deg_EditDegrees ();
|
||||
|
@ -2265,22 +2257,32 @@ void Deg_ContEditAfterChgDeg (void)
|
|||
/*****************************************************************************/
|
||||
/************************ Put button to go to degree *************************/
|
||||
/*****************************************************************************/
|
||||
// Gbl.Degs.EditingDeg is the degree that is beeing edited
|
||||
// Gbl.CurrentDeg.Deg.DegCod is the current degree
|
||||
|
||||
void Deg_PutButtonToGoToDeg (struct Degree *Deg)
|
||||
void Deg_ShowAlertAndButtonToGoToDeg (void)
|
||||
{
|
||||
extern const char *Txt_Go_to_X;
|
||||
|
||||
// If the degree is different to the current one...
|
||||
if (Deg->DegCod != Gbl.CurrentDeg.Deg.DegCod)
|
||||
/***** Start alert *****/
|
||||
Lay_ShowAlertAndButton1 (Gbl.Alert.Type,Gbl.Alert.Txt);
|
||||
|
||||
// If the degree being edited is different to the current one...
|
||||
if (Gbl.Degs.EditingDeg.DegCod != Gbl.CurrentDeg.Deg.DegCod)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<div class=\"BUTTONS_AFTER_ALERT\">");
|
||||
Act_FormStart (ActSeeCrs);
|
||||
Deg_PutParamDegCod (Deg->DegCod);
|
||||
sprintf (Gbl.Title,Txt_Go_to_X,Deg->ShrtName);
|
||||
Lay_PutConfirmButtonInline (Gbl.Title);
|
||||
Act_FormEnd ();
|
||||
fprintf (Gbl.F.Out,"</div>");
|
||||
/***** Put button to go to degree and end alert *****/
|
||||
sprintf (Gbl.Title,Txt_Go_to_X,Gbl.Degs.EditingDeg.ShrtName);
|
||||
Lay_ShowAlertAndButton2 (ActSeeCrs,NULL,Deg_PutParamGoToDeg,
|
||||
Lay_CONFIRM_BUTTON,Gbl.Title);
|
||||
}
|
||||
else
|
||||
/***** End alert *****/
|
||||
Lay_ShowAlertAndButton2 (ActUnk,NULL,NULL,Lay_NO_BUTTON,NULL);
|
||||
}
|
||||
|
||||
static void Deg_PutParamGoToDeg (void)
|
||||
{
|
||||
Deg_PutParamDegCod (Gbl.Degs.EditingDeg.DegCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -130,7 +130,7 @@ void Deg_ChangeDegWWWInConfig (void);
|
|||
void Deg_ChangeDegStatus (void);
|
||||
void Deg_ContEditAfterChgDeg (void);
|
||||
|
||||
void Deg_PutButtonToGoToDeg (struct Degree *Deg);
|
||||
void Deg_ShowAlertAndButtonToGoToDeg (void);
|
||||
|
||||
void Deg_RequestLogo (void);
|
||||
void Deg_ReceiveLogo (void);
|
||||
|
|
|
@ -998,34 +998,30 @@ static bool DT_CheckIfDegreeTypeNameExists (const char *DegTypName,long DegTypCo
|
|||
void DT_ChangeDegreeType (void)
|
||||
{
|
||||
extern const char *Txt_The_type_of_degree_of_the_degree_X_has_changed;
|
||||
struct Degree *Deg;
|
||||
long NewDegTypCod;
|
||||
char Query[128];
|
||||
|
||||
Deg = &Gbl.Degs.EditingDeg;
|
||||
|
||||
/***** Get parameters from form *****/
|
||||
/* Get degree code */
|
||||
Deg->DegCod = Deg_GetAndCheckParamOtherDegCod ();
|
||||
Gbl.Degs.EditingDeg.DegCod = Deg_GetAndCheckParamOtherDegCod ();
|
||||
|
||||
/* Get the new degree type */
|
||||
NewDegTypCod = DT_GetParamOtherDegTypCod ();
|
||||
|
||||
/***** Get data of degree *****/
|
||||
Deg_GetDataOfDegreeByCod (Deg);
|
||||
Deg_GetDataOfDegreeByCod (&Gbl.Degs.EditingDeg);
|
||||
|
||||
/***** Update the table of degrees changing old type by new type *****/
|
||||
sprintf (Query,"UPDATE degrees SET DegTypCod=%ld WHERE DegCod=%ld",
|
||||
NewDegTypCod,Deg->DegCod);
|
||||
NewDegTypCod,Gbl.Degs.EditingDeg.DegCod);
|
||||
DB_QueryUPDATE (Query,"can not update the type of a degree");
|
||||
|
||||
/***** Write message to show the change made *****/
|
||||
/***** Write message to show the change made
|
||||
and put button to go to degree changed *****/
|
||||
Gbl.Alert.Type = Lay_SUCCESS;
|
||||
sprintf (Gbl.Alert.Txt,Txt_The_type_of_degree_of_the_degree_X_has_changed,
|
||||
Deg->FullName);
|
||||
Lay_ShowAlert (Lay_SUCCESS,Gbl.Alert.Txt);
|
||||
|
||||
/***** Put button to go to degree changed *****/
|
||||
Deg_PutButtonToGoToDeg (Deg);
|
||||
Gbl.Degs.EditingDeg.FullName);
|
||||
Deg_ShowAlertAndButtonToGoToDeg ();
|
||||
|
||||
/***** Show the form again *****/
|
||||
Gbl.Degs.EditingDegTyp.DegTypCod = NewDegTypCod;
|
||||
|
|
Loading…
Reference in New Issue