From 3224647ec9085e6e2000bee14e3167916223e62d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 1 Aug 2019 18:48:38 +0200 Subject: [PATCH] Version18.138.5 --- sql/swad.sql | 1 - swad_changelog.h | 10 ++- swad_database.c | 4 +- swad_game.c | 173 +++++++++++++++++++---------------------------- swad_game.h | 1 - swad_text.c | 65 ++++++++++++------ 6 files changed, 123 insertions(+), 131 deletions(-) diff --git a/sql/swad.sql b/sql/swad.sql index ca690f70e..4f344d22e 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -640,7 +640,6 @@ CREATE TABLE IF NOT EXISTS gam_matches ( QstCod INT NOT NULL DEFAULT -1, QstStartTime DATETIME NOT NULL, ShowingAnswers ENUM('N','Y') NOT NULL DEFAULT 'N', - Finished ENUM('N','Y') NOT NULL DEFAULT 'N', UNIQUE INDEX(MchCod), INDEX(GamCod)); -- diff --git a/swad_changelog.h b/swad_changelog.h index eae9323f5..ee5b1e458 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -460,11 +460,17 @@ En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 18.138.3 (2019-07-31)" +#define Log_PLATFORM_VERSION "SWAD 18.138.5 (2019-08-01)" #define CSS_FILE "swad18.138.css" #define JS_FILE "swad18.130.2.js" /* - Version 18.138.4: Jul 31, 2019 Time of current match and current match question are stored in database. (? lines) + Version 18.138.7: Aug 01, 2019 Time of current match and current match question are stored in database. (? lines) + Version 18.138.6: Aug 01, 2019 Matches finished can be played again from list of matches. (? lines) + Version 18.138.5: Aug 01, 2019 Finished column in matches replaced by a special value in question index. (244108 lines) + 1 change necessary in database: +ALTER TABLE gam_matches DROP COLUMN Finished; + + Version 18.138.4: Aug 01, 2019 Changes in backward and forward behaviour and buttons in matches. (244121 lines) Version 18.138.3: Jul 31, 2019 Button backward on finished match. (244118 lines) Version 18.138.2: Jul 31, 2019 Changes in backward and forward behaviour and buttons in matches. (244111 lines) Version 18.138.1: Jul 31, 2019 Close button in games always present. diff --git a/swad_database.c b/swad_database.c index f3eee7d64..cbe34fc83 100644 --- a/swad_database.c +++ b/swad_database.c @@ -1382,9 +1382,8 @@ mysql> DESCRIBE gam_matches; | QstCod | int(11) | NO | | -1 | | | QstStartTime | datetime | NO | | NULL | | | ShowingAnswers | enum('N','Y') | NO | | N | | -| Finished | enum('N','Y') | NO | | N | | +----------------+---------------+------+-----+---------+----------------+ -11 rows in set (0.00 sec) +10 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_matches (" "MchCod INT NOT NULL AUTO_INCREMENT," @@ -1397,7 +1396,6 @@ mysql> DESCRIBE gam_matches; "QstCod INT NOT NULL DEFAULT -1," "QstStartTime DATETIME NOT NULL," "ShowingAnswers ENUM('N','Y') NOT NULL DEFAULT 'N'," - "Finished ENUM('N','Y') NOT NULL DEFAULT 'N'," "UNIQUE INDEX(MchCod)," "INDEX(GamCod)"); diff --git a/swad_game.c b/swad_game.c index 4daa6675c..b77cb3260 100644 --- a/swad_game.c +++ b/swad_game.c @@ -74,6 +74,8 @@ const char *Gam_StrAnswerTypesDB[Gam_NUM_ANS_TYPES] = #define Gam_NEW_MATCH_SECTION_ID "new_match" +#define Gam_AFTER_LAST_QUESTION ((unsigned)((1UL << 31) - 1)) // 2^31 - 1, don't change this number because it is used in database to indicate that a match is finished + /*****************************************************************************/ /******************************* Private types *******************************/ /*****************************************************************************/ @@ -91,7 +93,6 @@ struct Match long QstCod; time_t QstStartTimeUTC; bool ShowingAnswers; - bool Finished; bool BeingPlayed; unsigned NumPlayers; } Status; @@ -488,10 +489,8 @@ static void Gam_ShowOneGame (long GamCod, UniqueId++; fprintf (Gbl.F.Out,""); @@ -507,10 +506,8 @@ static void Gam_ShowOneGame (long GamCod, /***** End date/time *****/ fprintf (Gbl.F.Out,""); @@ -801,8 +798,7 @@ void Gam_GetDataOfGameByCod (struct Game *Game) { case Rol_STD: Game->Status.ICanViewResults = Game->NumQsts != 0 && - Game->Status.Visible && - Game->Status.Open; + Game->Status.Visible; Game->Status.ICanEdit = false; break; case Rol_NET: @@ -864,19 +860,11 @@ void Gam_GetDataOfGameByCod (struct Game *Game) /* Free structure that stores the query result */ DB_FreeMySQLResult (&mysql_res); - - /***** Get whether the game is open or closed *****/ - Game->Status.Open = DB_QueryCOUNT ("can not get game data", - "SELECT COUNT(*) FROM gam_matches" - " WHERE GamCod=%ld" - " AND Finished='N'", // Matches not finished - Game->GamCod); } else { Game->TimeUTC[Gam_START_TIME] = Game->TimeUTC[Gam_END_TIME ] = (time_t) 0; - Game->Status.Open = false; } } @@ -1230,7 +1218,6 @@ void Gam_RequestCreatOrEditGame (void) Game.Title[0] = '\0'; Game.NumQsts = 0; Game.Status.Visible = true; - Game.Status.Open = true; Game.Status.ICanViewResults = false; } else @@ -1878,7 +1865,7 @@ static unsigned Gam_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd) { MYSQL_RES *mysql_res; MYSQL_ROW row; - unsigned NextQstInd = INT_MAX; // End of questions has been reached + unsigned NextQstInd = Gam_AFTER_LAST_QUESTION; // End of questions has been reached /***** Get next question index in a game from database *****/ // Although indexes are always continuous... @@ -2680,8 +2667,7 @@ static void Gam_ListMatches (struct Game *Game,bool PutFormNewMatch) "QstInd," // row[ 6] "QstCod," // row[ 7] "UNIX_TIMESTAMP(QstStartTime)," // row[ 8] - "ShowingAnswers," // row[ 9] - "Finished" // row[10] + "ShowingAnswers" // row[ 9] " FROM gam_matches" " WHERE GamCod=%ld%s" " ORDER BY MchCod", @@ -2742,8 +2728,7 @@ void Gam_GetDataOfMatchByCod (struct Match *Match) "QstInd," // row[ 6] "QstCod," // row[ 7] "UNIX_TIMESTAMP(QstStartTime)," // row[ 8] - "ShowingAnswers," // row[ 9] - "Finished" // row[10] + "ShowingAnswers" // row[ 9] " FROM gam_matches" " WHERE MchCod=%ld" " AND GamCod IN" // Extra check @@ -2767,7 +2752,6 @@ void Gam_GetDataOfMatchByCod (struct Match *Match) Match->Status.QstCod = -1L; Match->Status.QstStartTimeUTC = (time_t) 0; Match->Status.ShowingAnswers = false; - Match->Status.Finished = false; Match->Status.BeingPlayed = false; } @@ -2875,8 +2859,8 @@ static void Gam_ListOneOrMoreMatches (struct Game *Game, fprintf (Gbl.F.Out,"", UniqueId, - Match.Status.Finished ? "DATE_RED" : - "DATE_GREEN", + Match.Status.QstInd >= Gam_AFTER_LAST_QUESTION ? "DATE_RED" : + "DATE_GREEN", Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"