Version 15.245.4

This commit is contained in:
Antonio Cañas Vargas 2016-07-26 01:03:41 +02:00
parent 7074316c9b
commit 4c75fcfd91
4 changed files with 54 additions and 42 deletions

View File

@ -412,8 +412,7 @@ bool ID_ICanSeeAnotherUsrID (struct UsrData *UsrDat)
case Rol_TEACHER:
/* If I am a teacher of current course,
I only can see the user's IDs of students from current course */
return (UsrDat->Accepted &&
UsrDat->RoleInCurrentCrsDB == Rol_STUDENT);
return (UsrDat->RoleInCurrentCrsDB == Rol_STUDENT && UsrDat->Accepted);
case Rol_DEG_ADM:
/* If I am an administrator of current degree,
I only can see the user's IDs of users from current degree */

View File

@ -136,13 +136,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.245.3 (2016-07-24)"
#define Log_PLATFORM_VERSION "SWAD 15.245.4 (2016-07-26)"
#define CSS_FILE "swad15.229.css"
#define JS_FILE "swad15.238.1.js"
// Number of lines (includes comments but not blank lines) has been got with the following command:
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/*
Version 15.245.4: Jul 26, 2016 Fixed bug in user's data. (? lines)
Version 15.245.3: Jul 25, 2016 Listing of guests uses the list filled instead of querying database a second time to get all user's data. (204088 lines)
Version 15.245.2: Jul 25, 2016 Listing of students/teachers uses the list filled instead of querying database a second time to get all user's data. (204088 lines)
Version 15.245.1: Jul 25, 2016 Code refactoring in building of queries to get/search users. (204081 lines)

View File

@ -3575,18 +3575,20 @@ static void Usr_BuildQueryToGetUsrsLstCrs (Rol_Role_t Role,char *Query)
"usr_data.Photo,"
"usr_data.PhotoVisibility,"
"usr_data.InsCod,"
"crs_usr.Role,"
"crs_usr.Accepted";
/*
row[0]: usr_data.UsrCod
row[1]: usr_data.EncryptedUsrCod
row[2]: usr_data.Surname1
row[3]: usr_data.Surname2
row[4]: usr_data.FirstName
row[5]: usr_data.Sex
row[6]: usr_data.Photo
row[7]: usr_data.PhotoVisibility
row[8]: usr_data.InsCod
row[9]: crs_usr.Accepted (only if Scope == Sco_SCOPE_CRS)
row[ 0]: usr_data.UsrCod
row[ 1]: usr_data.EncryptedUsrCod
row[ 2]: usr_data.Surname1
row[ 3]: usr_data.Surname2
row[ 4]: usr_data.FirstName
row[ 5]: usr_data.Sex
row[ 6]: usr_data.Photo
row[ 7]: usr_data.PhotoVisibility
row[ 8]: usr_data.InsCod
row[ 9]: crs_usr.Role (only if Scope == Sco_SCOPE_CRS)
row[10]: crs_usr.Accepted (only if Scope == Sco_SCOPE_CRS)
*/
/***** If there are no groups selected, don't do anything *****/
@ -3736,16 +3738,17 @@ void Usr_GetListUsrs (Rol_Role_t Role,Sco_Scope_t Scope)
"usr_data.PhotoVisibility,"
"usr_data.InsCod";
/*
row[0]: usr_data.UsrCod
row[1]: usr_data.EncryptedUsrCod
row[2]: usr_data.Surname1
row[3]: usr_data.Surname2
row[4]: usr_data.FirstName
row[5]: usr_data.Sex
row[6]: usr_data.Photo
row[7]: usr_data.PhotoVisibility
row[8]: usr_data.InsCod
row[9]: crs_usr.Accepted (only if Scope == Sco_SCOPE_CRS)
row[ 0]: usr_data.UsrCod
row[ 1]: usr_data.EncryptedUsrCod
row[ 2]: usr_data.Surname1
row[ 3]: usr_data.Surname2
row[ 4]: usr_data.FirstName
row[ 5]: usr_data.Sex
row[ 6]: usr_data.Photo
row[ 7]: usr_data.PhotoVisibility
row[ 8]: usr_data.InsCod
row[ 9]: crs_usr.Role (only if Scope == Sco_SCOPE_CRS)
row[10]: crs_usr.Accepted (only if Scope == Sco_SCOPE_CRS)
*/
/***** Build query *****/
@ -4426,16 +4429,17 @@ static void Usr_GetListUsrsFromQuery (const char *Query,Rol_Role_t Role,Sco_Scop
/* Get next user */
row = mysql_fetch_row (mysql_res);
/*
row[0]: usr_data.UsrCod
row[1]: usr_data.EncryptedUsrCod
row[2]: usr_data.Surname1
row[3]: usr_data.Surname2
row[4]: usr_data.FirstName
row[5]: usr_data.Sex
row[6]: usr_data.Photo
row[7]: usr_data.PhotoVisibility
row[8]: usr_data.InsCod
row[9]: crs_usr.Accepted (only if Scope == Sco_SCOPE_CRS)
row[ 0]: usr_data.UsrCod
row[ 1]: usr_data.EncryptedUsrCod
row[ 2]: usr_data.Surname1
row[ 3]: usr_data.Surname2
row[ 4]: usr_data.FirstName
row[ 5]: usr_data.Sex
row[ 6]: usr_data.Photo
row[ 7]: usr_data.PhotoVisibility
row[ 8]: usr_data.InsCod
row[ 9]: crs_usr.Role (only if Scope == Sco_SCOPE_CRS)
row[10]: crs_usr.Accepted (only if Scope == Sco_SCOPE_CRS)
*/
UsrInList = &Gbl.Usrs.LstUsrs[Role].Lst[NumUsr];
@ -4471,8 +4475,8 @@ static void Usr_GetListUsrsFromQuery (const char *Query,Rol_Role_t Role,Sco_Scop
/* Get user's institution code (row[8]) */
UsrInList->InsCod = Str_ConvertStrCodToLongCod (row[8]);
/* Get user's acceptance of enrollment in course(s)
(row[9] if Scope == Sco_SCOPE_CRS) */
/* Get user's role and acceptance of enrollment in course(s)
(row[9], row[10] if Scope == Sco_SCOPE_CRS) */
switch (Role)
{
case Rol_UNKNOWN: // Here Rol_UNKNOWN means any user
@ -4482,7 +4486,8 @@ static void Usr_GetListUsrsFromQuery (const char *Query,Rol_Role_t Role,Sco_Scop
Lay_ShowErrorAndExit ("Wrong scope.");
break;
case Sco_SCOPE_SYS: // System
// Query result has not a third column with the acceptation
// Query result has not a column with the acceptation
UsrInList->RoleInCurrentCrsDB = Rol_UNKNOWN;
if (Usr_GetNumCrssOfUsr (UsrInList->UsrCod))
UsrInList->Accepted = (Usr_GetNumCrssOfUsrNotAccepted (UsrInList->UsrCod) == 0);
else
@ -4492,12 +4497,14 @@ static void Usr_GetListUsrsFromQuery (const char *Query,Rol_Role_t Role,Sco_Scop
case Sco_SCOPE_INS: // Institution
case Sco_SCOPE_CTR: // Centre
case Sco_SCOPE_DEG: // Degree
// Query result has not a third column with the acceptation
// Query result has not a column with the acceptation
UsrInList->RoleInCurrentCrsDB = Rol_UNKNOWN;
UsrInList->Accepted = (Usr_GetNumCrssOfUsrNotAccepted (UsrInList->UsrCod) == 0);
break;
case Sco_SCOPE_CRS: // Course
// Query result has a third column with the acceptation
UsrInList->Accepted = (Str_ConvertToUpperLetter (row[9][0]) == 'Y');
// Query result has a column with the acceptation
UsrInList->RoleInCurrentCrsDB = Rol_ConvertUnsignedStrToRole (row[9]);
UsrInList->Accepted = (Str_ConvertToUpperLetter (row[10][0]) == 'Y');
break;
}
break;
@ -4505,6 +4512,7 @@ static void Usr_GetListUsrsFromQuery (const char *Query,Rol_Role_t Role,Sco_Scop
// ...so they have not accepted...
// ...inscription in any course
case Rol_DEG_ADM: // Any admin (degree, centre, institution or system)
UsrInList->RoleInCurrentCrsDB = Rol_UNKNOWN;
UsrInList->Accepted = false;
break;
case Rol_STUDENT:
@ -4519,12 +4527,14 @@ static void Usr_GetListUsrsFromQuery (const char *Query,Rol_Role_t Role,Sco_Scop
case Sco_SCOPE_INS: // Institution
case Sco_SCOPE_CTR: // Centre
case Sco_SCOPE_DEG: // Degree
// Query result has not a third column with the acceptation
// Query result has not a column with the acceptation
UsrInList->RoleInCurrentCrsDB = Rol_UNKNOWN;
UsrInList->Accepted = (Usr_GetNumCrssOfUsrWithARoleNotAccepted (UsrInList->UsrCod,Role) == 0);
break;
case Sco_SCOPE_CRS: // Course
// Query result has a third column with the acceptation
UsrInList->Accepted = (Str_ConvertToUpperLetter (row[9][0]) == 'Y');
// Query result has a column with the acceptation
UsrInList->RoleInCurrentCrsDB = Rol_ConvertUnsignedStrToRole (row[9]);
UsrInList->Accepted = (Str_ConvertToUpperLetter (row[10][0]) == 'Y');
break;
}
break;
@ -4561,6 +4571,7 @@ void Usr_CopyBasicUsrDataFromList (struct UsrData *UsrDat,const struct UsrInList
strcpy (UsrDat->Photo ,UsrInList->Photo);
UsrDat->PhotoVisibility = UsrInList->PhotoVisibility;
UsrDat->InsCod = UsrInList->InsCod;
UsrDat->RoleInCurrentCrsDB = UsrInList->RoleInCurrentCrsDB;
UsrDat->Accepted = UsrInList->Accepted;
}

View File

@ -184,6 +184,7 @@ struct UsrInList
char Photo[Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64+1]; // Name of public link to photo
Pri_Visibility_t PhotoVisibility; // Who can see user's photo
long InsCod; // Institution
Rol_Role_t RoleInCurrentCrsDB; // Role in current course in database
bool Accepted; // User has accepted joining to one/all courses?
bool Remove; // A boolean associated with each user that indicates if it must be removed
};