diff --git a/swad_centre.c b/swad_centre.c
index 73a335d4d..e6801663f 100644
--- a/swad_centre.c
+++ b/swad_centre.c
@@ -754,7 +754,7 @@ static void Ctr_ListOneCentreForSeeing (struct Centre *Ctr,unsigned NumCtr)
"%u"
"",
TxtClassNormal,BgColor,
- Ctr->NumDegs);
+ Ctr->Degs.Num);
/***** Number of courses *****/
fprintf (Gbl.F.Out,"
"
@@ -937,7 +937,7 @@ void Ctr_GetListCentres (long InsCod)
Ctr->NumUsrsWhoClaimToBelongToCtr = 0;
/* Get number of degrees in this centre */
- Ctr->NumDegs = Deg_GetNumDegsInCtr (Ctr->CtrCod);
+ Ctr->Degs.Num = Deg_GetNumDegsInCtr (Ctr->CtrCod);
/* Get number of courses in this centre */
Ctr->NumCrss = Crs_GetNumCrssInCtr (Ctr->CtrCod);
@@ -973,7 +973,8 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr)
Ctr->FullName[0] = '\0';
Ctr->WWW[0] = '\0';
Ctr->NumUsrsWhoClaimToBelongToCtr = 0;
- Ctr->NumDegs = Ctr->NumCrss = 0;
+ Ctr->Degs.Num =
+ Ctr->NumCrss = 0;
Ctr->NumUsrs = 0;
/***** Check if centre code is correct *****/
@@ -1031,7 +1032,7 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr)
Ctr->NumUsrsWhoClaimToBelongToCtr = 0;
/* Get number of degrees in this centre */
- Ctr->NumDegs = Deg_GetNumDegsInCtr (Ctr->CtrCod);
+ Ctr->Degs.Num = Deg_GetNumDegsInCtr (Ctr->CtrCod);
/* Get number of courses in this centre */
Ctr->NumCrss = Crs_GetNumCrssInCtr (Ctr->CtrCod);
@@ -1285,7 +1286,7 @@ static void Ctr_ListCentresForEdition (void)
/* Put icon to remove centre */
fprintf (Gbl.F.Out,"
"
"
");
- if (Ctr->NumDegs ||
+ if (Ctr->Degs.Num ||
Ctr->NumUsrsWhoClaimToBelongToCtr ||
Ctr->NumUsrs || // Centre has degrees or users ==> deletion forbidden
!ICanEdit)
@@ -1439,7 +1440,7 @@ static void Ctr_ListCentresForEdition (void)
fprintf (Gbl.F.Out,"
"
"%u"
"
",
- Ctr->NumDegs);
+ Ctr->Degs.Num);
/* Number of users in courses of this centre */
fprintf (Gbl.F.Out,"
"
@@ -1595,7 +1596,7 @@ void Ctr_RemoveCentre (void)
Ctr_GetDataOfCentreByCod (&Ctr);
/***** Check if this centre has teachers *****/
- if (Ctr.NumDegs ||
+ if (Ctr.Degs.Num ||
Ctr.NumUsrsWhoClaimToBelongToCtr ||
Ctr.NumUsrs) // Centre has degrees or users ==> don't remove
Lay_ShowAlert (Lay_WARNING,Txt_To_remove_a_centre_you_must_first_remove_all_degrees_and_teachers_in_the_centre);
diff --git a/swad_centre.h b/swad_centre.h
index ada371c29..4dc78451d 100644
--- a/swad_centre.h
+++ b/swad_centre.h
@@ -29,6 +29,7 @@
#include "swad_action.h"
#include "swad_constant.h"
+#include "swad_degree.h"
#include "swad_role.h"
/*****************************************************************************/
@@ -68,7 +69,7 @@ struct Centre
char FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME+1];
char WWW[Cns_MAX_LENGTH_WWW+1];
unsigned NumUsrsWhoClaimToBelongToCtr; // Number of users who claim to belong in this centre
- unsigned NumDegs; // Number of degrees in this centre
+ struct ListDegrees Degs; // List of degrees in this centre
unsigned NumCrss; // Number of courses in this centre
unsigned NumUsrs; // Number of users in courses of this centre
};
diff --git a/swad_changelog.h b/swad_changelog.h
index 438c1adf5..d06e88b02 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -148,13 +148,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 16.23.2 (2016-10-19)"
+#define Log_PLATFORM_VERSION "SWAD 16.24 (2016-10-20)"
#define CSS_FILE "swad15.229.css"
#define JS_FILE "swad15.238.1.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.24: Oct 20, 2016 Code refactoring in list of degrees. (205326 lines)
Version 16.23.2: Oct 19, 2016 Code refactoring in course edition. (205448 lines)
Version 16.23.1: Oct 19, 2016 Code refactoring in degree edition. (205441 lines)
Version 16.23: Oct 19, 2016 New form in degree configuration to move degree to another centre. (205434 lines)
diff --git a/swad_course.c b/swad_course.c
index e3dd996d5..9ededa454 100644
--- a/swad_course.c
+++ b/swad_course.c
@@ -99,7 +99,6 @@ static void Crs_CreateCourse (struct Course *Crs,unsigned Status);
static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row);
static void Crs_UpdateCrsDegreeDB (long CrsCod,long DegCod);
-static bool Crs_CheckIfICanChangeCrsToNewDeg (struct Degree *NewDeg);
static void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear);
@@ -216,32 +215,31 @@ static void Crs_Configuration (bool PrintView)
Txt_Degree);
/* Get list of degrees administrated by me */
- if (!PrintView)
- Deg_GetListDegsAdminByMe ();
-
- /* Put form to select degree */
if (!PrintView &&
- Gbl.Usrs.Me.MyAdminDegs.Num)
+ Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM) // Only centre admins, institution admins and system admin can move a course to another degree
{
+ /* Get list of degrees of the current centre */
+ Deg_GetListDegsOfCurrentCtr ();
+
+ /* Put form to select degree */
Act_FormStart (ActChgCrsDegCfg);
fprintf (Gbl.F.Out,"");
-
Act_FormEnd ();
- /* Free list of degrees administrated by me */
- Deg_FreeListMyAdminDegs ();
+ /* Free list of degrees of the current centre */
+ Deg_FreeListDegs (&Gbl.CurrentCtr.Ctr.Degs);
}
else // I can not move course to another degree
fprintf (Gbl.F.Out,"%s",Gbl.CurrentDeg.Deg.FullName);
@@ -954,8 +952,8 @@ void Crs_ReqEditCourses (void)
/***** Get list of courses in this degree *****/
Crs_GetListCoursesInDegree (Crs_ALL_COURSES_EXCEPT_REMOVED);
- /***** Get list of degrees administrated by me *****/
- Deg_GetListDegsAdminByMe ();
+ /***** Get list of degrees in this centre *****/
+ Deg_GetListDegsOfCurrentCtr ();
/***** Put form to edit courses *****/
Crs_EditCourses ();
@@ -963,8 +961,8 @@ void Crs_ReqEditCourses (void)
/***** Free list of courses in this degree *****/
Crs_FreeListCoursesInDegree (&Gbl.CurrentDeg.Deg);
- /***** Free list of degrees administrated by me *****/
- Deg_FreeListMyAdminDegs ();
+ /***** Free list of degrees in this centre *****/
+ Deg_FreeListDegs (&Gbl.CurrentCtr.Ctr.Degs);
}
}
@@ -1427,13 +1425,13 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year)
" onchange=\"document.getElementById('%s').submit();\">",
Gbl.Form.Id);
for (NumDeg = 0;
- NumDeg < Gbl.Usrs.Me.MyAdminDegs.Num;
+ NumDeg < Gbl.CurrentCtr.Ctr.Degs.Num;
NumDeg++)
fprintf (Gbl.F.Out,"",
- Gbl.Usrs.Me.MyAdminDegs.Lst[NumDeg].DegCod,
- Gbl.Usrs.Me.MyAdminDegs.Lst[NumDeg].DegCod == Gbl.CurrentDeg.Deg.DegCod ? " selected=\"selected\"" :
- "",
- Gbl.Usrs.Me.MyAdminDegs.Lst[NumDeg].ShortName);
+ Gbl.CurrentCtr.Ctr.Degs.Lst[NumDeg].DegCod,
+ Gbl.CurrentCtr.Ctr.Degs.Lst[NumDeg].DegCod == Gbl.CurrentDeg.Deg.DegCod ? " selected=\"selected\"" :
+ "",
+ Gbl.CurrentCtr.Ctr.Degs.Lst[NumDeg].ShortName);
fprintf (Gbl.F.Out,"");
Act_FormEnd ();
}
@@ -2434,7 +2432,7 @@ void Crs_ChangeCrsDegreeInConfig (void)
Deg_GetDataOfDegreeByCod (&NewDeg);
/***** If I have permission to change course to this new degree... *****/
- if (Crs_CheckIfICanChangeCrsToNewDeg (&NewDeg))
+ if (Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM)
{
/***** If name of course was in database in the new degree... *****/
if (Crs_CheckIfCourseNameExistsInCourses (NewDeg.DegCod,Gbl.CurrentCrs.Crs.Year,
@@ -2519,7 +2517,7 @@ void Crs_ChangeCrsDegree (void)
Deg_GetDataOfDegreeByCod (&NewDeg);
/***** If I have permission to change course to this new degree... *****/
- if (Crs_CheckIfICanChangeCrsToNewDeg (&NewDeg))
+ if (Gbl.Usrs.Me.LoggedRole >= Rol_CTR_ADM)
{
/***** If name of course was in database in the new degree... *****/
if (Crs_CheckIfCourseNameExistsInCourses (NewDeg.DegCod,Crs->Year,
@@ -2569,43 +2567,6 @@ static void Crs_UpdateCrsDegreeDB (long CrsCod,long DegCod)
DB_QueryUPDATE (Query,"can not move course to another degree");
}
-/*****************************************************************************/
-/************* Check if I can change the course to a new degree **************/
-/*****************************************************************************/
-
-static bool Crs_CheckIfICanChangeCrsToNewDeg (struct Degree *NewDeg)
- {
- struct Centre NewCtr;
-
- /***** Check if I have permission to change course to this degree *****/
- switch (Gbl.Usrs.Me.LoggedRole)
- {
- case Rol_DEG_ADM:
- return Usr_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
- Sco_SCOPE_DEG,
- NewDeg->DegCod);
- break;
- case Rol_CTR_ADM:
- return Usr_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
- Sco_SCOPE_CTR,
- NewDeg->CtrCod);
- break;
- case Rol_INS_ADM:
- /* Get data of centre of new degree */
- NewCtr.CtrCod = NewDeg->CtrCod;
- Ctr_GetDataOfCentreByCod (&NewCtr);
-
- return Usr_CheckIfUsrIsAdm (Gbl.Usrs.Me.UsrDat.UsrCod,
- Sco_SCOPE_INS,
- NewCtr.InsCod);
- break;
- case Rol_SYS_ADM:
- return true;
- default:
- return false;
- }
- }
-
/*****************************************************************************/
/*********** Change the year of a course in course configuration *************/
/*****************************************************************************/
diff --git a/swad_degree.c b/swad_degree.c
index b0cc662dd..fd82da39e 100644
--- a/swad_degree.c
+++ b/swad_degree.c
@@ -102,8 +102,6 @@ static void Deg_ListDegrees (void);
static void Deg_PutIconToEditDegrees (void);
static void Deg_ListOneDegreeForSeeing (struct Degree *Deg,unsigned NumDeg);
-static void Deg_GetListDegsOfCurrentCtr (void);
-static void Deg_FreeListDegsOfCurrentCtr (void);
static void Deg_RecFormRequestOrCreateDeg (unsigned Status);
static void Deg_PutParamOtherDegCod (long DegCod);
@@ -1045,7 +1043,7 @@ void Deg_ShowDegsOfCurrentCtr (void)
Deg_ListDegrees ();
/***** Free list of degrees and centres *****/
- Deg_FreeListDegsOfCurrentCtr ();
+ Deg_FreeListDegs (&Gbl.CurrentCtr.Ctr.Degs);
Ctr_FreeListCentres ();
}
}
@@ -1082,10 +1080,10 @@ static void Deg_ListDegreesForEdition (void)
/***** List the degrees *****/
for (NumDeg = 0;
- NumDeg < Gbl.CurrentCtr.Ctr.NumDegs;
+ NumDeg < Gbl.CurrentCtr.Ctr.Degs.Num;
NumDeg++)
{
- Deg = &(Gbl.CurrentCtr.LstDegs[NumDeg]);
+ Deg = &(Gbl.CurrentCtr.Ctr.Degs.Lst[NumDeg]);
NumCrss = Crs_GetNumCrssInDeg (Deg->DegCod);
@@ -1617,7 +1615,7 @@ static void Deg_ListDegrees (void)
Lay_StartRoundFrame (NULL,Gbl.Title,ICanEdit ? Deg_PutIconToEditDegrees :
NULL);
- if (Gbl.CurrentCtr.Ctr.NumDegs) // There are degrees in the current centre
+ if (Gbl.CurrentCtr.Ctr.Degs.Num) // There are degrees in the current centre
{
/***** Start table *****/
fprintf (Gbl.F.Out,"