Version 14.81.2

This commit is contained in:
Antonio Cañas Vargas 2015-03-09 19:22:25 +01:00
parent 5c0fafb58a
commit aec8df96e4
3 changed files with 108 additions and 4 deletions

View File

@ -103,11 +103,12 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 14.81.1 (2015/03/09)"
#define Log_PLATFORM_VERSION "SWAD 14.81.2 (2015/03/09)"
// 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 | tail -1
/*
Version 14.81.2: Mar 09, 2015 Information about number of courses in user's public profile. (? lines)
Version 14.81.1: Mar 09, 2015 Information about number of messages sent in user's public profile. (179545 lines)
Version 14.81: Mar 09, 2015 Information about number of forum posts in user's public profile. (179512 lines)
Version 14.80.19: Mar 09, 2015 Fixed bug in web service, reported by Juan Miguel Boyero Corral. (179482 lines)

View File

@ -5548,6 +5548,27 @@ const char *Txt_courses =
"disciplinas";
#endif
const char *Txt_Courses_as_a_ROLE = // Warning: it is very important to include %s in the following sentences
#if L==0
"Assignatures com %s";
#elif L==1
"Kurse als %s";
#elif L==2
"Courses as %s";
#elif L==3
"Asignaturas como %s";
#elif L==4
"Matières comme %s";
#elif L==5
"Asignaturas como %s"; // Okoteve traducción
#elif L==6
"Corsi come %s";
#elif L==7
"Kursy jako %s";
#elif L==8
"Disciplinas como %s";
#endif
const char *Txt_X_courses_have_been_eliminated = // Warning: it is very important to include %u in the following sentences
#if L==0
"Se ha(n) eliminado %u asignatura(s)."; // Necessita traduccio

View File

@ -110,6 +110,9 @@ static void Usr_GetMyLastData (void);
static void Usr_GetUsrCommentsFromString (char *Str,struct UsrData *UsrDat);
static Usr_Sex_t Usr_GetSexFromStr (const char *Str);
static unsigned Usr_GetNumCrssOfUsrWithARole (long UsrCod,Rol_Role_t Role);
static unsigned Usr_GetNumUsrsOtherRoleInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,Rol_Role_t OthersRole);
static bool Usr_CheckIfMyBirthdayHasNotBeenCongratulated (void);
static void Usr_InsertMyBirthday (void);
@ -716,7 +719,7 @@ bool Usr_CheckIfUsrIsAdm (long UsrCod,Sco_Scope_t Scope,long Cod)
bool Usr_CheckIfUsrIsSuperuser (long UsrCod)
{
char Query[512];
char Query[128];
/***** Get if a user is superuser from database *****/
sprintf (Query,"SELECT COUNT(*) FROM admin"
@ -725,6 +728,38 @@ bool Usr_CheckIfUsrIsSuperuser (long UsrCod)
return (DB_QueryCOUNT (Query,"can not check if a user is superuser") != 0);
}
/*****************************************************************************/
/********* Get number of courses in with a user have a given role ************/
/*****************************************************************************/
static unsigned Usr_GetNumCrssOfUsrWithARole (long UsrCod,Rol_Role_t Role)
{
char Query[128];
/***** Get the number of teachers in a course from database ******/
sprintf (Query,"SELECT COUNT(*) FROM crs_usr"
" WHERE UsrCod='%ld' AND Role='%u'",
UsrCod,(unsigned) Role);
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of courses of a user with a role");
}
/*****************************************************************************/
/********* Get number of students in courses of a user as teacher ************/
/*****************************************************************************/
static unsigned Usr_GetNumUsrsOtherRoleInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,Rol_Role_t OthersRole)
{
char Query[256];
/***** Get the number of teachers in a course from database ******/
sprintf (Query,"SELECT COUNT(DISTINCT UsrCod) FROM crs_usr"
" WHERE CrsCod IN"
" (SELECT CrsCod FROM crs_usr WHERE UsrCod='%ld' AND Role='%u')"
" AND Role='%u'",
UsrCod,(unsigned) UsrRole,(unsigned) OthersRole);
return (unsigned) DB_QueryCOUNT (Query,"can not get the number of courses of a user with a role");
}
/*****************************************************************************/
/*************** Check if a user belongs to any of my courses ****************/
/*****************************************************************************/
@ -7518,15 +7553,21 @@ void Usr_ChangeProfileVisibility (void)
void Usr_ShowDetailsUserProfile (const struct UsrData *UsrDat)
{
extern const char *The_ClassFormul[The_NUM_THEMES];
extern const char *Txt_Shortcut;
extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES];
// extern const char *Txt_Shortcut;
// extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES];
extern const char *Txt_Courses_as_a_ROLE;
extern const char *Txt_ROLES_SINGULAR_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
extern const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
extern const char *Txt_Forum_posts;
extern const char *Txt_Messages_sent;
unsigned NumCrssUsrIsTeacher = Usr_GetNumCrssOfUsrWithARole (UsrDat->UsrCod,Rol_ROLE_TEACHER);
unsigned NumCrssUsrIsStudent = Usr_GetNumCrssOfUsrWithARole (UsrDat->UsrCod,Rol_ROLE_STUDENT);
/***** Start table *****/
Lay_StartRoundFrameTable10 (NULL,2,NULL);
/***** Shortcut to the user's profile *****/
/*
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s\""
" style=\"text-align:right; vertical-align:middle;\">"
@ -7543,6 +7584,47 @@ void Usr_ShowDetailsUserProfile (const struct UsrData *UsrDat)
Txt_Shortcut,
Cfg_HTTPS_URL_SWAD_CGI,Txt_STR_LANG_ID[Gbl.Prefs.Language],UsrDat->Nickname,
Cfg_HTTPS_URL_SWAD_CGI,Txt_STR_LANG_ID[Gbl.Prefs.Language],UsrDat->Nickname);
*/
/***** Number of courses in which the user is teacher or student *****/
if (NumCrssUsrIsTeacher)
{
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s\""
" style=\"text-align:right; vertical-align:middle;\">",
The_ClassFormul[Gbl.Prefs.Theme]);
fprintf (Gbl.F.Out,Txt_Courses_as_a_ROLE,
Txt_ROLES_SINGULAR_abc[Rol_ROLE_TEACHER][UsrDat->Sex]);
fprintf (Gbl.F.Out,":"
"</td>"
"<td class=\"DAT\""
" style=\"text-align:left; vertical-align:middle;\">"
"%u (%u %s)"
"</a>"
"</td>",
NumCrssUsrIsTeacher,
Usr_GetNumUsrsOtherRoleInCrssOfAUsr (UsrDat->UsrCod,Rol_ROLE_TEACHER,Rol_ROLE_STUDENT),
Txt_ROLES_PLURAL_abc[Rol_ROLE_STUDENT][Usr_SEX_UNKNOWN]);
}
if (NumCrssUsrIsStudent)
{
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s\""
" style=\"text-align:right; vertical-align:middle;\">",
The_ClassFormul[Gbl.Prefs.Theme]);
fprintf (Gbl.F.Out,Txt_Courses_as_a_ROLE,
Txt_ROLES_SINGULAR_abc[Rol_ROLE_STUDENT][UsrDat->Sex]);
fprintf (Gbl.F.Out,":"
"</td>"
"<td class=\"DAT\""
" style=\"text-align:left; vertical-align:middle;\">"
"%u (%u %s)"
"</a>"
"</td>"
"</tr>",
NumCrssUsrIsStudent,
Usr_GetNumUsrsOtherRoleInCrssOfAUsr (UsrDat->UsrCod,Rol_ROLE_STUDENT,Rol_ROLE_TEACHER),
Txt_ROLES_PLURAL_abc[Rol_ROLE_TEACHER][Usr_SEX_UNKNOWN]);
}
/***** Number of posts in forums *****/
fprintf (Gbl.F.Out,"<tr>"