diff --git a/swad_account.c b/swad_account.c index eeae7dbde..9a3675f6a 100644 --- a/swad_account.c +++ b/swad_account.c @@ -1049,7 +1049,10 @@ void Acc_CompletelyEliminateAccount (struct UsrData *UsrDat, /***** Remove user from possible duplicate users *****/ Dup_RemoveUsrFromDuplicated (UsrDat->UsrCod); - /***** Remove user from the table of courses and users *****/ + /***** Remove user from the tables of courses and users *****/ + DB_QueryDELETE ("can not remove a user from all courses", + "DELETE FROM crs_usr_last WHERE UsrCod=%ld", + UsrDat->UsrCod); DB_QueryDELETE ("can not remove a user from all courses", "DELETE FROM crs_usr WHERE UsrCod=%ld", UsrDat->UsrCod); diff --git a/swad_changelog.h b/swad_changelog.h index 466b82cee..0439a1b4a 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -544,10 +544,41 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.206.2 (2020-04-29)" +#define Log_PLATFORM_VERSION "SWAD 19.207 (2020-04-29)" #define CSS_FILE "swad19.193.1.css" #define JS_FILE "swad19.193.1.js" /* + 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: +RENAME TABLE crs_usr_old TO crs_usr_old_backup_delete_me; +CREATE TABLE crs_usr_backup_delete_me AS SELECT * FROM crs_usr; +CREATE TABLE crs_usr_last AS SELECT * FROM crs_usr; +ALTER TABLE crs_usr_last DROP COLUMN Role; +ALTER TABLE crs_usr_last DROP COLUMN Accepted; +ALTER TABLE crs_usr_last ADD UNIQUE INDEX(CrsCod,UsrCod); +ALTER TABLE crs_usr_last ADD UNIQUE INDEX(UsrCod,CrsCod); +ALTER TABLE crs_usr DROP COLUMN LastDowGrpCod, DROP COLUMN LastComGrpCod, DROP COLUMN LastAssGrpCod, DROP COLUMN NumAccTst, DROP COLUMN LastAccTst, DROP COLUMN NumQstsLastTst, DROP COLUMN UsrListType, DROP COLUMN ColsClassPhoto, DROP COLUMN ListWithPhotos; + If you want to use MyISAM: +ALTER TABLE crs_usr_last ENGINE=MyISAM; +OPTIMIZE TABLE crs_usr_last; +OPTIMIZE TABLE crs_usr; + + Version 19.206.3: Apr 30, 2020 Added indexes on database table. (300244 lines) + 10 changes necessary in database: +RENAME TABLE crs_usr TO crs_usr_old; +CREATE TABLE crs_usr AS SELECT * FROM crs_usr_old; +ALTER TABLE crs_usr ADD UNIQUE INDEX(CrsCod,UsrCod); +ALTER TABLE crs_usr ADD UNIQUE INDEX(CrsCod,UsrCod,Role); +ALTER TABLE crs_usr ADD UNIQUE INDEX(UsrCod,CrsCod); +ALTER TABLE crs_usr ADD UNIQUE INDEX(UsrCod,CrsCod,Role); +ALTER TABLE crs_usr ADD UNIQUE INDEX(Role,CrsCod,UsrCod); +ALTER TABLE crs_usr ADD UNIQUE INDEX(Role,UsrCod,CrsCod); +ALTER TABLE crs_usr ADD INDEX(CrsCod,Role); +ALTER TABLE crs_usr ADD INDEX(UsrCod,Role); + If you want to use MyISAM: +ALTER TABLE crs_usr ENGINE=MyISAM; +OPTIMIZE TABLE crs_usr; + Version 19.206.2: Apr 29, 2020 Teachers and administrators can not be seen by non logged users. (300244 lines) Version 19.206.1: Apr 29, 2020 Changes in phones. (300243 lines) Version 19.206: Apr 29, 2020 Removed addresses in user's data. (300259 lines) @@ -613,6 +644,7 @@ ALTER TABLE exa_sets ADD COLUMN Title VARCHAR(2047) NOT NULL AFTER NumQstsToExam 1 change necessary in database: CREATE TABLE IF NOT EXISTS exa_sets (SetCod INT NOT NULL AUTO_INCREMENT,ExaCod INT NOT NULL,SetInd INT NOT NULL DEFAULT 0,UNIQUE INDEX(SetCod),INDEX(ExaCod,SetInd)); +--------------------------------------- Version 19.193.5: Apr 23, 2020 Fixed bug in exam events. (297871 lines) Version 19.193.4: Apr 23, 2020 Fixed bugs in exams, exam events, games and matches. (297860 lines) Version 19.193.3: Apr 23, 2020 Added new MIME type, reported by Jesús Garrido Manrique. diff --git a/swad_course.c b/swad_course.c index 1f8057574..5cb710966 100644 --- a/swad_course.c +++ b/swad_course.c @@ -1930,6 +1930,9 @@ static void Crs_EmptyCourseCompletely (long CrsCod) CrsCod); /***** Remove possible users remaining in the course (teachers) *****/ + DB_QueryDELETE ("can not remove users from a course", + "DELETE FROM crs_usr_last WHERE CrsCod=%ld", + CrsCod); DB_QueryDELETE ("can not remove users from a course", "DELETE FROM crs_usr WHERE CrsCod=%ld", CrsCod); diff --git a/swad_database.c b/swad_database.c index fa2829317..231154480 100644 --- a/swad_database.c +++ b/swad_database.c @@ -871,6 +871,40 @@ mysql> DESCRIBE crs_usr; "UsrCod INT NOT NULL," "Role TINYINT NOT NULL DEFAULT 0," "Accepted ENUM('N','Y') NOT NULL DEFAULT 'N'," + "UNIQUE INDEX(CrsCod,UsrCod)," + "UNIQUE INDEX(CrsCod,UsrCod,Role)," + "UNIQUE INDEX(UsrCod,CrsCod)," + "UNIQUE INDEX(UsrCod,CrsCod,Role)," + "UNIQUE INDEX(Role,CrsCod,UsrCod)," + "UNIQUE INDEX(Role,UsrCod,CrsCod)," + "INDEX(CrsCod,Role)," + "INDEX(UsrCod,Role))"); + + /***** Table crs_usr_last *****/ +/* +mysql> DESCRIBE crs_usr_last; ++----------------+---------------------------+------+-----+------------+-------+ +| Field | Type | Null | Key | Default | Extra | ++----------------+---------------------------+------+-----+------------+-------+ +| CrsCod | int(11) | NO | PRI | -1 | | +| UsrCod | int(11) | NO | PRI | NULL | | +| Role | tinyint(4) | NO | PRI | 0 | | +| Accepted | enum('N','Y') | NO | | N | | +| LastDowGrpCod | int(11) | NO | | -1 | | +| LastComGrpCod | int(11) | NO | | -1 | | +| 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_last (" + "CrsCod INT NOT NULL DEFAULT -1," + "UsrCod INT NOT NULL," "LastDowGrpCod INT NOT NULL DEFAULT -1," "LastComGrpCod INT NOT NULL DEFAULT -1," "LastAssGrpCod INT NOT NULL DEFAULT -1," @@ -880,10 +914,8 @@ mysql> DESCRIBE crs_usr; "UsrListType ENUM('classphoto','list') NOT NULL DEFAULT 'classphoto'," "ColsClassPhoto TINYINT NOT NULL," "ListWithPhotos ENUM('N','Y') NOT NULL DEFAULT 'Y'," - "UNIQUE INDEX(CrsCod,UsrCod,Role)," - "UNIQUE INDEX(UsrCod,CrsCod,Role)," - "INDEX(CrsCod,Role)," - "INDEX(UsrCod,Role))"); + "UNIQUE INDEX(CrsCod,UsrCod)," + "UNIQUE INDEX(UsrCod,CrsCod))"); /***** Table crs_usr_requests *****/ /* diff --git a/swad_enrolment.c b/swad_enrolment.c index c79626b7e..ae3b29f83 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -290,18 +290,26 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole, /***** Register user in current course in database *****/ DB_QueryINSERT ("can not register user in course", "INSERT INTO crs_usr" - " (CrsCod,UsrCod,Role,Accepted," + " (CrsCod,UsrCod,Role,Accepted)" + " VALUES" + " (%ld,%ld,%u,'%c')", + Gbl.Hierarchy.Crs.CrsCod,UsrDat->UsrCod,(unsigned) NewRole, + KeepOrSetAccepted == Enr_SET_ACCEPTED_TO_TRUE ? 'Y' : + 'N'); + + /***** Register last prefs in current course in database *****/ + DB_QueryINSERT ("can not register user in course", + "INSERT INTO crs_usr_last" + " (CrsCod,UsrCod," "LastDowGrpCod,LastComGrpCod,LastAssGrpCod," "NumAccTst,LastAccTst,NumQstsLastTst," "UsrListType,ColsClassPhoto,ListWithPhotos)" " VALUES" - " (%ld,%ld,%u,'%c'," + " (%ld,%ld," "-1,-1,-1," "0,FROM_UNIXTIME(%ld),0," "'%s',%u,'%c')", - Gbl.Hierarchy.Crs.CrsCod,UsrDat->UsrCod,(unsigned) NewRole, - KeepOrSetAccepted == Enr_SET_ACCEPTED_TO_TRUE ? 'Y' : - 'N', + Gbl.Hierarchy.Crs.CrsCod,UsrDat->UsrCod, (long) (time_t) 0, // The user never accessed to tests in this course Usr_StringsUsrListTypeInDB[Usr_SHOW_USRS_TYPE_DEFAULT], Usr_CLASS_PHOTO_COLS_DEF, @@ -4126,7 +4134,11 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat, except notifications about new messages *****/ Ntf_MarkNotifInCrsAsRemoved (UsrDat->UsrCod,Crs->CrsCod); - /***** Remove user from the table of courses-users *****/ + /***** Remove user from the tables of courses-users *****/ + DB_QueryDELETE ("can not remove a user from a course", + "DELETE FROM crs_usr_last" + " WHERE CrsCod=%ld AND UsrCod=%ld", + Crs->CrsCod,UsrDat->UsrCod); DB_QueryDELETE ("can not remove a user from a course", "DELETE FROM crs_usr" " WHERE CrsCod=%ld AND UsrCod=%ld", diff --git a/swad_file_browser.c b/swad_file_browser.c index a88a07418..f80db7e4d 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -3921,7 +3921,7 @@ static void Brw_UpdateGrpLastAccZone (const char *FieldNameDB,long GrpCod) { /***** 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", - "UPDATE crs_usr SET %s=%ld" + "UPDATE crs_usr_last SET %s=%ld" " WHERE CrsCod=%ld AND UsrCod=%ld", FieldNameDB,GrpCod, Gbl.Hierarchy.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod); @@ -5249,7 +5249,7 @@ static long Brw_GetGrpLastAccZone (const char *FieldNameDB) NumRows = DB_QuerySELECT (&mysql_res,"can not get the group" " of your last access" " to a file browser", - "SELECT %s FROM crs_usr" + "SELECT %s FROM crs_usr_last" " WHERE CrsCod=%ld AND UsrCod=%ld", FieldNameDB, Gbl.Hierarchy.Crs.CrsCod, diff --git a/swad_group.c b/swad_group.c index 7a5bce141..7b11f6bad 100644 --- a/swad_group.c +++ b/swad_group.c @@ -979,6 +979,7 @@ static void Grp_LockTables (void) "crs_grp WRITE," "crs_grp_usr WRITE," "crs_usr READ," + "crs_usr_last READ," "rooms READ"); Gbl.DB.LockedTables = true; } diff --git a/swad_main.c b/swad_main.c index f03974a18..3c261d5c4 100644 --- a/swad_main.c +++ b/swad_main.c @@ -87,10 +87,10 @@ int main (void) "%s" "



" "

" - "%s está parado por mantenimiento durante unos minutos." + "%s está parado un momento por mantenimiento." "

" "

" - "Intente acceder más tarde, por favor." + "Intente acceder pasados unos minutos, por favor." "

" "" "", diff --git a/swad_test.c b/swad_test.c index 9b2607ccb..0c91f0267 100644 --- a/swad_test.c +++ b/swad_test.c @@ -704,7 +704,7 @@ static bool Tst_CheckIfNextTstAllowed (void) "SELECT UNIX_TIMESTAMP(LastAccTst+INTERVAL (NumQstsLastTst*%lu) SECOND)-" "UNIX_TIMESTAMP()," // row[0] "UNIX_TIMESTAMP(LastAccTst+INTERVAL (NumQstsLastTst*%lu) SECOND)" // row[1] - " FROM crs_usr" + " FROM crs_usr_last" " WHERE CrsCod=%ld AND UsrCod=%ld", TstCfg_GetConfigMinTimeNxtTstPerQst (), TstCfg_GetConfigMinTimeNxtTstPerQst (), @@ -757,7 +757,7 @@ static unsigned Tst_GetNumExamsGeneratedByMe (void) /***** Get number of test exams generated by me from database *****/ NumRows = DB_QuerySELECT (&mysql_res,"can not get number of test exams generated", "SELECT NumAccTst" // row[0] - " FROM crs_usr" + " FROM crs_usr_last" " WHERE CrsCod=%ld AND UsrCod=%ld", Gbl.Hierarchy.Crs.CrsCod, Gbl.Usrs.Me.UsrDat.UsrCod); @@ -1169,7 +1169,7 @@ static void Tst_IncreaseMyNumAccessTst (void) /***** Update my number of accesses to test in this course *****/ DB_QueryUPDATE ("can not update the number of accesses to test", - "UPDATE crs_usr SET NumAccTst=NumAccTst+1" + "UPDATE crs_usr_last SET NumAccTst=NumAccTst+1" " WHERE CrsCod=%ld AND UsrCod=%ld", Gbl.Hierarchy.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod); } @@ -1182,7 +1182,7 @@ static void Tst_UpdateLastAccTst (unsigned NumQsts) { /***** Update date-time and number of questions of this test *****/ DB_QueryUPDATE ("can not update time and number of questions of this test", - "UPDATE crs_usr SET LastAccTst=NOW(),NumQstsLastTst=%u" + "UPDATE crs_usr_last SET LastAccTst=NOW(),NumQstsLastTst=%u" " WHERE CrsCod=%ld AND UsrCod=%ld", NumQsts, Gbl.Hierarchy.Crs.CrsCod, diff --git a/swad_user.c b/swad_user.c index 18c68fdb5..3a0b6f769 100644 --- a/swad_user.c +++ b/swad_user.c @@ -7598,7 +7598,7 @@ static void Usr_GetMyUsrListTypeFromDB (void) /***** Get type of listing of users from database *****/ NumRows = DB_QuerySELECT (&mysql_res,"can not get type of listing of users", - "SELECT UsrListType FROM crs_usr" + "SELECT UsrListType FROM crs_usr_last" " WHERE CrsCod=%ld AND UsrCod=%ld", Gbl.Hierarchy.Crs.CrsCod, Gbl.Usrs.Me.UsrDat.UsrCod); @@ -7637,7 +7637,7 @@ static void Usr_UpdateMyUsrListTypeInDB (void) { /***** Update type of users listing *****/ DB_QueryUPDATE ("can not update type of listing", - "UPDATE crs_usr SET UsrListType='%s'" + "UPDATE crs_usr_last SET UsrListType='%s'" " WHERE CrsCod=%ld AND UsrCod=%ld", Usr_StringsUsrListTypeInDB[Gbl.Usrs.Me.ListType], Gbl.Hierarchy.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod); @@ -7702,7 +7702,7 @@ static void Usr_GetMyColsClassPhotoFromDB (void) /***** Get number of columns in class photo from database *****/ NumRows = DB_QuerySELECT (&mysql_res,"can not get number of columns" " in class photo", - "SELECT ColsClassPhoto FROM crs_usr" + "SELECT ColsClassPhoto FROM crs_usr_last" " WHERE CrsCod=%ld AND UsrCod=%ld", Gbl.Hierarchy.Crs.CrsCod, Gbl.Usrs.Me.UsrDat.UsrCod); @@ -7736,7 +7736,7 @@ static void Usr_UpdateMyColsClassPhotoInDB (void) Gbl.Hierarchy.Level == Hie_CRS) // Course selected /***** Update number of colums in class photo for current course *****/ DB_QueryUPDATE ("can not update number of columns in class photo", - "UPDATE crs_usr SET ColsClassPhoto=%u" + "UPDATE crs_usr_last SET ColsClassPhoto=%u" " WHERE CrsCod=%ld AND UsrCod=%ld", Gbl.Usrs.ClassPhoto.Cols, Gbl.Hierarchy.Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod); @@ -7806,7 +7806,7 @@ void Usr_GetMyPrefAboutListWithPhotosFromDB (void) /***** Get if listing of users must show photos from database *****/ NumRows = DB_QuerySELECT (&mysql_res,"can not check if listing of users" " must show photos", - "SELECT ListWithPhotos FROM crs_usr" + "SELECT ListWithPhotos FROM crs_usr_last" " WHERE CrsCod=%ld AND UsrCod=%ld", Gbl.Hierarchy.Crs.CrsCod, Gbl.Usrs.Me.UsrDat.UsrCod); @@ -7837,7 +7837,7 @@ static void Usr_UpdateMyPrefAboutListWithPhotosPhotoInDB (void) Gbl.Hierarchy.Level == Hie_CRS) // Course selected /***** Update number of colums in class photo for current course *****/ DB_QueryUPDATE ("can not update your preference about photos in listing", - "UPDATE crs_usr SET ListWithPhotos='%c'" + "UPDATE crs_usr_last SET ListWithPhotos='%c'" " WHERE CrsCod=%ld AND UsrCod=%ld", Gbl.Usrs.Listing.WithPhotos ? 'Y' : 'N',