Version18.138.5

This commit is contained in:
Antonio Cañas Vargas 2019-08-01 18:48:38 +02:00
parent 125bc3653f
commit 3224647ec9
6 changed files with 123 additions and 131 deletions

View File

@ -640,7 +640,6 @@ CREATE TABLE IF NOT EXISTS gam_matches (
QstCod INT NOT NULL DEFAULT -1, QstCod INT NOT NULL DEFAULT -1,
QstStartTime DATETIME NOT NULL, QstStartTime DATETIME NOT NULL,
ShowingAnswers ENUM('N','Y') NOT NULL DEFAULT 'N', ShowingAnswers ENUM('N','Y') NOT NULL DEFAULT 'N',
Finished ENUM('N','Y') NOT NULL DEFAULT 'N',
UNIQUE INDEX(MchCod), UNIQUE INDEX(MchCod),
INDEX(GamCod)); INDEX(GamCod));
-- --

View File

@ -460,11 +460,17 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf 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 CSS_FILE "swad18.138.css"
#define JS_FILE "swad18.130.2.js" #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.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.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. Version 18.138.1: Jul 31, 2019 Close button in games always present.

View File

@ -1382,9 +1382,8 @@ mysql> DESCRIBE gam_matches;
| QstCod | int(11) | NO | | -1 | | | QstCod | int(11) | NO | | -1 | |
| QstStartTime | datetime | NO | | NULL | | | QstStartTime | datetime | NO | | NULL | |
| ShowingAnswers | enum('N','Y') | NO | | N | | | 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 (" DB_CreateTable ("CREATE TABLE IF NOT EXISTS gam_matches ("
"MchCod INT NOT NULL AUTO_INCREMENT," "MchCod INT NOT NULL AUTO_INCREMENT,"
@ -1397,7 +1396,6 @@ mysql> DESCRIBE gam_matches;
"QstCod INT NOT NULL DEFAULT -1," "QstCod INT NOT NULL DEFAULT -1,"
"QstStartTime DATETIME NOT NULL," "QstStartTime DATETIME NOT NULL,"
"ShowingAnswers ENUM('N','Y') NOT NULL DEFAULT 'N'," "ShowingAnswers ENUM('N','Y') NOT NULL DEFAULT 'N',"
"Finished ENUM('N','Y') NOT NULL DEFAULT 'N',"
"UNIQUE INDEX(MchCod)," "UNIQUE INDEX(MchCod),"
"INDEX(GamCod)"); "INDEX(GamCod)");

View File

@ -74,6 +74,8 @@ const char *Gam_StrAnswerTypesDB[Gam_NUM_ANS_TYPES] =
#define Gam_NEW_MATCH_SECTION_ID "new_match" #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 *******************************/ /******************************* Private types *******************************/
/*****************************************************************************/ /*****************************************************************************/
@ -91,7 +93,6 @@ struct Match
long QstCod; long QstCod;
time_t QstStartTimeUTC; time_t QstStartTimeUTC;
bool ShowingAnswers; bool ShowingAnswers;
bool Finished;
bool BeingPlayed; bool BeingPlayed;
unsigned NumPlayers; unsigned NumPlayers;
} Status; } Status;
@ -488,10 +489,8 @@ static void Gam_ShowOneGame (long GamCod,
UniqueId++; UniqueId++;
fprintf (Gbl.F.Out,"<td id=\"gam_date_start_%u\" class=\"%s LEFT_TOP", fprintf (Gbl.F.Out,"<td id=\"gam_date_start_%u\" class=\"%s LEFT_TOP",
UniqueId, UniqueId,
Game.Status.Visible ? (Game.Status.Open ? "DATE_GREEN" : Game.Status.Visible ? "DATE_GREEN" :
"DATE_RED") : "DATE_GREEN_LIGHT");
(Game.Status.Open ? "DATE_GREEN_LIGHT" :
"DATE_RED_LIGHT"));
if (!ShowOnlyThisGame) if (!ShowOnlyThisGame)
fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd); fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd);
fprintf (Gbl.F.Out,"\">"); fprintf (Gbl.F.Out,"\">");
@ -507,10 +506,8 @@ static void Gam_ShowOneGame (long GamCod,
/***** End date/time *****/ /***** End date/time *****/
fprintf (Gbl.F.Out,"<td id=\"gam_date_end_%u\" class=\"%s LEFT_TOP", fprintf (Gbl.F.Out,"<td id=\"gam_date_end_%u\" class=\"%s LEFT_TOP",
UniqueId, UniqueId,
Game.Status.Visible ? (Game.Status.Open ? "DATE_GREEN" : Game.Status.Visible ? "DATE_GREEN" :
"DATE_RED") : "DATE_GREEN_LIGHT");
(Game.Status.Open ? "DATE_GREEN_LIGHT" :
"DATE_RED_LIGHT"));
if (!ShowOnlyThisGame) if (!ShowOnlyThisGame)
fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd); fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd);
fprintf (Gbl.F.Out,"\">"); fprintf (Gbl.F.Out,"\">");
@ -801,8 +798,7 @@ void Gam_GetDataOfGameByCod (struct Game *Game)
{ {
case Rol_STD: case Rol_STD:
Game->Status.ICanViewResults = Game->NumQsts != 0 && Game->Status.ICanViewResults = Game->NumQsts != 0 &&
Game->Status.Visible && Game->Status.Visible;
Game->Status.Open;
Game->Status.ICanEdit = false; Game->Status.ICanEdit = false;
break; break;
case Rol_NET: case Rol_NET:
@ -864,19 +860,11 @@ void Gam_GetDataOfGameByCod (struct Game *Game)
/* Free structure that stores the query result */ /* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res); 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 else
{ {
Game->TimeUTC[Gam_START_TIME] = Game->TimeUTC[Gam_START_TIME] =
Game->TimeUTC[Gam_END_TIME ] = (time_t) 0; 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.Title[0] = '\0';
Game.NumQsts = 0; Game.NumQsts = 0;
Game.Status.Visible = true; Game.Status.Visible = true;
Game.Status.Open = true;
Game.Status.ICanViewResults = false; Game.Status.ICanViewResults = false;
} }
else else
@ -1878,7 +1865,7 @@ static unsigned Gam_GetNextQuestionIndexInGame (long GamCod,unsigned QstInd)
{ {
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; 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 *****/ /***** Get next question index in a game from database *****/
// Although indexes are always continuous... // Although indexes are always continuous...
@ -2680,8 +2667,7 @@ static void Gam_ListMatches (struct Game *Game,bool PutFormNewMatch)
"QstInd," // row[ 6] "QstInd," // row[ 6]
"QstCod," // row[ 7] "QstCod," // row[ 7]
"UNIX_TIMESTAMP(QstStartTime)," // row[ 8] "UNIX_TIMESTAMP(QstStartTime)," // row[ 8]
"ShowingAnswers," // row[ 9] "ShowingAnswers" // row[ 9]
"Finished" // row[10]
" FROM gam_matches" " FROM gam_matches"
" WHERE GamCod=%ld%s" " WHERE GamCod=%ld%s"
" ORDER BY MchCod", " ORDER BY MchCod",
@ -2742,8 +2728,7 @@ void Gam_GetDataOfMatchByCod (struct Match *Match)
"QstInd," // row[ 6] "QstInd," // row[ 6]
"QstCod," // row[ 7] "QstCod," // row[ 7]
"UNIX_TIMESTAMP(QstStartTime)," // row[ 8] "UNIX_TIMESTAMP(QstStartTime)," // row[ 8]
"ShowingAnswers," // row[ 9] "ShowingAnswers" // row[ 9]
"Finished" // row[10]
" FROM gam_matches" " FROM gam_matches"
" WHERE MchCod=%ld" " WHERE MchCod=%ld"
" AND GamCod IN" // Extra check " AND GamCod IN" // Extra check
@ -2767,7 +2752,6 @@ void Gam_GetDataOfMatchByCod (struct Match *Match)
Match->Status.QstCod = -1L; Match->Status.QstCod = -1L;
Match->Status.QstStartTimeUTC = (time_t) 0; Match->Status.QstStartTimeUTC = (time_t) 0;
Match->Status.ShowingAnswers = false; Match->Status.ShowingAnswers = false;
Match->Status.Finished = false;
Match->Status.BeingPlayed = false; Match->Status.BeingPlayed = false;
} }
@ -2875,8 +2859,8 @@ static void Gam_ListOneOrMoreMatches (struct Game *Game,
fprintf (Gbl.F.Out,"<td id=\"mch_date_start_%u\"" fprintf (Gbl.F.Out,"<td id=\"mch_date_start_%u\""
" class=\"%s LEFT_TOP COLOR%u\">", " class=\"%s LEFT_TOP COLOR%u\">",
UniqueId, UniqueId,
Match.Status.Finished ? "DATE_RED" : Match.Status.QstInd >= Gam_AFTER_LAST_QUESTION ? "DATE_RED" :
"DATE_GREEN", "DATE_GREEN",
Gbl.RowEvenOdd); Gbl.RowEvenOdd);
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">" fprintf (Gbl.F.Out,"<script type=\"text/javascript\">"
"writeLocalDateHMSFromUTC('mch_date_start_%u',%ld," "writeLocalDateHMSFromUTC('mch_date_start_%u',%ld,"
@ -2890,8 +2874,8 @@ static void Gam_ListOneOrMoreMatches (struct Game *Game,
fprintf (Gbl.F.Out,"<td id=\"mch_date_end_%u\"" fprintf (Gbl.F.Out,"<td id=\"mch_date_end_%u\""
" class=\"%s LEFT_TOP COLOR%u\">", " class=\"%s LEFT_TOP COLOR%u\">",
UniqueId, UniqueId,
Match.Status.Finished ? "DATE_RED" : Match.Status.QstInd >= Gam_AFTER_LAST_QUESTION ? "DATE_RED" :
"DATE_GREEN", "DATE_GREEN",
Gbl.RowEvenOdd); Gbl.RowEvenOdd);
fprintf (Gbl.F.Out,"\">" fprintf (Gbl.F.Out,"\">"
"<script type=\"text/javascript\">" "<script type=\"text/javascript\">"
@ -2916,14 +2900,14 @@ static void Gam_ListOneOrMoreMatches (struct Game *Game,
/***** Match status ******/ /***** Match status ******/
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_TOP COLOR%u\">",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_TOP COLOR%u\">",Gbl.RowEvenOdd);
if (Match.Status.Finished) if (Match.Status.QstInd >= Gam_AFTER_LAST_QUESTION) // Finished match
/* Icon to inform about finished match */ /* Icon to inform about finished match */
// Ico_PutIconOff ("flag-checkered.svg",Txt_Finished_match); // Ico_PutIconOff ("flag-checkered.svg",Txt_Finished_match);
Lay_PutContextualLinkOnlyIcon (ActShoMchTch,NULL, Lay_PutContextualLinkOnlyIcon (ActShoMchTch,NULL,
Gam_PutParamCurrentMchCod, Gam_PutParamCurrentMchCod,
"flag-checkered.svg", "flag-checkered.svg",
Txt_View_game_results); Txt_View_game_results);
else // Unfinished match else // Unfinished match
{ {
/* Current question index / total of questions */ /* Current question index / total of questions */
fprintf (Gbl.F.Out,"<div class=\"DAT\">%u/%u</div>", fprintf (Gbl.F.Out,"<div class=\"DAT\">%u/%u</div>",
@ -3015,7 +2999,6 @@ static void Gam_GetMatchDataFromRow (MYSQL_RES *mysql_res,
row[ 7] QstCod row[ 7] QstCod
row[ 8] UNIX_TIMESTAMP(QstStartTime) row[ 8] UNIX_TIMESTAMP(QstStartTime)
row[ 9] ShowingAnswers row[ 9] ShowingAnswers
row[10] Finished
*/ */
/* Current question index (row[6]) */ /* Current question index (row[6]) */
Match->Status.QstInd = Gam_GetQstIndFromStr (row[6]); Match->Status.QstInd = Gam_GetQstIndFromStr (row[6]);
@ -3029,13 +3012,10 @@ static void Gam_GetMatchDataFromRow (MYSQL_RES *mysql_res,
/* Get whether to show question answers or not (row(9)) */ /* Get whether to show question answers or not (row(9)) */
Match->Status.ShowingAnswers = (row[9][0] == 'Y'); Match->Status.ShowingAnswers = (row[9][0] == 'Y');
/* Get whether the match is finished or not (row(10)) */
Match->Status.Finished = (row[10][0] == 'Y');
/***** Get whether the match is being played or not *****/ /***** Get whether the match is being played or not *****/
if (Match->Status.Finished) if (Match->Status.QstInd >= Gam_AFTER_LAST_QUESTION) // Finished
Match->Status.BeingPlayed = false; Match->Status.BeingPlayed = false;
else else // Unfinished
Match->Status.BeingPlayed = Gam_GetIfMatchIsBeingPlayed (Match->MchCod); Match->Status.BeingPlayed = Gam_GetIfMatchIsBeingPlayed (Match->MchCod);
} }
@ -3316,7 +3296,7 @@ static long Gam_CreateMatch (long GamCod,char Title[Gam_MAX_BYTES_TITLE + 1])
MchCod = DB_QueryINSERTandReturnCode ("can not create match", MchCod = DB_QueryINSERTandReturnCode ("can not create match",
"INSERT gam_matches" "INSERT gam_matches"
" (GamCod,UsrCod,StartTime,EndTime,Title," " (GamCod,UsrCod,StartTime,EndTime,Title,"
"QstInd,QstCod,QstStartTime,ShowingAnswers,Finished)" "QstInd,QstCod,QstStartTime,ShowingAnswers)"
" VALUES" " VALUES"
" (%ld," // GamCod " (%ld," // GamCod
"%ld," // UsrCod "%ld," // UsrCod
@ -3326,8 +3306,7 @@ static long Gam_CreateMatch (long GamCod,char Title[Gam_MAX_BYTES_TITLE + 1])
"0," // QstInd: Match has not started, so not the first question yet "0," // QstInd: Match has not started, so not the first question yet
"-1," // QstCod: Non-existent question "-1," // QstCod: Non-existent question
"NOW()," // QstStartTime "NOW()," // QstStartTime
"'N'," // ShowingAnswers: Don't show answers initially "'N')", // ShowingAnswers: Don't show answers initially
"'N')", // Finished: Game unfinished
GamCod, GamCod,
Gbl.Usrs.Me.UsrDat.UsrCod, // Game creator Gbl.Usrs.Me.UsrDat.UsrCod, // Game creator
Title); Title);
@ -3352,16 +3331,13 @@ static void Gam_UpdateMatchStatusInDB (struct Match *Match)
"gam_matches.QstInd=%u," "gam_matches.QstInd=%u,"
"gam_matches.QstCod=%ld," "gam_matches.QstCod=%ld,"
"gam_matches.QstStartTime=NOW()," "gam_matches.QstStartTime=NOW(),"
"gam_matches.ShowingAnswers='%c'," "gam_matches.ShowingAnswers='%c'"
"gam_matches.Finished='%c'"
" WHERE gam_matches.MchCod=%ld" " WHERE gam_matches.MchCod=%ld"
" AND gam_matches.GamCod=games.GamCod" " AND gam_matches.GamCod=games.GamCod"
" AND games.CrsCod=%ld", // Extra check " AND games.CrsCod=%ld", // Extra check
Match->Status.QstInd,Match->Status.QstCod, Match->Status.QstInd,Match->Status.QstCod,
Match->Status.ShowingAnswers ? 'Y' : Match->Status.ShowingAnswers ? 'Y' :
'N', 'N',
Match->Status.Finished ? 'Y' :
'N',
Match->MchCod,Gbl.Hierarchy.Crs.CrsCod); Match->MchCod,Gbl.Hierarchy.Crs.CrsCod);
if (Match->Status.BeingPlayed) if (Match->Status.BeingPlayed)
@ -3389,7 +3365,7 @@ void Gam_ResumeMatchTch (void)
Gam_GetDataOfMatchByCod (&Match); Gam_GetDataOfMatchByCod (&Match);
/***** If not yet finished, update status *****/ /***** If not yet finished, update status *****/
if (!Match.Status.Finished) if (Match.Status.QstInd < Gam_AFTER_LAST_QUESTION) // Unfinished
{ {
if (Match.Status.QstInd == 0) // Match has been created, but it has not started if (Match.Status.QstInd == 0) // Match has been created, but it has not started
Gam_SetMatchStatusToNextQuestion (&Match); Gam_SetMatchStatusToNextQuestion (&Match);
@ -3424,15 +3400,12 @@ void Gam_PrevStatusMatchTch (void)
Gam_GetDataOfMatchByCod (&Match); Gam_GetDataOfMatchByCod (&Match);
/***** Update status *****/ /***** Update status *****/
if (Match.Status.Finished) if (Match.Status.QstInd >= Gam_AFTER_LAST_QUESTION) // Finished
Gam_SetMatchStatusToPrevQuestion (&Match); Gam_SetMatchStatusToPrevQuestion (&Match);
else else // Unfinished
{ {
if (Match.Status.ShowingAnswers) // Showing answers currently if (Match.Status.ShowingAnswers) // Showing answers currently
{ Match.Status.ShowingAnswers = false; // Do not show answers
Match.Status.Finished = false; // Match is not finished
Match.Status.ShowingAnswers = false; // Do not show answers
}
else else
Gam_SetMatchStatusToPrevQuestion (&Match); Gam_SetMatchStatusToPrevQuestion (&Match);
} }
@ -3463,20 +3436,14 @@ void Gam_NextStatusMatchTch (void)
Gam_GetDataOfMatchByCod (&Match); Gam_GetDataOfMatchByCod (&Match);
/***** If not yet finished, update status *****/ /***** If not yet finished, update status *****/
if (!Match.Status.Finished) if (Match.Status.QstInd == 0) // Not started
Gam_SetMatchStatusToNextQuestion (&Match);
else if (Match.Status.QstInd < Gam_AFTER_LAST_QUESTION) // Unfinished
{ {
if (Match.Status.QstInd == 0) // Match has been created, but it has not started if (Match.Status.ShowingAnswers) // Showing answers currently
Gam_SetMatchStatusToNextQuestion (&Match); Gam_SetMatchStatusToNextQuestion (&Match);
else // Match has started else
{ Match.Status.ShowingAnswers = true; // Show answers
if (Match.Status.ShowingAnswers) // Showing answers currently
Gam_SetMatchStatusToNextQuestion (&Match);
else
{
Match.Status.Finished = false; // Match is not finished
Match.Status.ShowingAnswers = true; // Show answers
}
}
} }
/***** Update match status in database *****/ /***** Update match status in database *****/
@ -3510,7 +3477,6 @@ static void Gam_SetMatchStatusToPrevQuestion (struct Match *Match)
Match->Status.BeingPlayed = true; // Match is being played Match->Status.BeingPlayed = true; // Match is being played
Match->Status.ShowingAnswers = true; // Show answers Match->Status.ShowingAnswers = true; // Show answers
} }
Match->Status.Finished = false; // Match is not finished
} }
/*****************************************************************************/ /*****************************************************************************/
@ -3522,18 +3488,18 @@ static void Gam_SetMatchStatusToNextQuestion (struct Match *Match)
/***** Get index of the next question *****/ /***** Get index of the next question *****/
Match->Status.QstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod, Match->Status.QstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod,
Match->Status.QstInd); Match->Status.QstInd);
if (Match->Status.QstInd == INT_MAX) // End of questions has been reached if (Match->Status.QstInd < Gam_AFTER_LAST_QUESTION) // Unfinished
{
Match->Status.QstCod = -1L; // No more questions
Match->Status.Finished = true; // Match is finished
}
else // No more questions
{ {
Match->Status.QstCod = Gam_GetQstCodFromQstInd (Match->GamCod, Match->Status.QstCod = Gam_GetQstCodFromQstInd (Match->GamCod,
Match->Status.QstInd); Match->Status.QstInd);
Match->Status.Finished = false; // Match is not finished Match->Status.BeingPlayed = true;
} }
Match->Status.ShowingAnswers = false; // Don't show answers else // Finished
{
Match->Status.QstCod = -1L; // No more questions
Match->Status.BeingPlayed = false;
}
Match->Status.ShowingAnswers = false; // Don't show answers
} }
/*****************************************************************************/ /*****************************************************************************/
@ -3556,8 +3522,7 @@ static void Gam_ShowMatchStatusForTch (struct Match *Match)
Gam_ShowMatchTitleAndCloseButton (Match); Gam_ShowMatchTitleAndCloseButton (Match);
/***** Bottom row *****/ /***** Bottom row *****/
if (!Match->Status.Finished && if (Match->Status.BeingPlayed)
Match->Status.BeingPlayed)
/* Show current question and possible answers */ /* Show current question and possible answers */
Gam_ShowQuestionAndAnswersTch (Match); Gam_ShowQuestionAndAnswersTch (Match);
@ -3594,7 +3559,7 @@ static void Gam_ShowMatchStatusForStd (struct Match *Match)
Gam_ShowMatchTitleAndCloseButton (Match); Gam_ShowMatchTitleAndCloseButton (Match);
/***** Bottom row *****/ /***** Bottom row *****/
if (!Match->Status.Finished) if (Match->Status.QstInd < Gam_AFTER_LAST_QUESTION) // Unfinished
{ {
fprintf (Gbl.F.Out,"<div class=\"MATCH_BOTTOM\">"); fprintf (Gbl.F.Out,"<div class=\"MATCH_BOTTOM\">");
@ -3627,7 +3592,8 @@ static void Gam_ShowMatchStatusForStd (struct Match *Match)
static void Gam_ShowLeftColumnTch (struct Match *Match) static void Gam_ShowLeftColumnTch (struct Match *Match)
{ {
extern const char *Txt_End; extern const char *Txt_MATCH_Start;
extern const char *Txt_MATCH_End;
extern const char *Txt_Stem; extern const char *Txt_Stem;
extern const char *Txt_Previous_QUESTION; extern const char *Txt_Previous_QUESTION;
extern const char *Txt_Start; extern const char *Txt_Start;
@ -3650,8 +3616,10 @@ static void Gam_ShowLeftColumnTch (struct Match *Match)
/***** Write number of question *****/ /***** Write number of question *****/
NumQsts = Gam_GetNumQstsGame (Match->GamCod); NumQsts = Gam_GetNumQstsGame (Match->GamCod);
fprintf (Gbl.F.Out,"<div class=\"MATCH_NUM_QST\">"); fprintf (Gbl.F.Out,"<div class=\"MATCH_NUM_QST\">");
if (Match->Status.Finished) if (Match->Status.QstInd == 0) // Not started
fprintf (Gbl.F.Out,"%s",Txt_End); fprintf (Gbl.F.Out,"%s",Txt_MATCH_Start);
else if (Match->Status.QstInd >= Gam_AFTER_LAST_QUESTION) // Finished
fprintf (Gbl.F.Out,"%s",Txt_MATCH_End);
else else
fprintf (Gbl.F.Out,"%u/%u",Match->Status.QstInd,NumQsts); fprintf (Gbl.F.Out,"%u/%u",Match->Status.QstInd,NumQsts);
fprintf (Gbl.F.Out,"</div>"); fprintf (Gbl.F.Out,"</div>");
@ -3662,11 +3630,7 @@ static void Gam_ShowLeftColumnTch (struct Match *Match)
/* Left button */ /* Left button */
fprintf (Gbl.F.Out,"<div class=\"MATCH_BUTTON_LEFT_CONTAINER\">"); fprintf (Gbl.F.Out,"<div class=\"MATCH_BUTTON_LEFT_CONTAINER\">");
if (Match->Status.Finished) // Finished if (Match->Status.QstInd < Gam_AFTER_LAST_QUESTION) // Unfinished
/* Put button to show last question */
Gam_PutBigButton (ActPrvMchTch,Match->MchCod,
"step-backward.svg",Txt_Previous_QUESTION);
else // Not finished
{ {
if (Match->Status.BeingPlayed) if (Match->Status.BeingPlayed)
{ {
@ -3679,25 +3643,30 @@ static void Gam_ShowLeftColumnTch (struct Match *Match)
/* Get index of the previous question */ /* Get index of the previous question */
PrvQstInd = Gam_GetPrevQuestionIndexInGame (Match->GamCod, PrvQstInd = Gam_GetPrevQuestionIndexInGame (Match->GamCod,
Match->Status.QstInd); Match->Status.QstInd);
if (PrvQstInd) // There is a previous question if (PrvQstInd == 0) // There is not a previous question
/* Put button to resume match before first question */
Gam_PutBigButton (ActPrvMchTch,Match->MchCod,
"step-backward.svg",Txt_MATCH_Start);
else // There is a previous question
/* Put button to show previous question */ /* Put button to show previous question */
Gam_PutBigButton (ActPrvMchTch,Match->MchCod, Gam_PutBigButton (ActPrvMchTch,Match->MchCod,
"step-backward.svg",Txt_Previous_QUESTION); "step-backward.svg",Txt_Previous_QUESTION);
else // There is not a previous question
/* Put button to resume match before first question */
Gam_PutBigButton (ActPrvMchTch,Match->MchCod,
"step-backward.svg",Txt_Start);
} }
} }
else // Not being played else // Not being played
/* Put button to close browser tab */ /* Put button to close browser tab */
Gam_PutBigButtonClose (); Gam_PutBigButtonClose ();
} }
else // Finished
/* Put button to show last question */
Gam_PutBigButton (ActPrvMchTch,Match->MchCod,
"step-backward.svg",Txt_Previous_QUESTION);
fprintf (Gbl.F.Out,"</div>"); fprintf (Gbl.F.Out,"</div>");
/* Right button */ /* Right button */
fprintf (Gbl.F.Out,"<div class=\"MATCH_BUTTON_RIGHT_CONTAINER\">"); fprintf (Gbl.F.Out,"<div class=\"MATCH_BUTTON_RIGHT_CONTAINER\">");
if (Match->Status.Finished) if (Match->Status.QstInd >= Gam_AFTER_LAST_QUESTION) // Finished
/* Put button to close browser tab */ /* Put button to close browser tab */
Gam_PutBigButtonClose (); Gam_PutBigButtonClose ();
else if (Match->Status.BeingPlayed) else if (Match->Status.BeingPlayed)
@ -3707,11 +3676,11 @@ static void Gam_ShowLeftColumnTch (struct Match *Match)
/* Get index of the next question */ /* Get index of the next question */
NxtQstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod, NxtQstInd = Gam_GetNextQuestionIndexInGame (Match->GamCod,
Match->Status.QstInd); Match->Status.QstInd);
if (NxtQstInd == INT_MAX) // Last question if (NxtQstInd >= Gam_AFTER_LAST_QUESTION) // No more questions
/* Put button to finish */ /* Put button to finish */
Gam_PutBigButton (ActNxtMchTch,Match->MchCod, Gam_PutBigButton (ActNxtMchTch,Match->MchCod,
"flag-checkered.svg",Txt_Finish); "step-forward.svg",Txt_Finish);
else // Not last question else // There are more questions
/* Put button to show next question */ /* Put button to show next question */
Gam_PutBigButton (ActNxtMchTch,Match->MchCod, Gam_PutBigButton (ActNxtMchTch,Match->MchCod,
"step-forward.svg",Txt_Next_QUESTION); "step-forward.svg",Txt_Next_QUESTION);
@ -3737,9 +3706,8 @@ static void Gam_ShowLeftColumnTch (struct Match *Match)
Gam_ShowNumPlayers (Match); Gam_ShowNumPlayers (Match);
/***** Number of users who have answered *****/ /***** Number of users who have answered *****/
if (!Match->Status.Finished && if (Match->Status.BeingPlayed &&
Match->Status.BeingPlayed && Match->Status.ShowingAnswers)
Match->Status.ShowingAnswers)
{ {
NumAnswerers = Gam_GetNumAnswerers (Match); NumAnswerers = Gam_GetNumAnswerers (Match);
fprintf (Gbl.F.Out,"<div class=\"MATCH_NUM_ANSWERERS\">" fprintf (Gbl.F.Out,"<div class=\"MATCH_NUM_ANSWERERS\">"
@ -3759,7 +3727,8 @@ static void Gam_ShowLeftColumnTch (struct Match *Match)
static void Gam_ShowLeftColumnStd (struct Match *Match) static void Gam_ShowLeftColumnStd (struct Match *Match)
{ {
extern const char *Txt_End; extern const char *Txt_MATCH_Start;
extern const char *Txt_MATCH_End;
unsigned NumQsts; unsigned NumQsts;
/***** Start left container *****/ /***** Start left container *****/
@ -3771,10 +3740,10 @@ static void Gam_ShowLeftColumnStd (struct Match *Match)
/***** Write number of question *****/ /***** Write number of question *****/
NumQsts = Gam_GetNumQstsGame (Match->GamCod); NumQsts = Gam_GetNumQstsGame (Match->GamCod);
fprintf (Gbl.F.Out,"<div class=\"MATCH_NUM_QST\">"); fprintf (Gbl.F.Out,"<div class=\"MATCH_NUM_QST\">");
if (Match->Status.Finished) if (Match->Status.QstInd < Gam_AFTER_LAST_QUESTION) // Unfinished
fprintf (Gbl.F.Out,"%s",Txt_End);
else
fprintf (Gbl.F.Out,"%u/%u",Match->Status.QstInd,NumQsts); fprintf (Gbl.F.Out,"%u/%u",Match->Status.QstInd,NumQsts);
else // Finished
fprintf (Gbl.F.Out,"%s",Txt_MATCH_End);
fprintf (Gbl.F.Out,"</div>"); fprintf (Gbl.F.Out,"</div>");
/***** Buttons *****/ /***** Buttons *****/
@ -3787,7 +3756,7 @@ static void Gam_ShowLeftColumnStd (struct Match *Match)
/* Right button */ /* Right button */
fprintf (Gbl.F.Out,"<div class=\"MATCH_BUTTON_RIGHT_CONTAINER\">"); fprintf (Gbl.F.Out,"<div class=\"MATCH_BUTTON_RIGHT_CONTAINER\">");
if (Match->Status.Finished) if (Match->Status.QstInd >= Gam_AFTER_LAST_QUESTION) // Finished
/* Put button to close browser tab */ /* Put button to close browser tab */
Gam_PutBigButtonClose (); Gam_PutBigButtonClose ();
fprintf (Gbl.F.Out,"</div>"); fprintf (Gbl.F.Out,"</div>");

View File

@ -53,7 +53,6 @@ struct Game
struct struct
{ {
bool Visible; // Game is not hidden bool Visible; // Game is not hidden
bool Open; // Start date <= now <= end date
bool ICanViewResults; bool ICanViewResults;
bool ICanEdit; bool ICanEdit;
} Status; } Status;

View File

@ -10451,27 +10451,6 @@ const char *Txt_Email_X_removed = // Warning: it is very important to include %s
"Email <strong>%s</strong> removido."; "Email <strong>%s</strong> removido.";
#endif #endif
const char *Txt_End =
#if L==1 // ca
"Final";
#elif L==2 // de
"Ende";
#elif L==3 // en
"End";
#elif L==4 // es
"Final";
#elif L==5 // fr
"Fin";
#elif L==6 // gn
"Paha";
#elif L==7 // it
"Fine";
#elif L==8 // pl
"Koniec";
#elif L==9 // pt
"Fim";
#endif
const char *Txt_End_date = const char *Txt_End_date =
#if L==1 // ca #if L==1 // ca
"Data final"; "Data final";
@ -17972,6 +17951,48 @@ const char *Txt_Match = // of a game
"Jogo"; "Jogo";
#endif #endif
const char *Txt_MATCH_End =
#if L==1 // ca
"Final";
#elif L==2 // de
"Ende";
#elif L==3 // en
"End";
#elif L==4 // es
"Final";
#elif L==5 // fr
"Fin";
#elif L==6 // gn
"Paha";
#elif L==7 // it
"Fine";
#elif L==8 // pl
"Koniec";
#elif L==9 // pt
"Fim";
#endif
const char *Txt_MATCH_Start =
#if L==1 // ca
"Inici";
#elif L==2 // de
"Start";
#elif L==3 // en
"Start";
#elif L==4 // es
"Inicio";
#elif L==5 // fr
"D&eacute;but";
#elif L==6 // gn
"&Ntilde;epyr&utilde;";
#elif L==7 // it
"Inizio";
#elif L==8 // pl
"Pocz&aogon;tek";
#elif L==9 // pt
"In&iacute;cio";
#endif
const char *Txt_Match_X_removed = // Warning: it is very important to include %s in the following sentences const char *Txt_Match_X_removed = // Warning: it is very important to include %s in the following sentences
#if L==1 // ca #if L==1 // ca
"Partida <strong>%s</strong> eliminada."; "Partida <strong>%s</strong> eliminada.";
@ -41266,7 +41287,7 @@ const char *Txt_FIGURE_TYPES[Fig_NUM_FIGURES] =
#endif #endif
}; };
const char *Txt_Start = const char *Txt_Start = // As a verb
#if L==1 // ca #if L==1 // ca
"Comen&ccedil;ar"; "Comen&ccedil;ar";
#elif L==2 // de #elif L==2 // de