mirror of https://github.com/acanas/swad-core.git
Version 15.40
This commit is contained in:
parent
b2121bdcde
commit
10ace7a7a8
|
@ -11164,4 +11164,3 @@ SELECT TstCod,AllowTeachers,UNIX_TIMESTAMP(TstTime) AS T,NumQsts,NumQstsNotBlank
|
|||
SELECT * FROM expanded_folders WHERE UNIX_TIMESTAMP() > UNIX_TIMESTAMP(ClickTime)+'1000';
|
||||
SELECT * FROM expanded_folders WHERE ClickTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-'1000');
|
||||
|
||||
|
||||
|
|
|
@ -112,11 +112,12 @@
|
|||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.39.1 (2015/11/16)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.40 (2015/11/17)"
|
||||
|
||||
// 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 15.40: Nov 17, 2015 Changes in listing of countries. (187275 lines)
|
||||
Version 15.39.1: Nov 16, 2015 User' e-mail can be removed even if it is the unique. (187236 lines)
|
||||
Version 15.39: Nov 16, 2015 Administrators can edit another user' e-mails. (187268 lines)
|
||||
9 changes necessary in database:
|
||||
|
|
113
swad_country.c
113
swad_country.c
|
@ -65,6 +65,7 @@ extern struct Globals Gbl;
|
|||
|
||||
static void Cty_Configuration (bool PrintView);
|
||||
|
||||
static unsigned Cty_GetNumUsrsWhoClaimToBelongToCty (long CtyCod);
|
||||
static void Cty_GetParamCtyOrderType (void);
|
||||
static void Cty_GetMapAttribution (long CtyCod,char **MapAttribution);
|
||||
static void Cty_FreeMapAttribution (char **MapAttribution);
|
||||
|
@ -86,7 +87,7 @@ void Cty_SeeCtyWithPendingInss (void)
|
|||
extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES];
|
||||
extern const char *Txt_Countries_with_pending_institutions;
|
||||
extern const char *Txt_Country;
|
||||
extern const char *Txt_Institutions_ABBREVIATION;
|
||||
extern const char *Txt_Institutions;
|
||||
extern const char *Txt_There_are_no_countries_with_requests_for_institutions_to_be_confirmed;
|
||||
char Query[1024];
|
||||
MYSQL_RES *mysql_res;
|
||||
|
@ -126,7 +127,7 @@ void Cty_SeeCtyWithPendingInss (void)
|
|||
"</th>"
|
||||
"</tr>",
|
||||
Txt_Country,
|
||||
Txt_Institutions_ABBREVIATION);
|
||||
Txt_Institutions);
|
||||
|
||||
/***** List the countries *****/
|
||||
for (NumCty = 0;
|
||||
|
@ -453,22 +454,13 @@ void Cty_ListCountries2 (void)
|
|||
extern const char *Txt_Countries;
|
||||
extern const char *Txt_COUNTRIES_HELP_ORDER[2];
|
||||
extern const char *Txt_COUNTRIES_ORDER[2];
|
||||
extern const char *Txt_Students_ABBREVIATION;
|
||||
extern const char *Txt_Teachers_ABBREVIATION;
|
||||
extern const char *Txt_Institutions_ABBREVIATION;
|
||||
extern const char *Txt_Users_in_courses;
|
||||
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||
extern const char *Txt_Institutions;
|
||||
extern const char *Txt_Other_countries;
|
||||
extern const char *Txt_Country_unspecified;
|
||||
Cty_CtysOrderType_t Order;
|
||||
unsigned NumCty;
|
||||
unsigned NumUsrs;
|
||||
unsigned NumStds;
|
||||
unsigned NumTchs;
|
||||
unsigned NumUsrsWithCountry = 0;
|
||||
unsigned NumStdsWithCountry = 0;
|
||||
unsigned NumTchsWithCountry = 0;
|
||||
unsigned NumInssWithCountry = 0;
|
||||
unsigned NumUsrsInOtherCtys;
|
||||
unsigned NumInssInOtherCtys;
|
||||
const char *BgColor;
|
||||
|
||||
/***** Put link (form) to edit countries *****/
|
||||
|
@ -482,7 +474,9 @@ void Cty_ListCountries2 (void)
|
|||
Order <= Cty_ORDER_BY_NUM_USRS;
|
||||
Order++)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<th class=\"LEFT_MIDDLE\">");
|
||||
fprintf (Gbl.F.Out,"<th class=\"%s\">",
|
||||
Order == Cty_ORDER_BY_COUNTRY ? "LEFT_MIDDLE" :
|
||||
"RIGHT_MIDDLE");
|
||||
Act_FormStart (ActSeeCty);
|
||||
Par_PutHiddenParamUnsigned ("Order",(unsigned) Order);
|
||||
Act_LinkFormSubmit (Txt_COUNTRIES_HELP_ORDER[Order],"TIT_TBL");
|
||||
|
@ -496,6 +490,9 @@ void Cty_ListCountries2 (void)
|
|||
fprintf (Gbl.F.Out,"</th>");
|
||||
}
|
||||
fprintf (Gbl.F.Out,"<th class=\"RIGHT_MIDDLE\">"
|
||||
"%s"
|
||||
"</th>"
|
||||
"<th class=\"RIGHT_MIDDLE\">"
|
||||
"%s"
|
||||
"</th>"
|
||||
"<th class=\"RIGHT_MIDDLE\">"
|
||||
|
@ -505,9 +502,10 @@ void Cty_ListCountries2 (void)
|
|||
"%s"
|
||||
"</th>"
|
||||
"</tr>",
|
||||
Txt_Students_ABBREVIATION,
|
||||
Txt_Teachers_ABBREVIATION,
|
||||
Txt_Institutions_ABBREVIATION);
|
||||
Txt_Users_in_courses,
|
||||
Txt_ROLES_PLURAL_Abc[Rol_STUDENT][Usr_SEX_UNKNOWN],
|
||||
Txt_ROLES_PLURAL_Abc[Rol_TEACHER][Usr_SEX_UNKNOWN],
|
||||
Txt_Institutions);
|
||||
|
||||
/***** Write all the countries and their number of users and institutions *****/
|
||||
for (NumCty = 0;
|
||||
|
@ -526,8 +524,6 @@ void Cty_ListCountries2 (void)
|
|||
fprintf (Gbl.F.Out,"</td>");
|
||||
|
||||
/* Write stats of this country */
|
||||
NumStds = Usr_GetNumUsrsInCountry (Rol_STUDENT,Gbl.Ctys.Lst[NumCty].CtyCod);
|
||||
NumTchs = Usr_GetNumUsrsInCountry (Rol_TEACHER,Gbl.Ctys.Lst[NumCty].CtyCod);
|
||||
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
|
@ -540,33 +536,27 @@ void Cty_ListCountries2 (void)
|
|||
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"</tr>",
|
||||
BgColor,Gbl.Ctys.Lst[NumCty].NumUsrs,
|
||||
BgColor,NumStds,
|
||||
BgColor,NumTchs,
|
||||
BgColor,Usr_GetNumUsrsInCrssOfCty (Rol_UNKNOWN,Gbl.Ctys.Lst[NumCty].CtyCod),
|
||||
BgColor,Usr_GetNumUsrsInCrssOfCty (Rol_STUDENT,Gbl.Ctys.Lst[NumCty].CtyCod),
|
||||
BgColor,Usr_GetNumUsrsInCrssOfCty (Rol_TEACHER,Gbl.Ctys.Lst[NumCty].CtyCod),
|
||||
BgColor,Gbl.Ctys.Lst[NumCty].NumInss);
|
||||
NumUsrsWithCountry += Gbl.Ctys.Lst[NumCty].NumUsrs;
|
||||
NumInssWithCountry += Gbl.Ctys.Lst[NumCty].NumInss;
|
||||
NumStdsWithCountry += NumStds;
|
||||
NumTchsWithCountry += NumTchs;
|
||||
|
||||
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
||||
}
|
||||
|
||||
/***** Separation row *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td colspan=\"6\" class=\"DAT CENTER_MIDDLE\">"
|
||||
"<td colspan=\"7\" class=\"DAT CENTER_MIDDLE\">"
|
||||
" "
|
||||
"</td>"
|
||||
"</tr>");
|
||||
|
||||
/***** Write institutions and users with other country *****/
|
||||
NumUsrsInOtherCtys = Usr_GetNumUsrsInCountry (Rol_UNKNOWN,0); // Here Rol_ROLE_UNKNOWN means "all users"
|
||||
NumStds = Usr_GetNumUsrsInCountry (Rol_STUDENT,0);
|
||||
NumTchs = Usr_GetNumUsrsInCountry (Rol_TEACHER,0);
|
||||
NumInssInOtherCtys = Ins_GetNumInssInCty (0);
|
||||
/***** Write users and institutions in other countries *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td></td>"
|
||||
"<td class=\"DAT LEFT_MIDDLE\">"
|
||||
"%s"
|
||||
"</td>"
|
||||
|
@ -582,20 +572,19 @@ void Cty_ListCountries2 (void)
|
|||
"<td class=\"DAT RIGHT_MIDDLE\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"</tr>",
|
||||
Txt_Other_countries,
|
||||
NumUsrsInOtherCtys,NumStds,NumTchs,NumInssInOtherCtys);
|
||||
NumUsrsWithCountry += NumUsrsInOtherCtys;
|
||||
NumStdsWithCountry += NumStds;
|
||||
NumTchsWithCountry += NumTchs;
|
||||
NumInssWithCountry += NumInssInOtherCtys;
|
||||
Cty_GetNumUsrsWhoClaimToBelongToCty (0),
|
||||
Usr_GetNumUsrsInCrssOfCty (Rol_UNKNOWN,0), // Here Rol_ROLE_UNKNOWN means "all users",
|
||||
Usr_GetNumUsrsInCrssOfCty (Rol_STUDENT,0),
|
||||
Usr_GetNumUsrsInCrssOfCty (Rol_TEACHER,0),
|
||||
Ins_GetNumInssInCty (0));
|
||||
|
||||
/***** Write institutions with no country *****/
|
||||
NumStds = Sta_GetTotalNumberOfUsers (Sco_SCOPE_SYS,Rol_STUDENT);
|
||||
NumTchs = Sta_GetTotalNumberOfUsers (Sco_SCOPE_SYS,Rol_TEACHER);
|
||||
NumUsrs = Sta_GetTotalNumberOfUsers (Sco_SCOPE_SYS,Rol_UNKNOWN); // NumUsrs >= NumStds + NumTchs
|
||||
/***** Write users and institutions with unknown country *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td></td>"
|
||||
"<td class=\"DAT LEFT_MIDDLE\">"
|
||||
"%s"
|
||||
"</td>"
|
||||
|
@ -603,20 +592,21 @@ void Cty_ListCountries2 (void)
|
|||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE\">"
|
||||
"%u"
|
||||
"0"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE\">"
|
||||
"%u"
|
||||
"0"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE\">"
|
||||
"0"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"</tr>",
|
||||
Txt_Country_unspecified,
|
||||
NumUsrs - NumUsrsWithCountry,
|
||||
NumStds - NumStdsWithCountry,
|
||||
NumTchs - NumTchsWithCountry,
|
||||
Ins_GetNumInssTotal () - NumInssWithCountry);
|
||||
Cty_GetNumUsrsWhoClaimToBelongToCty (-1L),
|
||||
Ins_GetNumInssInCty (-1L));
|
||||
|
||||
/***** Table end *****/
|
||||
Lay_EndRoundFrameTable ();
|
||||
|
@ -624,8 +614,8 @@ void Cty_ListCountries2 (void)
|
|||
/***** Div for Google Geochart *****/
|
||||
if (Gbl.CurrentAct == ActSeeCty)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<div id='chart_div' style=\"width:625px;"
|
||||
" margin:12px auto;\">"
|
||||
fprintf (Gbl.F.Out,"<div id=\"chart_div\""
|
||||
" style=\"width:500px; margin:12px auto;\">"
|
||||
"</div>");
|
||||
}
|
||||
|
||||
|
@ -633,6 +623,21 @@ void Cty_ListCountries2 (void)
|
|||
Cty_FreeListCountries ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******** Get number of users who claim to belong to other countries *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
static unsigned Cty_GetNumUsrsWhoClaimToBelongToCty (long CtyCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get number of users from database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE CtyCod='%ld'",
|
||||
CtyCod);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get number of users who claim to belong to other countries");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Check if country map exists *************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -1698,7 +1703,7 @@ static void Cty_PutHeadCountries (void)
|
|||
extern const char *Txt_Name;
|
||||
extern const char *Txt_WWW;
|
||||
extern const char *Txt_Users;
|
||||
extern const char *Txt_Institutions_ABBREVIATION;
|
||||
extern const char *Txt_Institutions;
|
||||
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<th class=\"BM\"></th>"
|
||||
|
@ -1727,7 +1732,7 @@ static void Cty_PutHeadCountries (void)
|
|||
Txt_Name,
|
||||
Txt_WWW,
|
||||
Txt_Users,
|
||||
Txt_Institutions_ABBREVIATION);
|
||||
Txt_Institutions);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -176,7 +176,7 @@ void Dpt_SeeDepts (void)
|
|||
"</td>"
|
||||
"</tr>",
|
||||
Txt_Department_unspecified,
|
||||
Sta_GetTotalNumberOfUsers (Sco_SCOPE_INS,
|
||||
Sta_GetTotalNumberOfUsersInCourses (Sco_SCOPE_INS,
|
||||
Rol_TEACHER) - NumTchsInsWithDpt);
|
||||
|
||||
/***** Table end *****/
|
||||
|
|
|
@ -70,7 +70,7 @@ static void Ins_ListInstitutionsForSeeing (void);
|
|||
static void Ins_ListOneInstitutionForSeeing (struct Institution *Ins,unsigned NumIns);
|
||||
static void Ins_PutHeadInstitutionsForSeeing (bool OrderSelectable);
|
||||
static void Ins_GetParamInsOrderType (void);
|
||||
static unsigned Ins_GetNumUsrsInInstitution (long InsCod);
|
||||
static unsigned Ins_GetNumUsrsWhoClaimToBelongToIns (long InsCod);
|
||||
static void Ins_ListInstitutionsForEdition (void);
|
||||
static bool Ins_CheckIfICanEdit (struct Institution *Ins);
|
||||
static Ins_StatusTxt_t Ins_GetStatusTxtFromStatusBits (Ins_Status_t Status);
|
||||
|
@ -993,12 +993,13 @@ void Ins_GetShortNameOfInstitutionByCod (struct Institution *Ins)
|
|||
/****************** Get number of users in an institution ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static unsigned Ins_GetNumUsrsInInstitution (long InsCod)
|
||||
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'",
|
||||
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");
|
||||
}
|
||||
|
@ -1407,7 +1408,7 @@ void Ins_RemoveInstitution (void)
|
|||
|
||||
/***** Check if this institution has users *****/
|
||||
if (Ctr_GetNumCtrsInIns (Ins.InsCod) ||
|
||||
Ins_GetNumUsrsInInstitution (Ins.InsCod)) // Institution has centres or users ==> don't remove
|
||||
Ins_GetNumUsrsWhoClaimToBelongToIns (Ins.InsCod)) // 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);
|
||||
else // Institution has no users ==> remove it
|
||||
{
|
||||
|
|
|
@ -374,7 +374,7 @@ void Net_ShowWebAndSocialNetworksStats (void)
|
|||
unsigned NumUsrs;
|
||||
|
||||
/***** Get total number of users in platform *****/
|
||||
NumUsrsTotalInPlatform = Sta_GetTotalNumberOfUsers (Gbl.Scope.Current,Rol_UNKNOWN);
|
||||
NumUsrsTotalInPlatform = Sta_GetTotalNumberOfUsersInCourses (Gbl.Scope.Current,Rol_UNKNOWN);
|
||||
|
||||
/***** Get number of users with a web / social network *****/
|
||||
switch (Gbl.Scope.Current)
|
||||
|
|
|
@ -4007,8 +4007,12 @@ static void Sta_GetAndShowUsersStats (void)
|
|||
Txt_No_of_users,
|
||||
Txt_Average_number_of_courses_to_which_a_user_belongs,
|
||||
Txt_Average_number_of_users_belonging_to_a_course);
|
||||
Usr_GetAndShowNumUsrsInPlatform (Rol_STUDENT);
|
||||
Usr_GetAndShowNumUsrsInPlatform (Rol_TEACHER);
|
||||
Usr_GetAndShowNumUsrsInPlatform (Rol_STUDENT); // Students
|
||||
Usr_GetAndShowNumUsrsInPlatform (Rol_TEACHER); // Teachers
|
||||
Usr_GetAndShowNumUsrsInPlatform (Rol_UNKNOWN); // Students and teachers
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<th colspan=\"4\" style=\"height:10px;\">"
|
||||
"</tr>");
|
||||
Usr_GetAndShowNumUsrsInPlatform (Rol__GUEST_); // Users not beloging to any course
|
||||
|
||||
Lay_EndRoundFrameTable ();
|
||||
|
@ -5175,8 +5179,9 @@ static unsigned Sta_GetInsAndStat (struct Institution *Ins,MYSQL_RES *mysql_res)
|
|||
/*****************************************************************************/
|
||||
/************************* Get total number of users *************************/
|
||||
/*****************************************************************************/
|
||||
// Here Rol_ROLE_UNKNOWN means "students or teachers"
|
||||
|
||||
unsigned Sta_GetTotalNumberOfUsers (Sco_Scope_t Scope,Rol_Role_t Role)
|
||||
unsigned Sta_GetTotalNumberOfUsersInCourses (Sco_Scope_t Scope,Rol_Role_t Role)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
|
@ -5184,15 +5189,16 @@ unsigned Sta_GetTotalNumberOfUsers (Sco_Scope_t Scope,Rol_Role_t Role)
|
|||
switch (Scope)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
if (Role == Rol_UNKNOWN) // Here Rol_ROLE_UNKNOWN means "all users"
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data");
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT UsrCod)"
|
||||
" FROM crs_usr");
|
||||
else
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT UsrCod)"
|
||||
" FROM crs_usr WHERE Role='%u'",
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
if (Role == Rol_UNKNOWN) // Here Rol_ROLE_UNKNOWN means "all users"
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod='%ld'"
|
||||
|
@ -5213,7 +5219,7 @@ unsigned Sta_GetTotalNumberOfUsers (Sco_Scope_t Scope,Rol_Role_t Role)
|
|||
Gbl.CurrentCty.Cty.CtyCod,(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
if (Role == Rol_UNKNOWN) // Here Rol_ROLE_UNKNOWN means "all users"
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr"
|
||||
" WHERE centres.InsCod='%ld'"
|
||||
|
@ -5232,7 +5238,7 @@ unsigned Sta_GetTotalNumberOfUsers (Sco_Scope_t Scope,Rol_Role_t Role)
|
|||
Gbl.CurrentIns.Ins.InsCod,(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
if (Role == Rol_UNKNOWN) // Here Rol_ROLE_UNKNOWN means "all users"
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM degrees,courses,crs_usr"
|
||||
" WHERE degrees.CtrCod='%ld'"
|
||||
|
@ -5249,7 +5255,7 @@ unsigned Sta_GetTotalNumberOfUsers (Sco_Scope_t Scope,Rol_Role_t Role)
|
|||
Gbl.CurrentCtr.Ctr.CtrCod,(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
if (Role == Rol_UNKNOWN) // Here Rol_ROLE_UNKNOWN means "all users"
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod='%ld'"
|
||||
|
@ -5264,7 +5270,7 @@ unsigned Sta_GetTotalNumberOfUsers (Sco_Scope_t Scope,Rol_Role_t Role)
|
|||
Gbl.CurrentDeg.Deg.DegCod,(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
if (Role == Rol_UNKNOWN) // Here Rol_ROLE_UNKNOWN means "all users"
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT UsrCod) FROM crs_usr"
|
||||
" WHERE CrsCod='%ld'",
|
||||
Gbl.CurrentCrs.Crs.CrsCod);
|
||||
|
@ -6593,13 +6599,14 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
Txt_Number_of_BR_e_mails);
|
||||
|
||||
/***** Get total number of users in platform *****/
|
||||
NumUsrsTotalInPlatform = Sta_GetTotalNumberOfUsers (Gbl.Scope.Current,Rol_UNKNOWN);
|
||||
NumUsrsTotalInPlatform = Sta_GetTotalNumberOfUsersInCourses (Gbl.Scope.Current,Rol_UNKNOWN); // !!!!!!
|
||||
|
||||
/***** Get total number of users who want to be notified by e-mail on some event, from database *****/
|
||||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data WHERE EmailNtfEvents<>0");
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE EmailNtfEvents<>0");
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
|
@ -6666,7 +6673,8 @@ static void Sta_GetAndShowNumUsrsPerNotifyEvent (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data WHERE ((EmailNtfEvents & %u)<>0)",
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE ((EmailNtfEvents & %u)<>0)",
|
||||
(1 << NotifyEvent));
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
|
@ -8100,7 +8108,8 @@ static void Sta_GetAndShowNumUsrsPerIconSet (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data WHERE IconSet='%s'",
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE IconSet='%s'",
|
||||
Ico_IconSetId[IconSet]);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
|
@ -8373,7 +8382,8 @@ static void Sta_GetAndShowNumUsrsPerSideColumns (void)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data WHERE SideCols='%u'",
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE SideCols='%u'",
|
||||
SideCols);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
|
|
|
@ -148,7 +148,7 @@ void Sta_SeeCrsAccesses (void);
|
|||
void Sta_ReqUseOfPlatform (void);
|
||||
void Pho_PutHiddenParamFigureType (void);
|
||||
void Sta_ShowUseOfPlatform (void);
|
||||
unsigned Sta_GetTotalNumberOfUsers (Sco_Scope_t Scope,Rol_Role_t Role);
|
||||
unsigned Sta_GetTotalNumberOfUsersInCourses (Sco_Scope_t Scope,Rol_Role_t Role);
|
||||
void Sta_WriteParamsDatesSeeAccesses (void);
|
||||
|
||||
void Sta_ComputeTimeToGeneratePage (void);
|
||||
|
|
60
swad_text.c
60
swad_text.c
|
@ -5130,23 +5130,23 @@ const char *Txt_COUNTRIES_ORDER[2] =
|
|||
#endif
|
||||
,
|
||||
#if L==0
|
||||
"Usuaris"
|
||||
"Usuaris d'aquesta nacionalitat"
|
||||
#elif L==1
|
||||
"Benutzer"
|
||||
"Benutzer dieser Staatsangehörigkeit"
|
||||
#elif L==2
|
||||
"Users"
|
||||
"Users of that nationality"
|
||||
#elif L==3
|
||||
"Usuarios"
|
||||
"Usuarios de esa nacionalidad"
|
||||
#elif L==4
|
||||
"Utilisateurs"
|
||||
"Utilisateurs de cette nationalité"
|
||||
#elif L==5
|
||||
"Usuarios" // Okoteve traducción
|
||||
"Usuarios de esa nacionalidad" // Okoteve traducción
|
||||
#elif L==6
|
||||
"Utenti"
|
||||
"Utenti di questa nazionalità"
|
||||
#elif L==7
|
||||
"Users"
|
||||
"Użytkownicy tej narodowości"
|
||||
#elif L==8
|
||||
"Utilizadores"
|
||||
"Utilizadores dessa nacionalidade"
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -14781,27 +14781,6 @@ const char *Txt_Institutions =
|
|||
"Instituções";
|
||||
#endif
|
||||
|
||||
const char *Txt_Institutions_ABBREVIATION =
|
||||
#if L==0
|
||||
"Instit.";
|
||||
#elif L==1
|
||||
"Hochschulen";
|
||||
#elif L==2
|
||||
"Instit.";
|
||||
#elif L==3
|
||||
"Instit.";
|
||||
#elif L==4
|
||||
"Instit.";
|
||||
#elif L==5
|
||||
"Instit."; // Okoteve traducción
|
||||
#elif L==6
|
||||
"Istit.";
|
||||
#elif L==7
|
||||
"Instyt.";
|
||||
#elif L==8
|
||||
"Instit.";
|
||||
#endif
|
||||
|
||||
const char *Txt_institutions =
|
||||
#if L==0
|
||||
"institucions";
|
||||
|
@ -47392,6 +47371,27 @@ const char *Txt_X_users_have_been_removed = // Warning: it is very important to
|
|||
"%u users have been removed."; // Necessita de tradução
|
||||
#endif
|
||||
|
||||
const char *Txt_Users_in_courses =
|
||||
#if L==0
|
||||
"Usuaris en assignatures";
|
||||
#elif L==1
|
||||
"Benutzer in Kurse";
|
||||
#elif L==2
|
||||
"Users in courses";
|
||||
#elif L==3
|
||||
"Usuarios en asignaturas";
|
||||
#elif L==4
|
||||
"Utilisateurs dans matières";
|
||||
#elif L==5
|
||||
"Usuarios en asignaturas"; // Okoteve traducción
|
||||
#elif L==6
|
||||
"Utenti in corsi";
|
||||
#elif L==7
|
||||
"Użytkowników w kursõw";
|
||||
#elif L==8
|
||||
"Usuários em disciplinas";
|
||||
#endif
|
||||
|
||||
const char *Txt_usr = // Abbreviation of user (three characters + dot)
|
||||
#if L==0
|
||||
"usr."; // Necessita traduccio
|
||||
|
|
450
swad_user.c
450
swad_user.c
|
@ -178,7 +178,6 @@ static void Usr_DrawClassPhoto (Usr_ClassPhotoType_t ClassPhotoType,
|
|||
Rol_Role_t RoleInClassPhoto);
|
||||
|
||||
static unsigned Usr_GetNumUsrsNotBelongingToAnyCrs (void);
|
||||
static unsigned Usr_GetNumUsrsBelongingToAnyCrs (Rol_Role_t Role);
|
||||
static float Usr_GetNumCrssPerUsr (Rol_Role_t Role);
|
||||
static float Usr_GetNumUsrsPerCrs (Rol_Role_t Role);
|
||||
|
||||
|
@ -1362,7 +1361,8 @@ bool Usr_ChkIfEncryptedUsrCodExists (const char *EncryptedUsrCod)
|
|||
char Query[512];
|
||||
|
||||
/***** Get if an encrypted user's code already existed in database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data WHERE EncryptedUsrCod='%s'",
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE EncryptedUsrCod='%s'",
|
||||
EncryptedUsrCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if an encrypted user's code already existed") != 0);
|
||||
}
|
||||
|
@ -3424,43 +3424,32 @@ unsigned Usr_GetNumUsrsInCrssOfIns (Rol_Role_t Role,long InsCod)
|
|||
/*****************************************************************************/
|
||||
/****** Count how many users with a role belong to courses of a country ******/
|
||||
/*****************************************************************************/
|
||||
|
||||
// Here Rol_UNKNOWN means students or teachers
|
||||
unsigned Usr_GetNumUsrsInCrssOfCty (Rol_Role_t Role,long CtyCod)
|
||||
{
|
||||
char Query[512];
|
||||
|
||||
/***** Get the number of users in a degree from database ******/
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod='%ld'"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'",
|
||||
CtyCod,(unsigned) Role);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in courses of a country");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********************** Get number of users in a country ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned Usr_GetNumUsrsInCountry (Rol_Role_t Role,long CtyCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Get the number of users (with a role) in a country from database ******/
|
||||
if (Role == Rol_UNKNOWN) // Here Rol_ROLE_UNKNOWN means "all users"
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE CtyCod='%ld'",CtyCod);
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod='%ld'"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod",
|
||||
CtyCod);
|
||||
else
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT usr_data.UsrCod)"
|
||||
" FROM usr_data,crs_usr"
|
||||
" WHERE usr_data.CtyCod='%ld'"
|
||||
" AND usr_data.UsrCod=crs_usr.UsrCod AND crs_usr.Role='%u'",
|
||||
CtyCod,(unsigned) Role);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in a country");
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod='%ld'"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'",
|
||||
CtyCod,(unsigned) Role);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of users in courses of a country");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -7261,7 +7250,8 @@ bool Usr_ChkIfUsrCodExists (long UsrCod)
|
|||
return false;
|
||||
|
||||
/***** Get if a user exists in database *****/
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data WHERE UsrCod='%ld'",
|
||||
sprintf (Query,"SELECT COUNT(*) FROM usr_data"
|
||||
" WHERE UsrCod='%ld'",
|
||||
UsrCod);
|
||||
return (DB_QueryCOUNT (Query,"can not check if a user exists") != 0);
|
||||
}
|
||||
|
@ -7281,47 +7271,52 @@ void Usr_ShowWarningNoUsersFound (Rol_Role_t Role)
|
|||
/*****************************************************************************/
|
||||
/************************ See stats about the platform ***********************/
|
||||
/*****************************************************************************/
|
||||
// Here Rol_ROLE_UNKNOWN means "all users"
|
||||
|
||||
void Usr_GetAndShowNumUsrsInPlatform (Rol_Role_t Role)
|
||||
{
|
||||
extern const char *Txt_Total;
|
||||
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||
unsigned NumUsrs;
|
||||
float NumCrssPerUsr;
|
||||
float NumUsrsPerCrs;
|
||||
char *Class = (Role == Rol_UNKNOWN) ? "DAT_N_LINE_TOP RIGHT_BOTTOM" :
|
||||
"DAT RIGHT_BOTTOM";
|
||||
|
||||
/***** Get the number of users belonging to any course *****/
|
||||
if (Role == Rol__GUEST_) // Users not beloging to any course
|
||||
NumUsrs = Usr_GetNumUsrsNotBelongingToAnyCrs ();
|
||||
else
|
||||
NumUsrs = Usr_GetNumUsrsBelongingToAnyCrs (Role);
|
||||
NumUsrs = Sta_GetTotalNumberOfUsersInCourses (Gbl.Scope.Current,Role);
|
||||
|
||||
/***** Get average number of courses per user *****/
|
||||
NumCrssPerUsr = (Role == Rol__GUEST_) ? 0 :
|
||||
Usr_GetNumCrssPerUsr (Role);
|
||||
Usr_GetNumCrssPerUsr (Role);
|
||||
|
||||
/***** Query the number of users per course *****/
|
||||
NumUsrsPerCrs = (Role == Rol__GUEST_) ? 0 :
|
||||
Usr_GetNumUsrsPerCrs (Role);
|
||||
Usr_GetNumUsrsPerCrs (Role);
|
||||
|
||||
/***** Write the total number of users *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td class=\"DAT RIGHT_BOTTOM\">"
|
||||
"<td class=\"%s\">"
|
||||
"%s"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_BOTTOM\">"
|
||||
"<td class=\"%s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_BOTTOM\">"
|
||||
"<td class=\"%s\">"
|
||||
"%.2f"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_BOTTOM\">"
|
||||
"<td class=\"%s\">"
|
||||
"%.2f"
|
||||
"</td>"
|
||||
"</tr>",
|
||||
Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN],
|
||||
NumUsrs,
|
||||
NumCrssPerUsr,
|
||||
NumUsrsPerCrs);
|
||||
Class,(Role == Rol_UNKNOWN) ? Txt_Total :
|
||||
Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN],
|
||||
Class,NumUsrs,
|
||||
Class,NumCrssPerUsr,
|
||||
Class,NumUsrsPerCrs);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -7340,81 +7335,7 @@ static unsigned Usr_GetNumUsrsNotBelongingToAnyCrs (void)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************** Get number of courses with users of a type ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static unsigned Usr_GetNumUsrsBelongingToAnyCrs (Rol_Role_t Role)
|
||||
{
|
||||
char Query[1024];
|
||||
|
||||
/***** Get number of users who belong to any course *****/
|
||||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT UsrCod)"
|
||||
" FROM crs_usr"
|
||||
" WHERE Role='%u'",
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod='%ld'"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'",
|
||||
Gbl.CurrentCty.Cty.CtyCod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM centres,degrees,courses,crs_usr"
|
||||
" WHERE centres.InsCod='%ld'"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
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'",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod='%ld'"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'",
|
||||
Gbl.CurrentDeg.Deg.DegCod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||
" FROM crs_usr"
|
||||
" WHERE crs_usr.CrsCod='%ld'"
|
||||
" AND crs_usr.Role='%u'",
|
||||
Gbl.CurrentCrs.Crs.CrsCod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
default:
|
||||
Lay_ShowErrorAndExit ("Wrong scope.");
|
||||
break;
|
||||
}
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get number of users who belong to any course");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Get average number of courses with users of a type *************/
|
||||
/************ Get average number of courses with users of a role *************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static float Usr_GetNumCrssPerUsr (Rol_Role_t Role)
|
||||
|
@ -7428,61 +7349,109 @@ static float Usr_GetNumCrssPerUsr (Rol_Role_t Role)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(CrsCod) AS NumCrss"
|
||||
" FROM crs_usr"
|
||||
" WHERE Role='%u' GROUP BY UsrCod) AS NumCrssTable",
|
||||
(unsigned) Role);
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(CrsCod) AS NumCrss"
|
||||
" FROM crs_usr"
|
||||
" GROUP BY UsrCod) AS NumCrssTable");
|
||||
else
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(CrsCod) AS NumCrss"
|
||||
" FROM crs_usr"
|
||||
" WHERE Role='%u' GROUP BY UsrCod) AS NumCrssTable",
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(crs_usr.CrsCod) AS NumCrss"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod='%ld'"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.CurrentCty.Cty.CtyCod,
|
||||
(unsigned) Role);
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(crs_usr.CrsCod) AS NumCrss"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod='%ld'"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
else
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(crs_usr.CrsCod) AS NumCrss"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod='%ld'"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.CurrentCty.Cty.CtyCod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(crs_usr.CrsCod) AS NumCrss"
|
||||
" FROM centres,degrees,courses,crs_usr"
|
||||
" WHERE centres.InsCod='%ld'"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
(unsigned) Role);
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(crs_usr.CrsCod) AS NumCrss"
|
||||
" FROM centres,degrees,courses,crs_usr"
|
||||
" WHERE centres.InsCod='%ld'"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
else
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(crs_usr.CrsCod) AS NumCrss"
|
||||
" FROM centres,degrees,courses,crs_usr"
|
||||
" WHERE centres.InsCod='%ld'"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(crs_usr.CrsCod) AS NumCrss"
|
||||
" 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'"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
(unsigned) Role);
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(crs_usr.CrsCod) AS NumCrss"
|
||||
" FROM degrees,courses,crs_usr"
|
||||
" WHERE degrees.CtrCod='%ld'"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
else
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(crs_usr.CrsCod) AS NumCrss"
|
||||
" 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'"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(crs_usr.CrsCod) AS NumCrss"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod='%ld'"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.CurrentDeg.Deg.DegCod,
|
||||
(unsigned) Role);
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(crs_usr.CrsCod) AS NumCrss"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod='%ld'"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
else
|
||||
sprintf (Query,"SELECT AVG(NumCrss) FROM "
|
||||
"(SELECT COUNT(crs_usr.CrsCod) AS NumCrss"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod='%ld'"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'"
|
||||
" GROUP BY crs_usr.UsrCod) AS NumCrssTable",
|
||||
Gbl.CurrentDeg.Deg.DegCod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
return 1.0;
|
||||
|
@ -7517,65 +7486,114 @@ static float Usr_GetNumUsrsPerCrs (Rol_Role_t Role)
|
|||
switch (Gbl.Scope.Current)
|
||||
{
|
||||
case Sco_SCOPE_SYS:
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(UsrCod) AS NumUsrs"
|
||||
" FROM crs_usr"
|
||||
" WHERE Role='%u' GROUP BY CrsCod) AS NumUsrsTable",
|
||||
(unsigned) Role);
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(UsrCod) AS NumUsrs"
|
||||
" FROM crs_usr"
|
||||
" GROUP BY CrsCod) AS NumUsrsTable");
|
||||
else
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(UsrCod) AS NumUsrs"
|
||||
" FROM crs_usr"
|
||||
" WHERE Role='%u' GROUP BY CrsCod) AS NumUsrsTable",
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(crs_usr.UsrCod) AS NumUsrs"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod='%ld'"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.CurrentCty.Cty.CtyCod,
|
||||
(unsigned) Role);
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(crs_usr.UsrCod) AS NumUsrs"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod='%ld'"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
else
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(crs_usr.UsrCod) AS NumUsrs"
|
||||
" FROM institutions,centres,degrees,courses,crs_usr"
|
||||
" WHERE institutions.CtyCod='%ld'"
|
||||
" AND institutions.InsCod=centres.InsCod"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.CurrentCty.Cty.CtyCod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(crs_usr.UsrCod) AS NumUsrs"
|
||||
" FROM centres,degrees,courses,crs_usr"
|
||||
" WHERE centres.InsCod='%ld'"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
(unsigned) Role);
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(crs_usr.UsrCod) AS NumUsrs"
|
||||
" FROM centres,degrees,courses,crs_usr"
|
||||
" WHERE centres.InsCod='%ld'"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.CurrentIns.Ins.InsCod);
|
||||
else
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(crs_usr.UsrCod) AS NumUsrs"
|
||||
" FROM centres,degrees,courses,crs_usr"
|
||||
" WHERE centres.InsCod='%ld'"
|
||||
" AND centres.CtrCod=degrees.CtrCod"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.CurrentIns.Ins.InsCod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_CTR:
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(crs_usr.UsrCod) AS NumUsrs"
|
||||
" 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'"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
(unsigned) Role);
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(crs_usr.UsrCod) AS NumUsrs"
|
||||
" FROM degrees,courses,crs_usr"
|
||||
" WHERE degrees.CtrCod='%ld'"
|
||||
" AND degrees.DegCod=courses.DegCod"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod);
|
||||
else
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(crs_usr.UsrCod) AS NumUsrs"
|
||||
" 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'"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.CurrentCtr.Ctr.CtrCod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_DEG:
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(crs_usr.UsrCod) AS NumUsrs"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod='%ld'"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.CurrentDeg.Deg.DegCod,
|
||||
(unsigned) Role);
|
||||
if (Role == Rol_UNKNOWN) // Any user
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(crs_usr.UsrCod) AS NumUsrs"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod='%ld'"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.CurrentDeg.Deg.DegCod);
|
||||
else
|
||||
sprintf (Query,"SELECT AVG(NumUsrs) FROM "
|
||||
"(SELECT COUNT(crs_usr.UsrCod) AS NumUsrs"
|
||||
" FROM courses,crs_usr"
|
||||
" WHERE courses.DegCod='%ld'"
|
||||
" AND courses.CrsCod=crs_usr.CrsCod"
|
||||
" AND crs_usr.Role='%u'"
|
||||
" GROUP BY crs_usr.CrsCod) AS NumUsrsTable",
|
||||
Gbl.CurrentDeg.Deg.DegCod,
|
||||
(unsigned) Role);
|
||||
break;
|
||||
case Sco_SCOPE_CRS:
|
||||
return (float) ((Role == Rol_TEACHER) ? Gbl.CurrentCrs.Crs.NumTchs :
|
||||
Gbl.CurrentCrs.Crs.NumStds);
|
||||
return (float) ( Role == Rol_UNKNOWN ? Gbl.CurrentCrs.Crs.NumUsrs : // Any user
|
||||
(Role == Rol_TEACHER ? Gbl.CurrentCrs.Crs.NumTchs : // Teachers
|
||||
Gbl.CurrentCrs.Crs.NumStds)); // Students
|
||||
default:
|
||||
Lay_ShowErrorAndExit ("Wrong scope.");
|
||||
break;
|
||||
|
|
|
@ -278,7 +278,6 @@ unsigned Usr_GetNumUsrsInCrssOfDeg (Rol_Role_t Role,long DegCod);
|
|||
unsigned Usr_GetNumUsrsInCrssOfCtr (Rol_Role_t Role,long CtrCod);
|
||||
unsigned Usr_GetNumUsrsInCrssOfIns (Rol_Role_t Role,long InsCod);
|
||||
unsigned Usr_GetNumUsrsInCrssOfCty (Rol_Role_t Role,long CtyCod);
|
||||
unsigned Usr_GetNumUsrsInCountry (Rol_Role_t Role,long CtyCod);
|
||||
|
||||
long Usr_GetRamdomStdFromCrs (long CrsCod);
|
||||
long Usr_GetRamdomStdFromGrp (long GrpCod);
|
||||
|
|
Loading…
Reference in New Issue