Version19.207.1

This commit is contained in:
acanas 2020-04-30 02:29:44 +02:00
parent 88285fb61b
commit c9bbd04759
7 changed files with 62 additions and 61 deletions

View File

@ -1051,7 +1051,7 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat,
/***** Remove user from the tables of courses and users *****/ /***** Remove user from the tables of courses and users *****/
DB_QueryDELETE ("can not remove a user from all courses", DB_QueryDELETE ("can not remove a user from all courses",
"DELETE FROM crs_usr_last WHERE UsrCod=%ld", "DELETE FROM usr_crs_last WHERE UsrCod=%ld",
UsrDat->UsrCod); UsrDat->UsrCod);
DB_QueryDELETE ("can not remove a user from all courses", DB_QueryDELETE ("can not remove a user from all courses",
"DELETE FROM crs_usr WHERE UsrCod=%ld", "DELETE FROM crs_usr WHERE UsrCod=%ld",

View File

@ -544,10 +544,18 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD: En OpenSWAD:
ps2pdf source.ps destination.pdf ps2pdf source.ps destination.pdf
*/ */
#define Log_PLATFORM_VERSION "SWAD 19.207 (2020-04-29)" #define Log_PLATFORM_VERSION "SWAD 19.207.1 (2020-04-29)"
#define CSS_FILE "swad19.193.1.css" #define CSS_FILE "swad19.193.1.css"
#define JS_FILE "swad19.193.1.js" #define JS_FILE "swad19.193.1.js"
/* /*
Version 19.207.1: Apr 30, 2020 Optimization in table of last prefs on user-course. (300323 lines)
5 changes necessary in database:
ALTER TABLE crs_usr CHANGE COLUMN CrsCod CrsCod INT NOT NULL;
ALTER TABLE crs_usr_last CHANGE COLUMN CrsCod CrsCod INT NOT NULL AFTER UsrCod;
ALTER TABLE crs_usr_last DROP INDEX CrsCod;
OPTIMIZE TABLE crs_usr;
OPTIMIZE TABLE crs_usr_last;
Version 19.207: Apr 30, 2020 Table with inscriptions of users in courses is splitted into two tables for speed. (300323 lines) Version 19.207: Apr 30, 2020 Table with inscriptions of users in courses is splitted into two tables for speed. (300323 lines)
8 changes necessary in database: 8 changes necessary in database:
RENAME TABLE crs_usr_old TO crs_usr_old_backup_delete_me; RENAME TABLE crs_usr_old TO crs_usr_old_backup_delete_me;

View File

@ -847,27 +847,18 @@ mysql> DESCRIBE crs_records;
/***** Table crs_usr *****/ /***** Table crs_usr *****/
/* /*
mysql> DESCRIBE crs_usr; mysql> DESCRIBE crs_usr;
+----------------+---------------------------+------+-----+------------+-------+ +----------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+----------------+---------------------------+------+-----+------------+-------+ +----------+---------------+------+-----+---------+-------+
| CrsCod | int(11) | NO | PRI | -1 | | | CrsCod | int(11) | NO | PRI | NULL | |
| UsrCod | int(11) | NO | PRI | NULL | | | UsrCod | int(11) | NO | PRI | NULL | |
| Role | tinyint(4) | NO | PRI | 0 | | | Role | tinyint(4) | NO | MUL | 0 | |
| Accepted | enum('N','Y') | NO | | N | | | Accepted | enum('N','Y') | NO | | N | |
| LastDowGrpCod | int(11) | NO | | -1 | | +----------+---------------+------+-----+---------+-------+
| LastComGrpCod | int(11) | NO | | -1 | | 4 rows in set (0.00 sec)
| LastAssGrpCod | int(11) | NO | | -1 | |
| NumAccTst | int(11) | NO | | 0 | |
| LastAccTst | datetime | NO | | NULL | |
| NumQstsLastTst | int(11) | NO | | 0 | |
| UsrListType | enum('classphoto','list') | NO | | classphoto | |
| ColsClassPhoto | tinyint(4) | NO | | NULL | |
| ListWithPhotos | enum('N','Y') | NO | | Y | |
+----------------+---------------------------+------+-----+------------+-------+
13 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS crs_usr (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS crs_usr ("
"CrsCod INT NOT NULL DEFAULT -1," "CrsCod INT NOT NULL,"
"UsrCod INT NOT NULL," "UsrCod INT NOT NULL,"
"Role TINYINT NOT NULL DEFAULT 0," "Role TINYINT NOT NULL DEFAULT 0,"
"Accepted ENUM('N','Y') NOT NULL DEFAULT 'N'," "Accepted ENUM('N','Y') NOT NULL DEFAULT 'N',"
@ -886,10 +877,8 @@ mysql> DESCRIBE crs_usr_last;
+----------------+---------------------------+------+-----+------------+-------+ +----------------+---------------------------+------+-----+------------+-------+
| Field | Type | Null | Key | Default | Extra | | Field | Type | Null | Key | Default | Extra |
+----------------+---------------------------+------+-----+------------+-------+ +----------------+---------------------------+------+-----+------------+-------+
| CrsCod | int(11) | NO | PRI | -1 | |
| UsrCod | int(11) | NO | PRI | NULL | | | UsrCod | int(11) | NO | PRI | NULL | |
| Role | tinyint(4) | NO | PRI | 0 | | | CrsCod | int(11) | NO | PRI | NULL | |
| Accepted | enum('N','Y') | NO | | N | |
| LastDowGrpCod | int(11) | NO | | -1 | | | LastDowGrpCod | int(11) | NO | | -1 | |
| LastComGrpCod | int(11) | NO | | -1 | | | LastComGrpCod | int(11) | NO | | -1 | |
| LastAssGrpCod | int(11) | NO | | -1 | | | LastAssGrpCod | int(11) | NO | | -1 | |
@ -900,11 +889,11 @@ mysql> DESCRIBE crs_usr_last;
| ColsClassPhoto | tinyint(4) | NO | | NULL | | | ColsClassPhoto | tinyint(4) | NO | | NULL | |
| ListWithPhotos | enum('N','Y') | NO | | Y | | | ListWithPhotos | enum('N','Y') | NO | | Y | |
+----------------+---------------------------+------+-----+------------+-------+ +----------------+---------------------------+------+-----+------------+-------+
13 rows in set (0.00 sec) 11 rows in set (0.00 sec)
*/ */
DB_CreateTable ("CREATE TABLE IF NOT EXISTS crs_usr_last (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS crs_usr_last ("
"CrsCod INT NOT NULL DEFAULT -1,"
"UsrCod INT NOT NULL," "UsrCod INT NOT NULL,"
"CrsCod INT NOT NULL,"
"LastDowGrpCod INT NOT NULL DEFAULT -1," "LastDowGrpCod INT NOT NULL DEFAULT -1,"
"LastComGrpCod INT NOT NULL DEFAULT -1," "LastComGrpCod INT NOT NULL DEFAULT -1,"
"LastAssGrpCod INT NOT NULL DEFAULT -1," "LastAssGrpCod INT NOT NULL DEFAULT -1,"
@ -914,7 +903,6 @@ mysql> DESCRIBE crs_usr_last;
"UsrListType ENUM('classphoto','list') NOT NULL DEFAULT 'classphoto'," "UsrListType ENUM('classphoto','list') NOT NULL DEFAULT 'classphoto',"
"ColsClassPhoto TINYINT NOT NULL," "ColsClassPhoto TINYINT NOT NULL,"
"ListWithPhotos ENUM('N','Y') NOT NULL DEFAULT 'Y'," "ListWithPhotos ENUM('N','Y') NOT NULL DEFAULT 'Y',"
"UNIQUE INDEX(CrsCod,UsrCod),"
"UNIQUE INDEX(UsrCod,CrsCod))"); "UNIQUE INDEX(UsrCod,CrsCod))");
/***** Table crs_usr_requests *****/ /***** Table crs_usr_requests *****/

View File

@ -300,7 +300,7 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
/***** Register last prefs in current course in database *****/ /***** Register last prefs in current course in database *****/
DB_QueryINSERT ("can not register user in course", DB_QueryINSERT ("can not register user in course",
"INSERT INTO crs_usr_last" "INSERT INTO crs_usr_last"
" (CrsCod,UsrCod," " (UsrCod,CrsCod,"
"LastDowGrpCod,LastComGrpCod,LastAssGrpCod," "LastDowGrpCod,LastComGrpCod,LastAssGrpCod,"
"NumAccTst,LastAccTst,NumQstsLastTst," "NumAccTst,LastAccTst,NumQstsLastTst,"
"UsrListType,ColsClassPhoto,ListWithPhotos)" "UsrListType,ColsClassPhoto,ListWithPhotos)"
@ -309,7 +309,7 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
"-1,-1,-1," "-1,-1,-1,"
"0,FROM_UNIXTIME(%ld),0," "0,FROM_UNIXTIME(%ld),0,"
"'%s',%u,'%c')", "'%s',%u,'%c')",
Gbl.Hierarchy.Crs.CrsCod,UsrDat->UsrCod, UsrDat->UsrCod,Gbl.Hierarchy.Crs.CrsCod,
(long) (time_t) 0, // The user never accessed to tests in this course (long) (time_t) 0, // The user never accessed to tests in this course
Usr_StringsUsrListTypeInDB[Usr_SHOW_USRS_TYPE_DEFAULT], Usr_StringsUsrListTypeInDB[Usr_SHOW_USRS_TYPE_DEFAULT],
Usr_CLASS_PHOTO_COLS_DEF, Usr_CLASS_PHOTO_COLS_DEF,
@ -4137,8 +4137,8 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,
/***** Remove user from the tables of courses-users *****/ /***** Remove user from the tables of courses-users *****/
DB_QueryDELETE ("can not remove a user from a course", DB_QueryDELETE ("can not remove a user from a course",
"DELETE FROM crs_usr_last" "DELETE FROM crs_usr_last"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE UsrCod=%ld AND CrsCod=%ld",
Crs->CrsCod,UsrDat->UsrCod); UsrDat->UsrCod,Crs->CrsCod);
DB_QueryDELETE ("can not remove a user from a course", DB_QueryDELETE ("can not remove a user from a course",
"DELETE FROM crs_usr" "DELETE FROM crs_usr"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE CrsCod=%ld AND UsrCod=%ld",

View File

@ -3922,9 +3922,10 @@ static void Brw_UpdateGrpLastAccZone (const char *FieldNameDB,long GrpCod)
/***** Update the group of my last access to a common zone *****/ /***** Update the group of my last access to a common zone *****/
DB_QueryUPDATE ("can not update the group of the last access to a file browser", DB_QueryUPDATE ("can not update the group of the last access to a file browser",
"UPDATE crs_usr_last SET %s=%ld" "UPDATE crs_usr_last SET %s=%ld"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE UsrCod=%ld AND CrsCod=%ld",
FieldNameDB,GrpCod, FieldNameDB,GrpCod,
Gbl.Hierarchy.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Hierarchy.Crs.CrsCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -5250,10 +5251,10 @@ static long Brw_GetGrpLastAccZone (const char *FieldNameDB)
" of your last access" " of your last access"
" to a file browser", " to a file browser",
"SELECT %s FROM crs_usr_last" "SELECT %s FROM crs_usr_last"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE UsrCod=%ld AND CrsCod=%ld",
FieldNameDB, FieldNameDB,
Gbl.Hierarchy.Crs.CrsCod, Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Hierarchy.Crs.CrsCod);
if (NumRows == 0) // May be an administrator not belonging to this course if (NumRows == 0) // May be an administrator not belonging to this course
GrpCod = -1L; GrpCod = -1L;

View File

@ -705,10 +705,10 @@ static bool Tst_CheckIfNextTstAllowed (void)
"UNIX_TIMESTAMP()," // row[0] "UNIX_TIMESTAMP()," // row[0]
"UNIX_TIMESTAMP(LastAccTst+INTERVAL (NumQstsLastTst*%lu) SECOND)" // row[1] "UNIX_TIMESTAMP(LastAccTst+INTERVAL (NumQstsLastTst*%lu) SECOND)" // row[1]
" FROM crs_usr_last" " FROM crs_usr_last"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE UsrCod=%ld AND CrsCod=%ld",
TstCfg_GetConfigMinTimeNxtTstPerQst (), TstCfg_GetConfigMinTimeNxtTstPerQst (),
TstCfg_GetConfigMinTimeNxtTstPerQst (), TstCfg_GetConfigMinTimeNxtTstPerQst (),
Gbl.Hierarchy.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod) == 1) Gbl.Usrs.Me.UsrDat.UsrCod,Gbl.Hierarchy.Crs.CrsCod) == 1)
{ {
/* Get seconds from now to next access to test */ /* Get seconds from now to next access to test */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
@ -758,9 +758,9 @@ static unsigned Tst_GetNumExamsGeneratedByMe (void)
NumRows = DB_QuerySELECT (&mysql_res,"can not get number of test exams generated", NumRows = DB_QuerySELECT (&mysql_res,"can not get number of test exams generated",
"SELECT NumAccTst" // row[0] "SELECT NumAccTst" // row[0]
" FROM crs_usr_last" " FROM crs_usr_last"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE UsrCod=%ld AND CrsCod=%ld",
Gbl.Hierarchy.Crs.CrsCod, Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Hierarchy.Crs.CrsCod);
if (NumRows == 0) if (NumRows == 0)
NumExamsGeneratedByMe = 0; NumExamsGeneratedByMe = 0;
@ -1170,8 +1170,9 @@ static void Tst_IncreaseMyNumAccessTst (void)
/***** Update my number of accesses to test in this course *****/ /***** Update my number of accesses to test in this course *****/
DB_QueryUPDATE ("can not update the number of accesses to test", DB_QueryUPDATE ("can not update the number of accesses to test",
"UPDATE crs_usr_last SET NumAccTst=NumAccTst+1" "UPDATE crs_usr_last SET NumAccTst=NumAccTst+1"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE UsrCod=%ld AND CrsCod=%ld",
Gbl.Hierarchy.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Hierarchy.Crs.CrsCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1183,10 +1184,10 @@ static void Tst_UpdateLastAccTst (unsigned NumQsts)
/***** Update date-time and number of questions of this test *****/ /***** Update date-time and number of questions of this test *****/
DB_QueryUPDATE ("can not update time and number of questions of this test", DB_QueryUPDATE ("can not update time and number of questions of this test",
"UPDATE crs_usr_last SET LastAccTst=NOW(),NumQstsLastTst=%u" "UPDATE crs_usr_last SET LastAccTst=NOW(),NumQstsLastTst=%u"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE UsrCod=%ld AND CrsCod=%ld",
NumQsts, NumQsts,
Gbl.Hierarchy.Crs.CrsCod, Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Hierarchy.Crs.CrsCod);
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -7599,9 +7599,9 @@ static void Usr_GetMyUsrListTypeFromDB (void)
/***** Get type of listing of users from database *****/ /***** Get type of listing of users from database *****/
NumRows = DB_QuerySELECT (&mysql_res,"can not get type of listing of users", NumRows = DB_QuerySELECT (&mysql_res,"can not get type of listing of users",
"SELECT UsrListType FROM crs_usr_last" "SELECT UsrListType FROM crs_usr_last"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE UsrCod=%ld AND CrsCod=%ld",
Gbl.Hierarchy.Crs.CrsCod, Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Hierarchy.Crs.CrsCod);
if (NumRows == 1) // Should be one only row if (NumRows == 1) // Should be one only row
{ {
/* Get type of users' listing used to select some of them */ /* Get type of users' listing used to select some of them */
@ -7638,9 +7638,10 @@ static void Usr_UpdateMyUsrListTypeInDB (void)
/***** Update type of users listing *****/ /***** Update type of users listing *****/
DB_QueryUPDATE ("can not update type of listing", DB_QueryUPDATE ("can not update type of listing",
"UPDATE crs_usr_last SET UsrListType='%s'" "UPDATE crs_usr_last SET UsrListType='%s'"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE UsrCod=%ld AND CrsCod=%ld",
Usr_StringsUsrListTypeInDB[Gbl.Usrs.Me.ListType], Usr_StringsUsrListTypeInDB[Gbl.Usrs.Me.ListType],
Gbl.Hierarchy.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Hierarchy.Crs.CrsCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -7703,9 +7704,9 @@ static void Usr_GetMyColsClassPhotoFromDB (void)
NumRows = DB_QuerySELECT (&mysql_res,"can not get number of columns" NumRows = DB_QuerySELECT (&mysql_res,"can not get number of columns"
" in class photo", " in class photo",
"SELECT ColsClassPhoto FROM crs_usr_last" "SELECT ColsClassPhoto FROM crs_usr_last"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE UsrCod=%ld AND CrsCod=%ld",
Gbl.Hierarchy.Crs.CrsCod, Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Hierarchy.Crs.CrsCod);
if (NumRows == 1) // Should be one only row if (NumRows == 1) // Should be one only row
{ {
/* Get number of columns in class photo */ /* Get number of columns in class photo */
@ -7737,9 +7738,10 @@ static void Usr_UpdateMyColsClassPhotoInDB (void)
/***** Update number of colums in class photo for current course *****/ /***** Update number of colums in class photo for current course *****/
DB_QueryUPDATE ("can not update number of columns in class photo", DB_QueryUPDATE ("can not update number of columns in class photo",
"UPDATE crs_usr_last SET ColsClassPhoto=%u" "UPDATE crs_usr_last SET ColsClassPhoto=%u"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE UsrCod=%ld AND CrsCod=%ld",
Gbl.Usrs.ClassPhoto.Cols, Gbl.Usrs.ClassPhoto.Cols,
Gbl.Hierarchy.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Hierarchy.Crs.CrsCod);
} }
/*****************************************************************************/ /*****************************************************************************/
@ -7807,9 +7809,9 @@ void Usr_GetMyPrefAboutListWithPhotosFromDB (void)
NumRows = DB_QuerySELECT (&mysql_res,"can not check if listing of users" NumRows = DB_QuerySELECT (&mysql_res,"can not check if listing of users"
" must show photos", " must show photos",
"SELECT ListWithPhotos FROM crs_usr_last" "SELECT ListWithPhotos FROM crs_usr_last"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE UsrCod=%ld AND CrsCod=%ld",
Gbl.Hierarchy.Crs.CrsCod, Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Hierarchy.Crs.CrsCod);
if (NumRows == 1) // Should be one only row if (NumRows == 1) // Should be one only row
{ {
/* Get number of columns in class photo */ /* Get number of columns in class photo */
@ -7838,10 +7840,11 @@ static void Usr_UpdateMyPrefAboutListWithPhotosPhotoInDB (void)
/***** Update number of colums in class photo for current course *****/ /***** Update number of colums in class photo for current course *****/
DB_QueryUPDATE ("can not update your preference about photos in listing", DB_QueryUPDATE ("can not update your preference about photos in listing",
"UPDATE crs_usr_last SET ListWithPhotos='%c'" "UPDATE crs_usr_last SET ListWithPhotos='%c'"
" WHERE CrsCod=%ld AND UsrCod=%ld", " WHERE UsrCod=%ld AND CrsCod=%ld",
Gbl.Usrs.Listing.WithPhotos ? 'Y' : Gbl.Usrs.Listing.WithPhotos ? 'Y' :
'N', 'N',
Gbl.Hierarchy.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod); Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Hierarchy.Crs.CrsCod);
} }
/*****************************************************************************/ /*****************************************************************************/