diff --git a/swad_centre.c b/swad_centre.c
index 9bf3eb3e5..74089231e 100644
--- a/swad_centre.c
+++ b/swad_centre.c
@@ -79,6 +79,7 @@ extern struct Globals Gbl;
static void Ctr_Configuration (bool PrintView);
static void Ctr_PutIconsToPrintAndUpload (void);
static void Ctr_PutIconToChangePhoto (void);
+static void Ctr_ShowNumUsrsInCrssOfCtr (Rol_Role_t Role);
static void Ctr_ListCentres (void);
static bool Ctr_CheckIfICanCreateCentres (void);
@@ -288,7 +289,6 @@ static void Ctr_Configuration (bool PrintView)
extern const char *Txt_Degrees;
extern const char *Txt_Degrees_of_CENTRE_X;
extern const char *Txt_Courses;
- extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
unsigned NumIns;
struct Place Plc;
char PathPhoto[PATH_MAX + 1];
@@ -618,59 +618,11 @@ static void Ctr_Configuration (bool PrintView)
Txt_Courses,
Crs_GetNumCrssInCtr (Gbl.CurrentCtr.Ctr.CtrCod));
- /***** Number of teachers in courses of this centre *****/
- fprintf (Gbl.F.Out,"
"
- ""
- "%s:"
- " | "
- ""
- "%u"
- " | "
- "
",
- The_ClassForm[Gbl.Prefs.Theme],
- Txt_ROLES_PLURAL_Abc[Rol_TCH][Usr_SEX_UNKNOWN],
- Usr_GetNumUsrsInCrssOfCtr (Rol_TCH,Gbl.CurrentCtr.Ctr.CtrCod));
-
- /***** Number of non-editing teachers in courses of this centre *****/
- fprintf (Gbl.F.Out,""
- ""
- "%s:"
- " | "
- ""
- "%u"
- " | "
- "
",
- The_ClassForm[Gbl.Prefs.Theme],
- Txt_ROLES_PLURAL_Abc[Rol_NED_TCH][Usr_SEX_UNKNOWN],
- Usr_GetNumUsrsInCrssOfCtr (Rol_NED_TCH,Gbl.CurrentCtr.Ctr.CtrCod));
-
- /***** Number of students in courses of this centre *****/
- fprintf (Gbl.F.Out,""
- ""
- "%s:"
- " | "
- ""
- "%u"
- " | "
- "
",
- The_ClassForm[Gbl.Prefs.Theme],
- Txt_ROLES_PLURAL_Abc[Rol_STD][Usr_SEX_UNKNOWN],
- Usr_GetNumUsrsInCrssOfCtr (Rol_STD,Gbl.CurrentCtr.Ctr.CtrCod));
-
/***** Number of users in courses of this centre *****/
- fprintf (Gbl.F.Out,""
- ""
- "%s + %s + %s:"
- " | "
- ""
- "%u"
- " | "
- "
",
- The_ClassForm[Gbl.Prefs.Theme],
- Txt_ROLES_PLURAL_Abc[Rol_TCH ][Usr_SEX_UNKNOWN],
- Txt_ROLES_PLURAL_Abc[Rol_NED_TCH][Usr_SEX_UNKNOWN],
- Txt_ROLES_PLURAL_Abc[Rol_STD ][Usr_SEX_UNKNOWN],
- Usr_GetNumUsrsInCrssOfCtr (Rol_UNK,Gbl.CurrentCtr.Ctr.CtrCod));
+ Ctr_ShowNumUsrsInCrssOfCtr (Rol_TCH);
+ Ctr_ShowNumUsrsInCrssOfCtr (Rol_NED_TCH);
+ Ctr_ShowNumUsrsInCrssOfCtr (Rol_STD);
+ Ctr_ShowNumUsrsInCrssOfCtr (Rol_UNK);
}
/***** End table *****/
@@ -727,6 +679,30 @@ static void Ctr_PutIconToChangePhoto (void)
NULL);
}
+/*****************************************************************************/
+/**************** Number of users in courses of this centre ******************/
+/*****************************************************************************/
+
+static void Ctr_ShowNumUsrsInCrssOfCtr (Rol_Role_t Role)
+ {
+ extern const char *The_ClassForm[The_NUM_THEMES];
+ extern const char *Txt_Users_in_courses;
+ extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
+
+ fprintf (Gbl.F.Out,""
+ ""
+ "%s:"
+ " | "
+ ""
+ "%u"
+ " | "
+ "
",
+ The_ClassForm[Gbl.Prefs.Theme],
+ (Role == Rol_UNK) ? Txt_Users_in_courses :
+ Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN],
+ Usr_GetNumUsrsInCrssOfCtr (Role,Gbl.CurrentCtr.Ctr.CtrCod));
+ }
+
/*****************************************************************************/
/*************** Show the centres of the current institution *****************/
/*****************************************************************************/
diff --git a/swad_changelog.h b/swad_changelog.h
index a7fabe096..d04e67f4b 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -233,13 +233,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 16.220.1 (2017-05-20)"
+#define Log_PLATFORM_VERSION "SWAD 16.220.2 (2017-05-21)"
#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.220.2: May 21, 2017 Changes related with new role. Not finished. (219319 lines)
Version 16.220.1: May 20, 2017 Changes related with new role. Not finished. (219332 lines)
Version 16.220: May 19, 2017 Changes permission of actions after creating new role. Not finished. (219227 lines)
Version 16.219: May 19, 2017 New role: non-editing teacher. Not finished. (219226 lines)
diff --git a/swad_country.c b/swad_country.c
index e50706a90..ca60d6fb1 100644
--- a/swad_country.c
+++ b/swad_country.c
@@ -65,6 +65,7 @@ extern struct Globals Gbl;
static void Cty_Configuration (bool PrintView);
static void Cty_PutIconToPrint (void);
+static void Cty_ShowNumUsrsInCrssOfCty (Rol_Role_t Role);
static void Cty_PutHeadCountriesForSeeing (bool OrderSelectable);
static void Cty_ListOneCountryForSeeing (struct Country *Cty,unsigned NumCty);
@@ -232,7 +233,6 @@ static void Cty_Configuration (bool PrintView)
extern const char *Txt_Degrees;
extern const char *Txt_Courses;
extern const char *Txt_Users_of_the_country;
- extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
char *MapAttribution = NULL;
bool PutLink = !PrintView && Gbl.CurrentCty.Cty.WWW[Gbl.Prefs.Language][0];
@@ -428,45 +428,11 @@ static void Cty_Configuration (bool PrintView)
Txt_Courses,
Crs_GetNumCrssInCty (Gbl.CurrentCty.Cty.CtyCod));
- /***** Number of teachers in courses of this country *****/
- fprintf (Gbl.F.Out,""
- ""
- "%s:"
- " | "
- ""
- "%u"
- " | "
- "
",
- The_ClassForm[Gbl.Prefs.Theme],
- Txt_ROLES_PLURAL_Abc[Rol_TCH][Usr_SEX_UNKNOWN],
- Usr_GetNumUsrsInCrssOfCty (Rol_TCH,Gbl.CurrentCty.Cty.CtyCod));
-
- /***** Number of students in courses of this country *****/
- fprintf (Gbl.F.Out,""
- ""
- "%s:"
- " | "
- ""
- "%u"
- " | "
- "
",
- The_ClassForm[Gbl.Prefs.Theme],
- Txt_ROLES_PLURAL_Abc[Rol_STD][Usr_SEX_UNKNOWN],
- Usr_GetNumUsrsInCrssOfCty (Rol_STD,Gbl.CurrentCty.Cty.CtyCod));
-
/***** Number of users in courses of this country *****/
- fprintf (Gbl.F.Out,""
- ""
- "%s + %s:"
- " | "
- ""
- "%u"
- " | "
- "
",
- The_ClassForm[Gbl.Prefs.Theme],
- Txt_ROLES_PLURAL_Abc[Rol_TCH][Usr_SEX_UNKNOWN],
- Txt_ROLES_PLURAL_Abc[Rol_STD][Usr_SEX_UNKNOWN],
- Usr_GetNumUsrsInCrssOfCty (Rol_UNK,Gbl.CurrentCty.Cty.CtyCod));
+ Cty_ShowNumUsrsInCrssOfCty (Rol_TCH);
+ Cty_ShowNumUsrsInCrssOfCty (Rol_NED_TCH);
+ Cty_ShowNumUsrsInCrssOfCty (Rol_STD);
+ Cty_ShowNumUsrsInCrssOfCty (Rol_UNK);
}
/***** End table *****/
@@ -486,6 +452,30 @@ static void Cty_PutIconToPrint (void)
Lay_PutContextualIconToPrint (ActPrnCtyInf,NULL);
}
+/*****************************************************************************/
+/**************** Number of users in courses of this country *****************/
+/*****************************************************************************/
+
+static void Cty_ShowNumUsrsInCrssOfCty (Rol_Role_t Role)
+ {
+ extern const char *The_ClassForm[The_NUM_THEMES];
+ extern const char *Txt_Users_in_courses;
+ extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
+
+ fprintf (Gbl.F.Out,""
+ ""
+ "%s:"
+ " | "
+ ""
+ "%u"
+ " | "
+ "
",
+ The_ClassForm[Gbl.Prefs.Theme],
+ (Role == Rol_UNK) ? Txt_Users_in_courses :
+ Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN],
+ Usr_GetNumUsrsInCrssOfCty (Role,Gbl.CurrentCty.Cty.CtyCod));
+ }
+
/*****************************************************************************/
/*************************** List all the countries **************************/
/*****************************************************************************/
diff --git a/swad_course.c b/swad_course.c
index 09b3e8947..7c674306b 100644
--- a/swad_course.c
+++ b/swad_course.c
@@ -73,6 +73,7 @@ extern struct Globals Gbl;
static void Crs_Configuration (bool PrintView);
static void Crs_PutIconToPrint (void);
+static void Crs_ShowNumUsrsInCrs (Rol_Role_t Role);
static void Crs_WriteListMyCoursesToSelectOne (void);
@@ -170,7 +171,6 @@ static void Crs_Configuration (bool PrintView)
extern const char *Txt_Shortcut;
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
extern const char *Txt_QR_code;
- extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
extern const char *Txt_Indicators;
extern const char *Txt_of_PART_OF_A_TOTAL;
unsigned NumDeg;
@@ -427,29 +427,10 @@ static void Crs_Configuration (bool PrintView)
}
else
{
- /***** Number of teachers *****/
- fprintf (Gbl.F.Out,""
- ""
- "%s:"
- " | "
- ""
- "%u"
- " | "
- "
",
- The_ClassForm[Gbl.Prefs.Theme],
- Txt_ROLES_PLURAL_Abc[Rol_TCH][Usr_SEX_UNKNOWN],Gbl.CurrentCrs.Crs.NumTchs);
-
- /***** Number of students *****/
- fprintf (Gbl.F.Out,""
- ""
- "%s:"
- " | "
- ""
- "%u"
- " | "
- "
",
- The_ClassForm[Gbl.Prefs.Theme],
- Txt_ROLES_PLURAL_Abc[Rol_STD][Usr_SEX_UNKNOWN],Gbl.CurrentCrs.Crs.NumStds);
+ /***** Number of users *****/
+ Crs_ShowNumUsrsInCrs (Rol_TCH);
+ Crs_ShowNumUsrsInCrs (Rol_NED_TCH);
+ Crs_ShowNumUsrsInCrs (Rol_STD);
/***** Indicators *****/
NumIndicatorsFromDB = Ind_GetNumIndicatorsCrsFromDB (Gbl.CurrentCrs.Crs.CrsCod);
@@ -495,6 +476,28 @@ static void Crs_PutIconToPrint (void)
Lay_PutContextualIconToPrint (ActPrnCrsInf,NULL);
}
+/*****************************************************************************/
+/**************** Number of users in courses of this country *****************/
+/*****************************************************************************/
+
+static void Crs_ShowNumUsrsInCrs (Rol_Role_t Role)
+ {
+ extern const char *The_ClassForm[The_NUM_THEMES];
+ extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
+
+ fprintf (Gbl.F.Out,""
+ ""
+ "%s:"
+ " | "
+ ""
+ "%u"
+ " | "
+ "
",
+ The_ClassForm[Gbl.Prefs.Theme],
+ Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN],
+ Gbl.CurrentCrs.Crs.NumUsrs[Role]);
+ }
+
/*****************************************************************************/
/************************ Write menu with my courses *************************/
/*****************************************************************************/
@@ -1245,12 +1248,12 @@ static bool Crs_ListCoursesOfAYearForSeeing (unsigned Year)
"",
BgColor,
Gbl.Prefs.IconsURL,
- Crs->NumUsrs ? "ok_green" :
- "tr",
- Crs->NumUsrs ? Txt_COURSE_With_users :
- Txt_COURSE_Without_users,
- Crs->NumUsrs ? Txt_COURSE_With_users :
- Txt_COURSE_Without_users);
+ Crs->NumUsrs[Rol_UNK] ? "ok_green" :
+ "tr",
+ Crs->NumUsrs[Rol_UNK] ? Txt_COURSE_With_users :
+ Txt_COURSE_Without_users,
+ Crs->NumUsrs[Rol_UNK] ? Txt_COURSE_With_users :
+ Txt_COURSE_Without_users);
/* Institutional code of the course */
fprintf (Gbl.F.Out,""
@@ -1282,13 +1285,13 @@ static bool Crs_ListCoursesOfAYearForSeeing (unsigned Year)
fprintf (Gbl.F.Out," | "
"%u"
" | ",
- TxtClassNormal,BgColor,Crs->NumTchs);
+ TxtClassNormal,BgColor,Crs->NumUsrs[Rol_TCH]);
/* Current number of students in this course */
fprintf (Gbl.F.Out,""
"%u"
" | ",
- TxtClassNormal,BgColor,Crs->NumStds);
+ TxtClassNormal,BgColor,Crs->NumUsrs[Rol_STD]);
/* Course status */
StatusTxt = Crs_GetStatusTxtFromStatusBits (Crs->Status);
@@ -1404,7 +1407,7 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year)
/* Put icon to remove course */
fprintf (Gbl.F.Out,""
"");
- if (Crs->NumUsrs || // Course has users ==> deletion forbidden
+ if (Crs->NumUsrs[Rol_UNK] || // Course has users ==> deletion forbidden
!ICanEdit)
Lay_PutIconRemovalNotAllowed ();
else // Crs->NumUsrs == 0 && ICanEdit
@@ -1506,13 +1509,13 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year)
fprintf (Gbl.F.Out," | "
"%u"
" | ",
- Crs->NumTchs);
+ Crs->NumUsrs[Rol_TCH]);
/* Current number of students in this course */
fprintf (Gbl.F.Out,""
"%u"
" | ",
- Crs->NumStds);
+ Crs->NumUsrs[Rol_STD]);
/* Course requester */
UsrDat.UsrCod = Crs->RequesterUsrCod;
@@ -1946,9 +1949,9 @@ void Crs_RemoveCourse (void)
if (Crs_CheckIfICanEdit (&Crs))
{
/***** Check if this course has users *****/
- if (Crs.NumUsrs) // Course has users ==> don't remove
+ if (Crs.NumUsrs[Rol_UNK]) // Course has users ==> don't remove
Ale_ShowAlert (Ale_WARNING,Txt_To_remove_a_course_you_must_first_remove_all_users_in_the_course);
- else // Course has no users ==> remove it
+ else // Course has no users ==> remove it
{
/***** Remove course *****/
Crs_RemoveCourseCompletely (Crs.CrsCod);
@@ -1984,9 +1987,9 @@ bool Crs_GetDataOfCourseByCod (struct Course *Crs)
Crs->RequesterUsrCod = -1L;
Crs->ShrtName[0] = '\0';
Crs->FullName[0] = '\0';
- Crs->NumStds = 0;
- Crs->NumTchs = 0;
- Crs->NumUsrs = 0;
+ Crs->NumUsrs[Rol_UNK] = 0;
+ Crs->NumUsrs[Rol_STD] = 0;
+ Crs->NumUsrs[Rol_TCH] = 0;
/***** Check if course code is correct *****/
if (Crs->CrsCod > 0)
@@ -2047,14 +2050,15 @@ static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row)
Str_Copy (Crs->FullName,row[7],
Hie_MAX_BYTES_FULL_NAME);
- /***** Get number of teachers *****/
- Crs->NumTchs = Usr_GetNumUsrsInCrs (Rol_TCH,Crs->CrsCod);
-
/***** Get number of students *****/
- Crs->NumStds = Usr_GetNumUsrsInCrs (Rol_STD,Crs->CrsCod);
+ Crs->NumUsrs[Rol_STD] = Usr_GetNumUsrsInCrs (Rol_STD,Crs->CrsCod);
- Crs->NumUsrs = Crs->NumStds +
- Crs->NumTchs;
+ /***** Get number of teachers *****/
+ Crs->NumUsrs[Rol_TCH] = Usr_GetNumUsrsInCrs (Rol_TCH,Crs->CrsCod);
+
+ /***** Compute total of users in course *****/
+ Crs->NumUsrs[Rol_UNK] = Crs->NumUsrs[Rol_STD] +
+ Crs->NumUsrs[Rol_TCH];
}
/*****************************************************************************/
diff --git a/swad_course.h b/swad_course.h
index b4d26b7fe..d9b057c87 100644
--- a/swad_course.h
+++ b/swad_course.h
@@ -85,9 +85,7 @@ struct Course
long RequesterUsrCod; // User code of the person who requested the creation of this course
char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; // Short name of course
char FullName[Hie_MAX_BYTES_FULL_NAME + 1]; // Full name of course
- unsigned NumUsrs; // Number of users (students + teachers)
- unsigned NumTchs; // Number of teachers
- unsigned NumStds; // Number of students
+ unsigned NumUsrs[Rol_NUM_ROLES]; // Number of users
};
/*****************************************************************************/
diff --git a/swad_enrolment.c b/swad_enrolment.c
index 54f057c07..5a059fc61 100644
--- a/swad_enrolment.c
+++ b/swad_enrolment.c
@@ -595,9 +595,9 @@ static void Enr_ShowFormRegRemSeveralUsrs (Rol_Role_t Role)
extern const char *Txt_Confirm;
/***** Put contextual links *****/
- if (Role == Rol_STD && // Users to admin: students
- Gbl.CurrentCrs.Crs.CrsCod > 0 && // Course selected
- Gbl.CurrentCrs.Crs.NumStds) // This course has students
+ if (Role == Rol_STD && // Users to admin: students
+ Gbl.CurrentCrs.Crs.CrsCod > 0 && // Course selected
+ Gbl.CurrentCrs.Crs.NumUsrs[Rol_STD]) // This course has students
{
fprintf (Gbl.F.Out,"