mirror of https://github.com/acanas/swad-core.git
Version 15.62
This commit is contained in:
parent
bad0711ad9
commit
c02c7f76d0
260
swad_centre.c
260
swad_centre.c
|
@ -249,7 +249,6 @@ void Ctr_PrintConfiguration (void)
|
||||||
static void Ctr_Configuration (bool PrintView)
|
static void Ctr_Configuration (bool PrintView)
|
||||||
{
|
{
|
||||||
extern const char *The_ClassForm[The_NUM_THEMES];
|
extern const char *The_ClassForm[The_NUM_THEMES];
|
||||||
extern const char *Txt_Degrees;
|
|
||||||
extern const char *Txt_Print;
|
extern const char *Txt_Print;
|
||||||
extern const char *Txt_Centre;
|
extern const char *Txt_Centre;
|
||||||
extern const char *Txt_Short_name;
|
extern const char *Txt_Short_name;
|
||||||
|
@ -257,8 +256,12 @@ static void Ctr_Configuration (bool PrintView)
|
||||||
extern const char *Txt_Shortcut;
|
extern const char *Txt_Shortcut;
|
||||||
extern const char *Txt_STR_LANG_ID[1+Txt_NUM_LANGUAGES];
|
extern const char *Txt_STR_LANG_ID[1+Txt_NUM_LANGUAGES];
|
||||||
extern const char *Txt_QR_code;
|
extern const char *Txt_QR_code;
|
||||||
|
extern const char *Txt_Users_of_the_centre;
|
||||||
|
extern const char *Txt_Place;
|
||||||
|
extern const char *Txt_Degrees;
|
||||||
extern const char *Txt_Courses;
|
extern const char *Txt_Courses;
|
||||||
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||||
|
struct Place Plc;
|
||||||
char PathPhoto[PATH_MAX+1];
|
char PathPhoto[PATH_MAX+1];
|
||||||
bool PhotoExists;
|
bool PhotoExists;
|
||||||
char *PhotoAttribution = NULL;
|
char *PhotoAttribution = NULL;
|
||||||
|
@ -454,6 +457,34 @@ static void Ctr_Configuration (bool PrintView)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/***** Place *****/
|
||||||
|
Plc.PlcCod = Gbl.CurrentCtr.Ctr.PlcCod;
|
||||||
|
Plc_GetDataOfPlaceByCod (&Plc);
|
||||||
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
|
"%s:"
|
||||||
|
"</td>"
|
||||||
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
||||||
|
"%s"
|
||||||
|
"</td>"
|
||||||
|
"</tr>",
|
||||||
|
The_ClassForm[Gbl.Prefs.Theme],
|
||||||
|
Txt_Place,
|
||||||
|
Plc.FullName);
|
||||||
|
|
||||||
|
/***** Number of users who claim to belong to this centre *****/
|
||||||
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
|
"%s:"
|
||||||
|
"</td>"
|
||||||
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
||||||
|
"%u"
|
||||||
|
"</td>"
|
||||||
|
"</tr>",
|
||||||
|
The_ClassForm[Gbl.Prefs.Theme],
|
||||||
|
Txt_Users_of_the_centre,
|
||||||
|
Usr_GetNumUsrsWhoClaimToBelongToCtr (Gbl.CurrentCtr.Ctr.CtrCod));
|
||||||
|
|
||||||
/***** Number of degrees *****/
|
/***** Number of degrees *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">"
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
|
@ -480,7 +511,7 @@ static void Ctr_Configuration (bool PrintView)
|
||||||
Txt_Courses,
|
Txt_Courses,
|
||||||
Crs_GetNumCrssInCtr (Gbl.CurrentCtr.Ctr.CtrCod));
|
Crs_GetNumCrssInCtr (Gbl.CurrentCtr.Ctr.CtrCod));
|
||||||
|
|
||||||
/***** Number of teachers *****/
|
/***** Number of teachers in courses of this centre *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">"
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
"%s:"
|
"%s:"
|
||||||
|
@ -493,7 +524,7 @@ static void Ctr_Configuration (bool PrintView)
|
||||||
Txt_ROLES_PLURAL_Abc[Rol_TEACHER][Usr_SEX_UNKNOWN],
|
Txt_ROLES_PLURAL_Abc[Rol_TEACHER][Usr_SEX_UNKNOWN],
|
||||||
Usr_GetNumUsrsInCrssOfCtr (Rol_TEACHER,Gbl.CurrentCtr.Ctr.CtrCod));
|
Usr_GetNumUsrsInCrssOfCtr (Rol_TEACHER,Gbl.CurrentCtr.Ctr.CtrCod));
|
||||||
|
|
||||||
/***** Number of students *****/
|
/***** Number of students in courses of this centre *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">"
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
"%s:"
|
"%s:"
|
||||||
|
@ -505,6 +536,20 @@ static void Ctr_Configuration (bool PrintView)
|
||||||
The_ClassForm[Gbl.Prefs.Theme],
|
The_ClassForm[Gbl.Prefs.Theme],
|
||||||
Txt_ROLES_PLURAL_Abc[Rol_STUDENT][Usr_SEX_UNKNOWN],
|
Txt_ROLES_PLURAL_Abc[Rol_STUDENT][Usr_SEX_UNKNOWN],
|
||||||
Usr_GetNumUsrsInCrssOfCtr (Rol_STUDENT,Gbl.CurrentCtr.Ctr.CtrCod));
|
Usr_GetNumUsrsInCrssOfCtr (Rol_STUDENT,Gbl.CurrentCtr.Ctr.CtrCod));
|
||||||
|
|
||||||
|
/***** Number of users in courses of this centre *****/
|
||||||
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
|
"%s + %s:"
|
||||||
|
"</td>"
|
||||||
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
||||||
|
"%u"
|
||||||
|
"</td>"
|
||||||
|
"</tr>",
|
||||||
|
The_ClassForm[Gbl.Prefs.Theme],
|
||||||
|
Txt_ROLES_PLURAL_Abc[Rol_TEACHER][Usr_SEX_UNKNOWN],
|
||||||
|
Txt_ROLES_PLURAL_Abc[Rol_STUDENT][Usr_SEX_UNKNOWN],
|
||||||
|
Usr_GetNumUsrsInCrssOfCtr (Rol_UNKNOWN,Gbl.CurrentCtr.Ctr.CtrCod));
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** End frame *****/
|
/***** End frame *****/
|
||||||
|
@ -596,8 +641,6 @@ static void Ctr_ListCentresForSeeing (void)
|
||||||
|
|
||||||
static void Ctr_ListOneCentreForSeeing (struct Centre *Ctr,unsigned NumCtr)
|
static void Ctr_ListOneCentreForSeeing (struct Centre *Ctr,unsigned NumCtr)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Another_place;
|
|
||||||
extern const char *Txt_Go_to_X;
|
|
||||||
extern const char *Txt_CENTRE_STATUS[Ctr_NUM_STATUS_TXT];
|
extern const char *Txt_CENTRE_STATUS[Ctr_NUM_STATUS_TXT];
|
||||||
struct Place Plc;
|
struct Place Plc;
|
||||||
const char *TxtClassNormal;
|
const char *TxtClassNormal;
|
||||||
|
@ -636,12 +679,19 @@ static void Ctr_ListOneCentreForSeeing (struct Centre *Ctr,unsigned NumCtr)
|
||||||
TxtClassStrong,"CENTER_MIDDLE");
|
TxtClassStrong,"CENTER_MIDDLE");
|
||||||
fprintf (Gbl.F.Out,"</td>");
|
fprintf (Gbl.F.Out,"</td>");
|
||||||
|
|
||||||
/***** Number of teachers *****/
|
/***** Number of users who claim to belong to this centre *****/
|
||||||
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
|
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
|
||||||
"%u"
|
"%u"
|
||||||
"</td>",
|
"</td>",
|
||||||
TxtClassNormal,BgColor,
|
TxtClassNormal,BgColor,
|
||||||
Ctr->NumTchs);
|
Ctr->NumUsrsWhoClaimToBelongToCtr);
|
||||||
|
|
||||||
|
/***** Place *****/
|
||||||
|
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE %s\">"
|
||||||
|
"%s"
|
||||||
|
"</td>",
|
||||||
|
TxtClassNormal,BgColor,
|
||||||
|
Plc.ShortName);
|
||||||
|
|
||||||
/***** Number of degrees *****/
|
/***** Number of degrees *****/
|
||||||
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
|
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
|
||||||
|
@ -650,13 +700,33 @@ static void Ctr_ListOneCentreForSeeing (struct Centre *Ctr,unsigned NumCtr)
|
||||||
TxtClassNormal,BgColor,
|
TxtClassNormal,BgColor,
|
||||||
Ctr->NumDegs);
|
Ctr->NumDegs);
|
||||||
|
|
||||||
/***** Place *****/
|
/***** Number of courses *****/
|
||||||
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE %s\">"
|
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
|
||||||
"%s"
|
"%u"
|
||||||
"</td>",
|
"</td>",
|
||||||
TxtClassNormal,BgColor,
|
TxtClassNormal,BgColor,
|
||||||
Plc.PlcCod > 0 ? Plc.ShortName :
|
Ctr->NumCrss);
|
||||||
Txt_Another_place);
|
|
||||||
|
/***** Number of teachers in courses of this centre *****/
|
||||||
|
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
|
||||||
|
"%u"
|
||||||
|
"</td>",
|
||||||
|
TxtClassNormal,BgColor,
|
||||||
|
Ctr->NumTchs);
|
||||||
|
|
||||||
|
/***** Number of students in courses of this centre *****/
|
||||||
|
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
|
||||||
|
"%u"
|
||||||
|
"</td>",
|
||||||
|
TxtClassNormal,BgColor,
|
||||||
|
Ctr->NumStds);
|
||||||
|
|
||||||
|
/***** Number of users in courses of this centre *****/
|
||||||
|
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE %s\">"
|
||||||
|
"%u"
|
||||||
|
"</td>",
|
||||||
|
TxtClassNormal,BgColor,
|
||||||
|
Ctr->NumUsrs);
|
||||||
|
|
||||||
/***** Centre status *****/
|
/***** Centre status *****/
|
||||||
StatusTxt = Ctr_GetStatusTxtFromStatusBits (Ctr->Status);
|
StatusTxt = Ctr_GetStatusTxtFromStatusBits (Ctr->Status);
|
||||||
|
@ -755,53 +825,28 @@ void Ctr_GetListCentres (long InsCod)
|
||||||
sprintf (OrderBySubQuery,"FullName");
|
sprintf (OrderBySubQuery,"FullName");
|
||||||
break;
|
break;
|
||||||
case Ctr_ORDER_BY_NUM_TCHS:
|
case Ctr_ORDER_BY_NUM_TCHS:
|
||||||
sprintf (OrderBySubQuery,"NumTchs DESC,FullName");
|
sprintf (OrderBySubQuery,"NumUsrs DESC,FullName");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (InsCod > 0) // Only the centres of the specified institution
|
sprintf (Query,"(SELECT centres.CtrCod,centres.InsCod,centres.PlcCod,"
|
||||||
sprintf (Query,"(SELECT centres.CtrCod,centres.InsCod,centres.PlcCod,"
|
"centres.Status,centres.RequesterUsrCod,"
|
||||||
"centres.Status,centres.RequesterUsrCod,"
|
"centres.ShortName,centres.FullName,centres.WWW,"
|
||||||
"centres.ShortName,centres.FullName,centres.WWW,"
|
"COUNT(DISTINCT usr_data.UsrCod) AS NumUsrs"
|
||||||
"COUNT(DISTINCT usr_data.UsrCod) AS NumTchs"
|
" FROM centres,usr_data"
|
||||||
" FROM centres,usr_data,crs_usr"
|
" WHERE centres.InsCod='%ld'"
|
||||||
" WHERE centres.InsCod='%ld' AND crs_usr.Role='%u'"
|
" AND centres.CtrCod=usr_data.CtrCod"
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod AND usr_data.CtrCod=centres.CtrCod"
|
" GROUP BY centres.CtrCod)"
|
||||||
" GROUP BY centres.CtrCod)"
|
" UNION "
|
||||||
" UNION "
|
"(SELECT CtrCod,InsCod,PlcCod,Status,RequesterUsrCod,"
|
||||||
"(SELECT CtrCod,InsCod,PlcCod,Status,RequesterUsrCod,"
|
"ShortName,FullName,WWW,0 AS NumUsrs"
|
||||||
"ShortName,FullName,WWW,0 AS NumTchs"
|
" FROM centres"
|
||||||
" FROM centres"
|
" WHERE centres.InsCod='%ld'"
|
||||||
" WHERE centres.InsCod='%ld' AND CtrCod NOT IN"
|
" AND CtrCod NOT IN"
|
||||||
" (SELECT DISTINCT usr_data.CtrCod FROM usr_data,crs_usr"
|
" (SELECT DISTINCT CtrCod FROM usr_data))"
|
||||||
" WHERE centres.InsCod='%ld' AND crs_usr.Role='%u'"
|
" ORDER BY %s",
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod))"
|
InsCod,
|
||||||
" ORDER BY %s",
|
InsCod,
|
||||||
InsCod,
|
OrderBySubQuery);
|
||||||
(unsigned) Rol_TEACHER,
|
|
||||||
InsCod,InsCod,
|
|
||||||
(unsigned) Rol_TEACHER,
|
|
||||||
OrderBySubQuery);
|
|
||||||
else // InsCod <= 0 ==> all the centres
|
|
||||||
sprintf (Query,"(SELECT centres.CtrCod,centres.InsCod,centres.PlcCod,"
|
|
||||||
"centres.Status,centres.RequesterUsrCod,"
|
|
||||||
"centres.ShortName,centres.FullName,centres.WWW,"
|
|
||||||
"COUNT(DISTINCT usr_data.UsrCod) AS NumTchs"
|
|
||||||
" FROM centres,usr_data,crs_usr"
|
|
||||||
" WHERE crs_usr.Role='%u'"
|
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod AND usr_data.CtrCod=centres.CtrCod"
|
|
||||||
" GROUP BY centres.CtrCod)"
|
|
||||||
" UNION "
|
|
||||||
"(SELECT CtrCod,InsCod,PlcCod,Status,RequesterUsrCod,"
|
|
||||||
"ShortName,FullName,WWW,0 AS NumTchs"
|
|
||||||
" FROM centres"
|
|
||||||
" WHERE CtrCod NOT IN"
|
|
||||||
" (SELECT DISTINCT usr_data.CtrCod FROM usr_data,crs_usr"
|
|
||||||
" WHERE crs_usr.Role='%u'"
|
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod))"
|
|
||||||
" ORDER BY %s",
|
|
||||||
(unsigned) Rol_TEACHER,
|
|
||||||
(unsigned) Rol_TEACHER,
|
|
||||||
OrderBySubQuery);
|
|
||||||
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get centres");
|
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get centres");
|
||||||
|
|
||||||
if (NumRows) // Centres found...
|
if (NumRows) // Centres found...
|
||||||
|
@ -849,12 +894,20 @@ void Ctr_GetListCentres (long InsCod)
|
||||||
/* Get the URL of the centre (row[7]) */
|
/* Get the URL of the centre (row[7]) */
|
||||||
strcpy (Ctr->WWW,row[7]);
|
strcpy (Ctr->WWW,row[7]);
|
||||||
|
|
||||||
/* Get number of teachers in this centre (row[8]) */
|
/* Get number of users who claim to belong to this centre (row[8]) */
|
||||||
if (sscanf (row[8],"%u",&Ctr->NumTchs) != 1)
|
if (sscanf (row[8],"%u",&Ctr->NumUsrsWhoClaimToBelongToCtr) != 1)
|
||||||
Ctr->NumTchs = 0;
|
Ctr->NumUsrsWhoClaimToBelongToCtr = 0;
|
||||||
|
|
||||||
/* Count number of degrees in this centre */
|
/* Get number of degrees in this centre */
|
||||||
Ctr->NumDegs = Deg_CountNumDegsInCtr (Ctr->CtrCod);
|
Ctr->NumDegs = Deg_GetNumDegsInCtr (Ctr->CtrCod);
|
||||||
|
|
||||||
|
/* Get number of courses in this centre */
|
||||||
|
Ctr->NumCrss = Crs_GetNumCrssInCtr (Ctr->CtrCod);
|
||||||
|
|
||||||
|
/* Get number of users in courses of this centre */
|
||||||
|
Ctr->NumUsrs = Usr_GetNumUsrsInCrssOfCtr (Rol_UNKNOWN,Ctr->CtrCod); // Here Rol_UNKNOWN means "all users", NumUsrs <= NumStds + NumTchs
|
||||||
|
Ctr->NumTchs = Usr_GetNumUsrsInCrssOfCtr (Rol_TEACHER,Ctr->CtrCod);
|
||||||
|
Ctr->NumStds = Usr_GetNumUsrsInCrssOfCtr (Rol_STUDENT,Ctr->CtrCod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -883,30 +936,36 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr)
|
||||||
Ctr->ShortName[0] = '\0';
|
Ctr->ShortName[0] = '\0';
|
||||||
Ctr->FullName[0] = '\0';
|
Ctr->FullName[0] = '\0';
|
||||||
Ctr->WWW[0] = '\0';
|
Ctr->WWW[0] = '\0';
|
||||||
|
Ctr->NumUsrsWhoClaimToBelongToCtr = 0;
|
||||||
Ctr->NumDegs = 0;
|
Ctr->NumDegs = 0;
|
||||||
|
Ctr->NumCrss = 0;
|
||||||
|
Ctr->NumUsrs = 0;
|
||||||
Ctr->NumTchs = 0;
|
Ctr->NumTchs = 0;
|
||||||
|
Ctr->NumStds = 0;
|
||||||
|
|
||||||
/***** Check if centre code is correct *****/
|
/***** Check if centre code is correct *****/
|
||||||
if (Ctr->CtrCod > 0)
|
if (Ctr->CtrCod > 0)
|
||||||
{
|
{
|
||||||
/***** Get data of a centre from database *****/
|
/***** Get data of a centre from database *****/
|
||||||
sprintf (Query,"(SELECT centres.InsCod,centres.PlcCod,centres.Status,centres.RequesterUsrCod,centres.ShortName,centres.FullName,"
|
sprintf (Query,"(SELECT centres.InsCod,centres.PlcCod,"
|
||||||
"centres.WWW,COUNT(DISTINCT usr_data.UsrCod) AS NumTchs"
|
"centres.Status,centres.RequesterUsrCod,"
|
||||||
" FROM centres,usr_data,crs_usr"
|
"centres.ShortName,centres.FullName,centres.WWW,"
|
||||||
|
"COUNT(DISTINCT usr_data.UsrCod) AS NumUsrs"
|
||||||
|
" FROM centres,usr_data"
|
||||||
" WHERE centres.CtrCod='%ld'"
|
" WHERE centres.CtrCod='%ld'"
|
||||||
" AND centres.CtrCod=usr_data.CtrCod AND usr_data.UsrCod=crs_usr.UsrCod AND crs_usr.Role='%u'"
|
" AND centres.CtrCod=usr_data.CtrCod"
|
||||||
" GROUP BY centres.CtrCod)"
|
" GROUP BY centres.CtrCod)"
|
||||||
" UNION "
|
" UNION "
|
||||||
"(SELECT InsCod,PlcCod,Status,RequesterUsrCod,ShortName,FullName,WWW,0 AS NumTchs"
|
"(SELECT InsCod,PlcCod,"
|
||||||
|
"Status,RequesterUsrCod,"
|
||||||
|
"ShortName,FullName,WWW,"
|
||||||
|
"0 AS NumUsrs"
|
||||||
" FROM centres"
|
" FROM centres"
|
||||||
" WHERE CtrCod='%ld' AND CtrCod NOT IN"
|
" WHERE CtrCod='%ld'"
|
||||||
" (SELECT DISTINCT usr_data.CtrCod FROM usr_data,crs_usr"
|
" AND CtrCod NOT IN"
|
||||||
" WHERE crs_usr.Role='%u'"
|
" (SELECT DISTINCT CtrCod FROM usr_data))",
|
||||||
" AND crs_usr.UsrCod=usr_data.UsrCod))",
|
|
||||||
Ctr->CtrCod,
|
Ctr->CtrCod,
|
||||||
(unsigned) Rol_TEACHER,
|
Ctr->CtrCod);
|
||||||
Ctr->CtrCod,
|
|
||||||
(unsigned) Rol_TEACHER);
|
|
||||||
if (DB_QuerySELECT (Query,&mysql_res,"can not get data of a centre")) // Centre found...
|
if (DB_QuerySELECT (Query,&mysql_res,"can not get data of a centre")) // Centre found...
|
||||||
{
|
{
|
||||||
/* Get row */
|
/* Get row */
|
||||||
|
@ -934,12 +993,20 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr)
|
||||||
/* Get the URL of the centre (row[6]) */
|
/* Get the URL of the centre (row[6]) */
|
||||||
strcpy (Ctr->WWW,row[6]);
|
strcpy (Ctr->WWW,row[6]);
|
||||||
|
|
||||||
/* Get number of teachers in this centre (row[7]) */
|
/* Get number of users who claim to belong to this centre (row[7]) */
|
||||||
if (sscanf (row[7],"%u",&Ctr->NumTchs) != 1)
|
if (sscanf (row[7],"%u",&Ctr->NumUsrsWhoClaimToBelongToCtr) != 1)
|
||||||
Ctr->NumTchs = 0;
|
Ctr->NumUsrsWhoClaimToBelongToCtr = 0;
|
||||||
|
|
||||||
/* Count number of degrees in this centre */
|
/* Get number of degrees in this centre */
|
||||||
Ctr->NumDegs = Deg_CountNumDegsInCtr (Ctr->CtrCod);
|
Ctr->NumDegs = Deg_GetNumDegsInCtr (Ctr->CtrCod);
|
||||||
|
|
||||||
|
/* Get number of courses in this centre */
|
||||||
|
Ctr->NumCrss = Crs_GetNumCrssInCtr (Ctr->CtrCod);
|
||||||
|
|
||||||
|
/* Get number of users in courses of this centre */
|
||||||
|
Ctr->NumUsrs = Usr_GetNumUsrsInCrssOfCtr (Rol_UNKNOWN,Ctr->CtrCod); // Here Rol_UNKNOWN means "all users", NumUsrs <= NumStds + NumTchs
|
||||||
|
Ctr->NumTchs = Usr_GetNumUsrsInCrssOfCtr (Rol_TEACHER,Ctr->CtrCod);
|
||||||
|
Ctr->NumStds = Usr_GetNumUsrsInCrssOfCtr (Rol_STUDENT,Ctr->CtrCod);
|
||||||
|
|
||||||
/* Set return value */
|
/* Set return value */
|
||||||
CtrFound = true;
|
CtrFound = true;
|
||||||
|
@ -1188,7 +1255,8 @@ static void Ctr_ListCentresForEdition (void)
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"BM\">");
|
"<td class=\"BM\">");
|
||||||
if (Ctr->NumDegs ||
|
if (Ctr->NumDegs ||
|
||||||
Ctr->NumTchs || // Centre has degrees or teachers ==> deletion forbidden
|
Ctr->NumUsrsWhoClaimToBelongToCtr ||
|
||||||
|
Ctr->NumUsrs || // Centre has degrees or users ==> deletion forbidden
|
||||||
!ICanEdit)
|
!ICanEdit)
|
||||||
Lay_PutIconRemovalNotAllowed ();
|
Lay_PutIconRemovalNotAllowed ();
|
||||||
else
|
else
|
||||||
|
@ -2108,10 +2176,13 @@ static void Ctr_PutFormToCreateCentre (void)
|
||||||
|
|
||||||
static void Ctr_PutHeadCentresForSeeing (bool OrderSelectable)
|
static void Ctr_PutHeadCentresForSeeing (bool OrderSelectable)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Place;
|
|
||||||
extern const char *Txt_CENTRES_HELP_ORDER[2];
|
extern const char *Txt_CENTRES_HELP_ORDER[2];
|
||||||
extern const char *Txt_CENTRES_ORDER[2];
|
extern const char *Txt_CENTRES_ORDER[2];
|
||||||
|
extern const char *Txt_Place;
|
||||||
extern const char *Txt_Degrees_ABBREVIATION;
|
extern const char *Txt_Degrees_ABBREVIATION;
|
||||||
|
extern const char *Txt_Courses_ABBREVIATION;
|
||||||
|
extern const char *Txt_Teachers_ABBREVIATION;
|
||||||
|
extern const char *Txt_Students_ABBREVIATION;
|
||||||
extern const char *Txt_Status;
|
extern const char *Txt_Status;
|
||||||
tCtrsOrderType Order;
|
tCtrsOrderType Order;
|
||||||
|
|
||||||
|
@ -2121,7 +2192,9 @@ static void Ctr_PutHeadCentresForSeeing (bool OrderSelectable)
|
||||||
Order <= Ctr_ORDER_BY_NUM_TCHS;
|
Order <= Ctr_ORDER_BY_NUM_TCHS;
|
||||||
Order++)
|
Order++)
|
||||||
{
|
{
|
||||||
fprintf (Gbl.F.Out,"<th class=\"LEFT_MIDDLE\">");
|
fprintf (Gbl.F.Out,"<th class=\"%s\">",
|
||||||
|
Order == Ctr_ORDER_BY_CENTRE ? "LEFT_MIDDLE" :
|
||||||
|
"RIGHT_MIDDLE");
|
||||||
if (OrderSelectable)
|
if (OrderSelectable)
|
||||||
{
|
{
|
||||||
Act_FormStart (ActSeeCtr);
|
Act_FormStart (ActSeeCtr);
|
||||||
|
@ -2140,7 +2213,10 @@ static void Ctr_PutHeadCentresForSeeing (bool OrderSelectable)
|
||||||
}
|
}
|
||||||
fprintf (Gbl.F.Out,"</th>");
|
fprintf (Gbl.F.Out,"</th>");
|
||||||
}
|
}
|
||||||
fprintf (Gbl.F.Out,"<th class=\"RIGHT_MIDDLE\">"
|
fprintf (Gbl.F.Out,"<th class=\"LEFT_MIDDLE\">"
|
||||||
|
"%s"
|
||||||
|
"</th>"
|
||||||
|
"<th class=\"RIGHT_MIDDLE\">"
|
||||||
"%s"
|
"%s"
|
||||||
"</th>"
|
"</th>"
|
||||||
"<th class=\"LEFT_MIDDLE\">"
|
"<th class=\"LEFT_MIDDLE\">"
|
||||||
|
@ -2149,9 +2225,23 @@ static void Ctr_PutHeadCentresForSeeing (bool OrderSelectable)
|
||||||
"<th class=\"LEFT_MIDDLE\">"
|
"<th class=\"LEFT_MIDDLE\">"
|
||||||
"%s"
|
"%s"
|
||||||
"</th>"
|
"</th>"
|
||||||
"</tr>",
|
"<th class=\"LEFT_MIDDLE\">"
|
||||||
Txt_Degrees_ABBREVIATION,
|
"%s"
|
||||||
|
"</th>"
|
||||||
|
"<th class=\"LEFT_MIDDLE\">"
|
||||||
|
"%s+<br />%s"
|
||||||
|
"</th>"
|
||||||
|
"<th class=\"LEFT_MIDDLE\">"
|
||||||
|
"%s"
|
||||||
|
"</th>"
|
||||||
|
"</tr>",
|
||||||
Txt_Place,
|
Txt_Place,
|
||||||
|
Txt_Degrees_ABBREVIATION,
|
||||||
|
Txt_Courses_ABBREVIATION,
|
||||||
|
Txt_Teachers_ABBREVIATION,
|
||||||
|
Txt_Students_ABBREVIATION,
|
||||||
|
Txt_Teachers_ABBREVIATION,
|
||||||
|
Txt_Students_ABBREVIATION,
|
||||||
Txt_Status);
|
Txt_Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,12 @@ struct Centre
|
||||||
char ShortName[Ctr_MAX_LENGTH_CENTRE_SHORT_NAME+1];
|
char ShortName[Ctr_MAX_LENGTH_CENTRE_SHORT_NAME+1];
|
||||||
char FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME+1];
|
char FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME+1];
|
||||||
char WWW[Cns_MAX_LENGTH_WWW+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
|
unsigned NumDegs; // Number of degrees in this centre
|
||||||
unsigned NumTchs; // Number of teachers in this centre
|
unsigned NumCrss; // Number of courses in this centre
|
||||||
|
unsigned NumUsrs; // Number of users in courses of this centre
|
||||||
|
unsigned NumTchs; // Number of teachers in courses of this centre
|
||||||
|
unsigned NumStds; // Number of students in courses of this centre
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
|
|
@ -114,12 +114,13 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 15.61 (2015/12/09)"
|
#define Log_PLATFORM_VERSION "SWAD 15.62 (2015/12/09)"
|
||||||
#define CSS_FILE "swad15.60.7.css"
|
#define CSS_FILE "swad15.60.7.css"
|
||||||
|
|
||||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
||||||
/*
|
/*
|
||||||
|
Version 15.62: Dec 09, 2015 Changes in data of centres. (186949 lines)
|
||||||
Version 15.61: Dec 09, 2015 Bug fixing and lot of changes in data of countries and institutions. (186852 lines)
|
Version 15.61: Dec 09, 2015 Bug fixing and lot of changes in data of countries and institutions. (186852 lines)
|
||||||
Version 15.60.6: Dec 08, 2015 Changed icons in login. (186592 lines)
|
Version 15.60.6: Dec 08, 2015 Changed icons in login. (186592 lines)
|
||||||
Version 15.60.5: Dec 08, 2015 Changed some messages related to login. (186589 lines)
|
Version 15.60.5: Dec 08, 2015 Changed some messages related to login. (186589 lines)
|
||||||
|
|
|
@ -824,7 +824,7 @@ unsigned Crs_GetNumCrssTotal (void)
|
||||||
|
|
||||||
unsigned Crs_GetNumCrssInCty (long CtyCod)
|
unsigned Crs_GetNumCrssInCty (long CtyCod)
|
||||||
{
|
{
|
||||||
char Query[512];
|
char Query[256];
|
||||||
|
|
||||||
/***** Get number of courses in a country from database *****/
|
/***** Get number of courses in a country from database *****/
|
||||||
sprintf (Query,"SELECT COUNT(*) FROM institutions,centres,degrees,courses"
|
sprintf (Query,"SELECT COUNT(*) FROM institutions,centres,degrees,courses"
|
||||||
|
@ -842,7 +842,7 @@ unsigned Crs_GetNumCrssInCty (long CtyCod)
|
||||||
|
|
||||||
unsigned Crs_GetNumCrssInIns (long InsCod)
|
unsigned Crs_GetNumCrssInIns (long InsCod)
|
||||||
{
|
{
|
||||||
char Query[512];
|
char Query[256];
|
||||||
|
|
||||||
/***** Get number of courses in a degree from database *****/
|
/***** Get number of courses in a degree from database *****/
|
||||||
sprintf (Query,"SELECT COUNT(*) FROM centres,degrees,courses"
|
sprintf (Query,"SELECT COUNT(*) FROM centres,degrees,courses"
|
||||||
|
@ -859,11 +859,12 @@ unsigned Crs_GetNumCrssInIns (long InsCod)
|
||||||
|
|
||||||
unsigned Crs_GetNumCrssInCtr (long CtrCod)
|
unsigned Crs_GetNumCrssInCtr (long CtrCod)
|
||||||
{
|
{
|
||||||
char Query[512];
|
char Query[256];
|
||||||
|
|
||||||
/***** Get number of courses in a degree from database *****/
|
/***** Get number of courses in a degree from database *****/
|
||||||
sprintf (Query,"SELECT COUNT(*) FROM degrees,courses"
|
sprintf (Query,"SELECT COUNT(*) FROM degrees,courses"
|
||||||
" WHERE degrees.CtrCod='%ld' AND degrees.DegCod=courses.DegCod",
|
" WHERE degrees.CtrCod='%ld'"
|
||||||
|
" AND degrees.DegCod=courses.DegCod",
|
||||||
CtrCod);
|
CtrCod);
|
||||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of courses in a centre");
|
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of courses in a centre");
|
||||||
}
|
}
|
||||||
|
@ -874,7 +875,7 @@ unsigned Crs_GetNumCrssInCtr (long CtrCod)
|
||||||
|
|
||||||
unsigned Crs_GetNumCrssInDeg (long DegCod)
|
unsigned Crs_GetNumCrssInDeg (long DegCod)
|
||||||
{
|
{
|
||||||
char Query[256];
|
char Query[128];
|
||||||
|
|
||||||
/***** Get number of courses in a degree from database *****/
|
/***** Get number of courses in a degree from database *****/
|
||||||
sprintf (Query,"SELECT COUNT(*) FROM courses"
|
sprintf (Query,"SELECT COUNT(*) FROM courses"
|
||||||
|
|
|
@ -2763,20 +2763,6 @@ long Deg_GetParamOtherDegCod (void)
|
||||||
return Str_ConvertStrCodToLongCod (LongStr);
|
return Str_ConvertStrCodToLongCod (LongStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/****************** Count number of degrees in a centre *********************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
unsigned Deg_CountNumDegsInCtr (long CtrCod)
|
|
||||||
{
|
|
||||||
char Query[512];
|
|
||||||
|
|
||||||
/***** Get number of degrees of a type from database *****/
|
|
||||||
sprintf (Query,"SELECT COUNT(*) FROM degrees WHERE CtrCod='%ld'",
|
|
||||||
CtrCod);
|
|
||||||
return (unsigned) DB_QueryCOUNT (Query,"can not get number of degrees in a centre");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**************** Count number of degrees in a degree type ******************/
|
/**************** Count number of degrees in a degree type ******************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -3819,7 +3805,6 @@ bool Deg_CheckIfYearIsValidInDeg (unsigned Year,struct Degree *Deg)
|
||||||
|
|
||||||
void Deg_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
|
void Deg_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Go_to_X;
|
|
||||||
extern const char *Txt_all_degrees;
|
extern const char *Txt_all_degrees;
|
||||||
char Query[1024];
|
char Query[1024];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
|
|
|
@ -132,7 +132,6 @@ void Deg_RemoveDegree (void);
|
||||||
void Deg_PutParamDegCod (long DegCod);
|
void Deg_PutParamDegCod (long DegCod);
|
||||||
long Deg_GetParamOtherDegTypCod (void);
|
long Deg_GetParamOtherDegTypCod (void);
|
||||||
long Deg_GetParamOtherDegCod (void);
|
long Deg_GetParamOtherDegCod (void);
|
||||||
unsigned Deg_CountNumDegsInCtr (long CtrCod);
|
|
||||||
|
|
||||||
bool Deg_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp);
|
bool Deg_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp);
|
||||||
bool Deg_GetDataOfDegreeByCod (struct Degree *Deg);
|
bool Deg_GetDataOfDegreeByCod (struct Degree *Deg);
|
||||||
|
|
|
@ -70,7 +70,6 @@ static void Ins_ListInstitutionsForSeeing (void);
|
||||||
static void Ins_ListOneInstitutionForSeeing (struct Institution *Ins,unsigned NumIns);
|
static void Ins_ListOneInstitutionForSeeing (struct Institution *Ins,unsigned NumIns);
|
||||||
static void Ins_PutHeadInstitutionsForSeeing (bool OrderSelectable);
|
static void Ins_PutHeadInstitutionsForSeeing (bool OrderSelectable);
|
||||||
static void Ins_GetParamInsOrderType (void);
|
static void Ins_GetParamInsOrderType (void);
|
||||||
static unsigned Ins_GetNumUsrsWhoClaimToBelongToIns (long InsCod);
|
|
||||||
static void Ins_ListInstitutionsForEdition (void);
|
static void Ins_ListInstitutionsForEdition (void);
|
||||||
static bool Ins_CheckIfICanEdit (struct Institution *Ins);
|
static bool Ins_CheckIfICanEdit (struct Institution *Ins);
|
||||||
static Ins_StatusTxt_t Ins_GetStatusTxtFromStatusBits (Ins_Status_t Status);
|
static Ins_StatusTxt_t Ins_GetStatusTxtFromStatusBits (Ins_Status_t Status);
|
||||||
|
@ -807,16 +806,11 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData)
|
||||||
switch (GetExtraData)
|
switch (GetExtraData)
|
||||||
{
|
{
|
||||||
case Ins_GET_BASIC_DATA:
|
case Ins_GET_BASIC_DATA:
|
||||||
if (CtyCod <= 0) // Get all the institutions, belonging to any country
|
sprintf (Query,"SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW"
|
||||||
sprintf (Query,"SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW"
|
" FROM institutions"
|
||||||
" FROM institutions"
|
" WHERE CtyCod='%ld'"
|
||||||
" ORDER BY FullName");
|
" ORDER BY FullName",
|
||||||
else // Get only the institutions belonging to the country specified by CtyCod
|
CtyCod);
|
||||||
sprintf (Query,"SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW"
|
|
||||||
" FROM institutions"
|
|
||||||
" WHERE CtyCod='%ld'"
|
|
||||||
" ORDER BY FullName",
|
|
||||||
CtyCod);
|
|
||||||
break;
|
break;
|
||||||
case Ins_GET_EXTRA_DATA:
|
case Ins_GET_EXTRA_DATA:
|
||||||
switch (Gbl.Inss.SelectedOrderType)
|
switch (Gbl.Inss.SelectedOrderType)
|
||||||
|
@ -828,39 +822,23 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData)
|
||||||
sprintf (OrderBySubQuery,"NumUsrs DESC,FullName");
|
sprintf (OrderBySubQuery,"NumUsrs DESC,FullName");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (CtyCod <= 0) // Get all the institutions, belonging to any country
|
sprintf (Query,"(SELECT institutions.InsCod,institutions.CtyCod,"
|
||||||
sprintf (Query,"(SELECT institutions.InsCod,institutions.CtyCod,"
|
"institutions.Status,institutions.RequesterUsrCod,"
|
||||||
"institutions.Status,institutions.RequesterUsrCod,"
|
"institutions.ShortName,institutions.FullName,"
|
||||||
"institutions.ShortName,institutions.FullName,"
|
"institutions.WWW,COUNT(*) AS NumUsrs"
|
||||||
"institutions.WWW,COUNT(*) AS NumUsrs"
|
" FROM institutions,usr_data"
|
||||||
" FROM institutions,usr_data"
|
" WHERE institutions.CtyCod='%ld'"
|
||||||
" WHERE institutions.InsCod=usr_data.InsCod"
|
" AND institutions.InsCod=usr_data.InsCod"
|
||||||
" GROUP BY institutions.InsCod)"
|
" GROUP BY institutions.InsCod)"
|
||||||
" UNION "
|
" UNION "
|
||||||
"(SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW,0 AS NumUsrs"
|
"(SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW,0 AS NumUsrs"
|
||||||
" FROM institutions"
|
" FROM institutions"
|
||||||
" WHERE InsCod NOT IN"
|
" WHERE CtyCod='%ld'"
|
||||||
" (SELECT DISTINCT InsCod FROM usr_data))"
|
" AND InsCod NOT IN"
|
||||||
" ORDER BY %s",
|
" (SELECT DISTINCT InsCod FROM usr_data))"
|
||||||
OrderBySubQuery);
|
" ORDER BY %s",
|
||||||
else // Get only the institutions belonging to the country specified by CtyCod
|
CtyCod,CtyCod,
|
||||||
sprintf (Query,"(SELECT institutions.InsCod,institutions.CtyCod,"
|
OrderBySubQuery);
|
||||||
"institutions.Status,institutions.RequesterUsrCod,"
|
|
||||||
"institutions.ShortName,institutions.FullName,"
|
|
||||||
"institutions.WWW,COUNT(*) AS NumUsrs"
|
|
||||||
" FROM institutions,usr_data"
|
|
||||||
" WHERE institutions.CtyCod='%ld'"
|
|
||||||
" AND institutions.InsCod=usr_data.InsCod"
|
|
||||||
" GROUP BY institutions.InsCod)"
|
|
||||||
" UNION "
|
|
||||||
"(SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW,0 AS NumUsrs"
|
|
||||||
" FROM institutions"
|
|
||||||
" WHERE CtyCod='%ld'"
|
|
||||||
" AND InsCod NOT IN"
|
|
||||||
" (SELECT DISTINCT InsCod FROM usr_data))"
|
|
||||||
" ORDER BY %s",
|
|
||||||
CtyCod,CtyCod,
|
|
||||||
OrderBySubQuery);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get institutions");
|
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get institutions");
|
||||||
|
@ -1011,11 +989,6 @@ bool Ins_GetDataOfInstitutionByCod (struct Institution *Ins,
|
||||||
/* Get extra data */
|
/* Get extra data */
|
||||||
if (GetExtraData == Ins_GET_EXTRA_DATA)
|
if (GetExtraData == Ins_GET_EXTRA_DATA)
|
||||||
{
|
{
|
||||||
/* Get number of users in courses of this institution */
|
|
||||||
Ins->NumUsrs = Usr_GetNumUsrsInCrssOfIns (Rol_UNKNOWN,Ins->InsCod); // Here Rol_UNKNOWN means "all users", NumUsrs <= NumStds + NumTchs
|
|
||||||
Ins->NumStds = Usr_GetNumUsrsInCrssOfIns (Rol_STUDENT,Ins->InsCod);
|
|
||||||
Ins->NumTchs = Usr_GetNumUsrsInCrssOfIns (Rol_TEACHER,Ins->InsCod);
|
|
||||||
|
|
||||||
/* Get number of centres in this institution */
|
/* Get number of centres in this institution */
|
||||||
Ins->NumCtrs = Ctr_GetNumCtrsInIns (Ins->InsCod);
|
Ins->NumCtrs = Ctr_GetNumCtrsInIns (Ins->InsCod);
|
||||||
|
|
||||||
|
@ -1024,6 +997,11 @@ bool Ins_GetDataOfInstitutionByCod (struct Institution *Ins,
|
||||||
|
|
||||||
/* Get number of degrees in this institution */
|
/* Get number of degrees in this institution */
|
||||||
Ins->NumDegs = Deg_GetNumDegsInIns (Ins->InsCod);
|
Ins->NumDegs = Deg_GetNumDegsInIns (Ins->InsCod);
|
||||||
|
|
||||||
|
/* Get number of users in courses of this institution */
|
||||||
|
Ins->NumUsrs = Usr_GetNumUsrsInCrssOfIns (Rol_UNKNOWN,Ins->InsCod); // Here Rol_UNKNOWN means "all users", NumUsrs <= NumStds + NumTchs
|
||||||
|
Ins->NumStds = Usr_GetNumUsrsInCrssOfIns (Rol_STUDENT,Ins->InsCod);
|
||||||
|
Ins->NumTchs = Usr_GetNumUsrsInCrssOfIns (Rol_TEACHER,Ins->InsCod);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1067,21 +1045,6 @@ void Ins_GetShortNameOfInstitutionByCod (struct Institution *Ins)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/****************** Get number of users in an institution ********************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
static unsigned Ins_GetNumUsrsWhoClaimToBelongToIns (long InsCod)
|
|
||||||
{
|
|
||||||
char Query[256];
|
|
||||||
|
|
||||||
/***** Get number of users in an institution from database *****/
|
|
||||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
|
||||||
" WHERE InsCod='%ld'",
|
|
||||||
InsCod);
|
|
||||||
return (unsigned) DB_QueryCOUNT (Query,"can not check number of users in an institution");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************************* Free list of institutions *************************/
|
/************************* Free list of institutions *************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1207,6 +1170,7 @@ static void Ins_ListInstitutionsForEdition (void)
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"BM\">");
|
"<td class=\"BM\">");
|
||||||
if (Ins->NumCtrs ||
|
if (Ins->NumCtrs ||
|
||||||
|
Ins->NumUsrsWhoClaimToBelongToIns ||
|
||||||
Ins->NumUsrs || // Institution has centres or users ==> deletion forbidden
|
Ins->NumUsrs || // Institution has centres or users ==> deletion forbidden
|
||||||
!ICanEdit)
|
!ICanEdit)
|
||||||
Lay_PutIconRemovalNotAllowed ();
|
Lay_PutIconRemovalNotAllowed ();
|
||||||
|
@ -1485,11 +1449,14 @@ void Ins_RemoveInstitution (void)
|
||||||
Lay_ShowErrorAndExit ("Code of institution is missing.");
|
Lay_ShowErrorAndExit ("Code of institution is missing.");
|
||||||
|
|
||||||
/***** Get data of the institution from database *****/
|
/***** Get data of the institution from database *****/
|
||||||
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
|
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_EXTRA_DATA);
|
||||||
|
|
||||||
/***** Check if this institution has users *****/
|
/***** Check if this institution has users *****/
|
||||||
if (Ctr_GetNumCtrsInIns (Ins.InsCod) ||
|
if (!Ins_CheckIfICanEdit (&Ins))
|
||||||
Ins_GetNumUsrsWhoClaimToBelongToIns (Ins.InsCod)) // Institution has centres or users ==> don't remove
|
Lay_ShowErrorAndExit ("You don't have permission to remove institution.");
|
||||||
|
else if (Ins.NumCtrs ||
|
||||||
|
Ins.NumUsrsWhoClaimToBelongToIns ||
|
||||||
|
Ins.NumUsrs) // Institution has centres or users ==> don't remove
|
||||||
Lay_ShowAlert (Lay_WARNING,Txt_To_remove_an_institution_you_must_first_remove_all_centres_and_users_in_the_institution);
|
Lay_ShowAlert (Lay_WARNING,Txt_To_remove_an_institution_you_must_first_remove_all_centres_and_users_in_the_institution);
|
||||||
else // Institution has no users ==> remove it
|
else // Institution has no users ==> remove it
|
||||||
{
|
{
|
||||||
|
|
22
swad_place.c
22
swad_place.c
|
@ -327,6 +327,7 @@ void Plc_GetListPlaces (void)
|
||||||
|
|
||||||
void Plc_GetDataOfPlaceByCod (struct Place *Plc)
|
void Plc_GetDataOfPlaceByCod (struct Place *Plc)
|
||||||
{
|
{
|
||||||
|
extern const char *Txt_Place_unspecified;
|
||||||
extern const char *Txt_Another_place;
|
extern const char *Txt_Another_place;
|
||||||
char Query[1024];
|
char Query[1024];
|
||||||
MYSQL_RES *mysql_res;
|
MYSQL_RES *mysql_res;
|
||||||
|
@ -339,10 +340,19 @@ void Plc_GetDataOfPlaceByCod (struct Place *Plc)
|
||||||
Plc->NumCtrs = 0;
|
Plc->NumCtrs = 0;
|
||||||
|
|
||||||
/***** Check if place code is correct *****/
|
/***** Check if place code is correct *****/
|
||||||
if (Plc->PlcCod == 0)
|
if (Plc->PlcCod < 0)
|
||||||
{
|
{
|
||||||
strcpy (Plc->ShortName,Txt_Another_place);
|
strncpy (Plc->ShortName,Txt_Place_unspecified,Plc_MAX_LENGTH_PLACE_SHORT_NAME);
|
||||||
strcpy (Plc->FullName,Txt_Another_place);
|
Plc->ShortName[Plc_MAX_LENGTH_PLACE_SHORT_NAME] = '\0';
|
||||||
|
strncpy (Plc->FullName,Txt_Place_unspecified,Plc_MAX_LENGTH_PLACE_FULL_NAME);
|
||||||
|
Plc->FullName[Plc_MAX_LENGTH_PLACE_FULL_NAME] = '\0';
|
||||||
|
}
|
||||||
|
else if (Plc->PlcCod == 0)
|
||||||
|
{
|
||||||
|
strncpy (Plc->ShortName,Txt_Another_place,Plc_MAX_LENGTH_PLACE_SHORT_NAME);
|
||||||
|
Plc->ShortName[Plc_MAX_LENGTH_PLACE_SHORT_NAME] = '\0';
|
||||||
|
strncpy (Plc->FullName,Txt_Another_place,Plc_MAX_LENGTH_PLACE_FULL_NAME);
|
||||||
|
Plc->FullName[Plc_MAX_LENGTH_PLACE_FULL_NAME] = '\0';
|
||||||
}
|
}
|
||||||
else if (Plc->PlcCod > 0)
|
else if (Plc->PlcCod > 0)
|
||||||
{
|
{
|
||||||
|
@ -371,10 +381,12 @@ void Plc_GetDataOfPlaceByCod (struct Place *Plc)
|
||||||
row = mysql_fetch_row (mysql_res);
|
row = mysql_fetch_row (mysql_res);
|
||||||
|
|
||||||
/* Get the short name of the place (row[0]) */
|
/* Get the short name of the place (row[0]) */
|
||||||
strcpy (Plc->ShortName,row[0]);
|
strncpy (Plc->ShortName,row[0],Plc_MAX_LENGTH_PLACE_SHORT_NAME);
|
||||||
|
Plc->ShortName[Plc_MAX_LENGTH_PLACE_SHORT_NAME] = '\0';
|
||||||
|
|
||||||
/* Get the full name of the place (row[1]) */
|
/* Get the full name of the place (row[1]) */
|
||||||
strcpy (Plc->FullName,row[1]);
|
strncpy (Plc->FullName,row[1],Plc_MAX_LENGTH_PLACE_FULL_NAME);
|
||||||
|
Plc->FullName[Plc_MAX_LENGTH_PLACE_FULL_NAME] = '\0';
|
||||||
|
|
||||||
/* Get number of centres in this place (row[2]) */
|
/* Get number of centres in this place (row[2]) */
|
||||||
if (sscanf (row[2],"%u",&Plc->NumCtrs) != 1)
|
if (sscanf (row[2],"%u",&Plc->NumCtrs) != 1)
|
||||||
|
|
39
swad_text.c
39
swad_text.c
|
@ -4099,23 +4099,23 @@ const char *Txt_CENTRES_ORDER[2] =
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1
|
#if L==1
|
||||||
"Prof."
|
"Usuaris del centre"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"Lehrkräfte"
|
"Benutzer der Lehrinstitut"
|
||||||
#elif L==3
|
#elif L==3
|
||||||
"Teachers"
|
"Users of the centre"
|
||||||
#elif L==4
|
#elif L==4
|
||||||
"Prof."
|
"Usuarios del centro"
|
||||||
#elif L==5
|
#elif L==5
|
||||||
"Enseign."
|
"Utilisateurs du centre"
|
||||||
#elif L==6
|
#elif L==6
|
||||||
"Prof." // Okoteve traducción
|
"Usuarios del centro" // Okoteve traducción
|
||||||
#elif L==7
|
#elif L==7
|
||||||
"Prof."
|
"Utenti del centro"
|
||||||
#elif L==8
|
#elif L==8
|
||||||
"Nauczycieli"
|
"Użytkownicy centrum"
|
||||||
#elif L==9
|
#elif L==9
|
||||||
"Prof."
|
"Utilizadores do centro"
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47151,6 +47151,27 @@ const char *Txt_X_users_have_been_removed = // Warning: it is very important to
|
||||||
"%u users have been removed."; // Necessita de tradução
|
"%u users have been removed."; // Necessita de tradução
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
const char *Txt_Users_of_the_centre =
|
||||||
|
#if L==1
|
||||||
|
"Usuaris del centre";
|
||||||
|
#elif L==2
|
||||||
|
"Benutzer der Lehrinstitut";
|
||||||
|
#elif L==3
|
||||||
|
"Users of the centre";
|
||||||
|
#elif L==4
|
||||||
|
"Usuarios del centro";
|
||||||
|
#elif L==5
|
||||||
|
"Utilisateurs du centre";
|
||||||
|
#elif L==6
|
||||||
|
"Usuarios del centro"; // Okoteve traducción
|
||||||
|
#elif L==7
|
||||||
|
"Utenti del centro";
|
||||||
|
#elif L==8
|
||||||
|
"Użytkownicy centrum";
|
||||||
|
#elif L==9
|
||||||
|
"Utilizadores do centro";
|
||||||
|
#endif
|
||||||
|
|
||||||
const char *Txt_Users_of_the_country =
|
const char *Txt_Users_of_the_country =
|
||||||
#if L==1
|
#if L==1
|
||||||
"Usuaris del país";
|
"Usuaris del país";
|
||||||
|
|
41
swad_user.c
41
swad_user.c
|
@ -3390,19 +3390,28 @@ unsigned Usr_GetNumUsrsInCrssOfDeg (Rol_Role_t Role,long DegCod)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************ Count how many users with a role belong to a centre ************/
|
/************ Count how many users with a role belong to a centre ************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
// Here Rol_UNKNOWN means students or teachers
|
||||||
|
|
||||||
unsigned Usr_GetNumUsrsInCrssOfCtr (Rol_Role_t Role,long CtrCod)
|
unsigned Usr_GetNumUsrsInCrssOfCtr (Rol_Role_t Role,long CtrCod)
|
||||||
{
|
{
|
||||||
char Query[512];
|
char Query[512];
|
||||||
|
|
||||||
/***** Get the number of users in courses of a centre from database ******/
|
/***** Get the number of users in courses of a centre from database ******/
|
||||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
if (Role == Rol_UNKNOWN) // Any user
|
||||||
" FROM degrees,courses,crs_usr"
|
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||||
" WHERE degrees.CtrCod='%ld'"
|
" FROM degrees,courses,crs_usr"
|
||||||
" AND degrees.DegCod=courses.DegCod"
|
" WHERE degrees.CtrCod='%ld'"
|
||||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
" AND crs_usr.Role='%u'",
|
" AND courses.CrsCod=crs_usr.CrsCod",
|
||||||
CtrCod,(unsigned) Role);
|
CtrCod);
|
||||||
|
else
|
||||||
|
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||||
|
" FROM degrees,courses,crs_usr"
|
||||||
|
" WHERE degrees.CtrCod='%ld'"
|
||||||
|
" AND degrees.DegCod=courses.DegCod"
|
||||||
|
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||||
|
" AND crs_usr.Role='%u'",
|
||||||
|
CtrCod,(unsigned) Role);
|
||||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in courses of a centre");
|
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in courses of a centre");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3415,7 +3424,7 @@ unsigned Usr_GetNumUsrsInCrssOfIns (Rol_Role_t Role,long InsCod)
|
||||||
{
|
{
|
||||||
char Query[512];
|
char Query[512];
|
||||||
|
|
||||||
/***** Get the number of users in a courses of an institution from database ******/
|
/***** Get the number of users in courses of an institution from database ******/
|
||||||
if (Role == Rol_UNKNOWN) // Any user
|
if (Role == Rol_UNKNOWN) // Any user
|
||||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||||
" FROM centres,degrees,courses,crs_usr"
|
" FROM centres,degrees,courses,crs_usr"
|
||||||
|
@ -3578,6 +3587,22 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (long InsCod)
|
||||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in an institution");
|
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in an institution");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/*********** Get number of users who claim to belong to a centre *************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (long CtrCod)
|
||||||
|
{
|
||||||
|
char Query[128];
|
||||||
|
|
||||||
|
/***** Get the number of users in a centre from database *****/
|
||||||
|
sprintf (Query,"SELECT COUNT(DISTINCT UsrCod)"
|
||||||
|
" FROM usr_data"
|
||||||
|
" WHERE usr_data.CtrCod='%ld'",
|
||||||
|
CtrCod);
|
||||||
|
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in a centre");
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************* Get number of teachers in a centre **********************/
|
/******************* Get number of teachers in a centre **********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -283,8 +283,9 @@ long Usr_GetRamdomStdFromCrs (long CrsCod);
|
||||||
long Usr_GetRamdomStdFromGrp (long GrpCod);
|
long Usr_GetRamdomStdFromGrp (long GrpCod);
|
||||||
|
|
||||||
unsigned Usr_GetNumTchsCurrentInsInDepartment (long DptCod);
|
unsigned Usr_GetNumTchsCurrentInsInDepartment (long DptCod);
|
||||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (long InsCod);
|
unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (long CtyCod);
|
||||||
unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (long InsCod);
|
unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (long InsCod);
|
||||||
|
unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (long CtrCod);
|
||||||
unsigned Usr_GetNumberOfTeachersInCentre (long CtrCod);
|
unsigned Usr_GetNumberOfTeachersInCentre (long CtrCod);
|
||||||
|
|
||||||
void Usr_GetUsrsLst (Rol_Role_t Role,Sco_Scope_t ListUsrsRange,const char *TchQuery,bool Search);
|
void Usr_GetUsrsLst (Rol_Role_t Role,Sco_Scope_t ListUsrsRange,const char *TchQuery,bool Search);
|
||||||
|
|
Loading…
Reference in New Issue